Search code examples
pythonjythonmodelio

AttributeError: 'org.modelio.metamodel.impl.uml.behavior.activityMo' object has no attribute 'getOwnedNode'


I'm using a script to find all paths in an Activity Diagram. To do it, I use Modelio 4.0.

I put the below script in a macro.

Script

## return first initial node in the selected activity
def getInitialPoint(act):
    for node in act.getOwnedNode():
        if isinstance(node, InitialNode):
            return node

## parcours activity nodes
def getPaths(currentPath, currentNode): 
    for outgoing in currentNode.getOutgoing():
        node = outgoing.getTarget()
        if isinstance(node, ActivityFinalNode):
            paths.append(currentPath)
            return;
        elif  isinstance(node, DecisionMergeNode):
            getPaths(currentPath, node)  
        else:           
            getPaths(currentPath + " - "  + node.getName(), node) 

 ##Init
init = getInitialPoint(elt)
currentPath = init.getName()
global paths
paths = []
getPaths(currentPath, init)

 ##Print founded paths
for p in paths:
    print p

Error

But when I launch the macro, I'm facing the below error:

AttributeError: 'org.modelio.metamodel.impl.diagrams.ActivityDiagra' object has no attribute 'getOwnedNode' in <script> at line number 20
Traceback (most recent call last):
File "<script>", line 20, in <module>
File "<script>", line 3, in getInitialPoint
AttributeError: 'org.modelio.metamodel.impl.diagrams.ActivityDiagra' object has no attribute 'getOwnedNode'

Could you please help me to fix it please? Thank you.


Solution

  • In fact, elt is the selected Element. This script works if you launch it from an Activity Element and not a Activity Diagram.

    Best,