Python maya.cmds.optionVar() Examples
The following are 25
code examples of maya.cmds.optionVar().
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: 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 #2
Source File: dpAutoRig.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def checkLastOptionVar(self, optionVarName, preferableName, typeList): """ Verify if there's a optionVar with this name or create it with the preferable given value. Returns the lastValue found. """ lastValueExists = cmds.optionVar(exists=optionVarName) if not lastValueExists: # if not exists a last optionVar, set it to preferableName if it exists, or to the first value in the list: if preferableName in typeList: cmds.optionVar( stringValue=(optionVarName, preferableName) ) else: cmds.optionVar( stringValue=(optionVarName, typeList[0]) ) # get its value puting in a variable to return it: resultValue = cmds.optionVar( query=optionVarName ) # if the last value in the system was different of json files, set it to preferableName or to the first value in the list also: if not resultValue in typeList: if preferableName in typeList: resultValue = preferableName else: resultValue = resultValue[0] return resultValue
Example #3
Source File: pipeline.py From core with MIT License | 6 votes |
def _on_task_changed(*args): _update_menu_task_label() workdir = api.Session["AVALON_WORKDIR"] if os.path.exists(workdir): logger.info("Updating Maya workspace for task change to %s", workdir) _set_project() # Set Maya fileDialog's start-dir to /scenes frule_scene = cmds.workspace(fileRuleEntry="scene") cmds.optionVar(stringValue=("browserLocationmayaBinaryscene", workdir + "/" + frule_scene)) else: logger.warning("Can't set project for new context because " "path does not exist: %s", workdir)
Example #4
Source File: ml_arcTracer.py From ml_tools with MIT License | 6 votes |
def ui(): ''' User interface for arc tracer ''' globalScale = 1 if mc.optionVar(exists='ml_arcTracer_brushGlobalScale'): globalScale = mc.optionVar(query='ml_arcTracer_brushGlobalScale') with utl.MlUi('ml_arcTracer', 'Arc Tracer', width=400, height=180, info='''Select objects to trace. Choose camera space or worldspace arc. Press clear to delete the arcs, or retrace to redo the last arc.''') as win: win.buttonWithPopup(label='Trace Camera', command=traceCamera, annotation='Trace an arc as an overlay over the current camera.', shelfLabel='cam', shelfIcon='flowPathObj')#motionTrail win.buttonWithPopup(label='Trace World', command=traceWorld, annotation='Trace an arc in world space.', shelfLabel='world', shelfIcon='flowPathObj') win.buttonWithPopup(label='Retrace Previous', command=retraceArc, annotation='Retrace the previously traced arc.', shelfLabel='retrace', shelfIcon='flowPathObj') win.buttonWithPopup(label='Clear Arcs', command=clearArcs, annotation='Clear all arcs.', shelfLabel='clear', shelfIcon='flowPathObj') fsg = mc.floatSliderGrp( label='Line Width', minValue=0.1, maxValue=5, value=globalScale) mc.floatSliderGrp(fsg, edit=True, dragCommand=partial(setLineWidthCallback, fsg))
Example #5
Source File: ml_utilities.py From ml_tools with MIT License | 6 votes |
def upToDateCheck(revision, prompt=True): ''' This is a check that can be run by scripts that import ml_utilities to make sure they have the correct version. ''' if not '__revision__' in locals(): return if revision > __revision__: if prompt and mc.optionVar(query='ml_utilities_revision') < revision: result = mc.confirmDialog( title='Module Out of Date', message='Your version of ml_utilities may be out of date for this tool. Without the latest file you may encounter errors.', button=['Download Latest Revision','Ignore', "Don't Ask Again"], defaultButton='Download Latest Revision', cancelButton='Ignore', dismissString='Ignore' ) if result == 'Download Latest Revision': mc.showHelp(GITHUB_ROOT_URL+'ml_utilities.py', absolute=True) elif result == "Don't Ask Again": mc.optionVar(intValue=('ml_utilities_revision', revision)) return False return True
Example #6
Source File: dagmenu.py From mgear_core with MIT License | 6 votes |
def run(*args, **kwargs): # @UnusedVariable """ Menu run execution Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. """ # get check-box state state = args[0] if state: cmds.optionVar(intValue=("mgear_dag_menu_OV", 1)) else: cmds.optionVar(intValue=("mgear_dag_menu_OV", 0)) # runs dag menu right click mgear's override mgear_dagmenu_toggle(state)
Example #7
Source File: capture.py From maya-capture with MIT License | 6 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 #8
Source File: tests.py From maya-capture with MIT License | 6 votes |
def test_parse_active_scene(): """parse_active_scene() works""" parsed = capture.parse_active_scene() reference = { "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") } for key, value in reference.items(): assert parsed[key] == value
Example #9
Source File: ml_arcTracer.py From ml_tools with MIT License | 5 votes |
def setLineWidthCallback(slider, *args): value = mc.floatSliderGrp(slider, query=True, value=True) for each in mc.ls('ml_arcTracer_brush_*', type='brush'): mc.setAttr(each+'.globalScale', value) mc.optionVar(floatValue=('ml_arcTracer_brushGlobalScale', value))
Example #10
Source File: ml_colorControl.py From ml_tools with MIT License | 5 votes |
def ui(): '''Launch the UI ''' mc.optionVar( sv=('colorManagementColorPickerColorSpaceSelection','Display Space') ) win = ColorControlUI() win.buildMainLayout() win.finish()
Example #11
Source File: swingtwist.py From cmt with MIT License | 5 votes |
def get_kwargs(cls): """Gets the function arguments either from the option box widgets or the saved option vars. If the widgets exist, their values will be saved to the option vars. :return: A dictionary of the arguments to the create_twist_decomposition function.""" kwargs = {} if cmds.floatSliderGrp(Options.TWIST_WEIGHT_WIDGET, exists=True): kwargs["twist_weight"] = cmds.floatSliderGrp( Options.TWIST_WEIGHT_WIDGET, q=True, value=True ) cmds.optionVar(fv=(Options.TWIST_WEIGHT_WIDGET, kwargs["twist_weight"])) else: kwargs["twist_weight"] = cmds.optionVar(q=Options.TWIST_WEIGHT_WIDGET) if cmds.floatSliderGrp(Options.SWING_WEIGHT_WIDGET, exists=True): kwargs["swing_weight"] = cmds.floatSliderGrp( Options.SWING_WEIGHT_WIDGET, q=True, value=True ) cmds.optionVar(fv=(Options.SWING_WEIGHT_WIDGET, kwargs["swing_weight"])) else: kwargs["twist_weight"] = cmds.optionVar(q=Options.TWIST_WEIGHT_WIDGET) if cmds.optionMenuGrp(Options.TWIST_AXIS_WIDGET, exists=True): value = cmds.optionMenuGrp(Options.TWIST_AXIS_WIDGET, q=True, sl=True) kwargs["twist_axis"] = value - 1 cmds.optionVar(iv=(Options.TWIST_AXIS_WIDGET, kwargs["twist_axis"])) else: kwargs["twist_axis"] = cmds.optionVar(q=Options.TWIST_AXIS_WIDGET) return kwargs
Example #12
Source File: shelf_loader.py From mGui with MIT License | 5 votes |
def instantiate(self, parent=None): if parent is None: parent = gui.wrap(self.parent) # initializes all the shelves if parent.selectTab: current_tab = parent.selectTab for child in parent.childArray: parent.selectTab = child parent.selectTab = current_tab for shelf in parent.controls: if shelf.key == self.key: break else: with parent.as_parent(): shelf = self.proxy(self.key) # Needed so that we don't throw a weird maya error until the next restart. # Pulled this from the shelf editor mel script. if parent == 'ShelfLayout': cmds.optionVar(stringValue=('shelfName{}'.format(parent.numberOfChildren), self.key)) cmds.optionVar(intValue=('shelfLoad{}'.format(parent.numberOfChildren), True)) cmds.optionVar(stringValue=('shelfFile{}'.format(parent.numberOfChildren), '')) for ctrl in self.controls: ctrl.instantiate(shelf) cmds.saveAllShelves(parent)
Example #13
Source File: capture.py From maya-capture with MIT License | 5 votes |
def _disabled_inview_messages(): """Disable in-view help messages during the context""" original = cmds.optionVar(q="inViewMessageEnable") cmds.optionVar(iv=("inViewMessageEnable", 0)) try: yield finally: cmds.optionVar(iv=("inViewMessageEnable", original))
Example #14
Source File: capture.py From pyblish-bumpybox with GNU Lesser General Public License v3.0 | 5 votes |
def _disabled_inview_messages(): """Disable in-view help messages during the context""" original = cmds.optionVar(q="inViewMessageEnable") cmds.optionVar(iv=("inViewMessageEnable", 0)) try: yield finally: cmds.optionVar(iv=("inViewMessageEnable", original))
Example #15
Source File: maya_warpper.py From pipeline with MIT License | 5 votes |
def insert_recent_file(path): cmds.optionVar(stringValueAppend=('RecentFilesList', path))
Example #16
Source File: dagmenu.py From mgear_core with MIT License | 5 votes |
def get_option_var_state(): """ Gets dag menu option variable Maya's optionVar command installs a variable that is kept on Maya's settings so that you can use it on future sessions. Maya's optionVar are a quick and simple way to store a custom variable on Maya's settings but beware that they are kept even after mGear's uninstall so you will need to run the following commands. Returns: bool: Whether or not mGear's dag menu override is used Example: The following removes mgears dag menu optionVar .. code-block:: python from maya import cmds if not cmds.optionVar(exists="mgear_dag_menu_OV"): cmds.optionVar(remove="mgear_dag_menu_OV") """ # if there is no optionVar the create one that will live during maya # current and following sessions if not cmds.optionVar(exists="mgear_dag_menu_OV"): cmds.optionVar(intValue=("mgear_dag_menu_OV", 0)) return cmds.optionVar(query="mgear_dag_menu_OV")
Example #17
Source File: shelf.py From dpa-pipe with MIT License | 5 votes |
def _shelf_error_fix(self): # FIXES error in shelf.mel. reassigns optionVars for this shelf shelves = cmds.shelfTabLayout( self.layout, query=True, tabLabelIndex=True) for index, shelf in enumerate(shelves): if shelf == self.name: cmds.optionVar( stringValue=("shelfName{i}".format(i=index+1), str(shelf)) )
Example #18
Source File: dpAutoRig.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def autoCheckUpdate(self, *args): """ Store user choose about automatically check for update in an optionVar. If active, try to check for update once a day. """ firstTimeOpenDPAR = False # verify if there is an optionVar of last autoCheckUpdate checkBox choose value by user in the maya system: autoCheckUpdateExists = cmds.optionVar(exists='dpAutoRigAutoCheckUpdate') if not autoCheckUpdateExists: cmds.optionVar(intValue=('dpAutoRigAutoCheckUpdate', 1)) firstTimeOpenDPAR = True # get its value puting in a variable userDefAutoCheckUpdate: self.userDefAutoCheckUpdate = cmds.optionVar(query='dpAutoRigAutoCheckUpdate') if self.userDefAutoCheckUpdate == 1: # verify if there is an optionVar for store the date of the lastest autoCheckUpdate ran in order to avoid many hits in the GitHub server: todayDate = str(datetime.datetime.now().date()) lastAutoCheckUpdateExists = cmds.optionVar(exists='dpAutoRigLastDateAutoCheckUpdate') if not lastAutoCheckUpdateExists: cmds.optionVar(stringValue=('dpAutoRigLastDateAutoCheckUpdate', todayDate)) # get its value puting in a variable userDefAutoCheckUpdate: lastDateAutoCheckUpdate = cmds.optionVar(query='dpAutoRigLastDateAutoCheckUpdate') if not lastDateAutoCheckUpdate == todayDate: # then check for update: self.checkForUpdate(verbose=False) cmds.optionVar(stringValue=('dpAutoRigLastDateAutoCheckUpdate', todayDate)) # force checkForUpdate if it's the first time openning the dpAutoRigSystem in this computer: if firstTimeOpenDPAR: self.checkForUpdate(verbose=True) ###################### End: UI ###################### Start: Rigging Modules Instances
Example #19
Source File: dpAutoRig.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def setAutoCheckUpdatePref(self, currentValue, *args): """ Set the optionVar for auto check update preference as stored userDefAutoCheckUpdate read variable. """ cmds.optionVar(intValue=('dpAutoRigAutoCheckUpdate', int(currentValue)))
Example #20
Source File: dpAutoRig.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def createPreset(self, *args): """ Just call ctrls create preset and set it as userDefined preset. """ newPresetString = self.ctrls.dpCreatePreset() if newPresetString: # create json file: resultDic = self.createJsonFile(newPresetString, PRESETS, '_preset') # set this new preset as userDefined preset: self.presetName = resultDic['_preset'] cmds.optionVar(remove="dpAutoRigLastPreset") cmds.optionVar(stringValue=("dpAutoRigLastPreset", self.presetName)) # show preset creation result window: self.info('i129_createPreset', 'i133_presetCreated', '\n'+self.presetName+'\n\n'+self.langDic[self.langName]['i134_rememberPublish']+'\n\n'+self.langDic[self.langName]['i018_thanks'], 'center', 205, 270) # close and reload dpAR UI in order to avoide Maya crash self.jobReloadUI()
Example #21
Source File: dpAutoRig.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def changeOptionDegree(self, degreeOption, *args): """ Set optionVar to choosen menu item. """ cmds.optionVar(stringValue=('dpAutoRigLastDegreeOption', degreeOption)) self.degreeOption = int(degreeOption[0])
Example #22
Source File: capture.py From pyblish-bumpybox with GNU Lesser General Public License v3.0 | 4 votes |
def apply_scene(**options): """Apply options from scene Example: >>> apply_scene({"start_frame": 1009}) Arguments: options (dict): Scene options """ if "start_frame" in options: cmds.playbackOptions(minTime=options["start_frame"]) if "end_frame" in options: cmds.playbackOptions(maxTime=options["end_frame"]) if "width" in options: cmds.setAttr("defaultResolution.width", options["width"]) if "height" in options: cmds.setAttr("defaultResolution.height", options["height"]) if "compression" in options: cmds.optionVar( stringValue=["playblastCompression", options["compression"]]) if "filename" in options: cmds.optionVar( stringValue=["playblastFile", options["filename"]]) if "format" in options: cmds.optionVar( stringValue=["playblastFormat", options["format"]]) if "off_screen" in options: cmds.optionVar( intValue=["playblastFormat", options["off_screen"]]) if "show_ornaments" in options: cmds.optionVar( intValue=["show_ornaments", options["show_ornaments"]]) if "quality" in options: cmds.optionVar( floatValue=["playblastQuality", options["quality"]])
Example #23
Source File: capture.py From maya-capture with MIT License | 4 votes |
def apply_scene(**options): """Apply options from scene Example: >>> apply_scene({"start_frame": 1009}) Arguments: options (dict): Scene options """ if "start_frame" in options: cmds.playbackOptions(minTime=options["start_frame"]) if "end_frame" in options: cmds.playbackOptions(maxTime=options["end_frame"]) if "width" in options: cmds.setAttr("defaultResolution.width", options["width"]) if "height" in options: cmds.setAttr("defaultResolution.height", options["height"]) if "compression" in options: cmds.optionVar( stringValue=["playblastCompression", options["compression"]]) if "filename" in options: cmds.optionVar( stringValue=["playblastFile", options["filename"]]) if "format" in options: cmds.optionVar( stringValue=["playblastFormat", options["format"]]) if "off_screen" in options: cmds.optionVar( intValue=["playblastFormat", options["off_screen"]]) if "show_ornaments" in options: cmds.optionVar( intValue=["show_ornaments", options["show_ornaments"]]) if "quality" in options: cmds.optionVar( floatValue=["playblastQuality", options["quality"]])
Example #24
Source File: qt.py From SISideBar with MIT License | 4 votes |
def make_flat_button(icon=None, name='', text=200, bg=[54, 51, 51], ui_color=68, border_col=[180, 140, 30], checkable=True, w_max=None, w_min=None, push_col=120, h_max=None, h_min=None, policy=None, icon_size=None, tip=None, flat=True, hover=True, destroy_flag=False, context=None, costom_push=None): button = RightClickButton() button.setText(name) if checkable: button.setCheckable(True)#チェックボタンに if icon: button.setIcon(QIcon(icon)) if flat: button.setFlat(True)#ボタンをフラットに change_button_color(button, textColor=text, bgColor=ui_color, hiColor=bg, mode='button', hover=hover, destroy=destroy_flag, dsColor=border_col) button.toggled.connect(lambda : change_button_color(button, textColor=text, bgColor=ui_color, hiColor=bg, mode='button', toggle=True, hover=hover, destroy=destroy_flag, dsColor=border_col)) else: button.setFlat(False) button.setFlat(False) if costom_push is None: change_button_color(button, textColor=text, bgColor=bg, hiColor=push_col, mode='button', hover=hover, destroy=destroy_flag, dsColor=border_col) else: change_button_color(button, textColor=text, bgColor=bg, hiColor=costom_push, mode='button', hover=hover, destroy=destroy_flag, dsColor=border_col) #UIスケーリングサイズを取得しておく if cmds.optionVar( exists='interfaceScalingValue' ) and cmds.optionVar( q='interfaceScalingMode' ) == 1: ui_scale = cmds.optionVar( q='interfaceScalingValue' ) else: ui_scale = 1.0 if w_max: button.setMaximumWidth(w_max*ui_scale) if w_min: button.setMinimumWidth(w_min*ui_scale) if h_max: button.setMaximumHeight(h_max*ui_scale) if h_min: button.setMinimumHeight(h_min*ui_scale) if icon_size: x = icon_size[0]*ui_scale y = icon_size[1]*ui_scale button.setIconSize(QSize(x, y)) else: icon_size = button.iconSize() #print icon_size x = icon_size.width()*ui_scale y = icon_size.height()*ui_scale button.setIconSize(QSize(x, y)) if policy:#拡大縮小するようにポリシー設定 button.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) if tip: button.setToolTip(tip) if context:#コンテキストメニュー設定 button.setContextMenuPolicy(Qt.CustomContextMenu) button.customContextMenuRequested.connect(context) return button
Example #25
Source File: swingtwist.py From cmt with MIT License | 4 votes |
def create_ui(self): cmds.columnLayout(adj=True) for widget in [ Options.SWING_WEIGHT_WIDGET, Options.TWIST_WEIGHT_WIDGET, Options.TWIST_AXIS_WIDGET, ]: # Delete the widgets so we don't create multiple controls with the same name try: cmds.deleteUI(widget, control=True) except RuntimeError: pass swing_weight = cmds.optionVar(q=Options.SWING_WEIGHT_WIDGET) cmds.floatSliderGrp( Options.SWING_WEIGHT_WIDGET, label="Swing weight", field=True, minValue=-1.0, maxValue=1.0, fieldMinValue=-1.0, fieldMaxValue=1.0, value=swing_weight, step=0.1, precision=2, ) twist_weight = cmds.optionVar(q=Options.TWIST_WEIGHT_WIDGET) cmds.floatSliderGrp( Options.TWIST_WEIGHT_WIDGET, label="Twist weight", field=True, minValue=-1.0, maxValue=1.0, fieldMinValue=-1.0, fieldMaxValue=1.0, value=twist_weight, step=0.1, precision=2, ) twist_axis = cmds.optionVar(q=Options.TWIST_AXIS_WIDGET) twist_axis = 1 if not twist_axis else twist_axis + 1 cmds.optionMenuGrp(Options.TWIST_AXIS_WIDGET, l="Twist Axis") cmds.menuItem(label="X") cmds.menuItem(label="Y") cmds.menuItem(label="Z") cmds.optionMenuGrp(Options.TWIST_AXIS_WIDGET, e=True, sl=twist_axis)