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.
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.
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”…