Lock layer by object

Hi there,

Is it possible to create a command that locks the layer of a highligted object.

A bit like the “!_SetLayerToObject”-command and then add a “lock layer”-command :slight_smile:
Or similar to “onelayeroff”-command…

I found this, but it depends on the name itself:

I hope this makes sense

Cheers,
Thomas

Here is a quickie script to do this. You can also select multiple objects to lock several layers at once if you want. Note, you cannot lock the current layer… if you try you will get a command line message to that effect.

LockSelectedObjectsLayer.py (578 Bytes)

2 Likes

Hi Helve

Thank you for your fast reply - impressive!

When I try to load the script I get this error:

billede

Yeah, sorry, there was a typo in that one - please re-download from same link above.

1 Like

This is very cool Mitch. Any chance you could also add ‘unlock selected layer’ ? Sometimes I have a layer locked and I’d like to do the opposite: unlock the layer based on picking an object in the locked layer.

So it needs a temporary ‘unlock all layers’ so I can pick what I want, then re-lock everything except that one layer. The trick is that sometimes an object is unpickable, not because its layer is locked, but because its layer’s parent layer is locked.

Thx!

G

Great idea Gus,

This command macro make it work perfectly :slight_smile:
“! _-RunPythonScript LockSelectedObjectsLayer.py”

Thank you Mitch, much appreciated!

Or the object itself is locked… yeah… picking locked objects by temporarily unlocking everything (layers, objects) is potentially risky - if you decide to bail before the command has finished, it will leave your file in a potentially undesirable state. Let me see if I can make something more or less “robust”…