activate object selected layer

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

Comment viewing options

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

thank you from me aswell :)

it will help me alot.!

titane357's picture

Thank you very much

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

Christopher Grant's picture

Here you go. You can either

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
AttachmentSize
cgCurrentLayerFromSelection.mcr 626 bytes
titane357's picture

pleazzz

pleazzz

Comment viewing options

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