nflow_reroute(sys)
nflow_reroute(sys, width)
nflow_reroute(sys, width, height)
| Parameter | Description |
|---|---|
| sys | a string: name of a loaded model ('model') to route its root diagram, or path of a subsystem ('model/Sub', 'model/Sub/Inner') to route that subsystem; or a numeric model handle. |
| width | a scalar: width of the routing area, in diagram units. Default: 4000. |
| height | a scalar: height of the routing area, in diagram units. Default: 4000. |
nflow_reroute computes a new route for every connection of a (sub)system and stores it on the connection as a list of waypoints. Routes are orthogonal and go around the blocks, from the output port to the input port.
Blocks do not move: call nflow_layout first to arrange them, then nflow_reroute to draw the wires for the new positions. Port positions are estimated from the number of ports declared by each block type.
Only the targeted depth is routed: call nflow_reroute on each subsystem path to route it too. Only the wire geometry changes, so the simulation result is unchanged.
The model must be loaded (new_system or load_system). An unknown subsystem path, or a routing failure, is an error. The model is marked as modified; use save_system to keep the routes.
new_system('demo');
add_block('nflow/source/sine', 'demo/S');
add_block('nflow/math/gain', 'demo/G', 'Gain', 2);
add_line('demo', 'S/1', 'G/1');
nflow_layout('demo');
nflow_reroute('demo');
f = [tempname(), '.nflow'];
save_system('demo', f);
m = jsondecode(fileread(f));
w = m.connections(1).waypoints;
[[w.x]', [w.y]']
bdclose('demo');
rmfile(f);
| Version | Description |
|---|---|
| 1.0.0 | initial version |