Check that point doesnt lay on line in Simulink block diagram

Hello!
I want to connect some block programatically. The simplest way for that is to add_line by points but when i add line by that way i encounter problem when points lay on existing line. In that situation two different lines are linked. Is there any way to check point to laying on existing line?

4 comentarios

I think it would be very hard if not possible. Why not add_line() by specifying ports and turn "autorouting" on?
add_line does not support more than two ports.
If you need to connect from a to b and a to c, can't you run add_line(a,b) and add_line(a,c) to achieve it?
It works! Thanks!
I sure that I have try that way some times and that doesnt work because one of port has a connection.
Write answer please. I will approve it.

Iniciar sesión para comentar.

 Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 23 de Nov. de 2020
Checking whether a point lays on any existing line will be very difficult. The answer to the OP's question seems to be utilizing add_line() in a different way. Rather than specifying multiple points in one add_line() to achieve connecting multiple ports, calling add_line(SourcePort, DestinationPort) multiple times seems to meet the need.

5 comentarios

Hello!
Today I encounter problem with add_line. Sometimes it throws error "The second port already has a line connection". If I add third block and try to connect it to any existing port (to "second port with connection" too) in any order it is ok. Simulink does not like only first two blocks. I cant understand why it happens because add_line works fine in model with about 100 block added and connected programatically. Do you have any ideas why it happens?
I wrote in comments to question I encounter that problem earlier when i worked with small diagrams.
Not fully understand your comment above.
In any case, you can check whenther the destination port (the second port) is already connected before add_line(). This will make your add_line() code more robust. A signal can go from one source to multiple destinations, but the signal at the destination can have only once source, right?
I am working with Simscape library. I can connect any lines to one port.
Now i have diagram with 346 blocks and a lot of connections (some thousands). Only 9 times i get error "The second port already has a line connection".
Could it be possible that those places only allow one connection?
No, because there are some connections to it already exist. Moreover I can connect another port to it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Preguntada:

el 22 de Nov. de 2020

Comentada:

el 4 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by