Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Python CallCommands Are Not Executed When Using Nodes?

    Cinema 4D SDK
    2023 python
    3
    9
    890
    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.
    • B
      bentraje
      last edited by

      Hi,

      Since there are no relevant APIs on the node editor commands, I'm trying to use the CallCommands. But they don't seem work with using nodes.

      Script below. Creates a node. Selects it. And hopefully rearranges it/layouts it.
      I included it four times. But when I execute it. It doesn't rearrange the nodes at all.

      Is there a way around this?

      import c4d
      import maxon
      from maxon import GraphModelHelper
      import os
      
      def main():
          doc = c4d.documents.GetActiveDocument()
          mat = doc.GetActiveMaterial()
          nodeMaterial = mat.GetNodeMaterialReference()
          nodespaceId = c4d.GetActiveNodeSpaceId()
          nimbusRef = mat.GetNimbusRef(nodespaceId)
          graph = nimbusRef.GetGraph()
      
      
          with graph.BeginTransaction() as transaction:
      
              GraphModelHelper.DeselectAll(graph, maxon.NODE_KIND.ALL_MASK)
              node_01 = graph.AddChild("", "com.redshift3d.redshift4c4d.nodes.core.standardmaterial", maxon.DataDictionary())
              node_02 = graph.AddChild("", "com.redshift3d.redshift4c4d.nodes.core.texturesampler", maxon.DataDictionary())
              node_03 = graph.AddChild("", "com.redshift3d.redshift4c4d.nodes.core.texturesampler", maxon.DataDictionary())
              
      
              maxon.GraphModelHelper.SelectNode(node_01)
              maxon.GraphModelHelper.SelectNode(node_02)
              maxon.GraphModelHelper.SelectNode(node_03)
      
              c4d.CallCommand(465002363) # Arrange All Nodes
      
              transaction.Commit()
              c4d.CallCommand(465002363) # Arrange All Nodes
      
      
          c4d.CallCommand(465002363) # Arrange All Nodes
          c4d.EventAdd()
          c4d.CallCommand(465002363) # Arrange All Nodes
      
      if __name__ == "__main__":
          main()
      
      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hi,

        you need to have the node editor opened yes; the command will be executed on the active node editor.

        There are lots of places to improvement our API so "basic" functionalities are accessible by external developers.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • B
          bentraje
          last edited by

          Hi @Manuel

          Thanks for the response.

          Yep yep. I have the node editor opened from the get go.
          Still doesn't execute.

          Here you can see in the demonstration below.
          I have to manually execute the arrange command.

          2022-12-14_23-51-16.gif

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by

            hi,

            It doesn't work on R25 but after r26, it does. Many things have change with the r26 and the node editor.

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            B 1 Reply Last reply Reply Quote 0
            • B
              bentraje @Manuel
              last edited by bentraje

              @manuel
              ah I'm using 2023 above. you can verify it since I'm using the GraphModeler methods which were not available in R25. It's also in the tag of this thread/post.

              1 Reply Last reply Reply Quote 0
              • ManuelM
                Manuel
                last edited by Manuel

                hi,

                because of that small animation i was thinking it was working. I will have a better look tomorrow to understand a bit more what is going on.
                My eyes will be fully opened as it seems that i am blind today >.<
                "Its just one of those days" as Limp Bizkit would say.

                Cheers,
                Manuel

                MAXON SDK Specialist

                MAXON Registered Developer

                1 Reply Last reply Reply Quote 0
                • B
                  bentraje
                  last edited by

                  No worries. Have a great day ahead! 🙂

                  1 Reply Last reply Reply Quote 0
                  • ManuelM
                    Manuel
                    last edited by

                    hi,
                    If i run your script on an empty graph, the command (arrange all node) does not see any nodes. There is some caches that need to be updated. I asked the question to the dev. Let's see.

                    Cheers,
                    Manuel

                    MAXON SDK Specialist

                    MAXON Registered Developer

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

                      Hello @bentraje,

                      please excuse the delay, but this bug has been fixed in 2023.2, your code from above should work properly now.

                      Cheers,
                      Ferdinand

                      MAXON SDK Specialist
                      developers.maxon.net

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