SOLVED Get the Name of the Node?

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?

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)

@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   

@dunhou

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

Hi @bentraje you can download R25 scripts example at SDK - Cinema 4D R25 SP1 Release. 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.

@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!

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