Why set_param( block, 'Position', pos ) shift subsystems ?
古いコメントを表示
Hi,
I am using this code to resize subsystems in a model :
function format_subsystems( model )
subsystems = find_system(model,'SearchDepth', 1, 'blocktype','SubSystem');
nb_tot = length(subsystems);
for subsystem_index = 1 : 1 : nb_tot
pos = get_param( subsystems{subsystem_index}, 'Position' );
nb_ports = get_param( subsystems{subsystem_index}, 'Ports' );
height = 35 * ( max( nb_ports(1), nb_ports(2)) - 1) + 36 ;
set_param( subsystems{subsystem_index}, 'Position', [ pos(1), pos(2), pos(1) + 100, pos(2) + height ] );
end
end
Example of result :
pos =
350 50 450 150
nb_ports =
1 2 0 0 0 0 0 0
height =
71
Final subsystem position should be :
50 50 150 121
But final subsystem position is :
50 52 150 123
This shift of two pixels is done systematically.
Does anybody can explain me why ? Is there a way to position subsytems as I want ?
Thank you for help.
1 件のコメント
Kaustubha Govind
2012 年 11 月 26 日
Bonneuil: If you don't receive a response here, you should probably contact MathWorks Technical Support about this.
回答 (1 件)
Sohan Lal
2021 年 2 月 24 日
0 投票
As per my understanding, you are facing the issue of the subsystem getting shifted a few pixels on setting the new position using the set_param function. This is possible with the pixel alignment. When we set the position, internally it tries to make it pixel align, and this might result in a bit of shift in the position.
We can even see this behavior when we manually move the block position, it will still go with the pixel alignment only.
カテゴリ
ヘルプ センター および File Exchange で Programmatic Model Editing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!