ScriptSpot home

Forum topic · Scripts Wanted

select object in layer

By jsrocha · 2011-01-21

Description

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 (9)
crystal3d

for those who are wondering

it is basically a working "select children" command (the one in max does not work), it checks the selected object's layer and do a "select children" for that layer.

example:

you have one box object in a layer called "ceiling", you run this script and it selects all the other objects that are assigned to "ceiling".

thank you MIAU!
U

rachka

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

Reply to rachka
miauu

.

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

Try this:

for obj in selection do obj.layer.select true

Reply to Garp
titane357

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

Reply to Garp
jsrocha

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

Jsrocha

jsrocha

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

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.

Vojtech Cada

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"