Python maya.cmds.getAttr() Examples
The following are 30
code examples of maya.cmds.getAttr().
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: maya_warpper.py From pipeline with MIT License | 8 votes |
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)
Example #3
Source File: capture.py From pyblish-bumpybox with GNU Lesser General Public License v3.0 | 7 votes |
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 }
Example #4
Source File: curve.py From maya-spline-ik with GNU General Public License v3.0 | 6 votes |
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 # ----------------------------------------------------------------------------
Example #5
Source File: transform.py From SISideBar with MIT License | 6 votes |
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()
Example #6
Source File: dpControls.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
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
Example #7
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 #8
Source File: dpUtils.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
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
Example #9
Source File: anim_utils.py From mgear_core with MIT License | 6 votes |
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
Example #10
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 #11
Source File: dpAutoRig.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
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
Example #12
Source File: capture.py From pyblish-bumpybox with GNU Lesser General Public License v3.0 | 6 votes |
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)
Example #13
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 #14
Source File: transform.py From SISideBar with MIT License | 5 votes |
def check_attr_locked(node): attr_lock_flag_list = [[None, None, None], [None, None, None], [None, None, None]] for i,attrs in enumerate(all_attr_list): for j, attr in enumerate(attrs): attr_lock_flag_list[i][j] = cmds.getAttr(node+attr, lock=True) cmds.setAttr(node+attr, lock=False) return attr_lock_flag_list
Example #15
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def BT_Setup(set = None): if not set: return False transforms = cmds.listConnections(set +'.dagSetMembers') if not transforms: return False if not cmds.attributeQuery('Blend_Node', n = set, ex = True): cmds.addAttr(set, ln = 'Blend_Node', k = False, h = True, dt = 'string') else: return False btNode = cmds.createNode("BlendTransforms") cmds.setAttr(set +'.Blend_Node', btNode, type = "string") for i in range(0, len(transforms)): baseMatrix = cmds.xform(transforms[i], q = True, m = True) baseScale = cmds.getAttr(transforms[i] +'.scale')[0] baseRotOffset = [0.0, 0.0, 0.0] if cmds.objectType(transforms[i], isType = 'joint'): baseRotOffset = cmds.getAttr(transforms[i] +'.jointOrient')[0] btAttr = 'transforms[' +str(i) +'].baseMatrix' btScaleAttr = 'transforms[' +str(i) +'].baseScale' btRotOffsetAttr = 'transforms[' +str(i) +'].baseRotOffset' BT_MatrixValuesToNode(values = baseMatrix, node = btNode, attr = btAttr) BT_Double3ValuesToNode(values = baseScale, node = btNode, attr = btScaleAttr) BT_Double3ValuesToNode(values = baseRotOffset, node = btNode, attr = btRotOffsetAttr) BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i]) return True
Example #16
Source File: capture.py From pyblish-bumpybox with GNU Lesser General Public License v3.0 | 5 votes |
def _maintain_camera(panel, camera): state = {} if not _in_standalone(): cmds.lookThru(panel, camera) else: state = dict((camera, cmds.getAttr(camera + ".rnd")) for camera in cmds.ls(type="camera")) cmds.setAttr(camera + ".rnd", True) try: yield finally: for camera, renderable in state.iteritems(): cmds.setAttr(camera + ".rnd", renderable)
Example #17
Source File: maya_warpper.py From pipeline with MIT License | 5 votes |
def snapshot(path = None, width = 96, height = 96): current_image_format = cmds.getAttr("defaultRenderGlobals.imageFormat") cmds.setAttr("defaultRenderGlobals.imageFormat", 32) # *.png #path = "/Users/liorbenhorin/Library/Preferences/Autodesk/maya/2015-x64/scripts/pipeline/thumb.png" cmds.playblast(cf = path, fmt="image", frame = cmds.currentTime( query=True ), orn=False, wh = [width,height], p=100, v=False) cmds.setAttr("defaultRenderGlobals.imageFormat", current_image_format) if os.path.isfile(path): return path else: return False
Example #18
Source File: anim_utils.py From mgear_core with MIT License | 5 votes |
def getWorldMatrices(self, start, end, val_src_nodes): # type: (int, int, List[pm.nodetypes.Transform]) -> # List[List[pm.datatypes.Matrix]] """ returns matrice List[frame][controller number].""" res = [] for x in range(start, end + 1): tmp = [] for n in val_src_nodes: tmp.append(pm.getAttr(n + '.worldMatrix', time=x)) res.append(tmp) return res
Example #19
Source File: anim_utils.py From mgear_core with MIT License | 5 votes |
def get_host_from_node(control): """Returns the host control name from the given control Args: control (str): Rig control Returns: str: Host UI control name """ # get host control namespace = getNamespace(control).split("|")[-1] host = cmds.getAttr("{}.uiHost".format(control)) return "{}:{}".format(namespace, host)
Example #20
Source File: maya_warpper.py From pipeline with MIT License | 5 votes |
def scene_resolution(): return [cmds.getAttr("defaultResolution.width"),cmds.getAttr("defaultResolution.height")]
Example #21
Source File: AEsporeNodeTemplate.py From spore with MIT License | 5 votes |
def index_cc(self, typ): """ """ min_id = cmds.getAttr('{}.minId'.format(self._node)) max_id = cmds.getAttr('{}.maxId'.format(self._node)) if typ == 'min' and min_id > max_id: cmds.setAttr('{}.maxId'.format(self._node), min_id) elif typ == 'max' and max_id < min_id: cmds.setAttr('{}.minId'.format(self._node), max_id)
Example #22
Source File: AEsporeNodeTemplate.py From spore with MIT License | 5 votes |
def use_pressure_cc(self, node): """ use pen pressure change command is triggered when the "Use Pen Pressure" checkbox is toggled """ use_pressure = not cmds.getAttr('{}.usePressureMapping'.format(node)) self.dimControl(node, 'pressureMapping', use_pressure) self.dimControl(node, 'minPressure', use_pressure) self.dimControl(node, 'maxPressure', use_pressure) context_mode = cmds.getAttr('{}.contextMode'.format(node)) if context_mode in (2, 3, 4): # disable for mode 2,3,4 self.dimControl(node, 'pressureMapping', True) elif context_mode == 5: self.dimControl(node, 'minPressure', True) self.dimControl(node, 'maxPressure', True)
Example #23
Source File: AEsporeNodeTemplate.py From spore with MIT License | 5 votes |
def change_max_slope(self, node): min_slope = cmds.getAttr('{}.minSlope'.format(node)) max_slope = cmds.getAttr('{}.maxSlope'.format(node)) if min_slope > max_slope: cmds.setAttr('{}.minSlope'.format(node), max_slope)
Example #24
Source File: create.py From maya-spline-ik with GNU General Public License v3.0 | 5 votes |
def __createJoints(self): # variables joints = [] # clear selection cmds.select(clear=True) # create root joint root = cmds.joint(n="{0}_root_jnt".format(self.name)) cmds.setAttr("{0}.drawStyle".format(root), 2) # position root joint pos = cmds.getAttr("{0}.result.position".format(self.pointOnCurves[0])) cmds.setAttr("{0}.translate".format(root), *pos[0]) # create curve joints for i, _ in enumerate(self.pointOnCurves): cmds.select(root) jnt = cmds.joint(n="{0}_jnt_{1:03d}".format(self.name, i + 1)) #cmds.setAttr("{0}.displayLocalAxis".format(jnt), 1) cmds.setAttr("{0}.inheritsTransform".format(jnt), 0) cmds.setAttr("{0}.segmentScaleCompensate".format(jnt), 0) cmds.setAttr("{0}.radius".format(jnt), 0.1) joints.append(jnt) return root, joints # ------------------------------------------------------------------------
Example #25
Source File: AEsporeNodeTemplate.py From spore with MIT License | 5 votes |
def change_min_slope(self, node): min_slope = cmds.getAttr('{}.minSlope'.format(node)) max_slope = cmds.getAttr('{}.maxSlope'.format(node)) if min_slope > max_slope: cmds.setAttr('{}.maxSlope'.format(node), min_slope)
Example #26
Source File: AEsporeNodeTemplate.py From spore with MIT License | 5 votes |
def emit(self, *args): """ run the actual sample command and check if transforms are frozen """ # exit spore context since it looses track of points after sampling if cmds.currentCtx().startswith('spore'): cmds.setToolTo('selectSuperContext') in_mesh = node_utils.get_connected_in_mesh(self._node) transform = cmds.listRelatives(in_mesh, p=True, f=True)[0] if cmds.getAttr(transform + '.translateX') != 0\ or cmds.getAttr(transform + '.translateY') != 0\ or cmds.getAttr(transform + '.translateZ') != 0\ or cmds.getAttr(transform + '.rotateX') != 0\ or cmds.getAttr(transform + '.rotateY') != 0\ or cmds.getAttr(transform + '.rotateZ') != 0\ or cmds.getAttr(transform + '.scaleX') != 1\ or cmds.getAttr(transform + '.scaleY') != 1\ or cmds.getAttr(transform + '.scaleZ') != 1: msg = 'Feeze transformations to sample the geomety!' result = message_utils.IOHandler().confirm_dialog(msg, 'Freeze Transformations') if result: cmds.makeIdentity(transform, a=True, s=True, r=True, t=True, n=0) else: return cmds.setAttr('{}.emit'.format(self._node), 1) cmds.sporeSampleCmd() # ------------------------------------------------------------------------ # # clear button # ------------------------------------------------------------------------ #
Example #27
Source File: AEsporeNodeTemplate.py From spore with MIT License | 5 votes |
def update_brush_btn(self, attr): cmds.button('placeBtn', e=True, bgc=(0.366, 0.366, 0.366), c=pm.Callback(self.activateContext, 'place', attr, 0)) cmds.button('sprayBtn', e=True, bgc=(0.366, 0.366, 0.366), c=pm.Callback(self.activateContext, 'spray', attr, 1)) cmds.button('scaleBtn', e=True, bgc=(0.366, 0.366, 0.366), c=pm.Callback(self.activateContext, 'scale', attr, 2)) cmds.button('alignBtn', e=True, bgc=(0.366, 0.366, 0.366), c=pm.Callback(self.activateContext, 'align', attr, 3)) cmds.button('moveBtn', e=True, bgc=(0.366, 0.366, 0.366), c=pm.Callback(self.activateContext, 'move', attr, 4)) cmds.button('idBtn', e=True, bgc=(0.366, 0.366, 0.366), c=pm.Callback(self.activateContext, 'id', attr, 5)) cmds.button('removeBtn', e=True, bgc=(0.366, 0.366, 0.366), c=pm.Callback(self.activateContext, 'remove', attr, 6)) self._node = attr.split('.')[0] if cmds.currentCtx().startswith('spore'): ctx_mode = cmds.getAttr(attr) if ctx_mode == 0: cmds.button('placeBtn', e=True, bgc=(0.148, 0.148, 0.148)) elif ctx_mode == 1: cmds.button('sprayBtn', e=True, bgc=(0.148, 0.148, 0.148)) elif ctx_mode == 2: cmds.button('scaleBtn', e=True, bgc=(0.148, 0.148, 0.148)) elif ctx_mode == 3: cmds.button('alignBtn', e=True, bgc=(0.148, 0.148, 0.148)) elif ctx_mode == 4: cmds.button('moveBtn', e=True, bgc=(0.148, 0.148, 0.148)) elif ctx_mode == 5: cmds.button('idBtn', e=True, bgc=(0.148, 0.148, 0.148)) elif ctx_mode == 6: cmds.button('removeBtn', e=True, bgc=(0.148, 0.148, 0.148))
Example #28
Source File: AEsporeNodeTemplate.py From spore with MIT License | 5 votes |
def change_max_altitude(self, node): min_altitude = cmds.getAttr('{}.minAltitude'.format(node)) max_altitude = cmds.getAttr('{}.maxAltitude'.format(node)) if min_altitude > max_altitude: cmds.setAttr('{}.minAltitude'.format(node), max_altitude)
Example #29
Source File: AEsporeNodeTemplate.py From spore with MIT License | 5 votes |
def change_min_altitude(self, node): min_altitude = cmds.getAttr('{}.minAltitude'.format(node)) max_altitude = cmds.getAttr('{}.maxAltitude'.format(node)) if min_altitude > max_altitude: cmds.setAttr('{}.maxAltitude'.format(node), min_altitude)
Example #30
Source File: AEsporeNodeTemplate.py From spore with MIT License | 5 votes |
def emit_type_cc(self, node): """ """ self._node = node emit_type = cmds.getAttr('{}.emitType'.format(node)) if emit_type == 0: self.dimControl(node, 'numSamples', False) self.dimControl(node, 'cellSize', True) self.dimControl(node, 'minRadius', True) self.dimControl(node, 'minRadius2d', True) elif emit_type == 1: self.dimControl(node, 'numSamples', True) self.dimControl(node, 'cellSize', False) self.dimControl(node, 'minRadius', True) self.dimControl(node, 'minRadius2d', True) self.estimate_num_samples(node) elif emit_type == 2: self.dimControl(node, 'numSamples', True) self.dimControl(node, 'cellSize', True) self.dimControl(node, 'minRadius', False) self.dimControl(node, 'minRadius2d', True) self.estimate_num_samples(node) elif emit_type == 3: self.dimControl(node, 'numSamples', True) self.dimControl(node, 'cellSize', True) self.dimControl(node, 'minRadius', True) self.dimControl(node, 'minRadius2d', False)