本文整理汇总了Python中maya.cmds.listAttr函数的典型用法代码示例。如果您正苦于以下问题:Python listAttr函数的具体用法?Python listAttr怎么用?Python listAttr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了listAttr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setMirrorObject
def setMirrorObject( fromList, toList ):
for i in range( len( fromList ) ):
fromCtl = fromList[i]
toCtl = toList[i]
isTransMirror = False
isZRotMirror = False
for transMirrorName in CtlInfo.xTransMirrorTargetNames:
if fromCtl.find( transMirrorName ) != -1:
isTransMirror = True
for zRotMirror in CtlInfo.zRotMirrorTargetNames:
if fromCtl.find( zRotMirror ) != -1 and fromCtl.find( 'wing_big4_CTL' ) == -1:
isZRotMirror = True
try:
if isTransMirror:
trValue = cmds.getAttr( fromCtl + '.t' )[0]
cmds.setAttr( toCtl+'.t', -trValue[0], trValue[1], trValue[2] )
elif isZRotMirror:
rotValue = cmds.getAttr( fromCtl + '.r' )[0]
cmds.setAttr( toCtl + '.r', -rotValue[0], -rotValue[1], rotValue[2] )
else:
keys = cmds.listAttr( fromCtl, k=1 )
for key in keys:
value = cmds.getAttr( fromCtl+'.'+key )
cmds.setAttr( toCtl + '.' + key, value )
except: pass
listAttr = cmds.listAttr( fromCtl, ud=1, k=1 )
if not listAttr: continue
for attr in listAttr:
cmds.setAttr( toCtl+'.'+attr, cmds.getAttr( fromCtl+'.'+attr ) )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:33,代码来源:cmdModel.py
示例2: setAttributeState
def setAttributeState(lock=None, hide=None):
sel = mc.ls(sl=True)
if not sel:
OpenMaya.MGlobal.displayWarning('Please make a selection.')
return
channels = utl.getSelectedChannels()
doAll = not bool(channels)
kwargs = dict()
for obj in sel:
attrs = channels[:]
#we unhide first, so hidden attributes can get unlocked.
if hide is False and doAll:
attrs = ['tx','ty','tz','rx','ry','rz','sx','sy','sz','v']
ud = mc.listAttr(obj, userDefined=True)
if ud:
attrs+=ud
elif doAll:
attrs = mc.listAttr(obj, keyable=True)
if lock is not None:
kwargs['lock'] = lock
if hide is not None:
kwargs['keyable'] = not hide
if attrs:
for attr in attrs:
try:
mc.setAttr(obj+'.'+attr, **kwargs)
except StandardError: pass
开发者ID:Italic-,项目名称:maya-prefs,代码行数:34,代码来源:ml_lockAndHideAttributes.py
示例3: getAttribute
def getAttribute(self):
# if lattice point is selected, returning list is 'attr.attr'
keyable = cmds.listAttr(self.name, k=True, s=True)
if keyable:
for attr in keyable:
if attr not in self.attributesDriven:
# hacky -- if attr.attr format, remove first attr
hack = False
if '.' in attr:
attr = attr.split('.')[1]
hack = True
try:
a = Attribute(self.name, attr, poseOnly=self.poseOnly)
a.get()
self.attributes.append(a)
except:
message('Hack fail: ' + attr)
else:
a = Attribute(self.name, attr, poseOnly=self.poseOnly)
a.get()
self.attributes.append(a)
settable = cmds.listAttr(self.name, cb=True) # future fix, make part of one pass, current code copied from above
if settable:
for attr in settable:
if attr not in self.attributesDriven:
# hacky -- if attr.attr format, remove first attr
if '.' in attr:
attr = attr.split('.')[1]
a = Attribute(self.name, attr, poseOnly=self.poseOnly, settable=True)
a.get()
self.attributes.append(a)
开发者ID:boochos,项目名称:work,代码行数:32,代码来源:clipPickle_lib.py
示例4: channelBox_Filter_Items
def channelBox_Filter_Items(box):
with sysCmd.Undo(0):
filters = []
names = []
for f in box.filter_items:
if f == "attr_userDefined":
user_cb = cmds.listAttr(ud=1, cb=1)
user_kv = cmds.listAttr(ud=1, k=1, v=1)
if user_cb:
names += user_cb
if user_kv:
names += user_kv
elif f == "attr_translate":
names.append("translateX")
names.append("translateY")
names.append("translateZ")
elif f == "attr_rotate":
names.append("rotateX")
names.append("rotateY")
names.append("rotateZ")
elif f == "attr_scale":
names.append("scaleX")
names.append("scaleY")
names.append("scaleZ")
else:
filters.append(f.split("_")[-1])
if len(filters) == 0 and len(names) == 0:
cmds.channelBox(box.channelbox, e=1, update=1)
return
_f = [] # create the actual filters
if "animCurve" in filters:
_f.append(cmds.itemFilterAttr(hasCurve=1))
if "expression" in filters:
_f.append(cmds.itemFilterAttr(hasExpression=1))
if "drivenKey" in filters:
_f.append(cmds.itemFilterAttr(hasDrivenKey=1))
if "scaleRotateTranslate" in filters:
_f.append(cmds.itemFilterAttr(scaleRotateTranslate=1))
if names:
_f.append(cmds.itemFilterAttr(byNameString=names))
destination = _f[0]
odd = len(_f) % 2 # determines odd/even number
loops = len(_f) / 2 + (1 if odd else 0)
for i in range(loops): # create union filters
index_1 = i * 2
index_2 = i * 2 + 1
use_last = odd and i + 1 == loops
destination = cmds.itemFilterAttr(union=(_f[index_1], _f[index_2] if not use_last else destination))
box.filter = destination
cmds.itemFilterAttr(box.filter, e=1, negate=box.saved_states["invertShown"][0])
cmds.channelBox(box.channelbox, e=1, attrFilter=box.filter, update=1)
for f in _f:
cmds.delete(f)
开发者ID:Vaei,项目名称:ModularChannelBox,代码行数:60,代码来源:jtChannelBox_Commands_Default.py
示例5: setMirrorObjectOnce
def setMirrorObjectOnce( target ):
otherTarget = ''
if target in CtlInfo.leftCtls:
otherTarget = target.replace( 'L_', 'R_' )
elif target in CtlInfo.rightCtls:
otherTarget = target.replace( 'R_', 'L_' )
if not otherTarget: return None
isTransMirror = False
isZRotMirror = False
for transMirrorName in CtlInfo.xTransMirrorTargetNames:
if target.find( transMirrorName ) != -1:
isTransMirror = True
for zRotMirror in CtlInfo.zRotMirrorTargetNames:
if target.find( zRotMirror ) != -1 and target.find( 'wing_big4_CTL' ) == -1:
isZRotMirror = True
if isTransMirror:
trValue = cmds.getAttr( target + '.t' )[0]
cmds.setAttr( otherTarget+'.t', -trValue[0], trValue[1], trValue[2] )
elif isZRotMirror:
rotValue = cmds.getAttr( target + '.r' )[0]
cmds.setAttr( otherTarget + '.r', -rotValue[0], -rotValue[1], rotValue[2] )
else:
keys = cmds.listAttr( target, k=1 )
for key in keys:
value = cmds.getAttr( target+'.'+key )
cmds.setAttr( otherTarget + '.' + key, value )
listAttr = cmds.listAttr( target, ud=1, k=1 )
if not listAttr: return None
for attr in listAttr:
cmds.setAttr( otherTarget+'.'+attr, cmds.getAttr( target+'.'+attr ) )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:34,代码来源:cmdModel.py
示例6: utilChannelBoxAttributes
def utilChannelBoxAttributes(source):
attributes = cmds.listAttr(source, k=True)
#extend non-keyable in channel box
nonKeyable = cmds.listAttr(source, cb=True)
if nonKeyable:
attributes.extend(nonKeyable)
return attributes
开发者ID:studiocoop,项目名称:maya-coop,代码行数:7,代码来源:coopAttrUtils.py
示例7: updateInputOutputs
def updateInputOutputs(self):
"""
finds attributes on module with "input_" & "output_" prefix then populates dicts
"""
# Get input attrs
inputsAttrs = cmds.listAttr( self.container, st='input_*')
# Get output attrs
outputsAttrs = cmds.listAttr( self.container, st='output_*')
if inputsAttrs:
for attr in inputsAttrs:
# get attr key
key = Util.getSuffix(attr)
if key != "data":
# get connected obj
objs = Util.getConnectedObjects( (self.container + "." + attr) )
# store obj
self.inputs[key] = Util.getFirst(objs)
if outputsAttrs:
for attr in outputsAttrs:
# get attr key
key = Util.getSuffix(attr)
if key != "data":
# get connected obj
objs = Util.getConnectedObjects( (self.container + "." + attr) )
# store obj
self.outputs[key] = Util.getFirst(objs)
开发者ID:jwnwilson,项目名称:nw_rig,代码行数:29,代码来源:Module.py
示例8: importAssetCache
def importAssetCache(self, cacheXmlLt, cacheErrorCheck = False):
""" cacheXmlLt = "R:/data/cache/sq001/sh001/light/char/ben00c_ben/ben00c_ben.xml" """
if os.path.exists(cacheXmlLt):
cacheChannels = mc.cacheFile(fileName=cacheXmlLt,q=1,channelName=1)
cacheGeos = self.getCacheGeos()
cacheGeoDict, cacheChannelsTmp = {}, []
for chn in cacheChannels:
for geo in cacheGeos:
baseChn = utils.stripNames(utils.convertName(chn, "texture"))
baseGeo = utils.stripNames(utils.stripNames(geo, ":"), "|")
if baseChn in baseGeo:
cacheGeoDict[chn] = geo
cacheChannelsTmp.append(chn)
continue
else:
utils.msgWin("Error", "File does not exist : %s"%cacheXmlLt, self.silent)
return False
if cacheErrorCheck:
missedChannels = list(set(cacheChannels).difference(set(cacheGeoDict.keys())))
if len(missedChannels) > 0:
msg = "Cache geometry missing\n"
msg += "\n".join(missedChannels)
utils.msgWin("Error", msg, self.silent)
return missedChannels
else:
return False
for chNode in self.getCacheNodes():
mc.delete(chNode)
for chn in cacheGeoDict.keys():
deformShp = cacheGeoDict[chn]
try:
shpSwitch = mc.deformer(deformShp, type="historySwitch")
except:
continue
shpHist = mc.listHistory(deformShp, pdo=1)
if shpHist:
for hist in shpHist:
if mc.nodeType(hist) == "tweak":
dblList = mc.listAttr("%s.plist"%hist, m= 1)
fltList = mc.listAttr("%s.vlist"%hist, m= 1)
dbCon, flCon = False, False
if dblList:
if len(dblList) > 1: dbCon = True
if fltList:
if len(fltList) > 1: flCon = True
if not(dbCon or flCon):
mc.delete(hist)
break
conns = mc.listConnections("%s.ip[0].ig"%shpSwitch[0], p=1)
mc.connectAttr(conns[0], "%s.ug[0]"%shpSwitch[0])
mc.setAttr("%s.playFromCache"%shpSwitch[0], 1)
mc.getAttr("%s.op[0]"%shpSwitch[0], sl = 1)
mc.setAttr("%s.playFromCache"%shpSwitch[0], 0)
mc.disconnectAttr(conns[0], "%s.ug[0]"%shpSwitch[0])
switch = mc.rename(shpSwitch[0],'cacheSwitch#')
mc.setAttr(switch+'.ihi',0)
cacheNode = mc.cacheFile(f = cacheXmlLt, attachFile = True, ia = '%s.inp[0]'%switch, cnm = chn)
mc.connectAttr(cacheNode+".inRange", switch + '.playFromCache')
utils.msgWin("Message", "Cache loaded successfully for %s"%self.namespace, self.silent)
return True
开发者ID:sid2364,项目名称:Maya_Python,代码行数:60,代码来源:pipeClasses.py
示例9: attrReset
def attrReset( ):
'''
This function will reset the attributes on the selected objects in the scene.
'''
selected = cmds.ls(sl=True)
# selCB = cmds.channelBox( "mainChannelBox", q=True, sma=True)
for sel in selected:
# Gathering all the attributes from the object.
selCB = cmds.listAttr(sel, k=True)
# Duplicating list because removing from the list your are looping through causes problems.
newAttrs = selCB[:]
try:
[selCB.remove(x) for x in newAttrs if x in cmds.listAttr( selected , k=True, l=True )]
except TypeError:
print( "None of the attributes are locked.")
for attr in selCB:
attrName = "%s.%s" %(sel,attr)
print(attrName)
# Check to see if keyable
if( cmds.getAttr( attrName, k=True) ):
# Get default value
# cmds.attributeQuery( "sx", node="nurbsCircle1", listDefault=True )
attrDV = cmds.attributeQuery( attr, node=sel, listDefault=True)[0]
print( "Object: %s Setting to Default: %s" %(attrName, attrDV))
cmds.setAttr( attrName, attrDV )
开发者ID:creuter23,项目名称:fs-tech-artist,代码行数:30,代码来源:mecAttrReset.py
示例10: getattributes
def getattributes(self):
for key, nodes in self.oldNodes.iteritems():
if key == 'expression':
expression = True
else:
expression = False
for oldNode in nodes:
listAttr = cmds.listAttr(oldNode)
if listAttr:
self.attributes[nodes[oldNode]] = {}
for attr in listAttr:
try:
self.attributes[nodes[oldNode]].update({attr: {'value': cmds.getAttr(oldNode + '.' + attr)}})
self.attributes[nodes[oldNode]][attr].update({'type': cmds.getAttr(oldNode + '.' + attr, type=True)})
if expression and attr == 'expression':
self.expressions.update({nodes[oldNode]: self.attributes[nodes[oldNode]][attr]['value']})
except RuntimeError as e:
pass
except ValueError as e:
pass
listAttrCustom = cmds.listAttr(oldNode, userDefined=True)
if listAttrCustom:
self.newAttributes[nodes[oldNode]] = {}
for attr in listAttrCustom:
try:
self.newAttributes[nodes[oldNode]].update({attr: {'type': cmds.getAttr(oldNode + '.' + attr, type=True)}})
if cmds.attributeQuery(attr, node=oldNode, minExists=True):
self.newAttributes[nodes[oldNode]][attr].update({'min': cmds.attributeQuery(attr, node=oldNode, min=True)})
if cmds.attributeQuery(attr, node=oldNode, maxExists=True):
self.newAttributes[nodes[oldNode]][attr].update({'max': cmds.attributeQuery(attr, node=oldNode, max=True)})
except RuntimeError as e:
pass
except ValueError as e:
pass
开发者ID:Regnareb,项目名称:Maya,代码行数:35,代码来源:autorig.py
示例11: copyAttribute
def copyAttribute( firstAttr, second ):
first, attr = firstAttr.split( '.' )
keyAttrs = cmds.listAttr( firstAttr, k=1 )
cbAttrs = cmds.listAttr( firstAttr, k=1 )
if not cmds.attributeQuery( attr, node=second, ex=1 ):
attrType = cmds.attributeQuery( attr, node=first, at=1 )
if attrType == 'enum':
enumList = cmds.attributeQuery( attr, node=first, le=1 )
cmds.addAttr( second, ln=attr, at=attrType, en= ':'.join( enumList ) + ':' )
else:
minValue = None
maxValue = None
if cmds.attributeQuery( attr, node=first, mne=1 ):
minValue = cmds.attributeQuery( attr, node=first, min=1 )[0]
if cmds.attributeQuery( attr, node=first, mxe=1 ):
maxValue = cmds.attributeQuery( attr, node=first, max=1 )[0]
if minValue != None and maxValue == None:
cmds.addAttr( second, ln=attr, at=attrType, min=minValue )
elif minValue == None and maxValue != None :
cmds.addAttr( second, ln=attr, at=attrType, max=maxValue )
elif minValue != None and maxValue != None :
cmds.addAttr( second, ln=attr, at=attrType, min=minValue, max=maxValue )
else:
cmds.addAttr( second, ln=attr, at=attrType )
if attr in keyAttrs:
cmds.setAttr( second+'.'+attr, e=1, k=1 )
elif attr in cbAttrs:
cmds.setAttr( second+'.'+attr, e=1, cb=1 )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:33,代码来源:sgRigConnection.py
示例12: userAttrCheck
def userAttrCheck(objList=[], includeShapes=False):
"""
Return a list of user defined attributes for a specified list of nodes (and shapes).
@param objList: List of objects to check for user defined attributes.
@type objList: list
@param includeShapes: Also check shapes for user defined attributes.
@type includeShapes: bool
"""
# Initialize Return List
result = []
# Check objList
if not objList: objList = cmds.ls()
# For each node
for obj in objList:
userAttrs = cmds.listAttr(obj, ud=True)
if not userAttrs: userAttrs = []
for attr in userAttrs:
result.append(obj + '.' + attr)
# Check Shapes
if includeShapes:
shapes = cmds.listRelatives(obj, s=True)
if not shapes: shapes = []
for shape in shapes:
userAttrs = cmds.listAttr(shape, ud=True)
if not userAttrs: userAttrs = []
for attr in userAttrs:
result.append(shape + '.' + attr)
# Return Result
return result
开发者ID:bennymuller,项目名称:glTools,代码行数:35,代码来源:cleanup.py
示例13: writeCtrlAttr
def writeCtrlAttr( ctrls = [] , fn = '' ) :
fid = open( fn , 'w' )
ctrlDct = {}
for ctrl in ctrls :
currCtrl = pc.Dag( ctrl )
currShape = pc.Dag( currCtrl.shape )
for each in ( currCtrl , currShape ) :
if mc.objExists( each ) :
attrs = mc.listAttr( each , ud=True )
keyableAttrs = mc.listAttr( each , k=True )
lockAttrs = mc.listAttr( each , l=True )
if attrs :
for attr in attrs :
currCtrlAttr = '%s.%s' % ( each , attr )
ctrlDct[ currCtrlAttr ] = [ False , False ]
if lockAttrs and ( attr in lockAttrs ) :
ctrlDct[ currCtrlAttr ][0] = True
if keyableAttrs and ( attr in keyableAttrs ) :
ctrlDct[ currCtrlAttr ][1] = True
pickle.dump( ctrlDct , fid )
fid.close()
开发者ID:myCodeTD,项目名称:pkmel,代码行数:30,代码来源:ctrlAttrTools.py
示例14: listNodeConnections
def listNodeConnections(*args,**keywords):
s=True
d=True
sn=False
sel=[]
if len(args)==0:
sel=mc.ls(sl=True)
for a in args:
if isIterable(a):
sel.extend(a)
else:
sel.append(a)
for k in keywords:
if k=='s' or k=='source':
s=keywords[k]
if k=='d' or k=='destination':
d=keywords[k]
if k=='sn' or k=='shortName':
sn=keywords[k]
elif k in locals():
exec(k+'=keywords[k]')
connections=[]
for conn in removeDuplicates(mc.listConnections(sel[0],s=s,d=d,p=True)):
if len(sel)==1 or mc.ls(conn,o=True)[0]==sel[1]:
if mc.connectionInfo(conn,isSource=True):
for dfs in mc.connectionInfo(conn,dfs=True):
if mc.ls(dfs,o=True)[0]==sel[0]:
if sn:
connections.append\
(
[
mc.ls(conn,o=True)[0]+'.'+mc.listAttr(conn,sn=True)[0],
mc.ls(dfs,o=True)[0]+'.'+mc.listAttr(dfs,sn=True)[0]
]
)
else:
connections.append([conn,dfs])
if mc.connectionInfo(conn,id=True):
sfd=mc.connectionInfo(conn,sfd=True)
if mc.ls(sfd,o=True)[0]==sel[0]:
if sn:
connections.append\
(
[
mc.ls(sfd,o=True)[0]+'.'+mc.listAttr(sfd,sn=True)[0],
mc.ls(conn,o=True)[0]+'.'+mc.listAttr(conn,sn=True)[0]
]
)
else:
connections.append([sfd,conn])
return removeDuplicates(connections)
开发者ID:jonntd,项目名称:zentools,代码行数:59,代码来源:listNodeConnections.py
示例15: addObjectID
def addObjectID():
'''
add object id to selected objects. check for existing object ID and add new one if there are existing.
'''
nodeList = cmds.ls(selection = True, dag=True, lf=True, type = 'mesh') # find shape nodes of current selection
allNodes = cmds.ls(type = 'mesh') # look for meshes only in the scene
existingIDs = [0]
for node in allNodes: # go through and check for existing object IDs here
attrList = cmds.listAttr(node)
if 'vrayObjectID' in attrList:
existingIDs.append (cmds.getAttr ('%s.vrayObjectID' % node))
newObjectID = 1
existingIDs.sort() # this is just for cleanliness. not required.
for id in range(max(existingIDs)+2): # look through the list and let's find an unused number if that exists we need to go one beyond the current values so we can add it if needed
if id not in existingIDs:
newObjectID = id
existingIDs.append(newObjectID)
break
for node in nodeList:
attrList = cmds.listAttr(node)
if 'vrayObjectID' not in attrList:
print newObjectID
mel.eval ('vray addAttributesFromGroup %s vray_objectID 1' % node)
cmds.setAttr('%s.vrayObjectID' % node ,newObjectID)
renderElements = cmds.ls (type = 'VRayRenderElement')
addedID = False # clear the slate here
attrsToSearch = ['vray_redid_multimatte','vray_greenid_multimatte','vray_blueid_multimatte'] # just looking for these attrs
multiMatteElements = [] # nice and tidy here
for element in renderElements: #go through and find multi matte elements and add them to our list
if cmds.getAttr('%s.vrayClassType' % element) == 'MultiMatteElement':
multiMatteElements.append(element)
if len(multiMatteElements) < int(math.modf((newObjectID+2)/3)[1]) : # check amount of multi matte elements against how many we can fit in a render element
newMMate = mel.eval('vrayAddRenderElement MultiMatteElement') # add the element
cmds.setAttr('%s.vray_considerforaa_multimatte' % newMMate, 1) #make sure it has AA on it...
multiMatteElements.append(newMMate)
for element in multiMatteElements: # go through the multimatte list
for multimatte in attrsToSearch: # we are looking only through the id attributes
if cmds.getAttr('%s.%s' % (element, multimatte)) == newObjectID : # if we find the ID already just try to skip the rest of the testing
addedID = True
if cmds.getAttr('%s.%s' % (element, multimatte)) == 0 and addedID == False : # didn't find anything eh? good. we add the id to the multimatte.
cmds.setAttr('%s.%s' % (element, multimatte), newObjectID)
addedID = True
开发者ID:AntiCG,项目名称:vfxpipe,代码行数:58,代码来源:addObjectID.py
示例16: _syncUI
def _syncUI(self):
# Since _syncUI is called in response to events that invalidate/clear
# the selections in the views, disable the buttons until something is
# selected again.
self.removeExportedAttrButton.setEnabled(False)
self.addExportedAttrButton.setEnabled(False)
selectedNodeNames = cmds.ls(selection=True, long=True)
if not selectedNodeNames:
self.addAttrsModel.setStringList([])
self.exportedAttrsModel.exportedAttributes = []
self.exportedAttrsView.resizeColumnsToContents()
return
# Collect the export attributes common to all selected nodes. If the
# same attribute is configured differently on multiple objects (e.g.
# different usdAttrName), then do not include that attribute.
allExportedAttributeNames = set()
commonExportedAttributeNames = set()
commonExportedAttrs = {}
for exportedAttr in ExportedAttribute.GetExportedAttributesFromNode(selectedNodeNames[0]):
mayaAttrName = exportedAttr.mayaAttrName
allExportedAttributeNames.add(mayaAttrName)
commonExportedAttributeNames.add(mayaAttrName)
commonExportedAttrs[mayaAttrName] = exportedAttr
for selectedNodeName in selectedNodeNames[1:]:
exportedAttrNames = set()
for exportedAttr in ExportedAttribute.GetExportedAttributesFromNode(selectedNodeName):
mayaAttrName = exportedAttr.mayaAttrName
allExportedAttributeNames.add(mayaAttrName)
if (mayaAttrName in commonExportedAttrs and
commonExportedAttrs[mayaAttrName] == exportedAttr):
exportedAttrNames.add(mayaAttrName)
commonExportedAttributeNames.intersection_update(exportedAttrNames)
commonExportedAttrs = [commonExportedAttrs[x] for x in commonExportedAttributeNames]
commonExportedAttrs.sort(key=lambda x: x.mayaAttrName)
self.exportedAttrsModel.exportedAttributes = commonExportedAttrs
self.exportedAttrsView.resizeColumnsToContents()
# Collect the attributes common to all selected nodes.
cmdOptions = {'read': True}
if self.userDefinedCheckBox.isChecked():
cmdOptions['userDefined'] = True
commonAttrNames = set(cmds.listAttr(selectedNodeNames[0], **cmdOptions) or [])
for selectedNodeName in selectedNodeNames[1:]:
attrNames = set(cmds.listAttr(selectedNodeName, **cmdOptions) or [])
commonAttrNames.intersection_update(attrNames)
# Subtract out reserved attribute names and attributes already being
# exported by ANY node.
commonAttrNames -= RESERVED_ATTRIBUTES
commonAttrNames -= allExportedAttributeNames
self.addAttrsModel.setStringList(sorted(list(commonAttrNames)))
开发者ID:400dama,项目名称:USD,代码行数:57,代码来源:userExportedAttributesUI.py
示例17: constrainAttributeNaming
def constrainAttributeNaming( cnstrs ) :
for cnstr in cnstrs :
cnstrType = mc.nodeType( cnstr )
dummyAttr = 'targetTranslate'
if cnstrType == 'parentConstraint' :
dummyAttr = 'target[000].targetTranslate'
elif cnstrType == 'pointConstraint' :
dummyAttr = 'target[000].targetTranslate'
elif cnstrType == 'orientConstraint' :
dummyAttr = 'target[000].targetRotate'
elif cnstrType == 'scaleConstraint' :
dummyAttr = 'target[000].targetScale'
elif cnstrType == 'aimConstraint' :
dummyAttr = 'target[000].targetTranslate'
elif cnstrType == 'poleVectorConstraint' :
dummyAttr = 'constraintRotatePivot'
if mc.listAttr( cnstr , ud=True ) :
udAttrs = sorted( mc.listAttr( cnstr , ud=True ) )
for ix in range( len( udAttrs ) ) :
currNodeAttrName = '%s.%s' % ( cnstr , udAttrs[ix] )
outAttr = dummyAttr.replace( '000' , str( ix ) )
target = mc.listConnections( '%s.%s' % ( cnstr , outAttr ) , s=True )[0]
newAttrName = '%sW%s' % ( target , str( ix ) )
print '%s -- %s' % ( udAttrs[ix] , newAttrName )
lock = False
if mc.getAttr( currNodeAttrName , l=True ) :
lock = True
mc.setAttr( currNodeAttrName , l=False )
if not udAttrs[ix] == newAttrName :
mc.renameAttr( currNodeAttrName , newAttrName )
if lock :
mc.setAttr( '%s.%s' % ( cnstr , newAttrName ) , l=True )
开发者ID:myCodeTD,项目名称:pkmel,代码行数:57,代码来源:rigTools.py
示例18: __cleanup
def __cleanup(self):
if self._lockGroups:
attr = ['shearXY', 'shearXZ', 'shearYZ', 'rotateOrder', 'rotateAxisX',
'rotateAxisY', 'rotateAxisZ', 'inheritsTransform']
if self.offsets:
#--- lock offsets
for i in self.offsets:
attrs = cmds.listAttr(i, keyable=True)
if attrs:
for j in attr:
attrs.append(j)
for a in attrs:
cmds.setAttr(i + '.' + a, lock=True, keyable=False)
attribute.lock_n_hide(i, ['t', 'r'], True)
#--- lock group
attrs = cmds.listAttr(self.group, keyable=True)
for i in attr:
attrs.append(i)
if attrs:
for a in attrs:
cmds.setAttr(self.group + '.' + a, lock=True, keyable=False)
#--- lock transform
attrs = ['sx', 'sy', 'sz', 'v']
for i in attr:
attrs.append(i)
for a in attrs:
cmds.setAttr(self.transform + '.' + a, lock=True, keyable=False)
cmds.setAttr(self.shape + '.ihi', 0)
#--- lock shape
attrs = cmds.listAttr(self.shape, channelBox=True)
if attrs:
for a in attrs:
cmds.setAttr(self.shape + '.' + a, lock=True, keyable=False)
cmds.setAttr(self.shape + '.' + a, channelBox=False)
cmds.setAttr(self.shape + '.ihi', 0)
if self._withGimbal:
#--- lock gimbal
attrs = ['sx', 'sy', 'sz', 'v']
for i in attr:
attrs.append(i)
for a in attrs:
cmds.setAttr(self.gimbal + '.' + a, lock=True, keyable=False)
cmds.setAttr(self._gshape + '.ihi', 0)
#--- lock gimbal shape
attrs = cmds.listAttr(self._gshape, channelBox=True)
if attrs:
for a in attrs:
cmds.setAttr(self._gshape + '.' + a, lock=True, keyable=False)
cmds.setAttr(self._gshape + '.' + a, channelBox=False)
cmds.setAttr(self._gshape + '.ihi', 0)
cmds.select(clear=True)
开发者ID:jonntd,项目名称:Public,代码行数:56,代码来源:controls.py
示例19: isolate
def isolate(option):
sel = mc.ls(sl=True)
if not sel:
return
graphVis = mc.selectionConnection('graphEditor1FromOutliner', query=True, obj=True)
channels = list()
wildCard = str()
alreadyIsolated = True
if graphVis:
for c in graphVis:
if not '.' in c and mc.objExists(c):
attrs = mc.listAttr(c, keyable=True, unlocked=True)
if attrs:
channels.extend([c+'.'+a for a in attrs])
else:
attr = c.split('.')[-1]
if attr.startswith(option):
channels.append(c)
if not wildCard:
wildCard = option+'*'
elif attr.endswith(option):
channels.append(c)
if not wildCard:
wildCard = '*'+option
elif attr == option:
channels.append(c)
if not wildCard:
wildCard = option
else:
#found a curve that is outside our search parameters
alreadyIsolated = False
if channels and alreadyIsolated:
#if the option is already the only thing being displayed, then show everything that matches the option
for obj in sel:
attrs = mc.listAttr(obj, keyable=True, unlocked=True, string=wildCard)
if attrs:
channels.extend([obj+'.'+a for a in attrs])
if not channels:
for obj in sel:
attrs = mc.listAttr(obj, keyable=True, unlocked=True)
for a in attrs:
if a==option or a.startswith(option) or a.endswith(option):
channels.append(obj+'.'+a)
clear()
for c in channels:
mc.selectionConnection('graphEditor1FromOutliner', edit=True, select=c)
开发者ID:Italic-,项目名称:maya-prefs,代码行数:56,代码来源:ml_graphEditorMask.py
示例20: complete_node_with_attr
def complete_node_with_attr( node, attr ):
#print "noe_with_attr", node, attr
long_attrs = cmds.listAttr( node )
short_attrs = cmds.listAttr( node , shortNames=1)
# if node is a plug ( 'persp.t' ), the first result will be the passed plug
if '.' in node:
attrs = long_attrs[1:] + short_attrs[1:]
else:
attrs = long_attrs + short_attrs
return [ u'%s.%s' % ( node, a) for a in attrs if a.startswith(attr) ]
开发者ID:SarielD,项目名称:pymel,代码行数:10,代码来源:ipymel.py
注:本文中的maya.cmds.listAttr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论