Use Simulink.BlockDiagram.arrangeSystem for signal line alignment but except one specific block
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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:
- 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.
- 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);
0 Kommentare
Antworten (1)
Suman
am 24 Jul. 2024
Bearbeitet: Suman
am 24 Jul. 2024
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!