package A {
package B {}
}
Say the above is my SysML v2 code - How can I check if an element is in the root namespace using Automator? E.g. I want to match package A but not package B.
package A {
package B {}
}
Say the above is my SysML v2 code - How can I check if an element is in the root namespace using Automator? E.g. I want to match package A but not package B.
You can use root_node.children.elements
- I hope this helps!
Thanks, but what can I use as my root node? I want to search for nodes in the entire model, in all documents
A good practice is to do the following:
(model, diagnostics) = syside.load_model([MODEL_FILE_PATH])
for doc in model.user_docs:
with doc.lock() as locked:
root_node = locked.root_node
for child in root_node.children.elements...
You can also check if the owner has an owner
element.owner is None # <- is a root namespace
or
element.owner is not None and element.owner.owner is None # <- owner is a root namespace, i.e. this i a top level element.