Table of Contents

Machine Chain Code

A chain code is a short bracket notation for the connectivity of a mechanism — the same structure the Equipment page's Topology column draws — meant for writing a machine down by hand. Build a machine tool from one with CreateFromChainCode(API); read any machine's code back from ChainCode, and assign ChainCodes to rebuild its structure. A hand-written code and a structure edited in the Topology column are interchangeable, with two exceptions on the way back: a mechanism with two components sharing one name, or with an unnamed component that more than one segment would have to mention, cannot be written down as code.

The code carries connectivity only. Pivots, exact axis vectors, end-anchor offsets and shapes are properties of the mechanism, and assigning a new code preserves them for every component whose name is unchanged. The error-term mark (IsErrorTerm) is not part of the notation either: assigning a new code carries a branch's mark over together with its transformer to the same-named component.

The notation itself is ChainCodeUtil, which knows nothing about machines and serves any mechanism. The machine's keywords below are laid on top of it by XyzabcChainCodeConvention.

The Notation

Each segment declares branches from left to right:

[O][base][Z][C][w];[O][base][Y][X][B][S][t]
  • [A][B][C] is shorthand for the branches [A][B];[B][C], so a segment is just a path.

  • Words are components. The same word in different segments is the same component, which is how segments join into one structure.

  • The first word of the whole code names the ground anchor. Within a segment each branch runs from the word on its left to the word on its right.

  • For a machine tool, the reserved words are the topology keywords: X, Y, Z, A, B, C become motion axes, w and t become the end anchors, and S, when t hangs from it as in [B][S][t] above, becomes the spindle: its branch carries a DynamicRotation about −Z through S's origin, bound as the machine's Spindle, which playback turns to the spindle angle while the spindle stands. The tool mount's offset from S is edited on the t branch; the spindle's pivot must move with it, onto the tool mount's origin, or the machine reports the spindle off the tool axis. Any other word is a plain component carried along without motion, such as base above, or an S that t does not hang from. A machine code must name exactly one [w] and one [t]; the six axes are optional, and each may be used at most once. Words merge by exact name, so no two components can claim one role; what the check refuses is a code naming no table mount at all — the chain code must contain the table mount [w]. A code carrying only [W] is refused by that same check, and the message names the near miss: The code carries [W], which differs only in letter case; the keyword is matched exactly, so rename it to [w].

  • Spell the keywords exactly in a code — upper case for the axes and S, lower case for t and w. A mis-cased axis in a code is a plain component contributing no motion, and a mis-cased end anchor stops the code building. (A machine file that takes its roles from these names, because it records no roles of its own, still loads with mis-cased anchors: its roles bind to the one anchor or branch that matches ignoring letter case, with a message asking for the rename.)

  • [] is an anonymous component. Each occurrence is a separate one, it cannot be referred to from another segment, and assigning a new code cannot carry its transformer, error-term mark or shape over, because the carry-over matches components by name.

  • Declaring the same branch twice is harmless; it states the same connection.

  • A segment with a single word just declares a component, which is how a ground anchor that only receives branches gets named.

  • Any number of segments is allowed, so auxiliary structures can branch off any component:

    [O][base][Z][C][w];[O][base][Y][X][B][S][t];[base][loader][gripper]
    
  • An error term sits in series on a branch of its own, just before the axis or the spindle it belongs to (Error-Term Branches), so the anchor it needs is one more plain word on that path, in front of that axis' or spindle's own word. A pivot offset of the C axis above reads [O][base][Z][Cerr][C][w];[O][base][Y][X][B][S][t], the anchor named as the Topology column names it when it adds Axis C's error term: the branch arriving at Cerr is the one to carry the error and the mark, and C keeps its axis.

Direction and Convergence

Branch direction is free. A branch authored towards the ground anchor is simply written that way, as in [Z][O]. A branch belongs to the component farther from the ground anchor, so [O][Y] and [Y][O] both make Y the axis; only the direction differs. Pointing every branch away from the ground anchor remains a readability convention — it makes the structure read outwards, ground → base → motion axes → the t and w end anchors — but the motion, the axis keywords and the default collision pairs all read a branch the same way round regardless.

Limbs may meet again. [A][B][D];[A][C][D] gives D two incoming branches. Only one route through such a loop drives the motion, so use it for structure rather than for a second motion path.

Axis directions follow the machine-building convention: axes between the ground anchor and w are seeded negative, the others positive.

Machine Files

A machine tool file stores its structure in full — every anchor, branch, transformer and shape, and IsErrorTerm="true" on a branch marked as an error term — not as a chain code. A file that carries a ChainCode element instead loads from that code, and one whose IsVertical element reads false loads laid on its side, with a root anchor ahead of its ground, which its code then names: [root][O]….

See Also