Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to access the "root" Scene Nodes graph

    Cinema 4D SDK
    python 2024
    2
    3
    556
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kng_ito
      last edited by

      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.

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @kng_ito
        last edited by ferdinand

        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

        MAXON SDK Specialist
        developers.maxon.net

        K 1 Reply Last reply Reply Quote 1
        • K
          kng_ito @ferdinand
          last edited by

          Hi @ferdinand ,
          Thanks as always for your clear answers, It solved the problem for me!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post