Bake objects to locked layers- VB / ELEFRONT

By Elefront plugin, I’m able with button to bake objects to layers and also replace old ones (BakeName attribute). In my case i want the layers that i bake to Rhino from grasshopper to be stay locked. Problem is that i cannot modify layer anymore if it is locked. So what iam trying is to unlock the layer–> modify layer objects–> lock again. But the computing order for the components is not consistent.

Any hints/ other approach how to solve it? (23.1 KB)