in Simulink, add line from line_node to block with command?
5 次查看(过去 30 天)
显示 更早的评论
In Simulink, I want to add 'B4' and connect to 'A' with command, I want it to look like bellow:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/291027/image.jpeg)
I tried the code of add_line(gcs, 'A/1', 'B4/1', 'autorouting', 'on'). but it looks like bellow:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/291028/image.jpeg)
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).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/291029/image.jpeg)
Thanks to all viewing/answering my question!
0 个评论
采纳的回答
Fangjun Jiang
2020-5-7
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.
3 个评论
Fangjun Jiang
2020-5-8
编辑:Fangjun Jiang
2020-5-8
- Your task is to connect from A to B4 and make the line pretty. In program, you have to decide where to start this new line. From P1 or the junction points above it (the intersection point of the vertical line with horizontal input line of B2 or B1). If you know it is P1 which actually means the block B3 is known, then it makes this task a little easier.
- Use this code. You will get the position of P1 from the points of B3 input line
lh=get_param([gcs,'/B3'],'LineHandles');
lh_inport=lh.Inport;
get_param(lh_inport,'Points')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!