in max script (and likely in python)&theNodesindicates a by reference array called theNodes
The by reference part means that it’s not an array of objects or values, but an array of referencesto the objects/values.
thus, if some external operation alters an element that the array references, the array will “know” that that element has changed.
in pratice, you can operate ontheNodes like any ordinary array.
So , the commandlayer.nodes &theNodes basically says:
"run the method layer.Nodes
and put references to resulting items into an array called theNodes
len(layer.nodes)returns 0 because its a method, not an array -I think so, anyhow.
Try using type() to see what python thinks they are.
layer.nodes &theNodes
type (layer.nodes)
type (theNodes)
as the variable in python will not get the result, you need to do a little bit of MaxScript in Python.
This is a way that works:
from Py3dsMax import mxs
# Get Layer
myLayer = mxs.LayerManager.getLayerFromName("Test")
# Create a max-function to wrap the operation (this will be a new global function)
mxs.execute("function getLayerNodes layerInterface = ( layerInterface.nodes &outputList; outputList)")
# Call this new (global) max-function and receive the nodes
getNodes = mxs.getLayerNodes(myLayer)
# Here they are :-)
print (getNodes)
Of course, it’s not the “most pythonic” solution but the only one that works definitely.