필터 지우기
필터 지우기

Simulink problem: Blocks positions are not maintained after the model is saved.

조회 수: 2 (최근 30일)
Marcelo
Marcelo 2018년 1월 24일
댓글: Marcelo 2018년 1월 24일
Hi,
I am with a problem related with blocks positions.
I have a Simulink model that I run a script to configure all its blocks positions.
When the execution of this script terminates, all the blocks are configure exactly as I want.
So I save and close the model.
The problem occoures when I open the model after that. Many of the blocks are not in the positions defined anymore when the model was saved.
Someone kowns why some positions changing when the model is opened?
Thank you
Marcelo Ávila
  댓글 수: 2
Marcelo
Marcelo 2018년 1월 24일
For example, one part of the code is like this:
load_system(model_name_no_extension);
% Positioning S-Function block
Block_current_Position = get_param(h_Block,'Position');
Block_new_Position = Block_current_Position;
Block_new_Position(1) = 1500;
Block_new_Position(3) = 3000;
Block_new_Position(2) = -32000;
Block_new_Position(4) = 32000;
set_param(h_Block,'Position',Block_new_Position);
Block_LineHandles = get_param(h_Block,'LineHandles');
Block_PortHandles = get_param(h_Block,'PortHandles');
% Positioning inports of S-Function block
inport_delta = abs(get_param(Block_PortHandles.Inport(1),'Position') - get_param(Block_PortHandles.Inport(2),'Position'));
inport_delta = floor(inport_delta(2)/2) - 10; % Consider only height
for i = 1:1:length(Block_PortHandles.Inport)
port_position = get_param(Block_PortHandles.Inport(i),'Position');
% Intermediate block
line_info = get(Block_LineHandles.Inport(i));
intermediate_block = line_info.SrcBlockHandle;
intermediate_block_position = [port_position(1)-500-200 port_position(2)-inport_delta port_position(1)-500 port_position(2)+inport_delta];
set_param(intermediate_block,'Position',intermediate_block_position)
% Initial block
LineHandles = get(intermediate_block,'LineHandles');
line_info = get(LineHandles.Inport);
inicial_block = line_info.SrcBlockHandle;
inicial_block_position = intermediate_block_position - [500 0 500 0];
set_param(inicial_block,'Position',inicial_block_position)
end
save_system(model_name_no_extension);
close_system(model_name_no_extension);

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by