フィルターのクリア

Use Simulink.B​lockDiagra​m.arrangeS​ystem for signal line alignment but except one specific block

7 ビュー (過去 30 日間)
Chuyen
Chuyen 2023 年 10 月 6 日
編集済み: Suman 2024 年 7 月 24 日 8:46
I am writing a script to automatically alignment for a Simulink model. I will find all subsystem blocks in my Simulink model and do alignment by using Simulink.BlockDiagram.arrangeSystem command. However,in one of subsystems, it included a TriggerPort as attached figure which leaded to this command did not work properly.
What I expected from that script that, after running, the result should be like:
I had some directions here but I did not know which the exact command to support:
  1. Trigger Simulink.BlockDiagram.arrangeSystem with each subsystems, and if the subsystem blocks include Process trigger block, this command for all components inside except Process trigger.
  2. Hold the Process trigger as fixed position all the time.
Anyways, because I do not know which command will be available here. Thus, please help me do this or guide me some ideas.
% Simulink model name
model = 'Sample_model';
% Open Simulink model
open_system(model);
% Find all Subsystems in model
subsystems = find_system(model, 'FollowLinks', 'on', 'LookUnderMasks', 'all','LookUnderReadProtectedSubsystems','on', 'BlockType','SubSystem');
% Iterate through the list of Inports
for i = 1:length(subsystems)
subsystemonebyone = subsystems{i};
Simulink.BlockDiagram.arrangeSystem(subsystemonebyone, FullLayout='true');
end
% Save and close Simulink model
% save_system(model);
% close_system(model);

回答 (1 件)

Suman
Suman 2024 年 7 月 24 日 8:43
編集済み: Suman 2024 年 7 月 24 日 8:46
Hi Chuyen,
Please try setting the 'FullLayout' option to 'false'. As per the examples here https://www.mathworks.com/help/simulink/slref/simulink.blockdiagram.arrangesystem.html?s_tid=doc_ta#mw_ff2319a7-b5f3-40c8-8a1e-f7bcd43b3204, this options can lead to poor arrangement in certain situations like if the arrangement to be is not better than the current one due to space constrains or some other reasons.
Also using the 'Simulink.BlockDiagram.arrangeSystem' and just passing the model name should arrange it in the best way.

カテゴリ

Help Center および File ExchangeSchedule Model Components についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by