Maxscript Magma Node Name

Is it possible to get a nodes Name from a magma flow modifier per max scirpt?

I was able to get some via:

mh = $.modifiers[1].magmaholder
nodesIDArr = mh.getNodes()

for i = 1 to nodesIDArr.count do
(
   try (print mh[i].name)
   catch (print ("mh[" +(i as string) + "] is undefined"))
)

But this only works on some nodes. For some reason the Magmaholder does not hold all nodes as subAnims.

Thanks

Goran

The MagmaHolder is the C++ component of Magma. It only uses the node IDs to access the nodes in the flow.
The user-defined Name seen in the Magma Editor is a completely MAXScript-level value and is not used internally for anything. It is meant only for your convenience, together with the Comments field. So the MagmaHolder has no knowledge of the node name entered in the Editor, and TrackView only shows nodes that require a keyframeable value (mostly InputValue nodes) using the node type and ID as an identifier.

Of course, you can easily access the custom name field via the GetNodeProperty() function. But if the user has never entered a name in the field, the field still shows the Type as the name, but the actual “Name” property is ‘undefined’ internally, so you have to account for that, too. And OUT nodes have no custom name, it is based off the channel that was selected, so you would have to say

[code]mh = $.modifiers[1].magmaholder
nodesIDArr = mh.getNodes()

for i in nodesIDArr do
(
theName = mh.getNodeProperty i “Name”
theType = mh.getNodeType i
if theName == undefined do theName = theType
if theType == “Output” do theName = “OUT:”+ (mh.getNodeProperty i “channelName”)
format “Node % of Type [%] has Custom Name “%”\n” i theType theName
)[/code]

In an example scene, I had set a (InputChannel Color) * (InputValue Float 1.0)–>Out:Color, and I entered “InputChannelColor” for the first node’s name.
So the output looked like

ReferenceTarget:MagmaHolder #(0, 1, 2, 3) Node 0 of Type [Output] has Custom Name "OUT:Color" Node 1 of Type [InputChannel] has Custom Name "InputChannelColor" Node 2 of Type [Multiply] has Custom Name "Multiply" Node 3 of Type [InputValue] has Custom Name "InputValue" OK

Hope this helps!

On a further note, you might want to check out the output of

ShowInterfaces mh

Using its functions, you can for example check what properties are defined for a specific node, for example in my case, node ID 1 had the custom Name property defined, so

mh.GetNodePropertyNames 1 #custom -->#("Collapsed", "Internal_BranchCollapsed", "Internal_NodeConnected", "Internal_OrderX", "Internal_OrderY", "Internal_Position", "Name", "Position", "Selected")
while

mh.GetNodePropertyNames 1 #internal -->#("enabled", "channelName", "channelType")
We decided to keep internal property names camelCase with lower case first letter, and custom properties with capital first letter. Thus “Name”, “Position” and “Selected” are all obviously MAXScript-level values used in the Editor, but not by the internal Magma flow evaluation, while “channelName” is a C++ level property the node has and actually makes it read that channel…

Thanks so much Bobo! This is very informative!
This whole MagmaHolder thing makes much more sense now.

What I’m trying to do is, to set up a little UI, that let’s the user control certain values in a whole magmaFlow stack from outside. So I want to be able to find my exact nodes. And so far the only way I can think of doing this, is going by node type and node name.

I think I did check the mh.GetNodePropertyNames(). I guess since the name was not defined on the node I was trying it on, it did not show the “Name” property in the array.
So in this case, this comes helpful, since I can filter out the nodes with custom names first :slight_smile:

Thanks

As you can see from my example, nodes without a “Name” property simply display the node Type as the Name - asking for a non-existent property returns undefined instead of an error.
So you can just list the Modifier name, Node ID, Node Name, and Node Type, and in some nodes without a name the Node Name will be shown the same as the Node Type. This way, you will mimic exactly what the Magma Editor shows…