select object in layer

Hi guys,
i always wanted a script that i - in my totally scripting ignorance - think can be done easily. I need to select objetcs in a layer that is not necessarily the current one. Wich means, the script must store the current layer, then make the selected object´s layer current, then select all the objects in the new current layer and then set the stored layer back to current. Is it hard to script this? any good soul could do that? :)
so here´s my suggestion for a new script, thanks for your attention!
cheers,

Jsrocha

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rachka's picture

Thank you for this script!

Thank you for this script! How can execute it via keyboard shortcut or set it on a quad or menu? Thanks!

miauu's picture

.

Save this as MCR file and drag and drop it in Max viewport

macroscript 
category:"Tools"
tooltip:"Select object in layer"
buttonText:"Select object in layer"
(
	max modify mode
	for obj in selection do obj.layer.select true
)

Go to Tools category and assign a hotkey to Select object in layer.
You can change the category name and the name of the script before to install it.

Garp's picture

Try this:

for obj in selection do obj.layer.select true

jsrocha's picture

Thanks man, this is exactly

Thanks man, this is exactly what i need!
cheers,

Jsrocha

titane357's picture

I will add "max create mode"

I will add "max create mode" because in modify mode the selection take a loooong time.

jsrocha's picture

Hey guys, thanks for your

Hey guys, thanks for your help!
what i really need is to select all the objects in the same layer as the SELECTED object. Is it possible to do that?
thanks in advance,

Jsrocha

Garp's picture

Say the current layer is

Say the current layer is Layer01 and you want to select everything in Layer02.
(layerManager.getLayerFromName "Layer02").select true
The current layer is still Layer01.

edit: Oops. Sorry Swordslayer. I should have refreshed before posting.

Swordslayer's picture

If you know the name of the

If you know the name of the layer, this should do the trick:

fn selectNodesInLayer layer_name =
(
local nodes
(LayerManager.getLayerFromName layer_name).nodes &nodes
select nodes
)
selectNodesInLayer "The Name of the Layer Goes Here"

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.