Use Simulink.BlockDiagram.arrangeSystem for signal line alignment but except one specific block
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1503644/image.png)
What I expected from that script that, after running, the result should be like:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1503649/image.png)
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 commentaires
Réponses (1)
Suman
le 24 Juil 2024
Modifié(e) : Suman
le 24 Juil 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 commentaires
Voir également
Catégories
En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!