當前位置: 首頁>>代碼示例>>Python>>正文


Python core.objExists方法代碼示例

本文整理匯總了Python中pymel.core.objExists方法的典型用法代碼示例。如果您正苦於以下問題:Python core.objExists方法的具體用法?Python core.objExists怎麽用?Python core.objExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pymel.core的用法示例。


在下文中一共展示了core.objExists方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_arnold_stand_in

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def create_arnold_stand_in(path=None):
    """A fixed version of original arnold script of SolidAngle Arnold core API
    """
    if not pm.objExists('ArnoldStandInDefaultLightSet'):
        pm.createNode(
            "objectSet",
            name="ArnoldStandInDefaultLightSet",
            shared=True
        )
        pm.lightlink(
            object='ArnoldStandInDefaultLightSet',
            light='defaultLightSet'
        )

    stand_in = pm.createNode('aiStandIn', n='ArnoldStandInShape')
    # temp fix until we can correct in c++ plugin
    stand_in.setAttr('visibleInReflections', True)
    stand_in.setAttr('visibleInRefractions', True)

    pm.sets('ArnoldStandInDefaultLightSet', add=stand_in)
    if path:
        stand_in.setAttr('dso', path)

    return stand_in 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:26,代碼來源:auxiliary.py

示例2: update_metanodes

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def update_metanodes(cls):
        """
        Call .update() on all metanodes in cls.update and return update messages.
        """
        update_message = ''
        for metanode in reversed(cls.update):
            cls.update.remove(metanode)
            if pm.objExists(metanode.node):
                cls.network_nodes.remove(metanode.node)
                new, missing, could_not_set = metanode.update()
                if new:
                    cls.network_nodes.append(new.node)
                    update_message += 'Updating Metanode: {0}\n'.format(new)
                if missing:
                    update_message += 'New Metanode lacks previous attributes: {0}'.format(missing)
                if could_not_set:
                    update_message += 'Could not set attributes: {0}'.format(could_not_set)

        return update_message

    # DEPRECATED 
開發者ID:arenanet,項目名稱:metanode,代碼行數:23,代碼來源:manager.py

示例3: _processAttr

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def _processAttr(plug, dups, forceKeys, staticValues, start, end):
    '''
    Used by `save`
    '''

    crvs = cmds.listConnections( plug, type='animCurve' )
    
    if not crvs:
        if forceKeys:
            setKeyframe( plug, t=start )
            setKeyframe( plug, t=end )
            crvs = cmds.listConnections( plug, type='animCurve' )
        else:
            if not cmds.getAttr(plug, lock=True) and not cmds.listConnections(plug, s=True, d=False):
                staticValues[plug] = cmds.getAttr(plug)
    
    if crvs:
        dup = cmds.duplicate(crvs)[0]
        if not objExists(dup + '.' + TAGGING_ATTR):
            cmds.addAttr( dup, ln=TAGGING_ATTR, dt='string' )
        cmds.setAttr( dup + '.' + TAGGING_ATTR, plug, type='string' )
        dups.append( dup ) 
開發者ID:patcorwin,項目名稱:fossil,代碼行數:24,代碼來源:anim.py

示例4: fetch_all_ctrls_shapes

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def fetch_all_ctrls_shapes():
    """
    Restore the snapshots of all shapes of all ctrls.
    """
    aSources = get_all_ctrlsnapshots()

    for oSource in aSources:
        sTargetName = oSource.name()[:-8]
        if pymel.objExists(sTargetName):
            oTarget = pymel.PyNode(str(sTargetName))

            fetch_ctrl_shapes(oSource, oTarget)
            #pymel.delete(oSource)
        else:
            pymel.warning("Can't find {0}".format(sTargetName)) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:17,代碼來源:sqCopyPasteShapes.py

示例5: getRootNode

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def getRootNode():
    """Returns the root node from a selected node

    Returns:
        PyNode: The root top node
    """

    root = None

    current = pm.ls(sl=True)
    if not current:
        raise RuntimeError("You need to select at least one rig node")

    if pm.objExists("{}.is_rig".format(current[0])):
        root = current[0]
    else:
        holder = current[0]
        while pm.listRelatives(holder, parent=True) and not root:
            if pm.objExists("{}.is_rig".format(holder)):
                root = holder
            else:
                holder = pm.listRelatives(holder, parent=True)[0]

    if not root:
        raise RuntimeError("Couldn't find root node from your selection")

    return root 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:29,代碼來源:anim_utils.py

示例6: addBreakLine

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def addBreakLine(ctrl, contentString):
    """
    add a breakline to object's channelbox, usually for ctrlers
    :param ctrl: `PyNode` object to add breakline to
    :param contentString: `string` breakline content
    :return:
    """
    attrName = "_"
    while pm.objExists("{0}.{1}".format(ctrl.name(), attrName)):
        attrName = attrName + "_"
    pm.addAttr(ctrl, ln=attrName, at="enum", en=contentString)
    pm.setAttr("{0}.{1}".format(ctrl.name(), attrName), e=1, channelBox=1) 
開發者ID:raina-wu,項目名稱:DynRigBuilder,代碼行數:14,代碼來源:mayautils.py

示例7: instance

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def instance(cls):
        """
        Controls access to the metanode type by returning one common instance of the node
        """
        nodes = cls.scene_metanodes()
        if nodes:
            if pm.objExists(cls.__name__):
                metanode = cls(pm.PyNode(cls.__name__))
            else:
                metanode = nodes[0]
        else:
            metanode = cls.create(cls.__name__)
        return metanode 
開發者ID:arenanet,項目名稱:metanode,代碼行數:15,代碼來源:core.py

示例8: find

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def find(obj):
    '''
    If there is a shared shape, returns it.  If not, returns None.
    '''
    shapes = cmds.listRelatives(obj.name(), type='nurbsCurve', f=True)
    if not shapes:
        return None
    
    for shape in shapes:
        if objExists( shape + '.sharedShape' ):
            return shape
    return None 
開發者ID:patcorwin,項目名稱:fossil,代碼行數:14,代碼來源:sharedShape.py

示例9: pruneUnused

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def pruneUnused():
    if not objExists('|main'):
        return

    shape = get()

    groups = existingGroups()
    for g in groups:
        attr = shape + '.' + g
        if not listConnections(attr):
            deleteAttr(attr) 
開發者ID:patcorwin,項目名稱:fossil,代碼行數:13,代碼來源:sharedShape.py

示例10: deserializeAllConnections

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def deserializeAllConnections(connections=None):
    
    if connections is None:
        connections = json.loads( core.text.clipboard.get() )

    for obj, data in connections.items():
        if objExists(obj):
            connect(PyNode(obj), data) 
開發者ID:patcorwin,項目名稱:fossil,代碼行數:10,代碼來源:sharedShape.py

示例11: getRoot

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def getRoot(nodes=None, make=None):
    '''
    Returns the root bone, trying to account for case and namespaces or None if
    not found.  `make` should be either 'root' or 'weaponRoot', specifying which
    to make (always top level) if a root is not found.
    
    Can be given a list of nodes to search for the root,
    '''

    names = [ 'b_root', 'b_Root', 'Rig:b_root', 'Rig:b_Root', 'b_weaponRoot', 'Rig:b_weaponRoot' ]

    if not nodes:
        # Check if any exist top level first
        top = ls(assemblies=True)
        for name in names:
            if name in top:
                return PyNode('|' + name)
    
    # See if there is a top level obj in a namespace named b_root of any casing.
    searchNodes = nodes if nodes else ls( assemblies=True )
    nodes = [obj for obj in searchNodes if simpleName( obj ).lower() == 'b_root' or simpleName(obj).lower() == 'b_weaponroot']
    if len(nodes) == 1:
        return nodes[0]

    # Then check if any exist at all (which will fail if several exist in separate groups).
    for name in names:
        if objExists( name ):
            return PyNode( name )

    if make:
        return joint(None, n='b_' + make)
    
    else:
        return None 
開發者ID:patcorwin,項目名稱:fossil,代碼行數:36,代碼來源:findNode.py

示例12: mainGroup

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def mainGroup(nodePool=None):
    '''
    Returns the main group containing the rig, named "main", or an object tagged as the main.
    
    todo: This logic should mainly go into `mainControls`, and this just returns the first.
    '''
    
    if nodePool:
        for n in nodePool:
            if simpleName(n) == 'main' or n.hasAttr(MAIN_CONTROL_TAG):
                return n
    
    if objExists('|main'):
        return PyNode('|main')
    else:
        # A pymel bug is sometimes returning duplicate nodes
        main = list(set([ obj for obj in ls( 'main', r=True) if not obj.getParent() ]))
        if len(main) == 1:
            return main[0]
    
    # No "main" ojbect was found, looking for tags
    plugs = ls('*.' + MAIN_CONTROL_TAG)
    if plugs:
        return plugs[0].node()
    
    return None 
開發者ID:patcorwin,項目名稱:fossil,代碼行數:28,代碼來源:findNode.py

示例13: test_basicBiped

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def test_basicBiped():
    
    #gui = main.RigTool()
    
    # Make the default biped
    card.bipedSetup(spineCount=5)
    
    # Make all the bones and test their existence
    select(core.findNode.allCards())
    main.RigTool.buildBones()
    
    for j in jointsToMake:
        assert objExists(j), 'Joint ' + j + ' was not made'
    
    root = core.findNode.getRoot()
    
    assert len(listRelatives(root, ad=True, type='joint')) == (len(jointsToMake) - 1), 'Too many bones were made'
    
    # Build the rig
    spine = PyNode('Spine_card')
    rigData = spine.rigData
    rigData['rigCmd'] = 'SplineChest'
    spine.rigData = rigData
    
    select(core.findNode.allCards())
    main.RigTool.buildRig() 
開發者ID:patcorwin,項目名稱:fossil,代碼行數:28,代碼來源:test_fossil.py

示例14: connect

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def connect( obj, name_level ):
    '''
    Hook the given obj's visibility to the `name` attribute on the sharedShape.
    If the attr doesn't exist, it will be made.
    
    Optionanal `level` will determine when the `obj` will become visible.  For
    example, 2 will not be visible at 1, but will at 2 and higher.
    '''
    
    name, level = name_level # Probably should just update this eventually to be 3 params
    
    orig = obj
    
    zero = core.dagObj.zero(obj, apply=False, make=False)
    if zero:
        obj = zero
    
    shape = get()
    
    if not shape:
        warning('Unable to add vis control, no object exists named "main" or tagged with ".fossilMainControl"')
        return
    
    log.debug('Applying vis control to {}, was given {} using {}'.format(obj, orig, shape))
    
    plug = shape + '.' + name
    if not cmds.objExists( plug ):
        cmds.addAttr( shape, ln=name, at='short', min=0, max=level, dv=1 )
        cmds.setAttr( shape + '.' + name, cb=True )
    elif cmds.getAttr( shape + '.' + name, type=True) not in ['bool', 'double', 'float', 'long', 'short']:
        warning( '{0} is not a good name for a vis group since the sharedShape has an attr already that is of the wrong type'.format(name) )
        return
    
    if cmds.addAttr(plug, q=True, max=True) < level:
        cmds.addAttr(plug, e=True, max=level)
    
    if level == 1:
        connectAttr( plug, obj.visibility.name(), f=True)
    else:
        connectAttr( getConditionNode(plug, level).outColorR, obj.visibility, f=True)
        
    obj.visibility.setKeyable(False)
    
    # If we have a main controller, put the container in a subgroup to make
    # the main group more organized.
    
    visGroupName = '_vis_' + name
    
    if not find(orig):
        use(orig)
    
    if isinstance(orig, nodeApi.RigController):
        if shortName(orig.container.getParent()) != visGroupName:
            orig.setGroup(visGroupName) 
開發者ID:patcorwin,項目名稱:fossil,代碼行數:56,代碼來源:sharedShape.py

示例15: rootMotion

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import objExists [as 別名]
def rootMotion(main=None):
    '''
    Returns the root motion, optionally making one if it doesn't exist.

    If main is specified, search its descendents.
    '''
    
    ''' Timing test with Swift as main, re and split are about equal and 200x faster!
        re and split were almost identical, even on the whole scene.
    
        s = time.time()
        #oldGetRootMotion(main)
        for child in listRelatives(main, ad=True, type='transform'):
        #for child in ls(type='transform'):
            if lib.dagObj.simpleName( child ) == 'rootMotion':
                break
                #return child
        print( time.time() - s, 'orig')

        s = time.time()
        for child in cmds.listRelatives(main.name(), ad=True, type='transform'):
        #for child in cmds.ls(type='transform'):
            if child.rsplit('|',1)[-1].rsplit(':', 1)[-1] == 'rootMotion':
                #print( child)
                break
        print( time.time() - s, 'split')

        s = time.time()
        simpleName = re.compile( '\w+$' )
        for child in cmds.listRelatives(main.name(), ad=True, type='transform'):
        #for child in cmds.ls(type='transform'):
            if simpleName.search(child).group(0) == 'rootMotion':
                #print( child)
                break
        print( time.time() - s, 're')
    '''
    
    if main:
                
        children = cmds.listRelatives(main.name(), ad=True, type='transform')
        if children:   # cmds returns None instead of emtpy list
            for child in children:
                if child.rsplit('|', 1)[-1].rsplit(':', 1)[-1] == 'rootMotion':
                    return PyNode(child)
                
        return None

    if objExists( 'rootMotion' ):
        return PyNode( 'rootMotion' )
    else:
        rms = ls( 'rootMotion', r=True )
        if len(rms) == 1:
            return rms[0]
    
    return None 
開發者ID:patcorwin,項目名稱:fossil,代碼行數:57,代碼來源:findNode.py


注:本文中的pymel.core.objExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。