pymel.core.general.lockNode

static general.lockNode(*args, **kwargs)

Locks or unlocks one or more dependency nodes. A locked node is restricted in the following ways: It may not be deleted.It may not be renamed.Its parenting may not be changed.Attributes may not be added to or removed from it.Locked attributes may not be unlocked.Unlocked attributes may not be locked.Note that an unlocked attribute of a locked node may still have its value set, or connections to it made or broken. For more information on attribute locking, see the setAttrcommand. If no node names are specified then the current selection list is used. There are a few special behaviors when locking containers. Containers are automatically expanded to their constituent objects. When a container is locked, members of the container may not be unlocked and the container membership may not be modified. Containers may also be set to lock unpublished attributes. When in this state, unpublished member attributes may not have existing connections broken, new connections cannot be made, and values on unconnected attributes may not be modified. Parenting is allowed to change on members of locked containers that have been published as parent or child anchors.

Flags:
Long name (short name) Argument Types Properties
ignoreComponents (ic) bool ../../../_images/create.gif ../../../_images/query.gif
 

Normally, the presence of a component in the list of objects to be locked will cause the command to fail with an error. But if this flag is supplied then components will be silently ignored.

lock (l) bool ../../../_images/create.gif ../../../_images/query.gif
 
Specifies the new lock state for the node. The default is true.
lockUnpublished (lu) bool ../../../_images/create.gif ../../../_images/query.gif
 

Used in conjunction with the lock flag. On a container, lock or unlock all unpublished attributes on the members of the container. For non-containers, lock or unlock unpublished attributes on the specified node. Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.lockNode

Example:

import pymel.core as pm

# create a sphere, lock it, then try to delete it.
pm.sphere( n='sphere1' )
# Result: [nt.Transform(u'sphere1'), nt.MakeNurbSphere(u'makeNurbSphere1')] #
pm.lockNode( 'sphere1' )
pm.delete( 'sphere1' )
# Error: Cannot delete locked nodes.
# Unlock the sphere, then it can be deleted.
pm.lockNode( 'sphere1', lock=False )
pm.delete( 'sphere1' )

Previous topic

pymel.core.general.listTransforms

Next topic

pymel.core.general.ls

Core

Core Modules

Other Modules

This Page