本文整理匯總了Python中maya.cmds.getAttr方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.getAttr方法的具體用法?Python cmds.getAttr怎麽用?Python cmds.getAttr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類maya.cmds
的用法示例。
在下文中一共展示了cmds.getAttr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: dpSelectAllCtrls
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
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"]+"\";")
示例2: playblast_snapshot
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
def playblast_snapshot(path = None,format = None, compression = None, hud = None, offscreen = None, range=None, scale = None):
current_image_format = cmds.getAttr("defaultRenderGlobals.imageFormat")
cmds.setAttr("defaultRenderGlobals.imageFormat", 32) # *.png
if range is None:
range = playback_selection_range()
print range
if range is None:
start = cmds.playbackOptions( q=True,min=True )
end = cmds.playbackOptions( q=True,max=True )
range = [start, end]
cmds.playblast(frame =int((range[0] + range[1])/2), cf = path, fmt="image", orn=hud, os=offscreen, wh = scene_resolution(), p=scale, v=False)
cmds.setAttr("defaultRenderGlobals.imageFormat", current_image_format)
示例3: parse_active_scene
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
def parse_active_scene():
"""Parse active scene for arguments for capture()
*Resolution taken from render settings.
"""
time_control = mel.eval("$gPlayBackSlider = $gPlayBackSlider")
return {
"start_frame": cmds.playbackOptions(minTime=True, query=True),
"end_frame": cmds.playbackOptions(maxTime=True, query=True),
"width": cmds.getAttr("defaultResolution.width"),
"height": cmds.getAttr("defaultResolution.height"),
"compression": cmds.optionVar(query="playblastCompression"),
"filename": (cmds.optionVar(query="playblastFile")
if cmds.optionVar(query="playblastSaveToFile") else None),
"format": cmds.optionVar(query="playblastFormat"),
"off_screen": (True if cmds.optionVar(query="playblastOffscreen")
else False),
"show_ornaments": (True if cmds.optionVar(query="playblastShowOrnaments")
else False),
"quality": cmds.optionVar(query="playblastQuality"),
"sound": cmds.timeControl(time_control, q=True, sound=True) or None
}
示例4: getBaseCtrl
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
def getBaseCtrl(self, sCtrlType, sAttrName, sCtrlName, fRadius, iDegree = 1, iSection = 8):
nCtrl = None
self.ctrlCreated = False
try:
nCtrl= self.masterGrp.getAttr(sAttrName)
except pymel.MayaAttributeError:
try:
nCtrl = pymel.PyNode(self.prefix + sCtrlName)
except pymel.MayaNodeError:
if (sCtrlName != (self.prefix + "Option_Ctrl")):
nCtrl = pymel.PyNode(self.ctrls.cvControl(sCtrlType, sCtrlName, r=fRadius, d=iDegree, dir="+X"))
else:
nCtrl = pymel.PyNode(self.ctrls.cvCharacter(sCtrlType, sCtrlName, r=(fRadius*0.2)))
self.ctrlCreated = True
finally:
#Since there is no connection between the master and the node found, create the connection
self.masterGrp.addAttr(sAttrName, attributeType='message')
nCtrl.message.connect(self.masterGrp.attr(sAttrName))
return nCtrl
示例5: verifyGuideModuleIntegrity
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
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
示例6: setSourceColorOverride
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
def setSourceColorOverride(self, sourceItem, destinationList, *args):
""" Check if there's a colorOverride for destination shapes
and try to set it to source shapes.
"""
colorList = []
for item in destinationList:
childShapeList = cmds.listRelatives(item, shapes=True, type="nurbsCurve", fullPath=True)
if childShapeList:
for childShape in childShapeList:
if cmds.getAttr(childShape+".overrideEnabled") == 1:
if cmds.getAttr(childShape+".overrideRGBColors") == 1:
colorList.append(cmds.getAttr(childShape+".overrideColorR"))
colorList.append(cmds.getAttr(childShape+".overrideColorG"))
colorList.append(cmds.getAttr(childShape+".overrideColorB"))
self.colorShape([sourceItem], colorList, True)
else:
colorList.append(cmds.getAttr(childShape+".overrideColor"))
self.colorShape([sourceItem], colorList[0])
break
示例7: findModuleLastNumber
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
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)
示例8: getOriginedFromDic
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
def getOriginedFromDic():
""" List all transforms in the scene, verify if there is an originedFrom string attribute and store it value in a dictionary.
Return a dictionary with originedFrom string as keys and transform nodes as values of these keys.
"""
originedFromDic = {}
allTransformList = cmds.ls(selection=False, type="transform")
if allTransformList:
for transform in allTransformList:
if cmds.objExists(transform+".originedFrom"):
tempOriginedFrom = cmds.getAttr(transform+".originedFrom")
if tempOriginedFrom:
if not ";" in tempOriginedFrom:
originedFromDic[tempOriginedFrom] = transform
else:
tempOriginedFromList = tempOriginedFrom.split(";")
for orignedFromString in tempOriginedFromList:
originedFromDic[orignedFromString] = transform
return originedFromDic
示例9: clearNodeGrp
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
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)
示例10: splitCurveToParametersByParameter
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
def splitCurveToParametersByParameter(curve, num):
"""
Get a list of parameters evenly spaced along a curve, based on the
division of its parameters. Ranges are normalizes to be between 0-1.
:param str curve:
:param int num:
:return: parameters
:rtype: list
"""
increment = 1.0 / (num - 1)
parameters = [i * increment for i in range(num)]
if cmds.getAttr("{0}.form".format(curve)) == 2:
parameters.insert(0, parameters[-1])
parameters.pop(-1)
return parameters
# ----------------------------------------------------------------------------
示例11: reset_actor
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
def reset_actor():
from . import sisidebar_sub
sel = cmds.ls(sl=True, l=True)
joints = cmds.ls(sl=True, l=True, type='joint')
if not joints:
joints = []
for s in sel:
if cmds.nodeType(s) == 'KTG_ModelRoot':
child_joints = cmds.ls(cmds.listRelatives(s, ad=True, f=True), l=True, type='joint')
if child_joints:
joints += child_joints
if not sel:
joints = cmds.ls(l=True, type='joint')
for j in joints:
con_info = cmds.connectionInfo(j+'.bindPose', dfs=True)
if not con_info:
continue
con_info = con_info[0]
bind_info = con_info.replace('world', 'xform')
pose = cmds.getAttr(bind_info)
cmds.xform(j, m=pose)
sisidebar_sub.get_matrix()
示例12: recordNodesMatrices
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
def recordNodesMatrices(nodes, desiredTime):
"""get the matrices of the nodes provided and return a dict of
node:matrix
Args:
nodes (list): of nodes
Returns:
dict: node:node matrix
"""
nodeToMat_dict = {}
for fk in nodes:
fk = pm.PyNode(fk)
nodeToMat_dict[fk.name()] = fk.getAttr("worldMatrix", time=desiredTime)
return nodeToMat_dict
示例13: _applied_camera_options
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
def _applied_camera_options(options, panel):
"""Context manager for applying `options` to `camera`"""
camera = cmds.modelPanel(panel, query=True, camera=True)
options = dict(CameraOptions, **(options or {}))
old_options = dict()
for opt in options.copy():
try:
old_options[opt] = cmds.getAttr(camera + "." + opt)
except:
sys.stderr.write("Could not get camera attribute "
"for capture: %s" % opt)
options.pop(opt)
for opt, value in options.iteritems():
cmds.setAttr(camera + "." + opt, value)
try:
yield
finally:
if old_options:
for opt, value in old_options.iteritems():
cmds.setAttr(camera + "." + opt, value)
示例14: is_locked
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
def is_locked():
"""Query whether current scene is locked"""
fname = cmds.file(query=True, sceneName=True)
basename = os.path.basename(fname)
if self._ignore_lock:
return False
try:
return cmds.getAttr("lock.basename") == basename
except ValueError:
return False
示例15: read
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getAttr [as 別名]
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