Python maya.cmds.listAttr() Examples
The following are 30
code examples of maya.cmds.listAttr().
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: ml_utilities.py From ml_tools with MIT License | 6 votes |
def channels(self): ''' The keySelection's channels list. ''' if not self._channels: if self._curves: for c in self._curves: self._channels.append(getChannelFromAnimCurve(c)) elif self._nodes: for obj in self._nodes: keyable = mc.listAttr(obj, keyable=True, unlocked=True, hasData=True, settable=True) if keyable: for attr in keyable: self._channels.append('.'.join((obj, attr))) return self._channels
Example #2
Source File: anim_utils.py From mgear_core with MIT License | 6 votes |
def reset_all_keyable_attributes(dagnodes, *args): # @unusedVariable """Resets to default values all keyable attributes on the given node Args: dagnodes (list): Maya transform nodes to reset *args: State of the menu item (if existing) send by mgear's dagmenu """ for node in dagnodes: keyable_attrs = cmds.listAttr(node, keyable=True) reset_selected_channels_value([node], keyable_attrs) ################################################## # Transfer space ##################################################
Example #3
Source File: utils.py From maya2katana with GNU General Public License v3.0 | 6 votes |
def node_attributes(node): """ Get Maya node attributes """ attributes = cmds.listAttr(node) attr = {} attr["node_name"] = node attr["node_type"] = cmds.nodeType(node) for attribute in attributes: if "." in attribute: continue try: val = cmds.getAttr(node + "." + attribute) except RuntimeError: continue attr[attribute] = val return attr
Example #4
Source File: uExport.py From uExport with zlib License | 6 votes |
def convertSkelSettingsToNN(delete=1): orig = 'SkeletonSettings_Cache' if cmds.objExists(orig): if cmds.nodeType(orig) == 'unknown': new = cmds.createNode('network') for att in cmds.listAttr(orig): if not cmds.attributeQuery(att, node=new, exists=1): typ = cmds.attributeQuery(att, node=orig, at=1) if typ == 'typed': cmds.addAttr(new, longName=att, dt='string') if cmds.getAttr(orig + '.' + att): cmds.setAttr(new + '.' + att, cmds.getAttr(orig + '.' + att), type='string') elif typ == 'enum': cmds.addAttr(new, longName=att, at='enum', enumName=cmds.attributeQuery(att, node=orig, listEnum=1)[0]) cmds.delete(orig) cmds.rename(new, 'SkeletonSettings_Cache')
Example #5
Source File: mayascenewrapper.py From cross3d with MIT License | 6 votes |
def _normalizeAttributeShortName(cls, name, uniqueOnObj=None): """ Creates a shortName for the provided attribute name by calling MayaSceneWrapper._normalizeAttributeName. It then adds the first character to any capital letters in the rest of the name. The name is then lowercased. If uniqueOnObj is provided with a object, it will ensure the returned attribute name is unique by attaching a 3 digit padded number to it. It will be the lowest available number. :param name: The string used to generate the short name. :param uniqueOnObj: Ensure the name is unque. Defaults to None. :return: string """ name = cls._normalizeAttributeName(name) if len(name): name = name[0] + re.sub(r'[a-z]', '', name[1:]) name = name.lower() if uniqueOnObj: # Ensure a unique object name by adding a value to the number. # TODO MIKE: Same issue with the "|groundPlane_transform". try: names = set(cmds.listAttr(cls._mObjName(uniqueOnObj), shortNames=True)) name = api.Scene._findUniqueName(name, names, incFormat='{name}{count}') except ValueError: pass return name
Example #6
Source File: mayauserprops.py From cross3d with MIT License | 6 votes |
def keys(self): # TODO MIKE: I had to do a try except here for the the object called "|groundPlane_transform". # It's apparently always in the scene and error with that line. try: keys = cmds.listAttr(cross3d.SceneWrapper._mObjName(self._nativePointer), userDefined=True) if keys: return keys except ValueError: pass return [] # http://forums.cgsociety.org/showthread.php?t=888612 # Note: I was unable to find a way to identify userDefined keys in the following method # so I used the maya.cmds method. If possible this finish this method and replace the # above code. #depNode = om.MFnDependencyNode(mObj) #total = depNode.attributeCount() #count = 0 #while count < total: # attr = depNode.attribute(count) # plug = om.MPlug(mObj, attr) # count += 1 # print count, attr.apiTypeStr(), plug.name()
Example #7
Source File: samplingFunc.py From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License | 6 votes |
def blendShapeSampling(node, interval=1): """ Args: node (str) interval (int) Returns: int """ assert cmds.nodeType(node) == 'blendShape', \ "node must be a blendShape type" start = cmds.currentTime(q=1) attrs = cmds.listAttr('%s.weight' % node, m=1) attrData = {node: [[attr, 0.0, 1.0] for attr in attrs]} currTime = attrsSampling(attrData, interval) end = currTime-1 utils.trimTimeRange(start, end) cmds.currentTime(start) #----------------------------------------------------------------------
Example #8
Source File: mayascenemodel.py From cross3d with MIT License | 5 votes |
def isReferenced(self): userProps = cross3d.UserProps(self._nativePointer) if userProps.get('referenced', False): # Checking if we need to set the resolution combobox. if not resolutionAttr in cmds.listAttr(self._nativeName()): # Create the user props for the reference. userProps['resolutions'] = OrderedDict(Offloaded='') self._createResolutionComboBox() return True return False
Example #9
Source File: freeze.py From SIWeightEditor with MIT License | 5 votes |
def save_cluster(node): #ノードの中からスキンクラスタを取得してくる#inMesh直上がSkinClusterとは限らないので修正 srcDeformerCluster = cmds.ls(cmds.listHistory(node),type='cluster') if not srcDeformerCluster: return#スキンクラスタがなかったら関数抜ける #スキンクラスタのパラメータ色々を取得しておく srcDeformerCluster = srcDeformerCluster[0] attributes = cmds.listAttr(srcDeformerCluster) weightList = cmds.getAttr(srcDeformerCluster+'.weightList[0]') envelope = cmds.getAttr(srcDeformerCluster+'.envelope') clusterMssage = cmds.getAttr(srcDeformerCluster+'.message') clusterWeight = cmds.getAttr(srcDeformerCluster+'.weightList[0].weights')
Example #10
Source File: ml_transferKeytimes.py From ml_tools with MIT License | 5 votes |
def transferKeytimes(source, destinations): if not isinstance(destinations, (list, tuple)): destinations = [destinations] attributes = mc.listAttr(source, keyable=True, unlocked=True) keytimes = dict() start = None end = None for a in attributes: currKeytimes = mc.keyframe(source, attribute=a, query=True, timeChange=True) if not currKeytimes: continue if start == None or currKeytimes[0] < start: start = currKeytimes[0] if end == None or currKeytimes[-1] > end: end = currKeytimes[-1] keytimes[a] = currKeytimes #allKeyTimes.extend(currKeytimes) if not keytimes: return with utl.IsolateViews(): mc.bakeResults(destinations, time=(start,end), sampleBy=1, preserveOutsideKeys=True, simulation=True) #euler filter mc.filterCurve(mc.listConnections(destinations,type='animCurve')) #go through all keys and delete for k in keytimes: for f in range(int(start), int(end)): if not f in keytimes[k]: mc.cutKey(destinations, attribute=k, time=(f,))
Example #11
Source File: ml_puppet.py From ml_tools with MIT License | 5 votes |
def copyPose(fromNode, toNode, flip=False): attrs = mc.listAttr(fromNode, keyable=True) if not attrs: return #if attributes are aliased, get the real names for mirroring axis aliases = mc.aliasAttr(fromNode, query=True) if aliases: for alias,real in zip(aliases[::2],aliases[1::2]): if alias in attrs: attrs.remove(alias) attrs.append(real) axis = getMirrorAxis(toNode) for attr in attrs: if attr == 'mirrorAxis': continue if not mc.attributeQuery(attr, node=toNode, exists=True): continue fromPlug = '{}.{}'.format(fromNode, attr) toPlug = '{}.{}'.format(toNode, attr) fromValue = mc.getAttr(fromPlug) toValue = mc.getAttr(toPlug) if attr in axis: fromValue *= -1.0 toValue *= -1.0 try: utl.setAnimValue(toPlug, fromValue) except:pass if flip: try: utl.setAnimValue(fromPlug, toValue) except:pass
Example #12
Source File: ml_puppet.py From ml_tools with MIT License | 5 votes |
def getSpaceSwitchData(node): data = {} attrs = mc.listAttr(node, userDefined=True, keyable=True) if not attrs: return data ssAttrs = [x for x in attrs if 'paceSwitch' in x or x == 'space'] for attr in ssAttrs: enumValues = [] spaceEnum = 'space' if attr == 'spaceSwitch' or attr == 'space': if not 'space' in attrs: spaceEnum = 'spaceSwitch' enumValues = mc.attributeQuery(spaceEnum, node=node, listEnum=True) elif 'SpaceSwitch' in attr: baseName = attr.replace('SpaceSwitch','') if baseName + 'Space' in attrs: spaceEnum = baseName+'Space' else: spaceEnum = attr if spaceEnum in attrs and mc.attributeQuery(spaceEnum, node=node, attributeType=True) == 'enum': enumValues = mc.attributeQuery(spaceEnum, node=node, listEnum=True) if not enumValues: continue data[attr] = {} data[attr]['enumValues'] = enumValues[0].split(':') data[attr]['currentValue'] = mc.getAttr(node+'.'+spaceEnum, asString=True) return data
Example #13
Source File: ml_resetChannels.py From ml_tools with MIT License | 5 votes |
def main(selectedChannels=True, transformsOnly=False, excludeChannels=None): ''' Resets selected channels in the channel box to default, or if nothing's selected, resets all keyable channels to default. ''' gChannelBoxName = mm.eval('$temp=$gChannelBoxName') sel = mc.ls(sl=True) if not sel: return if excludeChannels and not isinstance(excludeChannels, (list, tuple)): excludeChannels = [excludeChannels] chans = None if selectedChannels: chans = mc.channelBox(gChannelBoxName, query=True, sma=True) testList = ['translateX','translateY','translateZ','rotateX','rotateY','rotateZ','scaleX','scaleY','scaleZ', 'tx','ty','yz','rx','ry','rz','sx','sy','sz'] for obj in sel: attrs = chans if not chans: attrs = mc.listAttr(obj, keyable=True, unlocked=True) if excludeChannels and attrs: attrs = [x for x in attrs if x not in excludeChannels] if transformsOnly: attrs = [x for x in attrs if x in testList] if attrs: for attr in attrs: try: default = mc.attributeQuery(attr, listDefault=True, node=obj)[0] mc.setAttr(obj+'.'+attr, default) except StandardError: pass utl.deselectChannels()
Example #14
Source File: dge.py From cmt with MIT License | 5 votes |
def add_notes(self, node, op_str): node = node.split(".")[0] attrs = cmds.listAttr(node, ud=True) or [] if "notes" not in attrs: cmds.addAttr(node, ln="notes", dt="string") keys = self.kwargs.keys() keys.sort() notes = "Node generated by dge\n\nExpression:\n {}\n\nOperation:\n {}\n\nkwargs:\n {}".format( self.expression_string, op_str, "\n ".join(["{}: {}".format(x, self.kwargs[x]) for x in keys]), ) cmds.setAttr("{}.notes".format(node), notes, type="string")
Example #15
Source File: mayascenewrapper.py From cross3d with MIT License | 5 votes |
def propertyNames(self): """ Return a list of the property names linked to this instance :return: list of names """ name = self._mObjName(self._nativePointer, True) return cmds.listAttr(name, settable=True, output=True) #-------------------------------------------------------------------------------- # cross3d public methods #--------------------------------------------------------------------------------
Example #16
Source File: lib.py From core with MIT License | 5 votes |
def read(node): """Return user-defined attributes from `node`""" data = dict() for attr in cmds.listAttr(node, userDefined=True) or list(): try: value = cmds.getAttr(node + "." + attr, asString=True) except RuntimeError: # For Message type attribute or others that have connections, # take source node name as value. source = cmds.listConnections(node + "." + attr, source=True, destination=False) source = cmds.ls(source, long=True) or [None] value = source[0] except ValueError: # Some attributes cannot be read directly, # such as mesh and color attributes. These # are considered non-essential to this # particular publishing pipeline. value = None data[attr] = value return data
Example #17
Source File: ui.py From maya-channel-box-plus with GNU General Public License v3.0 | 5 votes |
def updateSearch(self, matchString, nodes): """ Loop over all keyable attributes and match them with the search string. :param str matchString: Search string to match with attributes :param list nodes: List of nodes to process the attributes from """ # reset of search string is empty if not matchString: cmds.channelBox(CHANNELBOX, edit=True, fixedAttrList=[]) return # split match string matches = [] matchStrings = matchString.lower().split() # get matching attributes for node in nodes: attrs = cmds.listAttr(node, k=True, v=True) for attr in attrs: if ( not attr in matches and self.matchSearch(attr, matchStrings) ): matches.append(attr) # append null if not matches are found ( cannot use empty list ) if not matches: matches.append("null") # filter channel box cmds.channelBox(CHANNELBOX, edit=True, fixedAttrList=matches) # ------------------------------------------------------------------------
Example #18
Source File: dpAutoRig.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def reorderAttributes(self, objList, attrList, *args): """ Reorder Attributes of a given objectList following the desiredAttribute list. Useful for organize the Option_Ctrl attributes, for example. """ if objList and attrList: for obj in objList: # load dpReorderAttribute: dpRAttr = dpReorderAttr.ReorderAttr(self, self.langDic, self.langName, False) # Reordering Option_Ctrl attributos progress window progressAmount = 0 cmds.progressWindow(title='Reordering Attributes', progress=progressAmount, status='Reordering: 0%', isInterruptable=False) nbDesAttr = len(attrList) delta = 0 for i, desAttr in enumerate(attrList): # update progress window progressAmount += 1 cmds.progressWindow(edit=True, maxValue=nbDesAttr, progress=progressAmount, status=('Reordering: ' + `progressAmount` + ' '+ obj + ' attributes')) # get current user defined attributes: currentAttrList = cmds.listAttr(obj, userDefined=True) if desAttr in currentAttrList: cAttrIndex = currentAttrList.index(desAttr) maxRange = cAttrIndex+1-i+delta for n in range(1, maxRange): dpRAttr.dpMoveAttr(1, [obj], [desAttr]) else: delta = delta+1 cmds.progressWindow(endProgress=True) dpRAttr.dpCloseReorderAttrUI()
Example #19
Source File: dpControls.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def copyAttr(self, sourceItem=False, attrList=False, verbose=False, *args): """ Get and store in a dictionary the attributes from sourceItem. Returns the dictionary with attribute values. """ # getting sourceItem: if not sourceItem: selList = cmds.ls(selection=True, long=True) if selList: sourceItem = selList[0] else: print self.dpUIinst.langDic[self.dpUIinst.langName]["e015_selectToCopyAttr"] if cmds.objExists(sourceItem): if not attrList: # getting channelBox selected attributes: currentAttrList = cmds.channelBox('mainChannelBox', query=True, selectedMainAttributes=True) if not currentAttrList: # list all attributes if nothing is selected: currentAttrList = cmds.listAttr(sourceItem, visible=True, keyable=True) attrList = currentAttrList if attrList: # store attribute values in a dic: self.attrValueDic = {} for attr in attrList: if cmds.objExists(sourceItem+'.'+attr): value = cmds.getAttr(sourceItem+'.'+attr) self.attrValueDic[attr] = value if verbose: print self.dpUIinst.langDic[self.dpUIinst.langName]["i125_copiedAttr"] return self.attrValueDic
Example #20
Source File: dpUtils.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
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
Example #21
Source File: freeze.py From SISideBar with MIT License | 5 votes |
def save_cluster(node): #ノードの中からスキンクラスタを取得してくる#inMesh直上がSkinClusterとは限らないので修正 srcDeformerCluster = cmds.ls(cmds.listHistory(node),type='cluster') if not srcDeformerCluster: return#スキンクラスタがなかったら関数抜ける #スキンクラスタのパラメータ色々を取得しておく srcDeformerCluster = srcDeformerCluster[0] attributes = cmds.listAttr(srcDeformerCluster) weightList = cmds.getAttr(srcDeformerCluster+'.weightList[0]') envelope = cmds.getAttr(srcDeformerCluster+'.envelope') clusterMssage = cmds.getAttr(srcDeformerCluster+'.message') clusterWeight = cmds.getAttr(srcDeformerCluster+'.weightList[0].weights')
Example #22
Source File: anim_utils.py From mgear_core with MIT License | 5 votes |
def listAttrForMirror(node): """List attributes to invert the value for mirror posing Args: node (PyNode): The Node with the attributes to invert Returns: list: Attributes to invert """ # TODO: should "ro" be here? res = ["tx", "ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz"] res.extend(pm.listAttr(node, userDefined=True, shortNames=True)) res = list(filter(lambda x: not x.startswith("inv"), res)) return res
Example #23
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def BT_GetPosesFromSet(set = None): if not set: return False allUserDefined = cmds.listAttr(set, ud = True) if not allUserDefined: return '' btUserDefined = [x[3:] for x in allUserDefined if x.startswith('BT_')] if not btUserDefined: return '' return btUserDefined
Example #24
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def BT_GetPosesFromSet(set = None): if not set: return False allUserDefined = cmds.listAttr(set, ud = True) if not allUserDefined: return '' btUserDefined = [x[3:] for x in allUserDefined if x.startswith('BT_')] if not btUserDefined: return '' return btUserDefined
Example #25
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def BT_GetPosesFromSet(set = None): if not set: return False allUserDefined = cmds.listAttr(set, ud = True) if not allUserDefined: return '' btUserDefined = [x[3:] for x in allUserDefined if x.startswith('BT_')] if not btUserDefined: return '' return btUserDefined
Example #26
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def BT_GetPosesFromSet(set = None): if not set: return False allUserDefined = cmds.listAttr(set, ud = True) if not allUserDefined: return '' btUserDefined = [x[3:] for x in allUserDefined if x.startswith('BT_')] if not btUserDefined: return '' return btUserDefined
Example #27
Source File: channelBox.py From tutorials with MIT License | 4 votes |
def showAttributes(self, node): """ showAttributes(str node) Set the ChannelBox to view the given node. If node is empty or None, the ChannelBox will simply be cleared. """ with noSignals(self.table): while self.table.rowCount() > 1: self.table.removeRow(1) if not node or not cmds.objExists(node): self._setTableVisible(False) return self._setTableVisible(True) # update the node name self._currentNode = node name = node.split('|')[-1] self.table.item(0,0).setText(name) # update the attributes attrs = cmds.listAttr(node, r=True, w=True, v=True, k=True) self.table.setRowCount(len(attrs)+1) for row, name in enumerate(attrs): row += 1 self.table.setRowHeight(row, 20) attr = '%s.%s' % (node, name) niceName = cmds.attributeName(attr) item = QtGui.QTableWidgetItem(niceName) item.attrName = attr item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) item.setTextAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignVCenter) self.table.setItem(row, 0, item) val = cmds.getAttr(attr) item = AttrItem() item.setTextAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) item.setBackgroundColor(QtGui.QColor(40,40,40)) item.attrName = attr item.attrVal = val item.setAttrValue(val) self.table.setItem(row, 1, item)
Example #28
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 4 votes |
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
Example #29
Source File: orientjoints.py From cmt with MIT License | 4 votes |
def rebuild_joints(*args): if not cmds.objExists(ORIENT_GROUP): return nodes = cmds.listRelatives(ORIENT_GROUP, ad=True, path=True) or [] joints = [] for node in nodes: attrs = cmds.listAttr(node, ud=True) or [] if MESSAGE_ATTRIBUTE not in attrs: continue joint = cmds.listConnections( "{0}.{1}".format(node, MESSAGE_ATTRIBUTE), d=False )[0] joints.append(joint) rotation = cmds.getAttr("{0}.rx".format(node)) children = cmds.listRelatives(joint, children=True, shapes=False, path=True) if children: # First unparent children so change in joint orient does not affect children children = [cmds.parent(child, world=True)[0] for child in children] # Add rotation offset to joint orient orient_x = cmds.getAttr("{0}.jointOrientX".format(joint)) orient_x += rotation while orient_x > 180.0: orient_x -= 360.0 while orient_x < -180.0: orient_x += 360.0 cmds.setAttr("{0}.jointOrientX".format(joint), orient_x) # Reparent child for child in children: cmds.parent(child, joint) else: # tip joint, just zero out joint orient cmds.setAttr("%s.jointOrientX" % joint, 0) cmds.setAttr("%s.jointOrientY" % joint, 0) cmds.setAttr("%s.jointOrientZ" % joint, 0) # Untemplate cmds.setAttr("{0}.template".format(joint), 0) # Delete arrow group cmds.delete(ORIENT_GROUP) cmds.select(joints)
Example #30
Source File: customAttributeEditor.py From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License | 4 votes |
def on_add_btn_clicked(self): selNodes = cmds.ls(sl=1, ap=1) if not selNodes: om.MGlobal.displayError("Please select some nodes and attributes.") return selAttrs = (cmds.channelBox("mainChannelBox", q=1, sma=1) or []) \ + (cmds.channelBox("mainChannelBox", q=1, sha=1) or []) \ + (cmds.channelBox("mainChannelBox", q=1, ssa=1) or []) \ + (cmds.channelBox("mainChannelBox", q=1, soa=1) or []) if not selAttrs: selAttrs = cmds.listAttr(selNodes, v=1, k=1, sn=1) selAttrs = list(set(selAttrs)) try: selAttrs.remove('v') except: pass self.table.clearSelection() for node in selNodes: for attr in selAttrs: name = "%s.%s" % (node, attr) minVal, maxVal = 0.0, 1.0 hasMinVal, hasMaxVal = False, False if not cmds.objExists(name): continue # Set minVal if cmds.attributeQuery(attr, node=node, minExists=1): minVal = cmds.attributeQuery(attr, node=node, min=1)[0] hasMinVal = True if cmds.attributeQuery(attr, node=node, softMinExists=1): minVal = cmds.attributeQuery(attr, node=node, smn=1)[0] hasMinVal = True # Set maxVal if cmds.attributeQuery(attr, node=node, maxExists=1): maxVal = cmds.attributeQuery(attr, node=node, max=1)[0] hasMaxVal = True if cmds.attributeQuery(attr, node=node, softMaxExists=1): maxVal = cmds.attributeQuery(attr, node=node, smx=1)[0] hasMaxVal = True currVal = cmds.getAttr(name) if hasMinVal: minVal = minVal - currVal if hasMaxVal: maxVal = maxVal - currVal self.appendRow() self.setRow(self.numRow()-1, [name, minVal, maxVal]) #----------------------------------------------------------------------