HI
I’m an Electronic Engineer with more than 20 years developing AutoCAD applications and add-ons
As you can see in my web [login to view URL] I have a large experience developing in different areas like Post tensioned slabs,
Fiber Optic design ISO & OSP, Reinforced Earth retaining walls, Navy Firefighting, Solar Panels, among others
For what I understood you want to lock all layers except for those that start with "_" "0" or "L" or maybe "L_"
I don't understand if you want to do the same with XREF layers with same characteristics
The function can be done for LOCK or UNLOCK the filtered layers
If you speak english, spanish or italian may be will be better to understand better your needs
I develop in VisualLisp and ActiveX,
If you consider necessary, do not hesitate in contact me
Regards