Networks
A harness has two bundle networks. The available network is every path the harness could take. The chosen network is the one path this harness takes. A harness build distills, modifies, and refines the available network into the chosen network, then flattens the chosen network into a 2D drawing (networks/flat.csv).
The calls a build uses for this are available_network, bundle_network_utils, chosen_network, and flattened_network in the schema.
Words
- Network — a dict with
"nodes"and"segments". - Node — a point in 3D: a connector, a branch, or a bend. It has a
node_idand alocation[x, y, z]. - Segment — a run of wire bundle between two points. It has a
segment_idand two end locations. - Available network — every route the harness could take. Saved in
networks/available.json. The available network editor shows exactly this file. - Chosen network — the one route this harness takes. Saved in
networks/chosen.json. The harness is built from it. - Needed node — a node the harness must reach. Usually one per connector, named
<connector_group>.node. - Source of truth — where a node or segment came from:
"gui": you drew it, or the build added it for you to edit. It stays in the file.- A routing context, such as
"source physical model.step"(the source system). The build reloads it fresh every time.
Where the available network comes from
- You draw it in the available network editor.
- The build reads it from the source system's physical model.
- You import it from CAD with
available_network.source_context_from_path. - You copy it from another project with
available_network.source_available_network_from_project.
How the calls work
- Each call returns a new network. The one you pass in is not changed.
- Always assign the result back, for example
network = bundle_network_utils.move_node(network, node_id, direction=offset).
Which function does what
- Building the route:
end_all_segments_in_nodes: gives every loose segment end a node.raise_on_duplicate_node_ids: stops the build if two nodes share a name.adopt_device_nodes: renames the node where a harness connector plugs into a device to<connector_group>.node, turned to face the device.ensure_nodes_exist: lists the needed nodes that are missing.calculate_possible_sub_networks: lists every route that reaches all the needed nodes. Empty means no route.find_network_with: keeps the routes that contain a segment or node you name.
- Editing the chosen route:
new_node,move_node,rename_node,reroute_segment,clock_backshell. - Placing connectors:
- With a backshell:
clock_backshellturns it toward the next node. It already shifts by the connector mate. - Without a backshell:
move_nodewithoutput_offset(..., "3d-mate").
- With a backshell:
- Order: layout moves go after one route is picked and before
chosen_network.save. Thenflattened_network.derivemakes the flat drawing.
Coordinate systems
- A coordinate system is a dict:
{x, y, z, alpha, beta, gamma}. x,y,z: the position.alpha,beta,gamma: degrees about X, Y, and Z.- The rotation is
Rx(alpha) · Ry(beta) · Rz(gamma). Z is applied first, then Y, then X. output_offsetanddifference_between_csysreturn one. Pass it tomove_nodeasdirection.
How the default harness build makes the chosen network
- Starts with:
networks/available.json. - Ends with:
networks/chosen.jsonand the flat drawing. - Boxes are steps, numbered [1] to [24]. The table below the diagram uses the same numbers. Arrows say why the build moves on.
- Dashed boxes are yes-or-no questions. The arrows out of them start with Yes or No.
- Two loops:
- The first places any needed node that is missing.
- The second connects every needed node into one route.
- Stop boxes are where the build fails with an error.
stateDiagram-v2
Load : [1] Read available.json<br>into memory as the<br><span style='color:red'>available network</span>. A<br>missing file gives an<br>empty available network.
ReloadContexts : [2] In the<br><span style='color:red'>available network</span>, drop<br>every node and segment<br>that is not gui, then add<br>the source system's device<br>nodes and routed<br>segments again.
SaveAvailable : [3] Write the<br><span style='color:red'>available network</span> to<br>available.json.
CopyToChosen : [4] Read the whole<br><span style='color:red'>available network</span> and copy<br>it into a new<br><span style='color:cyan'>chosen network</span>.
AdoptDeviceNodes : [5] In the <span style='color:cyan'>chosen network</span>,<br>rename each node at a<br>harness connector's device<br>node to<br>connector_group.node and<br>turn it to face the<br>device. The available<br>network keeps the old<br>name.
NamesUnique : [6] Read the<br><span style='color:cyan'>chosen network</span>. Is every<br>node name unique?
EndSegments : [7] In the <span style='color:cyan'>chosen network</span>,<br>give every segment end<br>that is not on a node a<br>new node. The available<br>network is not changed.
NextNeededNode : [8] Take the next needed<br>node from the<br><span style='color:yellow'>instances file</span>.
AlreadyInChosen : [9] Read the<br><span style='color:cyan'>chosen network</span>. Does it<br>already have a node with<br>this name?
PlaceNode : [10] Write the node to<br>both the <span style='color:red'>available network</span><br>and the <span style='color:cyan'>chosen network</span>, at<br>a random spot near the<br>other nodes of the chosen<br>network.
NeededLeftToCheck : [11] Are any needed nodes<br>left to check?
TwoOrMoreNeeded : [12] Are there two or more<br>needed nodes?
MaybeAddHub : [13] When there are more<br>than three connectors, no<br>segments in the<br><span style='color:red'>available network</span>, and no<br>hub, write a hub node to<br>both the <span style='color:red'>available network</span><br>and the <span style='color:cyan'>chosen network</span>.
StartConnectedNodes : [14] Start the list of<br>connected nodes with hub,<br>or with one needed node<br>picked at random when<br>there is no hub. Shuffle<br>the rest.
NeededLeftToConnect : [15] Are any needed nodes<br>left to connect?
AddNextNode : [16] Add the next needed<br>node to the connected<br>nodes.
RouteFound : [17] Read the<br><span style='color:cyan'>chosen network</span>. Does<br>calculate_possible_sub_networks<br>find a route that joins<br>all the connected nodes?
AddLeg : [18] Write a gui segment<br>to the new node, from hub<br>or from the nearest<br>connected node, to both<br>the <span style='color:red'>available network</span> and<br>the <span style='color:cyan'>chosen network</span>.
SaveAvailableAgain : [19] Write the<br><span style='color:red'>available network</span>, with<br>everything the build<br>added, to available.json.
ExactlyOneRoute : [20] Read the<br><span style='color:cyan'>chosen network</span>. Does<br>calculate_possible_sub_networks<br>find exactly one route<br>that joins all the needed<br>nodes?
MoveConnectorNodes : [21] In the one route<br>picked from the<br><span style='color:cyan'>chosen network</span>, move each<br>connector node by its<br>backshell clock or its<br>3d-mate offset.
SaveChosen : [22] Write that route to<br>chosen.json as the<br><span style='color:cyan'>chosen network</span>, and build<br>the flat drawing from it.
StopDuplicateNames : [23] The build stops with<br>an error that names the<br>duplicate nodes. Nothing<br>more is written.
StopRouteCount : [24] The build stops with<br>an error that says how<br>many routes it found.<br>Nothing more is written.<br>The user is encouraged to<br>use functions like<br>bundle_network_utils.find_network_with(input_networks,<br>segment_ids=[],<br>node_ids=[]) to approach<br>the desired network.
[*] --> Load : The harness build<br>reaches its network<br>section.
Load --> ReloadContexts : The available network<br>is in memory.
ReloadContexts --> SaveAvailable : The available network<br>has fresh source<br>system items.
SaveAvailable --> CopyToChosen : available.json matches<br>the available network.
CopyToChosen --> AdoptDeviceNodes : The chosen network has<br>every node and segment<br>of the available<br>network.
AdoptDeviceNodes --> NamesUnique : Connector nodes in the<br>chosen network have<br>their harness names.
NamesUnique --> StopDuplicateNames : No. Two nodes share a<br>name.
NamesUnique --> EndSegments : Yes.
EndSegments --> NextNeededNode : Every segment in the<br>chosen network ends on<br>a node.
NextNeededNode --> AlreadyInChosen : There is a needed node<br>to check.
AlreadyInChosen --> NeededLeftToCheck : Yes. Nothing to add.
AlreadyInChosen --> PlaceNode : No. It is missing.
PlaceNode --> NeededLeftToCheck : The node is in both<br>the available network<br>and the chosen<br>network.
NeededLeftToCheck --> NextNeededNode : Yes.
NeededLeftToCheck --> TwoOrMoreNeeded : No. Every needed node<br>is checked.
TwoOrMoreNeeded --> NeededLeftToConnect : No. There is nothing<br>to connect.
TwoOrMoreNeeded --> MaybeAddHub : Yes.
MaybeAddHub --> StartConnectedNodes : A hub exists if this<br>harness needs one.
StartConnectedNodes --> NeededLeftToConnect : The list has its first<br>node.
NeededLeftToConnect --> AddNextNode : Yes.
NeededLeftToConnect --> SaveAvailableAgain : No. Every needed node<br>is connected.
AddNextNode --> RouteFound : One more needed node<br>is on the list.
RouteFound --> NeededLeftToConnect : Yes. The new node is<br>already connected.
RouteFound --> AddLeg : No. The new node is<br>not connected yet.
AddLeg --> NeededLeftToConnect : The new node is now<br>connected in both the<br>available network and<br>the chosen network.
SaveAvailableAgain --> ExactlyOneRoute : available.json holds<br>everything the build<br>added.
ExactlyOneRoute --> StopRouteCount : No. There are zero<br>routes, or more than<br>one.
ExactlyOneRoute --> MoveConnectorNodes : Yes.
MoveConnectorNodes --> SaveChosen : Connector nodes sit at<br>their mating faces.
SaveChosen --> [*] : chosen.json and the<br>flat drawing are on<br>disk.
classDef question stroke-dasharray: 5 5
class NamesUnique,AlreadyInChosen,NeededLeftToCheck,TwoOrMoreNeeded,NeededLeftToConnect,RouteFound,ExactlyOneRoute question
| Block | State | What happens | What is written |
|---|---|---|---|
| 1 | Load | available_network.load() reads available.json. A missing file is an empty network. |
Nothing. |
| 2 | ReloadContexts | keep_only_gui drops every node and segment that is not "gui". The source system's device nodes and routed segments are added again, fresh, tagged "source physical model.step". |
Nothing yet. |
| 3 | SaveAvailable | available_network.save writes the available network. |
available.json |
| 4 | CopyToChosen | The chosen network starts as a copy of the whole available network. | Nothing. |
| 5 | AdoptDeviceNodes | A node named after the device node a harness connector plugs into (<device_side_refdes>.<device_side_connector_id>), whatever its source of truth, becomes <connector_group>.node, turned 180° to face the device. Chosen network only. |
Nothing. |
| 6 | NamesUnique | raise_on_duplicate_node_ids reads the chosen network. Two nodes with one name, whatever their source of truth, stop the build. |
Nothing. |
| 7 | EndSegments | end_all_segments_in_nodes gives every free segment end a node. Chosen network only. |
Nothing. |
| 8 | NextNeededNode | First loop. Takes each needed node (an instance with item_type "node") from the instances file, in turn. |
Nothing. |
| 9 | AlreadyInChosen | Reads the chosen network to see whether it already has a node with that name. | Nothing. |
| 10 | PlaceNode | Adds the missing node to both the available network and the chosen network as "gui", 6 to 18 inches from the average location of the chosen nodes, at a random angle in XY. |
Nothing yet. |
| 11 | NeededLeftToCheck | The first loop repeats until every needed node is checked. | Nothing. |
| 12 | TwoOrMoreNeeded | A harness with fewer than two needed nodes (one connector) has nothing to connect. It skips the hub and the list, and the next question answers No. | Nothing. |
| 13 | MaybeAddHub | With more than three connectors, no segments in the available network, and no hub yet, a hub node is added to both the available network and the chosen network as "gui", at the average location of the needed nodes. |
Nothing yet. |
| 14 | StartConnectedNodes | The list of connected nodes (needed nodes that one route already joins) starts with hub when there is one, otherwise with one needed node picked at random. The rest are shuffled. |
Nothing. |
| 15 | NeededLeftToConnect | The second loop repeats until every needed node is connected. | Nothing. |
| 16 | AddNextNode | Second loop. The next needed node is added to the connected nodes. | Nothing. |
| 17 | RouteFound | calculate_possible_sub_networks(chosen, connected_nodes) reads the chosen network and looks for a route that joins all the connected nodes. |
Nothing. |
| 18 | AddLeg | A "gui" segment named <new node>_leg goes into both the available network and the chosen network: from hub when there is one, otherwise from the nearest node already connected. |
Nothing yet. |
| 19 | SaveAvailableAgain | available_network.save writes the available network with every node and segment added above, so the next build reuses them. A harness with fewer than two needed nodes (one connector) comes straight here. |
available.json |
| 20 | ExactlyOneRoute | calculate_possible_sub_networks(chosen, needed_nodes) reads the chosen network and lists the routes. find_network_with can narrow them to the one with a preferred segment or node. Anything but exactly one route stops the build. |
Nothing. |
| 21 | MoveConnectorNodes | Each connector node is moved by its backshell clock or by its connector's 3d-mate offset. Chosen network only. |
Nothing. |
| 22 | SaveChosen | chosen_network.save writes the one route. flattened_network.derive then builds the flat drawing from it. |
chosen.json, flat.csv |
| 23 | StopDuplicateNames | The build raises an error that names the duplicate nodes and their sources of truth. | Nothing more. |
| 24 | StopRouteCount | The build raises an error that says how many routes it found. The user is encouraged to use functions like bundle_network_utils.find_network_with(input_networks, segment_ids=[], node_ids=[]) to approach the desired network. |
Nothing more. |