def setWidgetValues(self, optionVarDict): '''Set the Option Dialog widget values from the supplied dict ''' # REVISIT: There are some nuances with setting the values depending # on the widget type and optionVar typecasting # # LIMITATION: Only supporting 1 value per widget # # List the value1=<val> widgets value1Widgets = ( maya.cmds.checkBoxGrp, maya.cmds.floatFieldGrp, ) for optionVarDictKey,(widgetClass,widget) in self.optionVarToWidgetDict.iteritems(): widgetValue = optionVarDict[optionVarDictKey] try: if widgetClass in value1Widgets and not isinstance(widgetValue, list): widgetClass(widget, edit=True, value1=widgetValue) elif widgetClass == maya.cmds.optionMenuGrp: try: widgetClass(widget, edit=True, value=self.optionMenuGrp_enumToLabel[optionVarDictKey][widgetValue]) except RuntimeError,e: logger.error("self.optionMenuGrp_enumToLabel['%s']=%s Value=%s"%(optionVarDictKey,self.optionMenuGrp_enumToLabel[optionVarDictKey],widgetValue)) raise elif widgetClass == maya.cmds.floatFieldGrp and isinstance(widgetValue, list): # always send list of 4 floats to this widgetValue4 = [0,0,0,0] for i in range(len(widgetValue)): widgetValue4[i] = widgetValue[i] widgetClass(widget, edit=True, value=widgetValue4) elif widgetClass == maya.cmds.textFieldGrp: widgetClass( widget, edit=True, text=widgetValue )
def _reconnectBulletShapes(): """ When a scene is pasted, the pasted Bullet shapes will not be connected to the solver, so we connect them in this method. """ global bulletDagPaths try: existingSolverShape \ = mayabullet.BulletUtils \ .getSolver(bCreateIfMissing=False, \ bCheckForDuplicates=False) except: # if we don't actually need to use the solver, then this error # is harmless and should be ignored. existingSolverShape = None for bulletDagPath in bulletDagPaths: bulletShape = bulletDagPath.fullPathName() if existingSolverShape is None: # if we get to the point of actually trying to use the # solver, and it's not present, then an error has # occurred. logger.error(maya.stringTable['y_MayaUtils.kMissingSolver2']) return mayabullet.BulletUtils.connectToSolver(bulletShape, existingSolverShape) bulletDagPaths = []
def _getNodesToVisit(rootJointName): """ Returns a list of nodes for traversal. If the rootJointName is None, uses the current selection. """ # figure out where the traversal will start if (rootJointName is None): nodesToVisit = maya.cmds.ls(sl=True, long=True, type='joint') else: try: assert (_isJoint(rootJointName)) except: logger.error(maya.stringTable['y_Ragdoll.kUnableStartJoint'] % rootJointName) raise # end-try # end-if return nodesToVisit
widgetClass(widget, edit=True, value=self.optionMenuGrp_enumToLabel[optionVarDictKey][widgetValue]) except RuntimeError,e: logger.error("self.optionMenuGrp_enumToLabel['%s']=%s Value=%s"%(optionVarDictKey,self.optionMenuGrp_enumToLabel[optionVarDictKey],widgetValue)) raise elif widgetClass == maya.cmds.floatFieldGrp and isinstance(widgetValue, list): # always send list of 4 floats to this widgetValue4 = [0,0,0,0] for i in range(len(widgetValue)): widgetValue4[i] = widgetValue[i] widgetClass(widget, edit=True, value=widgetValue4) elif widgetClass == maya.cmds.textFieldGrp: widgetClass( widget, edit=True, text=widgetValue ) else: # assuming value=<val> widgets widgetClass(widget, edit=True, value=widgetValue) except TypeError,e: logger.error(maya.stringTable['y_CommandWithOptionVars.kRetrieveValsErr']%(widgetClass,widget,optionVarDictKey,widgetValue)) raise @Trace() def createOptionDialog(self, optionVarOverrideDict=None, saveOptionVars=True): '''Callback for the MenuItem OptionBox. Create and show the Option Dialog for this command. Supplies the header and footer for the dialog. Calls `addOptionDialogWidgets` to create the widgets. ''' # == Retrieve optionVars == optionVarDict = self.getOptionVars() # override specified values with incoming dict if != None if optionVarOverrideDict != None: optionVarDict.update(optionVarOverrideDict)