Notifications
Clear all

[Closed] How to select all nodes inside a layer

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.
4 Replies

From the Maxscript Help on Layer Properties:

<void>select <boolean>OnOff
[left]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 true

Or you could use the nodes by-reference array from the help file:

nodes <&node array>layerNodes
[left]layerNodes is Out parameter
[/left]
[left]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 thenodes

Give those a try.
[/left]

 -Eric
  [/left]

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

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.

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