Hi,
I try to get all nodes from a layer with the pymxs module to e.g. delete the nodes and the layer with pymxs.
maxscript example:
layer = LayerManager.getLayerFromName "test_layer";
layer.nodes &theNodes;
# Result:
#($Teapot:Teapot001 @ [29.285393,-25.283651,0.000000])
At first I tried to translate the maxscript code into a pymxs version but the node property seems not to work in pymxs.
from pymxs import runtime as rt
layer = rt.LayerManager.getLayerFromName("test_layer")
# These are the results that I get when I tried to access the node property in pymxs
layer.nodes #result: nodes()
layer.nodes() #result: -- Argument count error: nodes wanted 1, got 0
layer.nodes(0) #result: True
layer.nodes("Teapot001") #result: True
...
I found some other solutions to get the nodes from a layer (see below). But these solutions are much more complex than the maxscript example. So I just want to know why the nodes property is not working as expected in pymxs?
working pymxs example:
from pymxs import runtime as rt
layer = rt.LayerManager.getLayerFromName("test_layer")
nodes = rt.refs.dependents(layer.layerAsRefTarg)
# Result:
#($Teapot:Teapot001 @ [29.285393,-25.283651,0.000000], ReferenceTarget:NodeRefMgr, ReferenceTarget:LayerManager, $<rootScene>)
# Or
rt.clearSelection()
layer.select(True)
nodes = rt.getCurrentSelection()
# Result:
#($Teapot:Teapot001 @ [29.285393,-25.283651,0.000000])
Solved! Go to Solution.
This is the solution to use the nodes property from the layers mixin interface. But this one works only in 3ds Max 2021. Thanks to Jason (the master of pymxs) .
import pymxs
rt = pymxs.runtime
layer = rt.LayerManager.getLayerFromName("test_layer")
res, nodes = layer.nodes(pymxs.byref(None))
Anyone know how I could add an object to a layer with pymxs?
note: I have the object's name, and it's not selected. So I would need to add the item to the layer by giving the command the name of the item.
(I haven't been able to figure out how to select an item with pymxs, only all items in the scene.. so I've done a workaround to select all items and then loop through, checking for the item I need)
Oh hey, I figured out how to select my object -- so now I guess I just need to figure out how to add that selected object to my layer.
I've successfully been able to make my layer with
rt.LayerManager.newLayerFromName("export")
(this makes a layer named "export")
Now I just am trying to figure out how to put my object into that layer (that I can now select, yoo hoo!)
Any help with this would be greatly appreciated! I'm very new to pymxs and maxScript also..
(only really know Python and MEL currently)
Thanks you!
Can't find what you're looking for? Ask the community or share your knowledge.