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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    GraphModelInterface.GetNode not worked

    Cinema 4D SDK
    python windows 2025
    2
    3
    325
    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.
    • DunhouD
      Dunhou
      last edited by ferdinand

      Hi community,

      I notice GraphModelInterface.GetNode method seems broken in R2025.0.2, and also the ToString() seems broken too. Is my usage incorrect?

      Cheers~
      DunHou

      btw: R2025 tag is missing in forum

      
      import c4d
      import maxon
      import typing
      
      doc: c4d.documents.BaseDocument # The active document.
      
      def main():
      
          for material in doc.GetMaterials():
              nodeMaterial: c4d.NodeMaterial = material.GetNodeMaterialReference()
              if not nodeMaterial.HasSpace("com.redshift3d.redshift4c4d.class.nodespace"):
                  continue
              graph: maxon.GraphModelRef = nodeMaterial.GetGraph("com.redshift3d.redshift4c4d.class.nodespace")
              root: maxon.GraphNode = graph.GetViewRoot()
      
              spaceContext = root.GetValue(maxon.nodes.NODESPACE.NodeSpaceContext)
              nodeSpaceId = spaceContext.Get(maxon.nodes.NODESPACE.SPACEID)
              spaceData = maxon.NodeSpaceHelpersInterface.GetNodeSpaceData(nodeSpaceId)
              assetId = spaceData.Get(maxon.nodes.NODESPACE.IMAGENODEASSETID)
              inTexturePortId = spaceData.Get(maxon.nodes.NODESPACE.IMAGENODEPORTS)[1]
      
              for node in root.GetInnerNodes(maxon.NODE_KIND.NODE, False):
      
                  assetId: maxon.Id = node.GetValue("net.maxon.node.attribute.assetid")[0]
                  if assetId != maxon.Id("com.redshift3d.redshift4c4d.nodes.core.texturesampler"):
                      continue
      
                  pathPort: maxon.GraphNode = graph.GetNode(node.GetPath() + '>' + str(inTexturePortId))
      
                  url: str | None = pathPort.GetPortValue()
      
                  print (f"{pathPort}: {url}")
      
      
      if __name__ == "__main__":
          main()
      

      https://boghma.com
      https://github.com/DunHouGo

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        Hi thanks for contacting us, since you are calling node.GetPath() then use the + operator. This will use the + operator from the NodePath which add \ at the beginning so its not a bug but the expected behavior since it add a new folder.

        In your case if you really want to build the string then you need to first build a string and then construct a NodePath from this string like so:

        pathPort: maxon.GraphNode = graph.GetNode(maxon.NodePath(str(node.GetPath()) + '<' + str(inTexturePortId)))
        

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        DunhouD 1 Reply Last reply Reply Quote 0
        • DunhouD
          Dunhou @m_adam
          last edited by

          Hi @m_adam ,

          Thanks for your reply, it worked well.

          But I still have some doubts about the usage of Node Path, such as how to calculate the port through NodePath instead of concatenating strings (which can easily lead to misoperation).

          There are few examples and answers for NodePath on the forum, and it seems that people rarely use it. Do you have any insights on this, or in other words, what usage scenarios do you think NodePath is more suitable for.

          Cheers~
          DunHou

          https://boghma.com
          https://github.com/DunHouGo

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