1

I would know if - in maya - I can get the state of the 'lock selection'. I have this command:

updateLockSelectionIcon;

this command locks and unlock. but there is no argument with. this is a switch which depends on its previous state. But in the script I need to put the lock selection active in first. by advance thank you.

  • This command doesn't appear to do anything if I run it on a sphere. Are you referring to this command? `cmds.lockNode("pSphere1", lock=True)` – Green Cell Mar 03 '20 at 02:38
  • I know this command, it's just an order to avoid to delete the object. – maxime neko Mar 05 '20 at 08:18
  • If it's not related to locking the node then maybe include an image or something, because right now the question isn't clear. – Green Cell Mar 05 '20 at 09:07
  • Hello. I rephrase my question to be more precise. in fact, I would like that whatever the lock state of the selection, after the execution of the script, the selection is locked. https://cdnb.artstation.com/p/assets/images/images/024/911/515/large/maxime-neko-lockselection.jpg?1583938088 – maxime neko Mar 11 '20 at 14:53

1 Answers1

1

I believe what you're looking for is this:

import maya.cmds as cmds

cmds.selectPref(xformNoSelect=True)  # Lock selection.
cmds.selectPref(xformNoSelect=False)  # Unlock selection.

And you can also query the lock's state:

cmds.selectPref(q=True, xformNoSelect=True)
Green Cell
  • 4,677
  • 2
  • 18
  • 49