Clear Filters
Clear Filters

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

2 views (last 30 days)
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 Comments
Marcelo
Marcelo on 24 Jan 2018
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);

Sign in to comment.

Answers (0)

Categories

Find more on Modeling in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!