当前位置: 首页>>代码示例>>Python>>正文


Python cmds.deleteAttr方法代码示例

本文整理汇总了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 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:32,代码来源:dpUtils.py

示例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) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:11,代码来源:dpUtils.py

示例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) 
开发者ID:blurstudio,项目名称:cross3d,代码行数:6,代码来源:mayauserprops.py

示例4: teardown

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import deleteAttr [as 别名]
def teardown():
    cmds.deleteAttr("transform1.myAttr") 
开发者ID:mottosso,项目名称:cmdx,代码行数:4,代码来源:plot.py

示例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 
开发者ID:duncanskertchly,项目名称:BlendTransforms,代码行数:49,代码来源:BlendTransforms.py

示例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)
    ) 
开发者ID:chadmv,项目名称:cmt,代码行数:62,代码来源:spaceswitch.py


注:本文中的maya.cmds.deleteAttr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。