in Simulink, add line from line_node to block with command?

5 views (last 30 days)
In Simulink, I want to add 'B4' and connect to 'A' with command, I want it to look like bellow:
I tried the code of add_line(gcs, 'A/1', 'B4/1', 'autorouting', 'on'). but it looks like bellow:
Then my new idea is add_line from 'P1_position' to 'B4'. while I do not know how to get the 'P1_position' or 'Line3_length'(to calcute P1_position).
Thanks to all viewing/answering my question!

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 7 May 2020
If you know that the connection can be started from block B3, then you can get the line handles of B3, then get the line handle of Line 3, then get the 'Points' of Line 3.
I've been able to add the line directly from P1 to block B4 inport (get its position first), but 'autorouting' is not available when using add_line with points. You need to generate the way point based on the coordinates of point P1 and B4 inport point. I think it can be done.
Leo Zhai
Leo Zhai on 9 May 2020
Thank you very much, the bellow is exactly what I wanted.
(I had tried get_param(lh_inport, 'ObjectParameters') to search 'line_length' parameters but got none...)

Sign in to comment.

More Answers (0)


Find more on Programmatic Model Editing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!