Python maya.cmds.objExists() Examples
The following are 30
code examples of maya.cmds.objExists().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
maya.cmds
, or try the search function
.
Example #1
Source File: dpSelectAllControls.py From dpAutoRigSystem with GNU General Public License v2.0 | 8 votes |
def dpSelectAllCtrls(self, allGrpNode, *args): """ Select all controls using All_Grp. """ ctrlsToSelectList = [] if cmds.objExists(allGrpNode+"."+self.ctrlsAttr): ctrlsAttr = cmds.getAttr(allGrpNode+"."+self.ctrlsAttr) if ctrlsAttr: currentNamespace = "" if ":" in allGrpNode: currentNamespace = allGrpNode[:allGrpNode.find(":")] ctrlsList = ctrlsAttr.split(";") if ctrlsList: for ctrlName in ctrlsList: if ctrlName: if currentNamespace: ctrlsToSelectList.append(currentNamespace+":"+ctrlName) else: ctrlsToSelectList.append(ctrlName) cmds.select(ctrlsToSelectList) print self.langDic[self.langName]["m169_selectedCtrls"]+str(ctrlsToSelectList) else: mel.eval("warning \""+self.langDic[self.langName]["e019_notFoundAllGrp"]+"\";")
Example #2
Source File: pipeline.py From core with MIT License | 7 votes |
def lock(): """Lock scene Add an invisible node to your Maya scene with the name of the current file, indicating that this file is "locked" and cannot be modified any further. """ if not cmds.objExists("lock"): with lib.maintained_selection(): cmds.createNode("objectSet", name="lock") cmds.addAttr("lock", ln="basename", dataType="string") # Permanently hide from outliner cmds.setAttr("lock.verticesOnlySet", True) fname = cmds.file(query=True, sceneName=True) basename = os.path.basename(fname) cmds.setAttr("lock.basename", basename, type="string")
Example #3
Source File: dpLayoutClass.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def loadGeo(self, *args): """ Loads the selected node to geoTextField in selectedModuleLayout. """ isGeometry = False selList = cmds.ls(selection=True) if selList: if cmds.objExists(selList[0]): childList = cmds.listRelatives(selList[0], children=True, allDescendents=True) if childList: for item in childList: itemType = cmds.objectType(item) if itemType == "mesh" or itemType == "nurbsSurface": isGeometry = True if isGeometry: cmds.textField(self.geoTF, edit=True, text=selList[0]) cmds.setAttr(self.moduleGrp+".geo", selList[0], type='string')
Example #4
Source File: dpAddHandFollow.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def dpMain(self, *args): """ Main function. Check existen nodes and call the scripted function. """ callAction = True if not cmds.objExists(self.spineChestACtrl): callAction = False if not cmds.objExists(self.globalCtrl): callAction = False if not cmds.objExists(self.rootCtrl): callAction = False if not cmds.objExists(self.spineHipsBCtrl): callAction = False if not cmds.objExists(self.headCtrl): callAction = False if callAction: self.dpDoAddHandFollow()
Example #5
Source File: dpFacialControl.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def dpLoadJointNode(self, itemList, *args): """ Load the respective items to build the joint target list (offset group node). """ leftPrefix = self.langDic[self.langName]["p002_left"]+"_" rightPrefix = self.langDic[self.langName]["p003_right"]+"_" offsetSuffix = "_Ctrl_Offset_Grp" for item in itemList: centerName = item+offsetSuffix leftName = leftPrefix+item+offsetSuffix rightName = rightPrefix+item+offsetSuffix if cmds.objExists(centerName): self.dpLoadJointTgtList(centerName) if cmds.objExists(leftName): self.dpLoadJointTgtList(leftName) if cmds.objExists(rightName): self.dpLoadJointTgtList(rightName)
Example #6
Source File: dpFacialControl.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def dpLoadBSTgtList(self, bsNodeName, *args): """ Add target list found in the blendShape node to target textScroll list """ if cmds.objExists(bsNodeName): if cmds.objectType(bsNodeName) == "blendShape": tgtList = cmds.blendShape(bsNodeName, query=True, target=True) if tgtList: cmds.textScrollList(self.bsTargetScrollList, edit=True, removeAll=True) cmds.textScrollList(self.bsTargetScrollList, edit=True, append=tgtList) cmds.textField(self.bsNodeTextField, edit=True, text=bsNodeName) self.bsNode = bsNodeName
Example #7
Source File: dpRivet.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def dpCheckGeometry(self, item, *args): isGeometry = False if item: if cmds.objExists(item): childList = cmds.listRelatives(item, children=True) if childList: self.itemType = cmds.objectType(childList[0]) if self.itemType == "mesh" or self.itemType == "nurbsSurface": if self.itemType == "mesh": self.meshNode = childList[0] isGeometry = True else: mel.eval("warning \""+item+" is not a geometry.\";") else: mel.eval("warning \"Select the transform node instead of "+item+" shape, please.\";") else: mel.eval("warning \""+item+" does not exists, maybe it was deleted, sorry.\";") else: mel.eval("warning \"Not found "+item+"\";") return isGeometry
Example #8
Source File: dpIsolate.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def dpMain(self, *args): """ Main function. Check existen nodes and call the scripted function. # nodeList[0] = Root_Ctrl # nodeList[1] = Grand Father transform from selected item # nodeList[2] = Selected item (control) """ # declaring nodeList to create the isolate setup: nodeList = [self.rootCtrl, self.grandFatherItem, self.selItem] if len(nodeList) == 3: for nodeName in nodeList: if not cmds.objExists(nodeName): print self.langDic[self.langName]['e004_objNotExist'], nodeName return # call scripted function self.dpIsolate(self.isolateName, nodeList)
Example #9
Source File: dpBaseClass.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def verifyGuideModuleIntegrity(self, *args): """ This function verify the integrity of the current module. Returns True if Ok and False if Fail. """ # conditionals to be elegible as a rigged guide module: if cmds.objExists(self.moduleGrp): if cmds.objExists(self.moduleGrp+'.guideBase'): if cmds.getAttr(self.moduleGrp+'.guideBase') == 1: return True else: try: self.deleteModule() mel.eval('warning \"'+ self.langDic[self.langName]['e000_GuideNotFound'] +' - '+ self.moduleGrp +'\";') except: pass return False
Example #10
Source File: samplingFunc.py From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License | 6 votes |
def attrsSampling(attrData, interval=1): """ Args: attrData (dict): {node1: [[attr1, min, max], [attr2, min, max], ...], node2: [[attr1, min, max], [attr2, min, max], ...], ...} interval (int) Returns: int """ currTime = cmds.currentTime(q=1) for node, attrVals in attrData.iteritems(): for vals in attrVals: attr, minVal, maxVal = vals if not cmds.objExists('.'.join([node, attr])): continue currTime = attrSampling(node, attr, minVal, maxVal, interval) currTime -= 2 * interval cmds.currentTime(currTime) return currTime+1 * interval #----------------------------------------------------------------------
Example #11
Source File: dpUtils.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def findModuleLastNumber(className, typeName): """ Find the last used number of this type of module. Return its highest number. """ # work with rigged modules in the scene: numberList = [] guideTypeCount = 0 # list all transforms and find the existing value in them names: transformList = cmds.ls(selection=False, transforms=True) for transform in transformList: if cmds.objExists(transform+"."+typeName): if cmds.getAttr(transform+"."+typeName) == className: numberList.append(className) # try check if there is a masterGrp and get its counter: if cmds.objExists(transform+".masterGrp") and cmds.getAttr(transform+".masterGrp") == 1: guideTypeCount = cmds.getAttr(transform+'.dp'+className+'Count') if(guideTypeCount > len(numberList)): return guideTypeCount else: return len(numberList)
Example #12
Source File: dpUtils.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def clearNodeGrp(nodeGrpName='dpAR_GuideMirror_Grp', attrFind='guideBaseMirror', unparent=False): """ Check if there is any node with the attribute attrFind in the nodeGrpName and then unparent its children and delete it. """ if cmds.objExists(nodeGrpName): foundChildrenList = [] childrenList = cmds.listRelatives(nodeGrpName, children=True, type="transform") if childrenList: for child in childrenList: if cmds.objExists(child+"."+attrFind) and cmds.getAttr(child+"."+attrFind) == 1: foundChildrenList.append(child) if len(foundChildrenList) != 0: if unparent: for item in foundChildrenList: cmds.parent(item, world=True) cmds.delete(nodeGrpName) else: cmds.delete(nodeGrpName)
Example #13
Source File: node_utils.py From spore with MIT License | 6 votes |
def get_mobject_from_name(name): """ get mObject from a given dag-path :param name : the name or dag-path to a shapenode to return a mObject to """ sl = om.MSelectionList() if not cmds.objExists(name): raise RuntimeError('Object does not exist: {}'.format(name)) om.MGlobal.getSelectionListByName(name, sl) node = om.MObject() sl.getDependNode(0, node) return node
Example #14
Source File: util.py From core with MIT License | 6 votes |
def unique(name): assert isinstance(name, basestring), "`name` must be string" while cmds.objExists(name): matches = re.findall(r"\d+$", name) if matches: match = matches[-1] name = name.rstrip(match) number = int(match) + 1 else: number = 1 name = name + str(number) return name
Example #15
Source File: utils.py From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License | 6 votes |
def findRelatedDeltaMush(geometry): """ Return the delta mush deformer attached to the specified geometry Args: geometry (str): Geometry object/transform to query Returns: str """ # Check geometry if not cmds.objExists(geometry): raise Exception('Object '+geometry+' does not exist!') hist = cmds.listHistory(geometry, pdo=1, gl=1) try: if mayaVersion() >= 2016: return cmds.ls(hist, type=["deltaMush", "wbDeltaMush"])[0] else: return cmds.ls(hist, type="wbDeltaMush")[0] except: return None #----------------------------------------------------------------------
Example #16
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def BT_ConnectSetup(set = None): if not set or not cmds.objExists(set): return False if BT_IsSetupConnected(set = set): cmds.warning('Setup already connected!') return False btNode = cmds.getAttr(set +'.Blend_Node') if not btNode or not cmds.objExists(btNode): return False transforms = cmds.listConnections(set +'.dagSetMembers') for i in range(0, len(transforms)): try: BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i]) except: pass mults = cmds.listConnections(btNode, d = True, type = 'multiplyDivide') if mults: cmds.delete(mults) return True
Example #17
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def BT_ConnectSetup(set = None): if not set or not cmds.objExists(set): return False if BT_IsSetupConnected(set = set): cmds.warning('Setup already connected!') return False btNode = cmds.getAttr(set +'.Blend_Node') if not btNode or not cmds.objExists(btNode): return False transforms = cmds.listConnections(set +'.dagSetMembers') for i in range(0, len(transforms)): try: BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i]) except: pass mults = cmds.listConnections(btNode, d = True, type = 'multiplyDivide') if mults: cmds.delete(mults) return True
Example #18
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def BT_ConnectSetup(set = None): if not set or not cmds.objExists(set): return False if BT_IsSetupConnected(set = set): cmds.warning('Setup already connected!') return False btNode = cmds.getAttr(set +'.Blend_Node') if not btNode or not cmds.objExists(btNode): return False transforms = cmds.listConnections(set +'.dagSetMembers') for i in range(0, len(transforms)): try: BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i]) except: pass mults = cmds.listConnections(btNode, d = True, type = 'multiplyDivide') if mults: cmds.delete(mults) return True
Example #19
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def BT_ConnectSetup(set = None): if not set or not cmds.objExists(set): return False if BT_IsSetupConnected(set = set): cmds.warning('Setup already connected!') return False btNode = cmds.getAttr(set +'.Blend_Node') if not btNode or not cmds.objExists(btNode): return False transforms = cmds.listConnections(set +'.dagSetMembers') for i in range(0, len(transforms)): try: BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i]) except: pass mults = cmds.listConnections(btNode, d = True, type = 'multiplyDivide') if mults: cmds.delete(mults) return True
Example #20
Source File: manager.py From spore with MIT License | 6 votes |
def name_changed(self, widget, name): """ triggered by one of the spore widgets when the user requests a name change :param widget: the source of the signal :param name: the new name """ node_name = widget.long_name if cmds.objExists(node_name): if re.match('^[A-Za-z0-9_-]*$', name) and not name[0].isdigit(): # transform = cmds.listRelatives(node_name, p=True, f=True)[0] instancer = node_utils.get_instancer(node_name) cmds.rename(instancer, '{}Instancer'.format(name)) cmds.rename(node_name, '{}Shape'.format(name)) # cmds.rename(transform, name) else: self.io.set_message('Invalid Name: Use only A-Z, a-z, 0-9, -, _', 2) return self.refresh_spore()
Example #21
Source File: manager.py From spore with MIT License | 6 votes |
def item_clicked(self, widget, event): item_name = widget.long_name item_state = widget.is_selected if cmds.objExists(item_name): is_modified = event.modifiers() == Qt.ControlModifier if not is_modified: cmds.select(clear=True) for geo_item, spore_items in self.wdg_tree.iteritems(): for spore_item in spore_items: if is_modified \ and spore_item.is_selected: cmds.select(spore_item.long_name, add=True) else: spore_item.deselect() cmds.select(spore_item.long_name, deselect=True) widget.set_select(item_state) if not is_modified: cmds.select(item_name) else: self.refresh_spore()
Example #22
Source File: dpUtils.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def zeroOutJoints(jntList=None): """ Duplicate the joints, parent as zeroOut. Returns the father joints (zeroOuted). Deprecated = using zeroOut function insted. """ resultList = [] zeroOutJntSuffix = "_Jzt" if jntList: for jnt in jntList: if cmds.objExists(jnt): jxtName = jnt.replace("_Jnt", "").replace("_Jxt", "") if not zeroOutJntSuffix in jxtName: jxtName += zeroOutJntSuffix dup = cmds.duplicate(jnt, name=jxtName)[0] deleteChildren(dup) clearDpArAttr([dup]) cmds.parent(jnt, dup) resultList.append(dup) return resultList
Example #23
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def connectSetup(self): uiSet = str(self.ui.setEdit.text()) if not uiSet: return False if not cmds.objExists(uiSet): return False BT_ConnectSetup(set = uiSet) return True
Example #24
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def disconnectSetup(self): uiSet = str(self.ui.setEdit.text()) if not uiSet: return False if not cmds.objExists(uiSet): return False BT_DisconnectSetup(set = uiSet) return True
Example #25
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def connectSetup(self): uiSet = str(self.ui.setEdit.text()) if not uiSet: return False if not cmds.objExists(uiSet): return False BT_ConnectSetup(set = uiSet) return True
Example #26
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def BT_IsSetupConnected(set = None): if not set or not cmds.objExists(set): return None #test the first transform in the set setItems = cmds.listConnections(set +'.dagSetMembers') if not setItems: return None connections = cmds.listConnections(setItems[0], source = True, type = 'BlendTransforms') if connections: return True return False
Example #27
Source File: sqStickyLipsSetup.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def sqGetRecepts(self, receptA=None, receptB=None, *args): self.receptList = [] self.receptList.append(receptA) self.receptList.append(receptB) if receptA == None: receptAName = cmds.textField(self.receptA_TF, query=True, text=True) if cmds.objExists(receptAName): self.receptList[0] = receptAName if receptB == None: receptBName = cmds.textField(self.receptB_TF, query=True, text=True) if cmds.objExists(receptBName): self.receptList[1] = receptBName
Example #28
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def disconnectSetup(self): uiSet = str(self.ui.setEdit.text()) if not uiSet: return False if not cmds.objExists(uiSet): return False BT_DisconnectSetup(set = uiSet) return True
Example #29
Source File: manager.py From spore with MIT License | 5 votes |
def toggle_view(self, widget, mode): """ triggered by one of the spore widget's display toggle buttons :param widget: the source of the signal :param mode: 1==geometry, 2==bounding box, 3==bounding boxes """ node_name = widget.long_name if cmds.objExists(node_name): instancer = node_utils.get_instancer(node_name) if instancer: cmds.setAttr('{}.levelOfDetail'.format(instancer), mode)
Example #30
Source File: lib.py From core with MIT License | 5 votes |
def unique_name(name, format="%02d", namespace="", prefix="", suffix=""): """Return unique `name` The function takes into consideration an optional `namespace` and `suffix`. The suffix is included in evaluating whether a name exists - such as `name` + "_GRP" - but isn't included in the returned value. If a namespace is provided, only names within that namespace are considered when evaluating whether the name is unique. Arguments: format (str, optional): The `name` is given a number, this determines how this number is formatted. Defaults to a padding of 2. E.g. my_name01, my_name02. namespace (str, optional): Only consider names within this namespace. suffix (str, optional): Only consider names with this suffix. Example: >>> name = cmds.createNode("transform", name="MyName") >>> cmds.objExists(name) True >>> unique = unique_name(name) >>> cmds.objExists(unique) False """ iteration = 1 unique = prefix + (name + format % iteration) + suffix while cmds.objExists(namespace + ":" + unique): iteration += 1 unique = prefix + (name + format % iteration) + suffix if suffix: return unique[:-len(suffix)] return unique