PDA

View Full Version : How to select all nodes inside a layer


Xaimav
10-26-2009, 09:09 PM
I've tried to select every nodes in a layer and could not find a direct way.

The way I do it now (wich really sux) is by hiding every other layers and use the "max select all" function :

for i = 1 to layermanager.count do
(
layer = layermanager.getLayer i
layer.isHidden = true
)

layerName = "wanted_layer"
layer = layermanager.getLayerFromName layerName
layer.isHidden = false
max select all

Does anybody know a more elegant way to select all the nodes of a layer without having to hide every other one like I do?

Any advice would be greatly appreciated.

PiXeL_MoNKeY
10-26-2009, 09:43 PM
From the Maxscript Help on Layer Properties:<void>select <boolean>OnOff
If the Boolean value is passed as true, selects all objects on the layer in the scene. If the argument is passed as false, deselects all objects on the layer.So get you layer then call the select command.layer = layermanager.getLayerFromName layerName
layer.select trueOr you could use the nodes by-reference array from the help file:<boolean>nodes <&node array>layerNodes
layerNodes is Out parameter

Returns true on success, and an array of all nodes on the layer in the by-reference Out parameter.layer = layermanager.getLayerFromName layerName
layer.nodes &thenodes
select thenodesGive those a try.


-Eric

Xaimav
10-26-2009, 09:58 PM
Awesome, and this was a fast reply!

Works for me :
layer = layermanager.getLayerFromName layerName
layer.select true

I did try "layer.select = true" but not "layer.select true" ;)

Thkx a lot and have a nice day!!!

duke
07-20-2010, 09:21 AM
I cannot get this to work. Maybe you can't do it inside a function? I can get the layer by name, but the node output is always undefined, but there are most certainly nodes within that layer!

I'm not wanting to select the nodes, just hold a reference to them so I can iterate over them.

duke
07-20-2010, 12:10 PM
I ended up doing it a different way:

This finds a named layer and bNodes is a collection of nodes that belong to that layer, and are containers.


local bLayer = LayerManager.getLayerFromName("Buildings")

bNodes = for i in $* where i.layer == bLayer and classof i == Container collect i

CGTalk Moderation
07-20-2010, 12:10 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.