Add one port to a Simulink block, from command line AND automaticaly keep the same distance between ports

2 views (last 30 days)
Hi,
I'm trying to automate the creation of a Simulink model.
In some case I have to add sevral inport to BusCreators. The trouble is when I add an inport, using
get_param(buscreator_handle, 'Input', '15')
, while there were 13 inports before. The block keep the same size, but vertical distance between inports reduces...
Is there a quick way to automaticaly set block postion so that vertical distance between ports stay the same? Or does anyone know a simple computation to find 'Position' of block so that vertical distance between inports stay the same.
It's not just proportinal because I remember times ago I met BusCreator where first and last inports where exactly at top of and bottom of BusCreator, and sometimes not (gap between block top and first inport, and gap beetween last inport and block bottom).

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 11 Feb 2021
I dealt with this problem before. There is no quick or automatic way but the following method worked for me to keep the existing signal lines straight.
You can get and set the position of the block, which in effect is to control the height of the block. Make
BlockHeight=a+b*n, where a is the offset, b is the linear scale, n is the number of ports you just set for the BusCreator block. You just need to play with a and b to keep the port distance the same. You might also need to play with the corner position of the block to keep the existing signal lines straight.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!