本文整理匯總了Python中maya.cmds.deleteAttr方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.deleteAttr方法的具體用法?Python cmds.deleteAttr怎麽用?Python cmds.deleteAttr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類maya.cmds
的用法示例。
在下文中一共展示了cmds.deleteAttr方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: zeroOut
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import deleteAttr [as 別名]
def zeroOut(transformList=[], offset=False):
""" Create a group over the transform, parent the transform in it and set zero all transformations of the transform node.
If don't have a transformList given, try to get the current selection.
If want to create with offset, it'll be a, offset group between zeroGrp and transform.
Return a list of names of the zeroOut groups.
"""
zeroList = []
if not transformList:
transformList = cmds.ls(selection=True)
if transformList:
for transform in transformList:
zeroGrp = cmds.duplicate(transform, name=transform+'_Zero_Grp')[0]
zeroUserAttrList = cmds.listAttr(zeroGrp, userDefined=True)
if zeroUserAttrList:
for zUserAttr in zeroUserAttrList:
try:
cmds.deleteAttr(zeroGrp+"."+zUserAttr)
except:
pass
allChildrenList = cmds.listRelatives(zeroGrp, allDescendents=True, children=True, fullPath=True)
if allChildrenList:
cmds.delete(allChildrenList)
if offset:
offsetGrp = cmds.duplicate(zeroGrp, name=transform+'_Offset_Grp')[0]
cmds.parent(transform, offsetGrp, absolute=True)
cmds.parent(offsetGrp, zeroGrp, absolute=True)
else:
cmds.parent(transform, zeroGrp, absolute=True)
zeroList.append(zeroGrp)
return zeroList
示例2: clearDpArAttr
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import deleteAttr [as 別名]
def clearDpArAttr(itemList):
""" Delete all dpAR (dpAutoRigSystem) attributes in this joint
"""
dpArAttrList = ['dpAR_joint']
if itemList:
for item in itemList:
for dpArAttr in dpArAttrList:
if cmds.objExists(item+"."+dpArAttr):
cmds.deleteAttr(item+"."+dpArAttr)
示例3: __delitem__
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import deleteAttr [as 別名]
def __delitem__(self, key):
if not key in self:
raise KeyError('{} is not stored in UserProps'.format(key))
cmds.deleteAttr(cross3d.SceneWrapper._mObjName(self._nativePointer), attribute=key)
示例4: teardown
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import deleteAttr [as 別名]
def teardown():
cmds.deleteAttr("transform1.myAttr")
示例5: BT_DeletePose
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import deleteAttr [as 別名]
def BT_DeletePose(set = None, poseIndex = None):
if not set or poseIndex is None:
return False
if not cmds.attributeQuery('Blend_Node', ex = True, n = set):
return False
if BT_IsSetupConnected(set):
cmds.warning('Disconnect setup first!')
return False
blendNode = cmds.getAttr(set +'.Blend_Node')
if not cmds.objExists(blendNode) or not cmds.objExists(set):
return False
numTransforms = cmds.getAttr(blendNode +'.transforms', size = True)
if not numTransforms:
return False
numPoses = cmds.getAttr(blendNode +'.transforms[0].poses', size = True)
allUserDefined = cmds.listAttr(set, ud = True)
btUserDefined = [x for x in allUserDefined if x.startswith('BT_')]
if poseIndex >= numPoses:
return False
connectionsToBreak = cmds.listConnections(set +'.' +btUserDefined[poseIndex], d = True, s = False, p = True)
for ctb in connectionsToBreak:
cmds.disconnectAttr(set +'.' +btUserDefined[poseIndex], ctb)
cmds.deleteAttr(set +'.' +btUserDefined[poseIndex])
for i in range(0, numTransforms):
for p in range(poseIndex, numPoses-1):
#get the next items vales
matrix = cmds.getAttr(blendNode +'.transforms[' +str(i) +'].poses[' +str(p+1) +'].matrix')
scale = cmds.getAttr(blendNode +'.transforms[' +str(i) +'].poses[' +str(p+1) +'].scale')[0]
conn = cmds.listConnections(blendNode +'.transforms[' +str(i) +'].poses[' +str(p+1) +'].weight', s = True, d = False, p = True)[0]
cmds.setAttr(blendNode +'.transforms[' +str(i) +'].poses[' +str(p) +'].matrix', matrix, type = 'matrix')
cmds.setAttr(blendNode +'.transforms[' +str(i) +'].poses[' +str(p) +'].scale', scale[0], scale[1], scale[2], type = 'double3')
cmds.connectAttr(conn, blendNode +'.transforms[' +str(i) +'].poses[' +str(p) +'].weight', force = True)
cmds.disconnectAttr(conn, blendNode +'.transforms[' +str(i) +'].poses[' +str(p+1) +'].weight')
return True
示例6: create_space_switch
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import deleteAttr [as 別名]
def create_space_switch(
node, drivers, switch_attribute=None, use_translate=True, use_rotate=True
):
"""Creates a space switch network.
The network uses the offsetParentMatrix attribute and does not create any
constraints or new dag nodes.
:param node: Transform to drive
:param drivers: List of tuples: [(driver1, "spaceName1"), (driver2, "spaceName2")]
:param switch_attribute: Name of the switch attribute to create on the target node.
"""
if switch_attribute is None:
switch_attribute = "space"
if cmds.objExists("{}.{}".format(node, switch_attribute)):
cmds.deleteAttr(node, at=switch_attribute)
names = [d[1] for d in drivers]
cmds.addAttr(node, ln=switch_attribute, at="enum", en=":".join(names), keyable=True)
# Create attribute to toggle translation in the matrices
enable_translate_attr = _create_bool_attribute(
node, "{}UseTranslate".format(switch_attribute), use_translate
)
# Create attribute to toggle rotation in the matrices
enable_rotate_attr = _create_bool_attribute(
node, "{}UseRotate".format(switch_attribute), use_rotate
)
blend = cmds.createNode("blendMatrix", name="{}_spaceswitch".format(node))
# Get the current offset parent matrix. This is used as the starting blend point
m = OpenMaya.MMatrix(cmds.getAttr("{}.offsetParentMatrix".format(node)))
cmds.setAttr("{}.inputMatrix".format(blend), list(m), type="matrix")
parent = cmds.listRelatives(node, parent=True, path=True)
to_parent_local = "{}.worldInverseMatrix[0]".format(parent[0]) if parent else None
for i, driver in enumerate(drivers):
driver = driver[0]
_connect_driver_matrix_network(blend, node, driver, i, to_parent_local)
target_attr = "{}.target[{}]".format(blend, i)
# Hook up the weight toggle when switching spaces
dge(
"x = switch == {} ? 1 : 0".format(i),
x="{}.weight".format(target_attr),
switch="{}.{}".format(node, switch_attribute),
)
# Connect the translation, rotation toggles
cmds.connectAttr(enable_translate_attr, "{}.useTranslate".format(target_attr))
cmds.connectAttr(enable_rotate_attr, "{}.useRotate".format(target_attr, i))
cmds.connectAttr(
"{}.outputMatrix".format(blend), "{}.offsetParentMatrix".format(node)
)