示例#1
0
def _makeSharedShape(obj, name, shapeType):
    '''
    shapeType should be either 'sharedShape' or 'kinematicSwitch'
    
    Returns a string of the shape, ex 'Foot_L|sharedShape' (to bypass pymel warnings)
    '''
    shape = cmds.createNode( 'nurbsCurve', p=obj.longName() )
    
    # 2017 added a bunch of keyable attrs so get rid of them if possible.
    for attr in cmds.listAttr(shape, k=True):
        try:
            cmds.setAttr(shape + '.' + attr, k=False, l=True)
        except Exception as e:  # noqa
            #print( e )
            pass
        
    # Make it a valid curve so it doesn't get deleted during optimize scene
    # but lock and hide it.
    mel.eval('''setAttr "%s.cc" -type "nurbsCurve"
             1 1 0 no 3
             2 0 1
             2
             0 0 0
             0 0 0
             ;''' % shape )
    setAttr(shape + '.visibility', False, l=True)  # noqa
    addAttr(shape, ln=core.shape.sharedShapeTag, at='message')
    
    cmds.addAttr( shape, ln=shapeType, at='message' )
    cmds.rename( shape, name )
    return obj.longName() + '|' + name
示例#2
0
文件: visNode.py 项目: Mikfr83/fossil
def existingGroups():
    ''' Returns a list of names, or an empty list if the visNode doesn't exist (or is empty).
    '''
    shapeNode = get(create=False)

    if not shapeNode:
        return []

    groups = cmds.listAttr(shapeNode, ud=True, s=True)
    if not groups:
        groups = []
    return groups
示例#3
0
def existingGroups():
    '''
    .. todo::
        make a real check for if main exists
    '''
    if not objExists('|main'):
        return []

    shape = get()
    groups = cmds.listAttr( shape, ud=True, s=True )
    if not groups:
        groups = []
    return groups
示例#4
0
def existingGroups():
    '''
    .. todo::
        make a real check for if main exists
    '''
    shape = get()

    if not shape:
        return []

    groups = cmds.listAttr(shape, ud=True, s=True)
    if not groups:
        groups = []
    return groups
示例#5
0
def getSwitcherPlug(obj):
    '''
    Will return either a string like "Arm_L_FKIK_SWITCH" or empty string if no
    switcher is found.
    
    Can't use pymel to avoid warnings of invalid node (nurbs with no cvs).
    This also means listRelatives returns None instead of []. Lame.
    '''
    shapes = cmds.listRelatives(str(obj), type='nurbsCurve', f=True)
    if shapes:
        for shape in shapes:
            # Check for new style switch first
            if cmds.objExists(shape + '.IkSwitch'):
                return shape + '.IkSwitch'

            # Fallback to old style switch
            if cmds.objExists(shape + '.kinematicSwitch'):

                attr = cmds.listAttr(shape, ud=1, st='*_Switch')
                return cmds.ls(shape, l=False)[0] + '.' + attr[0]  # noqa
    return ''