When a layer is locked, you cannot target or add sublayers to it. If a locked layer has sublayers, the sublayers cannot have new parent layers added to them. You can lock the layers either through the UI or enforce system-level locks.
The sessionLayer will be automatically targeted in the following situations:
Administrators can enforce system-level locks on layers, preventing standard users from unlocking them. This can be done via Mel or Python scripts, or by locking the USD file on disk. The system-locked layers are easily identifiable by the disabled lock icons.
System locks are not saved as part of the Maya data.
Here is an example code for system-locking a layer using MEL scripts:
// Lock Type: 0 = Unlocked, 1 = Locked and 2 = System-Locked.
// Include Sublayers : 0 = Top Layer Only, 1 : Top and Sublayers
// example: System-lock lighting_shot_1.usda
mayaUsdLayerEditor -edit -lockLayer 2 0 "|shot_1|shot_1Shape" "d:/Assets/lighting_shot_1.usda"See Layer Locking for more information.