Files
dxdesigner-part-replacement/docs/superpowers/specs/2026-09-01-dxdesigner-795-part-replacement-design.md
T

526 lines
22 KiB
Markdown

# DxDesigner 7.9.5 Multi-Project Part Replacement Tool
Date: 2026-09-01
## 1. Purpose
Build the part-replacement module of the Dx Productivity suite for
DxDesigner/Expedition Enterprise 7.9.5. The module applies one set of
old-Part-Number to new-Part-Number rules across an explicit list of projects,
uses the native Replace Part workflow to obtain all new part data from the
central library, and verifies every changed project before it can be saved.
This is a true library part replacement. It is not a Part Number property edit,
an attribute annotation workflow, an ASCII design-file rewrite, or automatic
schematic rewiring.
Version 1 is intentionally semi-automatic. The tool prepares each replacement
group and verifies it, while an operator confirms the native Replace Part dialog
once for every project/mapping pair that has matches and confirms each project
once before save.
## 2. Compatibility Baseline
DxDesigner/Expedition Enterprise 7.9.5 is the only supported schematic
integration baseline. Compatibility with newer Siemens releases is not implied.
The module reuses the architecture approved for the Dx Productivity suite:
- one startup-imported `MenuAdd.vbs` entry point;
- all DxDesigner API access inside the internal VBScript host;
- UTF-8 snapshot, command, result, and status files between VBScript and Python;
- Python 3.12 for orchestration, validation, state, and reports;
- user-level path resolution through `DXTOOLS_HOME`;
- ASCII-only VBScript source; and
- preview, backup, stale-state checks, post-change verification, and recovery.
Python must not instantiate or attach to `ViewDraw.Application`. UI-coordinate
automation, `SendKeys`, and blind timing delays are prohibited.
The current repository contains the approved suite design but not an implemented
shared runtime. This module therefore creates only the minimum shared bridge and
run-storage foundations it needs. It does not implement the automatic reference
designator UI or other planned productivity modules.
## 3. Evidence and Route Choice
DxDesigner 7.9.x exposes the native `Edit -> Replace Symbol` workflow with
`Replace part`, a target selected through DxDataBook, and a library-precedence
choice. Community examples also show the automation method
`Block.ChangeComponentPreserveRefdes` and the command-line operation
`ccomp :component_name`.
The public evidence does not establish that either scripted operation is
equivalent to native Replace Part with Library Wins. Users have reported symbol
origin problems and Packager failures with `ChangeComponentPreserveRefdes`, and
a Siemens employee recommended `ccomp` as a manual workaround for that class of
failure. Therefore:
- native Replace Part with Library Wins is the version-1 production write path;
- `ccomp` is a compatibility-probe candidate for a later automation level;
- `ChangeComponentPreserveRefdes` is not a production write path in version 1;
- Databook annotation may help locate parts but is not a replacement mechanism;
and
- exported design files are never edited directly.
Research references:
- <https://community.sw.siemens.com/s/question/0D5Vb00001Tb2wMKAR/how-to-implement-part-replace-by-script-in-dxdesigner>
- <https://community.sw.siemens.com/s/question/0D5Vb00000ojyRYKAY/i-want-to-rearrange-the-selected-symbol-in-its-original-position-while-retaining-the-old-refdes-however-using-the-method-of-blockchangecomponentpreserverefdes-the-package-fails>
No maintained, downloadable open-source tool implementing this full 7.9.5
workflow was found during the design research. A live target-system probe remains
mandatory because community examples do not define a stable automation contract.
## 4. Version-1 Scope
### 4.1 Included
- Import a UTF-8 CSV mapping containing old and new Part Numbers.
- Import an explicit project list and optionally discover candidate projects
beneath a selected root using the extension allowlist in the verified 7.9.5
compatibility profile.
- Inventory every selected project before any project is modified.
- Show a project-by-mapping impact matrix and blocking issues.
- Apply the same enabled mapping set to every enabled project.
- Replace all matching logical components in a multi-project job.
- Support full-project, current-sheet, and selected-component scope for a
single-project job. Multi-project jobs use full-project scope only.
- Obtain the target part, symbol, pins, and library-controlled properties from
the central library through native Replace Part with Library Wins.
- Preserve and verify protected instance state.
- Back up, verify, save, report, resume, and recover at project granularity.
- Produce versioned JSON data plus operator-oriented CSV and static HTML reports.
### 4.2 Excluded
- Automatic rerouting or creation of schematic wires.
- Automatic acceptance of pin-count, pin-number, gate, origin, or pin-coordinate
incompatibility.
- Fully unattended dialog control.
- Direct SQL or file-level mutation of the central library.
- Inferring a target part from description, value, manufacturer, or AI output.
- Replacing a part by independently copying individual properties.
- Automatic correction of Packager, ERC, or netlist errors.
- AI approval of a save operation.
- A full PySide graphical application.
## 5. Inputs and Identity Rules
### 5.1 Replacement Mapping
The input file has exactly these required columns:
```csv
old_part_number,new_part_number
OLD-001,NEW-001
OLD-002,NEW-002
```
Part Number is the unique central-library key supplied by the user. The tool
trims surrounding whitespace, preserves the displayed spelling, and performs
case-insensitive identity comparisons. It rejects:
- blank old or new values;
- duplicate old values, including case-only duplicates;
- a rule whose old and new values are equal;
- chains such as `A -> B` and `B -> C`; and
- cycles such as `A -> B` and `B -> A`.
Rejecting chains and cycles prevents a newly replaced part from becoming input
to a later rule in the same job. Version 1 does not accept component names,
symbol names, attributes, or pin data in the replacement mapping. Those values
come from the project and the central library.
### 5.2 Project List
`projects.txt` contains one absolute project-definition path per line. Paths are
canonicalized without changing their on-disk case. Duplicate paths, missing
paths, nested duplicate discoveries, and unsupported project markers are
reported before inventory.
Root discovery is a convenience that produces a candidate `projects.txt`; it
does not silently add projects to a job. The operator reviews and confirms the
discovered list before inventory.
Each project receives a stable job-local ID derived from its canonical path and
an explicit display name. Reports never rely on a short project name as a unique
identifier.
## 6. Architecture
### 6.1 Batch Controller
The Python batch controller owns immutable job configuration, project queue
state, mapping validation, snapshot comparison, compatibility certifications,
status transitions, and report generation. It communicates only through the
versioned file protocol and never calls DxDesigner COM.
The first release exposes a command-line interface and a PowerShell launcher.
It may use standard file/folder pickers for input selection, but the underlying
job is fully reproducible from mapping, project-list, and job-directory paths.
### 6.2 Internal VBScript Bridge
The bridge runs inside the active DxDesigner 7.9.5 process. It owns:
- active-project identity and dirty-state checks;
- component enumeration and snapshot export;
- logical-component selection;
- the verified route for opening native Replace Part when available;
- monitoring for completion by observing design state rather than window text;
- Undo, save, close, and project-open operations only when separately verified;
and
- result and diagnostic publication back to the job directory.
The bridge never interprets replacement policy. It executes explicit commands
whose expected current state is included in the command file.
### 6.3 Native Replace Part Adapter
For each enabled mapping with matches, the adapter selects every matching
logical component in the approved scope and displays the exact target Part
Number and expected instance count.
If the compatibility probe proves a stable internal route, the bridge opens the
native Replace Part dialog. Otherwise it pauses after selection and instructs
the operator to invoke `Edit -> Replace Symbol`, choose `Replace part`, locate
the exact new Part Number through DxDataBook, and select Library Wins. This
manual-menu fallback is a supported version-1 route.
The tool does not automate target selection inside the dialog. When the dialog
closes, the bridge exports a new snapshot; Python determines whether the correct
target and count were applied.
### 6.4 Project Navigation Adapter
If the probe proves reliable project open/close APIs or commands, the bridge may
advance the queue automatically. Otherwise the baseline route displays the
canonical path of the next project and waits for the operator to open it.
In both routes, processing starts only after the active-project identity exactly
matches the queued project. Automatic project navigation is an optimization,
not a release requirement.
### 6.5 Run Store and Reports
Every batch receives a new run directory under the configured user-local run
root. It contains:
- an immutable copy of the accepted mapping and project list;
- `job.json` with schema version and configuration;
- per-project inventory and before/after snapshots;
- atomic command, result, and status mailboxes;
- backup manifests and content hashes;
- an append-only event log;
- a project-by-mapping impact CSV;
- detailed component and attribute difference CSV/JSON; and
- a static local HTML summary with no executable remote content.
Files use UTF-8 and atomic same-directory publication. VBScript uses
`ADODB.Stream` for encoding and never assumes an ANSI code page.
## 7. Inventory Phase
Inventory is a separate, read-only pass over all enabled projects. No Apply
action is available until every enabled project is inventoried or explicitly
excluded.
For each project, the bridge requires a saved, non-dirty active design and
exports:
- canonical project identity and design hierarchy;
- logical-component identity and every placed unit;
- Part Number and RefDes;
- sheet path, symbol identity, gate/slot identity;
- origin, position, rotation, and mirror state;
- visible and hidden instance attributes;
- pin numbers, pin names, pin positions, and pin-to-net identity; and
- a hashable project-state fingerprint.
The exact API names are supplied by the compatibility profile produced by the
probe. If the bridge cannot obtain unambiguous logical-component identity,
protected placement state, or pin/network state, that component is blocking and
cannot be replaced.
The batch controller then produces the complete impact matrix. Each cell records
the number of logical components and placed units matching a rule. It separately
reports no-match rules, stale or missing Part Numbers, duplicate RefDes values,
multi-unit parts, and data that cannot be verified.
## 8. Compatibility Certification
Automatic eligibility is limited to old/new pairs that have been certified as
interface compatible against the current central-library state.
Because the 7.9.5 public automation interface may not expose complete target
library geometry before placement, the baseline certification route is a trial
replacement in a disposable full project copy:
1. Copy a representative closed project containing the old part.
2. Record its complete pre-change snapshot.
3. Perform one native Replace Part operation with Library Wins.
4. Record the post-change snapshot.
5. Verify the compatibility invariants in Section 10.
6. Run Packager and the available ERC/netlist checks.
7. Store a certification keyed by old Part Number, new Part Number, target
library identity/revision when exposed, and observed interface fingerprint.
If no stable library revision is exposed, the certification records the target
part fingerprint observed during the trial. Every production replacement must
match that fingerprint. A changed fingerprint invalidates the certification and
requires another trial.
An uncertified pair is never silently treated as compatible. The operator may
run the disposable certification flow or exclude the mapping; there is no
"continue anyway" override in version 1.
## 9. Apply Workflow
The production workflow for one project is:
1. Require the project to be saved and closed before backup.
2. Copy the complete project tree to the run backup area and create a file-size
and content-hash manifest.
3. Open or ask the operator to open the queued project.
4. Verify canonical identity and compare the current fingerprint with inventory.
5. Re-inventory and require review if the project is stale.
6. For each enabled mapping with matches, select the exact baseline objects and
show the target Part Number and expected count.
7. Open or ask the operator to open native Replace Part.
8. The operator chooses the exact new Part Number and Library Wins, then confirms
once for the selected group.
9. Export the post-operation snapshot and run immediate verification.
10. Continue only after the mapping is verified.
11. After all mappings pass, present the complete project difference summary.
12. Save only after the operator selects `Save and continue`.
13. Re-open or re-enumerate the saved project, verify the persisted result, and
mark the project complete before advancing the queue.
No individual component requires confirmation. The manual workload is one
native confirmation per project/mapping pair that has at least one match, plus
one project-level save confirmation.
## 10. Verification Rules
### 10.1 Hard Success Conditions
For every replaced logical component:
- the resulting Part Number equals the requested new Part Number;
- the number of matched and replaced logical components is exact;
- RefDes is unchanged;
- sheet and hierarchical ownership are unchanged;
- every placed unit remains present;
- origin, position, rotation, and mirror state are unchanged;
- gate/slot structure and pin-number set are unchanged;
- every pin position is unchanged in schematic coordinates;
- every `RefDes + pin number` resolves to the same net identity; and
- no unrelated logical component changed.
Comparison uses invariant numeric serialization and probe-established coordinate
tolerance. The tolerance accounts only for API serialization precision; it must
not conceal a visible or grid-significant movement.
Any added, removed, renamed, or reconnected pin is a failure. The tool never
creates, deletes, moves, or redraws wires to make a replacement pass.
### 10.2 Library and Attribute Semantics
The target symbol, part definition, pins, and library-controlled properties must
come from native Replace Part with Library Wins. Version 1 does not independently
write those fields.
Protected instance fields include RefDes, hierarchy, placement, rotation,
mirroring, unit assignment, and connectivity. A change to a protected field is
blocking.
All other attribute changes are recorded in the difference report. The live
probe documents how the site's 7.9.5 build and central library treat custom
instance attributes. Conflicting library-controlled attributes follow native
Library Wins behavior; the tool neither reconstructs old values nor overrides
the native result. The operator reviews these non-protected differences at the
project save gate.
### 10.3 Project-Level Checks
After component checks pass, the release workflow requires:
- Packager produces no new error attributable to the replacement;
- ERC produces no new relevant error;
- generated net connectivity is unchanged for protected pins; and
- the saved-project re-read matches the verified in-memory result.
When Packager, ERC, or netlist execution cannot be automated through a verified
7.9.5 route, the tool emits exact pending checks and keeps the project in
`awaiting_external_checks` rather than marking it complete.
## 11. Failure Handling and Recovery
### 11.1 State Machine
Each project moves through these durable states:
- `inventory_pending`
- `inventory_complete`
- `apply_pending`
- `applying`
- `awaiting_save_confirmation`
- `awaiting_external_checks`
- `verified_saved`
- `blocked`
Transitions are append-only events. A status file is a projection of the event
log, not the sole record of progress.
### 11.2 Wrong Target or Verification Failure
If the operator chooses the wrong target or any hard invariant fails, the bridge
stops the current project immediately. It attempts one native Undo only through
the verified route and then compares the complete restored snapshot with the
pre-operation snapshot.
If Undo is unavailable or restoration does not verify exactly, the project must
be closed without saving. The tool then verifies that the on-disk files still
match the pre-apply fingerprint. It does not continue using uncertain in-memory
state.
### 11.3 Backup Restore
Restore is explicit and project-granular. The target project must be closed, the
canonical target path must match the job record, and the backup manifest must
verify before any restore begins. The restore process first preserves the failed
on-disk tree in a recovery location, then copies the verified backup. It never
overwrites an open project or an unrelated directory.
### 11.4 Interruption and Resume
After cancellation, process failure, application crash, or reboot, the
controller resumes only from durable states. `verified_saved` projects are not
reprocessed. A project left in `applying`, `awaiting_save_confirmation`, or an
unknown state is re-inventoried and reconciled against its backup before any
further action.
One blocked project does not prevent the operator from continuing with other
projects. The final report preserves all blocked reasons and never represents a
partially completed batch as fully successful.
## 12. Operator Experience
The command-line flow uses concise numbered prompts and writes richer detail to
the HTML report. At all times it shows:
- current job and project;
- project position in the queue;
- current old and new Part Numbers;
- expected component count;
- whether native-dialog and project-navigation routes are automatic or manual;
- current verification state; and
- the next permitted action.
The target Part Number remains visible while the native dialog is open. Cancel
before a verified save leaves the current project unsaved and records the job as
interrupted.
## 13. AI Review Boundary
The JSON schemas are versioned so a future AI agent or independent review tool
can consume inventory, before/after differences, Packager/ERC results, and
operator decisions.
AI review is advisory. It writes a separate review artifact and cannot alter
the source snapshots, event log, hard verification result, save permission, or
backup. No AI recommendation can approve changed connectivity or an uncertified
part pair.
## 14. Compatibility Probe
Implementation begins with a read-mostly probe on a disposable project. The
probe records the exact 7.9.5 build and establishes one explicit route or the
documented manual fallback for:
- application version and active-project identity;
- full-design logical-component enumeration;
- Part Number, RefDes, hierarchy, unit, symbol, placement, attribute, pin, and
net access;
- selecting an exact set of logical components;
- opening native Replace Part;
- detecting that the dialog operation completed;
- native Undo and save;
- dirty-state detection;
- project open and close; and
- Packager, ERC, and netlist invocation or result capture.
Probe output is a machine-readable compatibility profile plus a human-readable
report. A missing optional automation route selects its manual fallback. Missing
unambiguous identity, snapshot, selection, or post-change verification routes is
a release blocker because those capabilities have no safe fallback.
## 15. Testing Strategy
### 15.1 Python Tests
Unit tests cover:
- UTF-8 CSV parsing and path handling, including spaces and Chinese characters;
- duplicate, equal, chained, and cyclic mappings;
- project discovery confirmation and canonical identity;
- impact-matrix counts;
- immutable snapshots and schema versioning;
- coordinate, attribute, pin, and network comparison;
- certification creation and invalidation;
- stale-state rejection;
- every valid and invalid state transition;
- interruption reconciliation and resume; and
- report generation from complete and partial batches.
### 15.2 Bridge and Integration Tests
VBScript helper tests run under `cscript`. Static tests prohibit direct Python
COM attachment, fixed drive paths, operation-wide error suppression, ANSI file
exchange, `SendKeys`, and write operations before backup and stale-state checks.
A mocked DxDesigner bridge exercises inventory, group selection, correct target,
wrong target, changed RefDes, changed placement, pin-count change, pin-position
change, net change, unrelated-object change, Undo success, Undo failure, save,
crash, and resume.
### 15.3 Live 7.9.5 Acceptance
Release acceptance uses a disposable copy of representative site projects and
at least:
- one compatible single-unit replacement;
- one compatible multi-unit replacement if multi-unit parts are in site scope;
- one different-origin replacement that must be rejected unless coordinates are
demonstrably unchanged;
- one pin-number or pin-count mismatch that must be blocked;
- one deliberately wrong target selection;
- one stale project changed after inventory;
- one successful Undo and one close-without-save recovery;
- a multi-project resume after interruption; and
- Packager, ERC, and netlist comparison on a saved successful project.
The acceptance record captures build number, Windows version, central-library
identity/revision or fingerprint, project fixtures, mappings, route profile,
date, tester, and evidence files. Compatibility is not claimed until every
required item passes with no unresolved blocker.
## 16. Release Criteria
Version 1 is ready for production use only when:
- all automated tests pass;
- the live 7.9.5 probe has produced a valid compatibility profile;
- all required live acceptance cases pass;
- every successful replacement preserves protected instance state and
connectivity;
- Packager, ERC, and netlist checks introduce no relevant regression;
- backup restore has been demonstrated on a disposable project;
- interruption resume has been demonstrated across multiple projects; and
- operator documentation states the exact manual steps for every selected
fallback route.
Until then, generated scripts and reports are evaluation artifacts and must be
used only on disposable project copies.