How to find the connected elements of ports with JS ?
I tried using the "port.end" , but it doesn't work.
There are a number of scripts in this forum for this topic I thin, for example Find connected ports : Ansys medini analyze Support (freshdesk.com)
For the error: you should use this instead:
console.log("{0}", test);
At the moment our log fucntion doe snot recognize that the first argument is not a message format but an object.
Jan
I was wrong about my last statement, its not that the console API is wrong, its because test is undefined and undefined is for Rhino a problem when mapping its type to an API. So maybe you add some if check in between anyway.
I had found the topic Find connected ports : Ansys medini analyze Support (freshdesk.com) .
The solution "port.end", but it doesn't work.
Maybe the problem is caused by Metamodel.
In my script, when I select a port, the port's Metamodel is sysMLPortUsage.
In the topic the port's Metamodel is SysMLFlowPortUsage.
How can I achieve the following function with JS?
-- get all ports, navigate via the connector to the other port, then grab the container of the other port self.element.oclAsType(sysml::SysMLElement).the_owned_elements->select(o | o.oclIsKindOf(sysml::SysMLFlowPortUsage)).oclAsType(sysml::SysMLFlowPortUsage).end->collect(e | e.theConnector.theConnectorEnd->at(2)).role.eContainer()
We had separate meta classes for ports at Blocks (Types) and Parts (Instances) before, but in recent versions we only have Metamodel.sysml.SysMLPortUsage.
So just rephrase the scripts to your needs.