Cancel
Showing results for 
Search instead for 
Did you mean: 

Check if connection exists

Valued Contributor
Valued Contributor

Hi,

 

I create Connection between objects like this:

 

.MaterialFlow.Connector.connect(elementA, elementB);

but how can i check if there is already a connection between two elements ?

thx for your help Smiley Wink

 

Readock

4 REPLIES

Re: Check if connection exists

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Readock,

 

you can use the attributes succ and NumSucc to get all the successors of an object.

 

I.e. you can write a loop over you successors and check if there is already a connection to another object.

 

Regards,

Ralf

Regards,

Ralf
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: Check if connection exists

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Readock,

 

it is also possible to check if the connection could be done. Plant Simulatuion does not connect two objects twice.

So change you connect statement to:

 

local canConnect: boolean := .Materialflow.Connector.connect( objectA, ObjectB);

 

if canConnect is true, there Plant sim can connect and both objects had not been connected before.

 

If canConnect is false, both objects are already connected.

 

Regards

GG

Regards
GG

------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution

Re: Check if connection exists

Valued Contributor
Valued Contributor

hi,

 

this didn't work for me. I have tried this code:

local canConnect: boolean := .MaterialFlow.Connector.connect(.Models.Frame.Source, .Models.Frame.BrickSupply)

then i get an error that there is already a connection between this two elements.

But this works

if Source.succ(1) = BrickSupply then ...

although the other solution would be better because here i have to iterate through all the Connections of an element.

 

 

 

 

 

 

 

 

Re: Check if connection exists

Valued Contributor
Valued Contributor

can i do this or do i need  to be careful with this ?

is
do
    local check :=  executeSilent(":boolean is do .MaterialFlow.Connector.connect(.Models.BrickSupply.Source, .Models.BrickSupply.BrickSupply); return true; end;");
    print check;
end;