Clear Filters
Clear Filters

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

7 views (last 30 days)
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);

Answers (1)

Suman
Suman on 24 Jul 2024 at 8:43
Edited: Suman on 24 Jul 2024 at 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.

Categories

Find more on Schedule Model Components in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!