フィルターのクリア

Simulink align ports keyboard shortcut

43 ビュー (過去 30 日間)
ricard molins
ricard molins 2019 年 1 月 17 日
回答済み: Mingli ZHU 2021 年 1 月 19 日
I work on simulink for long periods of time. Having to "select some models" and then "right click / Arrange / Match Size " + "right click / Arrange / Align Left " + "right click / Arrange / Distribute Verticaly" is a time consuming task that should be automatizable.
I am already now how to add custom menus with custom functions which are binded to a keyboard shortcut that launches some scripts.
Is there any programatical way to "right click / Arrange / Align Left " without having to go block by block to read the properties an so on and compute the position (a way to launch matlab build it "Align Left" function ?

回答 (2 件)

Sandeep Disale
Sandeep Disale 2019 年 1 月 23 日
Hi Ricard,
Maybe this can help,
Thanks
  1 件のコメント
ricard molins
ricard molins 2019 年 1 月 28 日
Even though this answer is usefull this is not exactly what I am looking for. My objective is to avoid having to handle inports\outports of blocks and work more based on a selection of items and align them.

サインインしてコメントする。


Mingli ZHU
Mingli ZHU 2021 年 1 月 19 日
Hello,
%find current selected blocks
blocks=find_system(gcs,'selected','on');
L=length(blocks);
% create 3 arrays: blcoks top position/found numbers/new positions
top=zeros(L,1);
num=zeros(L,1);
pos=zeros(L,1);
for i=1:L
position=get_param(blocks{i},'Position');
top(i)=position(2);
num(i)=i;
end
new_top=sort(top);%sort top ascendantly
min=new_top(1);
max=new_top(L);
distance=(max-min)/(L-1);%calculate interval
for i=1:L
pos(i)= find(top(i)==new_top);%find block's new order
position=get_param(blocks{i},'Position');
position=position+[0 min+(pos(i)-1)*distance-position(2) 0 min+(pos(i)-1)*distance-position(2)];
set_param(blocks{i},'Position',position);% re placer
end

カテゴリ

Help Center および File ExchangeInteractive Model Editing についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by