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

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

我正在使用脚本查找 Activity Diagram 中的所有路径。为此,我使用 Modelio 4.0.

我把下面的脚本放在一个宏中。

脚本

## 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

错误

但是当我启动宏时,我遇到了以下错误:

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'

你能帮我解决一下吗?谢谢。

其实elt就是选中的Element。 如果您从 Activity 元素而不是 Activity 图表启动它,则此脚本有效。

最佳,