I have a part def where an attribute is defined, and then in a part usage I want to access the value of the attribute which I expect to be inherited.
part def MyPartDef {
attribute attr1 = 1;
attribute attr2 = 2;
attribute attrSum = attr1 + attr2;
}
part myPartUsage : MyPartDef;
In automator I’ve got this script:
def get_node(model: syside.Model, qualified_name: Sequence[str]) -> syside.Element:
# Using the function provided in syside_helpers.py in the state machine example
def get_attribute_value(node: syside.AttributeUsage):
return syside.Compiler().evaluate(node.feature_value_expression)[0]
print(get_node(model, ['MyPartDef','attrSum']))
print(get_attribute_value(get_node(model, ['MyPartDef','attrSum'])))
print(get_node(model, ['myPartUsage']))
print(get_node(model, ['myPartUsage','attr1']))
The output becomes:
MyPartDef::attrSum
3
myPartUsage
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
...
File XXXXXXX, in _get_node_by_qualified_name(node, qualified_name)
31 for segment in qualified_name:
32 assert isinstance(current_node, syside.Namespace)
---> 33 current_node = current_node[segment]
34 return current_node
KeyError: "No member named 'attr1' exists in this namespace"
Surely it is not an incorrect expectation that the attributes in the defintion would be inherited by the usages? Please advise.