本文整理汇总了Python中maya.cmds.deleteAttr函数的典型用法代码示例。如果您正苦于以下问题:Python deleteAttr函数的具体用法?Python deleteAttr怎么用?Python deleteAttr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deleteAttr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delmesh
def delmesh(nodename):
for attr in [nodename+"."+ext for ext in getnames()]:
try:
cmds.getAttr(attr)
cmds.deleteAttr(attr)
except:
pass
示例2: assetCheckAndTag
def assetCheckAndTag(type = '', customTag = False):
"""
Look for root level groups that have meshes as children and add a a type flag to it with the type as its value
@param type: The type of asset, eg PROP, BLD, CHAR
@type type: String
@param customTag: If you want to use a custom tag that differs from the type name.
@type customTag: String
"""
for grp in cmds.ls(assemblies = True, long = True):
if cmds.ls(grp, dag = True, type = "mesh"):
if '|ROOT_ARCHIVES_DNT_%s' % configCONST.GROUP_SUFFIX not in grp and '|CORE_ARCHIVES_%s' % configCONST.GROUP_SUFFIX not in grp:
if not grp.endswith('_%s' % configCONST.GROUP_SUFFIX):
return False
if configCONST.INSIST_PREFIX_IN_ROOT:
if type not in grp:
raise TankError("ROOT NODE MISSING PREFIX \"%s" % type)
return -1
if '_%s' % configCONST.GROUP_SUFFIX in grp:
if cmds.objExists('%s.type' % grp):
cmds.deleteAttr('%s.type' % grp)
try:
cmds.addAttr(grp, ln = 'type', dt = 'string')
except:
pass
if customTag:
cmds.setAttr('%s.type' % grp, customTag, type = 'string')
else:
cmds.setAttr('%s.type' % grp, type.lower(), type = 'string')
else:
raise TankError("This does not appear to be a valid %s asset" % type)
示例3: assetCheckAndTag
def assetCheckAndTag(type = '', customTag = False):
"""
Look for root level groups that have meshes as children and add a a type flag to it with the type as its value
@param type: The type of asset, eg PROP, BLD, CHAR
@type type: String
"""
for grp in cmds.ls(assemblies=True, long= True):
if cmds.ls(grp, dag=True, type="mesh"):
if '|ROOT_ARCHIVES_DNT_hrc' not in grp and '|CORE_ARCHIVES_hrc' not in grp:
debug(app = None, method = 'assetCheckAndTag', message = 'grp: %s' % grp, verbose = False)
if not grp.endswith('_hrc'):
return False
if type not in grp:
raise TankError("ROOT NODE MISSING PREFIX \"%s_\"\nPlease visit http://www.anim83d.com/bbb/dokuwiki/doku.php?id=bubblebathbay:pipeline:pipeline:modelling:namingconventions" % type)
if '_hrc' in grp and type in grp:
if cmds.objExists('%s.type' % grp):
cmds.deleteAttr('%s.type' % grp)
try:
cmds.addAttr(grp, ln = 'type', dt = 'string')
except:
pass
if customTag:
cmds.setAttr('%s.type' % grp, customTag, type = 'string')
else:
cmds.setAttr('%s.type' % grp, type.lower(), type = 'string')
else:
raise TankError("This does not appear to be a valid %s asset" % type)
示例4: updateOrigNamesFormat
def updateOrigNamesFormat(self,objectList=[]):
'''
Update a combined meshes origNames attribute to the newest format.
@param objectList: list of mesh objects to update origNames attribute on.
@type objectList: list
'''
# Confirm list
if type(objectList) == str:
objectList = [objectList]
# Iterate through object list
for obj in objectList:
# Check origNames attribute
if not mc.objExists(obj+'.origNames'):
raise Exception('Object '+obj+' does not have a "origNames" attribute!')
if mc.addAttr(obj+'.origNames',q=True,multi=True):
print(obj+'.origNames is already in the correct format.')
continue
# Extract original names list from old format
origNamesList = []
index = 0
while True:
if mc.objExists(obj+'.origNames.origNames_'+str(index)):
origNamesList.append(mc.getAttr(obj+'.origNames.origNames_'+str(index)))
index+=1
else: break
# Re-create the origNames attribute in the new format
mc.deleteAttr(obj+'.origNames')
mc.addAttr(obj,ln='origNames',dt='string',multi=True)
for i in range(len(origNamesList)):
mc.setAttr( obj+'.origNames['+str(i)+']', origNamesList[i], type='string')
示例5: on_remove
def on_remove( self, *a ):
for item in cmd.ls( sl=True ):
for attrName in listAttr( item, ud=True ):
if attrName.startswith( '_skeletonPart' ) or attrName.startswith( '_skeletonFinalize' ):
cmd.deleteAttr( '%s.%s' % (item, attrName) )
self.populate()
示例6: deleteColorAttr
def deleteColorAttr(self, nodes):
nodeList = nodes
# add attribute to selected meshes
for node in nodeList:
for i in range(1,100):
if mc.objExists(node + '.' + self.idColorAttr + str(i)):
mc.deleteAttr(node + '.' + self.idColorAttr + str(i))
示例7: removeCloneAttributes
def removeCloneAttributes():
import sgBModel_dag
targetAttrs = cmds.ls( '*.'+sgBModel_dag.cloneTargetAttrName )
for targetAttr in targetAttrs:
cmds.deleteAttr( targetAttr )
示例8: delete
def delete(self):
'''
Delete all dynamic nodes
'''
# check if mNode still exists
if self.mNode:
if cmds.objExists(self.mNode):
# nodes not to delete
startJoint = self.startJoint
endJoint = self.endJoint
joints = self.joints
# to store nodes to keep
nodes = []
for node in [startJoint, endJoint, joints]:
nodes.extend(node)
# get all the connections
connections = self.listConnections()
# delete all custom attributes - if any node connected to it is deleted the node is deleted
# so delete attributes first, then delete nodes to avoid runtime errors
attrs = cmds.listAttr(self.mNode, ud=True, u=True)
for attr in attrs:
cmds.deleteAttr(self.mNode + "." + attr)
# now lets delete the nodes
for conn in connections:
if conn not in nodes:
# check if node exists to avoid errors
if cmds.objExists(conn):
cmds.delete(conn)
# finally delete the mNode
cmds.delete(self.mNode)
示例9: fixResolution
def fixResolution():
log(app = None, method = 'fixResolution', message = 'Fixing Resolutions now...', printToLog = False, verbose = configCONST.DEBUGGING)
allLambert = cmds.ls(type = 'lambert')
for eachLambert in allLambert:
log(app = None, method = 'fixResolution', message = 'Processing: %s now...' % eachLambert, printToLog = False, verbose = configCONST.DEBUGGING)
if cmds.ls('%s.message' % eachLambert):
matInfo = findMaterialInfo('%s.message' % eachLambert)
log(app = None, method = 'fixResolution', message = 'matInfo: %s' % matInfo, printToLog = False, verbose = configCONST.DEBUGGING)
if matInfo:
texture = ''
try:
texture = cmds.listConnections("%s.texture[0]" % matInfo)[0]
except TypeError:
pass
if texture:
try:
resolution = cmds.listAttr(texture, string = 'resolution')
except ValueError:
pass
if resolution:
cmds.deleteAttr(texture, at = 'resolution')
disconnectTextureInfo(matInfo)
cmds.addAttr(texture, ln = "resolution", at = 'long', dv = 32)
cmds.connectAttr("%s.message" % texture, "%s.texture[0]" % matInfo)
cmds.setAttr("%s.resolution" % texture, 256)
else:
cmds.addAttr(texture, ln = "resolution", at = 'long', dv = 32)
cmds.setAttr("%s.resolution" % texture, 256)
示例10: _WriteExportedAttributesToNode
def _WriteExportedAttributesToNode(nodeName, exportedAttrs):
"""
Given a Maya node name, this method records the given list of
ExportedAttribute objects in exportedAttrs in the Maya attribute. the
passed in list replaces any previous data.
NOTE: This method will likely only ever be called by the Remove and
Update methods above since multiple nodes may be selected and only the
common attributes between them will be displayed.
"""
jsonDict = {}
for exportedAttr in exportedAttrs:
jsonDict.update(exportedAttr.GetJsonDict())
exportAttrExists = cmds.attributeQuery(EXPORTED_ATTRS_MAYA_ATTR_NAME,
node=nodeName, exists=True)
if not jsonDict:
if exportAttrExists:
# The export attribute exists but we'd be emptying it, so just
# remove the attribute instead.
cmds.deleteAttr('%s.%s' % (nodeName, EXPORTED_ATTRS_MAYA_ATTR_NAME))
return
if not exportAttrExists:
cmds.addAttr(nodeName, ln=EXPORTED_ATTRS_MAYA_ATTR_NAME, dt='string')
jsonString = json.dumps(jsonDict)
cmds.setAttr('%s.%s' % (nodeName, EXPORTED_ATTRS_MAYA_ATTR_NAME),
jsonString, type='string')
示例11: group
def group(joint,indexStr='A'):
'''
Create a joint buffer transform (joint).
@param joint: Joint to create buffer group for
@type joint: str
@param indexStr: Name index string
@type indexStr: str
'''
# Check joint
if not mc.objExists(joint):
raise Exception('Joint "'+joint+'" does not exist!')
# Get name prefix
prefix = glTools.utils.stringUtils.stripSuffix(joint)
# Create joint group
grp = mc.duplicate(joint,po=True,n=prefix+'Con'+indexStr+'_jnt')[0]
mc.parent(joint,grp)
# Delete user attrs
udAttrList = mc.listAttr(grp,ud=True)
if udAttrList:
for attr in udAttrList: mc.deleteAttr(grp+'.'+attr)
# Set display overrides
mc.setAttr(joint+'.overrideEnabled',1)
mc.setAttr(joint+'.overrideLevelOfDetail',0)
mc.setAttr(grp+'.overrideEnabled',1)
mc.setAttr(grp+'.overrideLevelOfDetail',0)
# Return result
return grp
示例12: deleteUserAttrs
def deleteUserAttrs(obj,attrList=[]):
'''
Delete user defined attrs from a specified object
@param obj: The source objects to copy the attributes from
@type obj: str
@param attrList: A list of attributes to delete. If empty, defaults to all.
@type attrList: list
'''
# Check object
if not mc.objExists(obj):
raise Exception('Object "'+obj+'" does not exist!!')
# Get attribute list
if not attrList: attrList = mc.listAttr(obj,ud=True)
if not attrList: attrList = []
# Delete attributes
for attr in attrList:
try:
mc.setAttr(obj+'.'+attr,l=False)
mc.deleteAttr(obj,at=attr)
except:
print('Problem removing attribute "'+obj+'.'+attr+'". Continuing onto next arttribute.')
# Return result
return attrList
示例13: rsReAtt
def rsReAtt():
l_oSels = rsObjList()
l_AttributeList = (cmds.textScrollList("rsAttributeScroll", query=True, allItems=True))
for s_Att in l_AttributeList:
s_orig = l_oSels[0] + "." + s_Att
i_LockState = cmds.getAttr(s_orig, lock=True)
if i_LockState:
cmds.setAttr(s_orig, lock=False)
l_paramDest = cmds.listConnections(s_orig, plugs=True, destination=True, source=True)
l_paramDestLock = []
if l_paramDest:
for z in range(len(l_paramDest)):
l_paramDestLock.append(cmds.getAttr(l_paramDest[z], lock=True))
if l_paramDestLock[z]:
cmds.setAttr(l_paramDest[z], lock=False)
cmds.deleteAttr(l_oSels[0], at=s_Att)
cmds.undo()
if l_paramDest:
for z in range(len(l_paramDest)):
l_paramDestLock.append(cmds.getAttr(l_paramDest[z], lock=True))
if l_paramDestLock[z]:
cmds.setAttr(l_paramDest[z], lock=True)
if i_LockState:
cmds.setAttr(s_orig, lock=True)
cmds.select(cl=True)
cmds.select(l_oSels[0], r=True)
return True
示例14: setAttr
def setAttr(self,target,intersectList=[],evalOrderList=[]):
'''
Store the calculated evaluation order list as a string array attribute to a specified control.
@param target: The maya node that will hold the evaluation order array attribute.
@type target: str
@param intersectList: Perform a list intersection between the calculated evaluation order with this list. If empty, no intersection is performed.
@type intersectList: list
@param evalOrderList: You can override the calculated evaluation order with a custom ordered list. If empty, use calculated evaluation order.
@type evalOrderList: list
'''
# Check object exists
if not mc.objExists(target):
raise UserInputError('Target object '+target+' does not exist!')
# Create attribute
if mc.objExists(target+'.'+self.attribute):
mc.deleteAttr(target,at=self.attribute)
self.addAttribute(target)
# Get calculated evaluation order list
if not evalOrderList: evalOrderList = self.hierarchy.generationList()
# Perform list intersection
if intersectList: evalOrderList = [i for i in evalOrderList if intersectList.count(i)]
# Set evaluation order array attribute
for i in range(len(evalOrderList)):
mc.setAttr(target+'.'+self.attribute+'['+str(i)+']',evalOrderList[i],type='string')
# Return evaluation order list
return evalOrderList
示例15: removeBindMarker
def removeBindMarker(ctrls=None, *args):
'''
remove the bind markers from nodes, these dictate what gets baked
'''
if not ctrls:
ctrls = cmds.ls(sl=True, l=True)
for ctr in ctrls:
cmds.deleteAttr('%s.%s' % (ctr, BAKE_MARKER))