Expand description
Rename a feature everywhere it is named (owner 2026-11-27: a TRUE rename).
A feature’s id is also the name of the solid it makes and the head of every
face, edge, frame and sketch child it publishes (E4:S3:PROFILE_START,
CU1_PZ, D1:XY, S3:G20, E4:S3:PROFILE_START|E4:S3:L1_SW). Those names
are what every other part of the document stores: feature params (reference
fields, boolean targets), sketch external references, assembly constraints,
PMI annotations, sheet views and dimension anchors, ports, wires, CAM,
simulation and instruction blocks. rename_feature_in_document rewrites
the id and every such name in one pass over the document, so the caller can
adopt the result as ONE history edit (one undo step).
A name is rewritten per TOKEN, never as a substring:
- a string is split into segments at
|(an edge between two faces) and#(a sheet anchor’s edge), and each segment into tokens at:; - a token is the old id, or the old id followed by
_,@,[,.or#(CU1_PZ,S1@0,0,0,Ext_top[0]), which keepsE40andxE4untouched; - after a component token (
ACOMP2:), the rest of the segment names the component’s own part and is never touched.
Only the blocks that hold model entity names are walked (NAMED_BLOCKS;
in ports, only the keys points are placed by). Free text (labels, notes,
annotation text), the eCAD blocks (reference designators: D1 is a diode
there), the expression and configurator blocks, the family table and the
parts library are left alone. The
metadata block is keyed by names; the engine keeps it apart from the
history and renames its keys with rename_name.
A COMPONENT renames the same way: its id heads every name of its part
(ACOMP2:Part_PZ becomes Motor:Part_PZ), a Pattern Component instance
names it inside (APAT1.ACOMP2.i4 becomes APAT1.Motor.i4), and the eCAD
blocks’ occurrence keys (instance, occurrence) follow it. Names are read
against the document’s crate::ComponentNamespace, so what follows a
component’s id is its part’s and is never rewritten.
Refused by name, so nothing is half renamed: an id that is not a feature,
a pattern of components (APAT<n>: its instance ids are read by that
shape), an illegal or reserved name, a name already used in the document,
and an id another feature’s id extends (E4 when E4_B exists: its
references could not be told apart).
Structs§
- Rename
Outcome - What a rename changed.
Constants§
- MAX_
NAME_ LEN - The longest name accepted.
Functions§
- name_
uses - The places in
documentthat namename(as an id or the head of a derived name):/-joined JSON paths. Empty when the name is free. - rename_
feature_ in_ document - Rename feature
oldtonewthroughoutdocument(a history document:features,assembly,pmi,sheets, …), in place. On a refusal the document is unchanged and the error says why. - rename_
name namewitholdrenamed tonewper the token rule, orNonewhen it does not nameold.- rename_
name_ in rename_nameread against a document’s components (namespace): a token that is a component there (registered, or of theACOMP<n>shape) opens a part’s own names, which are never rewritten. For a component rename the namespace holds both the old and the new id.- validate_
name - Whether
namemay be given to a feature: a letter, then letters, digits or-, at mostMAX_NAME_LENlong, not reserved and not a component id._,:,|,.,@,#and spaces are refused because they are the separators of the names built from an id.