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


Python cmds.referenceQuery方法代碼示例

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


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

示例1: validateAnimationCurve

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import referenceQuery [as 別名]
def validateAnimationCurve(animationCurve):
    """
    Check if the parsed animation curve can be reduces. Set driven keyframes
    and referenced animation curves will be ignored.

    :param str animationCurve:
    :return: Validation state of the animation curve
    :rtype: bool
    """
    if cmds.listConnections("{}.input".format(animationCurve)):
        return False
    elif cmds.referenceQuery(animationCurve, isNodeReferenced=True):
        return False

    return True


# ---------------------------------------------------------------------------- 
開發者ID:robertjoosten,項目名稱:maya-keyframe-reduction,代碼行數:20,代碼來源:utils.py

示例2: remove

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import referenceQuery [as 別名]
def remove(container):
    """Remove an existing `container` from Maya scene

    Deprecated; this functionality is replaced by `api.remove()`

    Arguments:
        container (avalon-core:container-1.0): Which container
            to remove from scene.

    """

    node = container["objectName"]

    # Assume asset has been referenced
    reference_node = next((node for node in cmds.sets(node, query=True)
                          if cmds.nodeType(node) == "reference"), None)

    assert reference_node, ("Imported container not supported; "
                            "container must be referenced.")

    log.info("Removing '%s' from Maya.." % container["name"])

    namespace = cmds.referenceQuery(reference_node, namespace=True)
    fname = cmds.referenceQuery(reference_node, filename=True)
    cmds.file(fname, removeReference=True)

    try:
        cmds.delete(node)
    except ValueError:
        # Already implicitly deleted by Maya upon removing reference
        pass

    try:
        # If container is not automatically cleaned up by May (issue #118)
        cmds.namespace(removeNamespace=namespace, deleteNamespaceContent=True)
    except RuntimeError:
        pass 
開發者ID:getavalon,項目名稱:core,代碼行數:39,代碼來源:compat.py

示例3: _modifiedAttrs

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import referenceQuery [as 別名]
def _modifiedAttrs(self):
		""" Returns a dictionary of modifications made to this referenced model.
		
		For referneced models return info describing the modifications made by the referencing
		system.
		"""
		modified = {}
		if self.isReferenced():
			fullName = self.path()
			refNode = cmds.referenceQuery(fullName, referenceNode=True)
			# Build the setAttr pattern
			pattern = r'setAttr {node}.(?P<attr>[^ ]+)'.format(node = fullName.replace('|', r'\|'))
			setAttrRegex = re.compile(pattern)
			# TODO: Add patterns for other mel commands like addAttr, etc
			for s in cmds.referenceQuery(refNode, editStrings=True):
				# Process setAttr
				match = setAttrRegex.match(s)
				if match:
					key = match.groupdict()['attr']
					if s.endswith('"'):
						# Found a string. Note, this does not include escaped quotes.
						openingQuote = s[::-1].find('"', 1)
						value = s[-openingQuote:-1]
					else:
						# its not a string
						value = s.split(' ')[-1]
					modified.setdefault(key, {}).setdefault('setAttr', {}).update(value=value, command=s)
		return modified 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:30,代碼來源:mayascenemodel.py

示例4: _referenceNodeName

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import referenceQuery [as 別名]
def _referenceNodeName(self):
		filename = self.userProps().get('reference')
		if filename:
			return cmds.referenceQuery(filename, referenceNode=True)
		return None

# register the symbol 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:9,代碼來源:mayascenemodel.py

示例5: _removeNativeModels

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import referenceQuery [as 別名]
def _removeNativeModels(self, models):
		""" Deletes provided native models.
			:param models: list of native models
			:return: <bool> success
		"""
		ret = True
		for model in models:
			nameInfo = cross3d.SceneWrapper._namespace(model)
			fullName = cross3d.SceneWrapper._mObjName(model)
			if cmds.referenceQuery(fullName, isNodeReferenced=True):
				# The model is referenced and we need to unload it.
				refNode = cmds.referenceQuery(fullName, referenceNode=True)
				filename = cmds.referenceQuery(refNode, filename=True)
				# If all nodes in the namespace are referenced, the namespace will be removed, otherwise
				# the namespace will still exist and contain all of those unreferenced nodes.
				cmds.file(filename, removeReference=True)
				# Remove nodes that were parented to referneced nodes
				leftovers = self.objects(wildcard='{refNode}fosterParent*'.format(refNode=refNode))
				if leftovers:
					self.removeObjects(leftovers)
			# Local node processing: check for unreferenced items in the namespace and remove them.
			namespace = nameInfo['namespace']
			if cmds.namespace(exists=namespace):
				cmds.namespace(removeNamespace=namespace, deleteNamespaceContent=True)
			if cmds.namespace(exists=namespace):
				print 'The namespace {ns} still exists the model {model} was not entirely removed.'.format(namespace, model=fullName)
				ret = False
		return ret 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:30,代碼來源:mayascene.py

示例6: meshesFromReference

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import referenceQuery [as 別名]
def meshesFromReference(control):
    '''
    Get meshes from the referenced file. This is faster and more accurate in most
    cases than traversing history, but only works if the rig is referenced.
    '''

    if not mc.referenceQuery(control, isNodeReferenced=True):
        return []

    ref = mc.referenceQuery(control, referenceNode=True)
    nodes = mc.referenceQuery(ref, nodes=True)

    meshes = mc.ls(nodes, type='mesh')

    return [x for x in meshes if isNodeVisible(x)] 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:17,代碼來源:ml_centerOfMass.py

示例7: curves

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import referenceQuery [as 別名]
def curves(self):
        '''
        The keySelections's animation curve list.
        '''

        # if self._curves is False or None, then it has been initialized and curves haven't been found.
        if self._curves == []:

            #find anim curves connected to channels or nodes
            for each in (self._channels, self._nodes):
                if not each:
                    continue
                # this will only return time based keyframes, not driven keys
                self._curves = mc.keyframe(each, time=(':',), query=True, name=True)

                if self._curves:
                    self._curvesCulled = False
                    break
            if not self._curves:
                self._curves = False

        # need to remove curves which are unkeyable
        # supposedly referenced keys are keyable in 2013, I'll need to test that and update
        if self._curves and not self._curvesCulled:
            remove = list()
            for c in self._curves:
                if mc.referenceQuery(c, isNodeReferenced=True):
                    remove.append(c)
                else:
                    plug = mc.listConnections('.'.join((c,'output')), source=False, plugs=True)
                    if plug:
                        if not mc.getAttr(plug, keyable=True) and not mc.getAttr(plug, settable=True):
                            remove.append(c)
            if remove:
                for r in remove:
                    self._curves.remove(r)
            self._curvesCulled = True

        return self._curves 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:41,代碼來源:ml_utilities.py

示例8: clean_up_file

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import referenceQuery [as 別名]
def clean_up_file():
    pass
    # import references
    """
    refs = cmds.ls(type='reference')
    for i in refs:
        rFile = cmds.referenceQuery(i, f=True)
        cmds.file(rFile, importReference=True, mnr=True)    
        
    defaults = ['UI', 'shared']

    # Used as a sort key, this will sort namespaces by how many children they have.
    def num_children(ns):
        return ns.count(':')

    namespaces = [ns for ns in cmds.namespaceInfo(lon=True, r=True) if ns not in defaults]
    # We want to reverse the list, so that namespaces with more children are at the front of the list.
    namespaces.sort(key=num_children, reverse=True)

    for ns in namespaces:

        if namespaces.index(ns)+1 < len(namespaces):
            parent_ns = namespaces[namespaces.index(ns)+1]   
            cmds.namespace(mv=[ns,parent_ns], f=True) 
            cmds.namespace(rm=ns) 
        else:
            cmds.namespace(mv=[ns,":"], f=True)  
            cmds.namespace(rm=ns) 
	
    # remove ngSkinTools custom nodes
    from ngSkinTools.layerUtils import LayerUtils 
    LayerUtils.deleteCustomNodes()
    
    # remove RRM proxies
    if cmds.objExists("RRM_MAIN"):
        cmds.select("RRM_MAIN",hi=True)
        proxies = cmds.ls(sl=True)
        cmds.lockNode(proxies,lock=False)
        cmds.delete(proxies)
        
        if cmds.objExists("RRM_ProxiesLayer"):
            cmds.delete("RRM_ProxiesLayer")""" 
開發者ID:liorbenhorin,項目名稱:pipeline,代碼行數:44,代碼來源:maya_warpper.py

示例9: parentBake

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import referenceQuery [as 別名]
def parentBake(objs, parent=None, bakeOnOnes=False):

    #check objects can be parented
    parentReferenced = mc.referenceQuery(parent, isNodeReferenced=True) if parent else False

    culledObjs = []
    for each in objs:
        eachParent = mc.listRelatives(each, parent=True)
        if mc.referenceQuery(each, isNodeReferenced=True):
            if parentReferenced:
                OpenMaya.MGlobal.displayWarning("Child and parent are both referenced, skipping: {} > {}".format(each, parent))
                continue
            if eachParent and mc.referenceQuery(eachParent[0], isNodeReferenced=True):
                OpenMaya.MGlobal.displayWarning("Node is referenced and can't be reparented, skipping: {}".format(each))
                continue
        if not parent and not eachParent:
            OpenMaya.MGlobal.displayWarning("Node is already child of the world, skipping: {}".format(each))
            continue
        culledObjs.append(each)

    if not culledObjs:
        OpenMaya.MGlobal.displayWarning("No nodes could be reparented.")
        return

    source = []
    destination = []
    for each in culledObjs:
        source.append(mc.duplicate(each, parentOnly=True)[0])
        mc.copyKey(each)
        mc.pasteKey(source[-1], option='replaceCompletely')
        try:
            if parent:
                destination.append(mc.parent(each, parent)[0])
            else:
                destination.append(mc.parent(each, world=True)[0])
        except RuntimeError as err:
            mc.delete(source)
            raise err

    utl.matchBake(source=source, destination=destination, bakeOnOnes=bakeOnOnes)

    mc.delete(source) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:44,代碼來源:ml_worldBake.py


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