Borrar filtros
Borrar filtros

How do I get the x,y coordinates of port handles on a susbsytem block?

17 visualizaciones (últimos 30 días)
How can I determine, programmatically (that is, in an M-script), the position of these port handles on a subsystem? As the subsystem resizes, or as ports are added, the "bubbled up" representation on the subsystem block changes; I want to position other elements relative to these ports and thus need to be able to determine their final positions.

Respuesta aceptada

Jeff Fetta
Jeff Fetta el 24 de Mzo. de 2017
Well, I answered my own question...PortConnectivity is the parameter I was looking for. Here is some code that will "clean up" the input and output ports for a subsystem like that above (assuming input and output port blocks are connected to the subsystem block). Make sure you select the subsystem to clean-up first!
% get the subsystem port handle positions
pc = get_param(gcb,'PortConnectivity');
% distance from the subsystem to the port
offset = 200;
for i = 1:numel(pc)
% position of port connector
y = pc(i).Position(2);
x = pc(i).Position(1);
% port block handle and size
if isempty(pc(i).SrcBlock)
ph = pc(i).DstBlock;
off = -(offset-50); % asthetics here...related to the width of the port block
else
ph = pc(i).SrcBlock;
off = offset;
end
% port block dimmensions
pp = get_param(ph,'Position');
w = pp(3)-pp(1);
h = pp(4)-pp(2);
% adjust position of port block
set_param(ph,'Position',[x-off,y-h/2,x-off+w,y+h-h/2]);
end

Más respuestas (1)

Praveen Kumar
Praveen Kumar el 24 de Jun. de 2019
Hi,
I need help, how to backtrace the inport in between the two subsytems.
Subsystem - A is connected with Subsystem - B. I want Subsystem - B 1st inport is connected to which outport of Subsystem - A.
I need programmatically.
Anyone help me.
  1 comentario
ciming zhu
ciming zhu el 27 de Abr. de 2023
Have you sloved this problem,if you did,plz tell me how did you make it,thanks a lot.

Iniciar sesión para comentar.

Categorías

Más información sobre Schedule Model Components en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by