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
    • Register
    • Login

    Get the Name of the Node?

    Cinema 4D SDK
    r25 python
    3
    7
    958
    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,

      I understand its simple but a hard time using this once again.

      I tried using
      node.GetName() but it doesn't work. Errors out. Does not have that method.

      I tried also using the "port" method.
      port = node.GetInputs().FindChild("net.maxon.node.base.name")

      It does not work. Returns a null.

      Is there a way around this?

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

        Also tried the following but to now avail.

        node.GetValue("net.maxon.node.base.name", expectedType=None)
        node.GetInputs().GetValue.GetValue("net.maxon.node.base.name", expectedType=None)
        
        DunhouD 1 Reply Last reply Reply Quote 0
        • DunhouD
          Dunhou @bentraje
          last edited by

          @bentraje

          I think name atttribute is not easy as old c4d SDK to use . It cann't print in console .

          I use this to get Name , and Set Name .
          some codes in python sdk didn't work and return None .Maxon SDK has a example to get info form node retrieve_information_r26.py

              # 获取名称 : 
              def GetNodeName(self, node, display=False):
                  """
                  Retrieve the displayed name of a node.
                  
                  Parameters
                  ----------        
                  Args:
                      node: (maxon.GraphNode): The node to retrieve the name from.
                      display: print info when display is True
                  Returns:
                      Optional[str]: The node name, or None if the Node name can't be retrieved.
                  """
                  if node is None:
                      return None
          
                  nodeName = node.GetValue(maxon.NODE.BASE.NAME)
          
                  if nodeName is None:
                      nodeName = node.GetValue(maxon.EffectiveName)
          
                  if nodeName is None:
                      nodeName = str(node)
                  if display ==True :
                      print(nodeName)
                  return nodeName   
          

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

          B 1 Reply Last reply Reply Quote 2
          • B
            bentraje @Dunhou
            last edited by

            @dunhou

            Thanks for response. Unfortunately, I'm at R25.
            So I can't use the maxon.NODE.BASE.NAME syntax.
            It errors out 😞

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

              Hi @bentraje you can download R25 scripts example at SDK - Cinema 4D R25 SP1 Release[URL-REMOVED]. Within examples\scripts\05_modules\node\retrieve_information_r24.py so previously you had to hardcode the ID like so:

                  def GetName(node):
                      if node is None:
                          return None
                      nodeName = None
              
                      # Retrieve the user-defined name (user renamed the node name)
                      nodeName = node.GetValue("net.maxon.node.base.name")
                      if nodeName is None:
              
                          # Retrieve the default name
                          nodeName = node.GetValue("effectivename")
                      if nodeName is None:
                          nodeName = str(node)
                      return nodeName
              

              @Dunhou here it work correctly, can you point us which code is not working and if you could provide us a scene this would be welcome.

              Cheers,
              Maxime.


              [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

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

                @m_adam

                Thanks for the response.
                GetValue("effectivename") works as expected.

                Interesting. You have separate API for the original name vs the user renamed node.
                Might come in handy for me later on using the original name as the "type" of the node.

                Thanks again!

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

                  You have to be careful since the value returned by effectivename will change according of the Cinema 4D language. The best way is really to work with IDs.

                  Cheers,
                  Maxime

                  MAXON SDK Specialist

                  Development Blog, MAXON Registered Developer

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