[Maya][Pymel] Bug with Reference ".lock / .unlock" commands?

Solution!

reference = pm.createReference(referenceFile)

referenceNode = pm.referenceQuery(reference, referenceNode=True)

pRNode = pm.PyNode(referenceNode)

reference.unload()
pRNode.locked.set(True)
reference.load()


Hey All,

I’ve encountered an issue thats frustrating me…

The .lock() .unlock() commands for references in PyMel dont seem to function. Can anyone else get locking & unlocking of layers working in Pymel?

Simple reproduction steps:

  1. Open a new scene
  2. Reference a random scene of your choosing
  3. Attempt to lock the reference

newRef = pm.system.createReference(‘PATHTOSCENE’)
newRef.lock()

You will notice that you can .load() / .unload() references in the same manner and they work fine, it’s just lock / unlock that seem to fall down

I’ve tried locking / unlocking the reference by setting the “.locked” attribute as well but with the same results, the command executes without error but to no result.

If anyone can reproduce this issue without a solution then I’ll just have to resort to using maya.cmds for this part of my tool… :sigh:

Thanks in advance!

Cheers

~ Joe :slight_smile:

edited

Interestingly the same behavior occurs when using maya.cmds you can lock the references as you create them but then you cannot lock / unlock them by using cmds.file(reference, edit=True, locked=False )

It might help to know what Maya version?

Fair point :slight_smile:

Maya 2011.

So over a year & a job change later - i encounter the same problem, then find my own thread on it.

Thankfully this time I’ve found a solution that I’ve edited into the original post :slight_smile: