Connect two simulink lines programatically
9 views (last 30 days)
Show older comments
Hi,
I have a need to remove all goto-from block pair (requirement for some project) and perform the connections with lines.
I can make a script that removes all goto-from blocks and I can basically track source for each goto and destination for each from which I can thn connect with add_line, but this appreach is awkward and has certain implementation problems (immagine from block that feeds some things one of which is some other goto block).
What I ould like to do is programatically connect the lines that connect from and to those goto-from pairs. i.e. I remove the blocks with delete_block and then would like to connect the wires that were previously connected to each pair. add_line doesn't seem to accept line handles as argument. So the question is:
How do I programatically connect to simulink lines?
0 Comments
Answers (1)
Fangjun Jiang
on 17 Jun 2020
%%
Model='ex_goto_tag_visibility_block';
open_system(Model);
Block=[Model,'/GotoGlobal'];
PC=get_param(Block,'PortConnectivity');
P1=PC(1).Position;
delete_block(Block);
Block=[Model,'/From'];
PC=get_param(Block,'PortConnectivity');
P2=PC(1).Position;
delete_block(Block);
add_line(Model,[P1;P2])
0 Comments
See Also
Categories
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!