Python maya.cmds.warning() Examples
The following are 30
code examples of maya.cmds.warning().
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: uExport.py From uExport with zlib License | 7 votes |
def msgConnect(attribFrom, attribTo, debug=0): # TODO needs a mode to dump all current connections (overwrite/force) objFrom, attFrom = attribFrom.split('.') objTo, attTo = attribTo.split('.') if debug: print 'msgConnect>>> Locals:', locals() if not attrExists(attribFrom): cmds.addAttr(objFrom, longName=attFrom, attributeType='message') if not attrExists(attribTo): cmds.addAttr(objTo, longName=attTo, attributeType='message') # check that both atts, if existing are msg atts for a in (attribTo, attribFrom): if cmds.getAttr(a, type=1) != 'message': cmds.warning('msgConnect: Attr, ' + a + ' is not a message attribute. CONNECTION ABORTED.') return False try: return cmds.connectAttr(attribFrom, attribTo, f=True) except Exception as e: print e return False
Example #2
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def loadSelectedSet(self): selection = BT_GetSelectedSet() if not selection: return False if not cmds.attributeQuery('Blend_Node', ex = True, n = selection): cmds.warning('Blend_Node attribute not found! This set might not be connected to a BlendTransforms node yet.') return False self.ui.poseList.clear() self.ui.setEdit.setText(selection) poses = BT_GetPosesFromSet(selection) if not poses: return False self.ui.poseList.addItems(poses) return True
Example #3
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def updatePose(self): uiSet = str(self.ui.setEdit.text()) ind = self.ui.poseList.currentRow() currentItem = self.ui.poseList.currentItem().text() if BT_IsSetupConnected(uiSet): cmds.warning('Disconnect setup first!') return False result = QtGui.QMessageBox.question(self, 'Update Pose', 'Really Update ' +str(currentItem) +' ?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if result != QtGui.QMessageBox.Yes: return False if not uiSet: return False if ind < 0: return False BT_AddPose(set = uiSet, index = ind) return True
Example #4
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def deletePose(self): uiSet = str(self.ui.setEdit.text()) currentItem = self.ui.poseList.currentItem().text() if not uiSet: return False if BT_IsSetupConnected(uiSet): cmds.warning('Disconnect setup first!') return False result = QtGui.QMessageBox.question(self, 'Delete Pose', 'Really Delete ' +str(currentItem) +' ?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if result != QtGui.QMessageBox.Yes: return False poseIndex = self.ui.poseList.currentRow() BT_DeletePose(set = uiSet, poseIndex = poseIndex) poses = BT_GetPosesFromSet(uiSet) self.ui.poseList.clear() self.ui.poseList.addItems(poses) return True
Example #5
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def loadSelectedSet(self): selection = BT_GetSelectedSet() if not selection: return False if not cmds.attributeQuery('Blend_Node', ex = True, n = selection): cmds.warning('Blend_Node attribute not found! This set might not be connected to a BlendTransforms node yet.') return False self.ui.poseList.clear() self.ui.setEdit.setText(selection) poses = BT_GetPosesFromSet(selection) if not poses: return False self.ui.poseList.addItems(poses) return True
Example #6
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def BT_DoSetup(): sets = cmds.ls(sl = True, type = 'objectSet') if len(sets) <= 0: cmds.warning("Select a set.") return False set = sets[0] unitResult = BT_SetUnits() if unitResult: QtGui.QMessageBox.warning(BT_GetMayaWindow(), "Blend Transforms", "Units set to centimetres.", "Okay") result = BT_Setup(set = set) if not result: QtGui.QMessageBox.warning(BT_GetMayaWindow(), "Blend Transforms", "Problem with setup. May already be connected.", "Okay") return False print('Success!') return True
Example #7
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def BT_ConnectSetup(set = None): if not set or not cmds.objExists(set): return False if BT_IsSetupConnected(set = set): cmds.warning('Setup already connected!') return False btNode = cmds.getAttr(set +'.Blend_Node') if not btNode or not cmds.objExists(btNode): return False transforms = cmds.listConnections(set +'.dagSetMembers') for i in range(0, len(transforms)): try: BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i]) except: pass mults = cmds.listConnections(btNode, d = True, type = 'multiplyDivide') if mults: cmds.delete(mults) return True
Example #8
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def deletePose(self): uiSet = str(self.ui.setEdit.text()) currentItem = self.ui.poseList.currentItem().text() if not uiSet: return False if BT_IsSetupConnected(uiSet): cmds.warning('Disconnect setup first!') return False result = QtGui.QMessageBox.question(self, 'Delete Pose', 'Really Delete ' +str(currentItem) +' ?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if result != QtGui.QMessageBox.Yes: return False poseIndex = self.ui.poseList.currentRow() BT_DeletePose(set = uiSet, poseIndex = poseIndex) poses = BT_GetPosesFromSet(uiSet) self.ui.poseList.clear() self.ui.poseList.addItems(poses) return True
Example #9
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def updatePose(self): uiSet = str(self.ui.setEdit.text()) ind = self.ui.poseList.currentRow() currentItem = self.ui.poseList.currentItem().text() if BT_IsSetupConnected(uiSet): cmds.warning('Disconnect setup first!') return False result = QtGui.QMessageBox.question(self, 'Update Pose', 'Really Update ' +str(currentItem) +' ?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if result != QtGui.QMessageBox.Yes: return False if not uiSet: return False if ind < 0: return False BT_AddPose(set = uiSet, index = ind) return True
Example #10
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def BT_ConnectSetup(set = None): if not set or not cmds.objExists(set): return False if BT_IsSetupConnected(set = set): cmds.warning('Setup already connected!') return False btNode = cmds.getAttr(set +'.Blend_Node') if not btNode or not cmds.objExists(btNode): return False transforms = cmds.listConnections(set +'.dagSetMembers') for i in range(0, len(transforms)): try: BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i]) except: pass mults = cmds.listConnections(btNode, d = True, type = 'multiplyDivide') if mults: cmds.delete(mults) return True
Example #11
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def BT_DoSetup(): sets = cmds.ls(sl = True, type = 'objectSet') if len(sets) <= 0: cmds.warning("Select a set.") return False set = sets[0] unitResult = BT_SetUnits() if unitResult: QtGui.QMessageBox.warning(BT_GetMayaWindow(), "Blend Transforms", "Units set to centimetres.", "Okay") result = BT_Setup(set = set) if not result: QtGui.QMessageBox.warning(BT_GetMayaWindow(), "Blend Transforms", "Problem with setup. May already be connected.", "Okay") return False print('Success!') return True
Example #12
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def deletePose(self): uiSet = str(self.ui.setEdit.text()) currentItem = self.ui.poseList.currentItem().text() if not uiSet: return False if BT_IsSetupConnected(uiSet): cmds.warning('Disconnect setup first!') return False result = QtGui.QMessageBox.question(self, 'Delete Pose', 'Really Delete ' +str(currentItem) +' ?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if result != QtGui.QMessageBox.Yes: return False poseIndex = self.ui.poseList.currentRow() BT_DeletePose(set = uiSet, poseIndex = poseIndex) poses = BT_GetPosesFromSet(uiSet) self.ui.poseList.clear() self.ui.poseList.addItems(poses) return True
Example #13
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def BT_ConnectSetup(set = None): if not set or not cmds.objExists(set): return False if BT_IsSetupConnected(set = set): cmds.warning('Setup already connected!') return False btNode = cmds.getAttr(set +'.Blend_Node') if not btNode or not cmds.objExists(btNode): return False transforms = cmds.listConnections(set +'.dagSetMembers') for i in range(0, len(transforms)): try: BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i]) except: pass mults = cmds.listConnections(btNode, d = True, type = 'multiplyDivide') if mults: cmds.delete(mults) return True
Example #14
Source File: commands.py From core with MIT License | 6 votes |
def reset_resolution(): project = io.find_one({"type": "project"}) try: resolution_width = project["data"].get( "resolutionWidth", # backwards compatibility project["data"].get("resolution_width", 1920) ) resolution_height = project["data"].get( "resolutionHeight", # backwards compatibility project["data"].get("resolution_height", 1080) ) except KeyError: cmds.warning("No resolution information found for %s" % project["name"]) return cmds.setAttr("defaultResolution.width", resolution_width) cmds.setAttr("defaultResolution.height", resolution_height)
Example #15
Source File: controllerLibrary.py From PythonForMayaSamples with GNU General Public License v3.0 | 6 votes |
def save(self): # We start off by getting the name in the text field name = self.saveNameField.text() # If the name is not given, then we will not continue and we'll warn the user # The strip method will remove empty characters from the string, so that if the user entered spaces, it won't be valid if not name.strip(): cmds.warning("You must give a name!") return # We use our library to save with the given name self.library.save(name) # Then we repopulate our UI with the new data self.populate() # And finally, lets remove the text in the name field so that they don't accidentally overwrite the file self.saveNameField.setText('')
Example #16
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def __init__( self, parent = BT_GetMayaWindow() ): super(BT_UIForm, self).__init__(parent) uicPath = BT_FindUIFile() if not uicPath: return None self.ui = None if BT_MayaVersionNumber < 2014: self.ui = uic.loadUi(uicPath, self) else: loader = QtUiTools.QUiLoader() self.ui = loader.load(uicPath, self) self.ui.loadSelectedButton.clicked.connect(self.loadSelectedSet) self.ui.connectButton.clicked.connect(self.connectSetup) self.ui.disconnectButton.clicked.connect(self.disconnectSetup) self.ui.setToBaseButton.clicked.connect(self.setToBasePose) self.ui.setToSelectedButton.clicked.connect(self.setToPose) self.ui.addPoseButton.clicked.connect(self.addPose) self.ui.deletePoseButton.clicked.connect(self.deletePose) self.ui.updateSelectedButton.clicked.connect(self.updatePose) unitResult = BT_SetUnits() if unitResult: QtGui.QMessageBox.warning(self, "Blend Transforms", "Units set to centimetres.", "Okay") self.ui.show()
Example #17
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def updatePose(self): uiSet = str(self.ui.setEdit.text()) ind = self.ui.poseList.currentRow() currentItem = self.ui.poseList.currentItem().text() if BT_IsSetupConnected(uiSet): cmds.warning('Disconnect setup first!') return False result = QtGui.QMessageBox.question(self, 'Update Pose', 'Really Update ' +str(currentItem) +' ?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if result != QtGui.QMessageBox.Yes: return False if not uiSet: return False if ind < 0: return False BT_AddPose(set = uiSet, index = ind) return True
Example #18
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def deletePose(self): uiSet = str(self.ui.setEdit.text()) currentItem = self.ui.poseList.currentItem().text() if not uiSet: return False if BT_IsSetupConnected(uiSet): cmds.warning('Disconnect setup first!') return False result = QtGui.QMessageBox.question(self, 'Delete Pose', 'Really Delete ' +str(currentItem) +' ?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if result != QtGui.QMessageBox.Yes: return False poseIndex = self.ui.poseList.currentRow() BT_DeletePose(set = uiSet, poseIndex = poseIndex) poses = BT_GetPosesFromSet(uiSet) self.ui.poseList.clear() self.ui.poseList.addItems(poses) return True
Example #19
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 6 votes |
def loadSelectedSet(self): selection = BT_GetSelectedSet() if not selection: return False if not cmds.attributeQuery('Blend_Node', ex = True, n = selection): cmds.warning('Blend_Node attribute not found! This set might not be connected to a BlendTransforms node yet.') return False self.ui.poseList.clear() self.ui.setEdit.setText(selection) poses = BT_GetPosesFromSet(selection) if not poses: return False self.ui.poseList.addItems(poses) return True
Example #20
Source File: util.py From core with MIT License | 5 votes |
def shape_from_element(element): """Return shape of given 'element' Supports components, meshes, and surfaces """ try: # Get either shape or transform, based on element-type node = cmds.ls(element, objectsOnly=True)[0] except: cmds.warning("Could not find node in %s" % element) return None if cmds.nodeType(node) == 'transform': try: return cmds.listRelatives(node, shapes=True)[0] except: cmds.warning("Could not find shape in %s" % element) return None else: return node
Example #21
Source File: uExport.py From uExport with zlib License | 5 votes |
def attrExists(attr): if '.' in attr: node, att = attr.split('.') return cmds.attributeQuery(att, node=node, ex=1) else: cmds.warning('attrExists: No attr passed in: ' + attr) return False
Example #22
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def BT_DisconnectSetup(set = None): if not set: return False if not BT_IsSetupConnected(set = set): cmds.warning('Setup already disconnected!') return False btNode = cmds.getAttr(set +'.Blend_Node') if not btNode or not cmds.objExists(btNode): return False numOutputs = cmds.getAttr(btNode +'.output', size = True) print numOutputs tempMult = None for i in range(0, numOutputs): conns = cmds.listConnections(btNode +'.output[' +str(i) +'].outputT', s = False, d = True) if conns: tempMult = cmds.createNode('multiplyDivide') cmds.disconnectAttr(btNode +'.output[' +str(i) +'].outputT', conns[0] +'.translate') cmds.connectAttr(btNode +'.output[' +str(i) +'].outputT', tempMult +'.input1') conns = cmds.listConnections(btNode +'.output[' +str(i) +'].outputR', s = False, d = True) if conns: tempMult = cmds.createNode('multiplyDivide') cmds.disconnectAttr(btNode +'.output[' +str(i) +'].outputR', conns[0] +'.rotate') cmds.connectAttr(btNode +'.output[' +str(i) +'].outputR', tempMult +'.input1') conns = cmds.listConnections(btNode +'.output[' +str(i) +'].outputS', s = False, d = True) if conns: tempMult = cmds.createNode('multiplyDivide') cmds.disconnectAttr(btNode +'.output[' +str(i) +'].outputS', conns[0] +'.scale') cmds.connectAttr(btNode +'.output[' +str(i) +'].outputS', tempMult +'.input1') cmds.select(cl = True) return True
Example #23
Source File: ml_colorControl.py From ml_tools with MIT License | 5 votes |
def colorSelected(self, *args): sel = mc.ls(sl=True) if not sel: mc.warning('Please make a selection') return hsv = self.getHSV(self.swatch_selected) for each in sel: colorShape(each, hsv=hsv)
Example #24
Source File: influence.py From maya-skinning-tools with GNU General Public License v3.0 | 5 votes |
def addInfluences(skinCluster, influences): """ Add influences to the skin cluster. Expects full path influences. Will try to reach the bind pose before attached the new influences to the skin cluster. :param str skinCluster: :param list influences: """ # get existing influences existing = cmds.skinCluster(skinCluster, query=True, influence=True) existing = cmds.ls(existing, l=True) # try restoring dag pose try: cmds.dagPose(existing, restore=True, g=True, bindPose=True) except: cmds.warning("Unable to reach dagPose!") # add influences for influence in influences: if influence not in existing: cmds.skinCluster( skinCluster, edit=True, addInfluence=influence, weight=0.0 )
Example #25
Source File: ml_colorControl.py From ml_tools with MIT License | 5 votes |
def setFromSelected(self, widget, *args): sel = mc.ls(sl=True) if not sel: mc.warning('Please make a selection') return if mc.getAttr('{}.overrideRGBColors'.format(sel[0])): color = mc.getAttr('{}.overrideColorRGB'.format(sel[0])) mc.colorSliderGrp(widget, edit=True, rgb=color[0]) else: mc.warning('Selected node is not in RGB color mode.')
Example #26
Source File: menu_loader.py From mGui with MIT License | 5 votes |
def checkbox(*_, **kwargs): cmds.warning("checkbox menu is %i" % int(kwargs['sender'].checkBox))
Example #27
Source File: runtimeCommands.py From mGui with MIT License | 5 votes |
def fire_callback(name, *args, **kwargs): """ Fire the runtimeEvent associated with <name> Print a warning if the event does not exist """ rc = RuntimeEvent.find(name) if rc: rc(*args, **kwargs) else: cmds.warning("no RuntimeEvent named %s. Create one using RuntimeEvent.create" % name)
Example #28
Source File: ctx.py From mGui with MIT License | 5 votes |
def fire(cls, name): target_event = cls.REGISTRY.get(name) if target_event: target_event() else: cmds.warning("no event for %s" % name)
Example #29
Source File: ml_colorControl.py From ml_tools with MIT License | 5 votes |
def colorSelectedRange(self, *args): sel = mc.ls(sl=True) if not sel: mc.warning('Please make a selection') return hsv1 = self.getHSV(self.swatch_range1) hsv2 = self.getHSV(self.swatch_range2) colorShapes(sel, hue1=hsv1[0], hue2=hsv2[0], saturation1=hsv1[1], saturation2=hsv2[1], value1=hsv1[2], value2=hsv2[2])
Example #30
Source File: BlendTransforms.py From BlendTransforms with The Unlicense | 5 votes |
def BT_DisconnectSetup(set = None): if not set: return False if not BT_IsSetupConnected(set = set): cmds.warning('Setup already disconnected!') return False btNode = cmds.getAttr(set +'.Blend_Node') if not btNode or not cmds.objExists(btNode): return False numOutputs = cmds.getAttr(btNode +'.output', size = True) print numOutputs tempMult = None for i in range(0, numOutputs): conns = cmds.listConnections(btNode +'.output[' +str(i) +'].outputT', s = False, d = True) if conns: tempMult = cmds.createNode('multiplyDivide') cmds.disconnectAttr(btNode +'.output[' +str(i) +'].outputT', conns[0] +'.translate') cmds.connectAttr(btNode +'.output[' +str(i) +'].outputT', tempMult +'.input1') conns = cmds.listConnections(btNode +'.output[' +str(i) +'].outputR', s = False, d = True) if conns: tempMult = cmds.createNode('multiplyDivide') cmds.disconnectAttr(btNode +'.output[' +str(i) +'].outputR', conns[0] +'.rotate') cmds.connectAttr(btNode +'.output[' +str(i) +'].outputR', tempMult +'.input1') conns = cmds.listConnections(btNode +'.output[' +str(i) +'].outputS', s = False, d = True) if conns: tempMult = cmds.createNode('multiplyDivide') cmds.disconnectAttr(btNode +'.output[' +str(i) +'].outputS', conns[0] +'.scale') cmds.connectAttr(btNode +'.output[' +str(i) +'].outputS', tempMult +'.input1') cmds.select(cl = True) return True