- %find_system out1 (or the list of what I was adding to)
- get the position of out1 = pos
- get the input port to out1
- get the line handle
- get the source port (out port of in1)
- delete the line
- set_param out1 to position [pos(1)+dx pos(2) pos(3)+dx pos(4)]
- add conv block to 'pos'
- addline in1 to conv
- addline conv to out1
Auto-connect block to existing line
조회 수: 30(최근 30일)
I want to add in some data type conversion blocks infront of some already existing inport blocks. I can create the block and add them to the model and they appear on the port line where I expect them, but they do not connect to that line. They appear above the line and I have to drag them to get them attached to the line. So I was wondering if there was any way I could connect the new block to the line that’s already there from the command line.
Albert Yam 2012년 9월 4일
편집: Albert Yam 2012년 9월 4일
How are you "getting the old block out out the way"? I never figured out how to leave lines in place.
Last time I did something like this,
Side note, if the list is really long, name the blocks 'well' and do a loop at the end to add all the lines. My code, with lines added at every step, took 2-3 hours. Doing lines at the end, took 20 mins. [Might only apply to Simulink 6.6.1]
EDIT: Actually, for your specific question, have you tried (no idea if this will work). get_param the port location (x,y location)
add_line([x y], [x y]) %effectively, draw a 'dot'
or get the port location of the existing block, port location of the new block, and add_line to those
Azzi Abdelmalek 2012년 9월 4일
편집: Azzi Abdelmalek 2012년 9월 4일
% the line fom you want connect to your new block "new_block" is an output for a certain block "block1"
%for example new_block is a "constant" block and modelname is the name of your simulink model
% to position your block
set_param('modelname/new_block','position' , [x0 y0 x0+x_width y0+y_width])
% 'block1/n' means n'th output of block1
% 'new_block/n' means n'th input of new_block