ScriptSpot home

Forum topic · General Scripting

activate object selected layer

By titane357 · 2009-10-01

Description

hello
I'm looking for a script to activate object selected layer.
I mean : I have loads of layers, I want to create an object in the same layer that the selected object , clic a button and voilà, the good layer is active !
Thanks

Comments (4)
crystal3d

thank you from me aswell :)

it will help me alot.!

titane357

Thank you very much Christopher !
One line code which will save me a lot of time !!!

Christopher Grant

Here you go. You can either run the code below directly or you can install the macroscript I've attached. You will find it in the "CG_Tools" category named "Current Layer From Selection".

It's a really simple script actually - it just checks the layer property of the currently selected object (if there is a selection) and sets the property "current" to True.


if selection[1] != undefined do --Verify there is an object selected
	selection[1].layer.current=TRUE --Make the currently selected object's layer the "current" layer

Attachments
titane357

pleazzz