I create Connection between objects like this:
but how can i check if there is already a connection between two elements ?
thx for your help
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.
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.
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.
can i do this or do i need to be careful with this ?
local check := executeSilent(":boolean is do .MaterialFlow.Connector.connect(.Models.BrickSupply.Source, .Models.BrickSupply.BrickSupply); return true; end;");