How to access the "root" Scene Nodes graph
-
Hi,
I am trying to access some nodes in Scene Nodes graph with python.
For node-based objects like Nodes Modifier, I can use BaseList2D.GetNimbusRef() to access the graph, but I don't know how to get into the "root" Scene Nodes graph. Is there an invisible BaseList2D that holds the root Scene Nodes graph and I can use the same way from that object?The code below is how I did it for node-based objects to access their nodes. I hope there is a way to access the root Scene Nodes graph in a similar way.
import maxon def main(): nbr = op.GetNimbusRef("net.maxon.neutron.nodespace") graph = nbr.GetGraph() root = graph.GetRoot() # Iterate over the direct children of the graph root. nodesList = [] root.GetChildren(nodesList, maxon.NODE_KIND.NODE) for node in nodesList: print(node) if __name__ == '__main__': main()
I would appreciate any examples or tips you could give me. Thank you.
-
Hey @kng_ito,
Thank you for reaching out to us. The "root" element of the document bound scene nodes graph is a scene hook. In case you are unfamiliar with that concept,
SceneHookData
is a plugin type of scene elements that are present by default in every scene. Scene hooks do not have any relation to scene nodes, it is just a coincidence that they both have the word "scene" in their name.We have this C++ example for how to do it, and here I did the same in Python. There is also GraphDescription.CreateGraph which can be used to retrieve graphs for given items. E.g., when you pass it a
BaseDocument
, it will return the document bound scene nodes graph for you.Cheers,
Ferdinand -
Hi @ferdinand ,
Thanks as always for your clear answers, It solved the problem for me!