Python maya.cmds 模块,optionVar() 实例源码

我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用maya.cmds.optionVar()

项目:SceneExplorer    作者:mochio326    | 项目源码 | 文件源码
def add_bookmark(type, value):
    '''
    ?????????????
    :param type: ??????????
    :param value: ??????
    :return:
    '''
    option_var_name = get_bookmark_option_var_name(type)
    ls = cmds.optionVar(q=option_var_name)
    if ls == 0:
        ls = []
    if value not in ls:
        ls.append(value)
    cmds.optionVar(ca=option_var_name)
    [cmds.optionVar(sva=(option_var_name, i)) for i in ls]
    return
项目:SceneExplorer    作者:mochio326    | 项目源码 | 文件源码
def delete_bookmark(ui, value):
    '''
    ???????????
    :param type: ??????????
    :param value: ??????
    :return:
    '''
    if ui.radio_bookmark_file.isChecked():
        type = 'file'
    elif ui.radio_bookmark_directory.isChecked():
        type = 'directory'
    option_var_name = get_bookmark_option_var_name(type)
    ls = cmds.optionVar(q=option_var_name)
    if ls != 0:
        if value in ls:
            ls.remove(value)
    cmds.optionVar(ca=option_var_name)
    [cmds.optionVar(sva=(option_var_name, i)) for i in ls]
    return
项目:SceneExplorer    作者:mochio326    | 项目源码 | 文件源码
def add_rectnt_project(project):
    '''
    ??????????????
    :param project:
    :return:
    '''
    optvar = cmds.optionVar
    opt_list = 'RecentProjectsList'
    ls = optvar(q=opt_list)
    max_size = optvar(q='RecentProjectsMaxSize')
    # ?????????
    for i, x in enumerate(ls):
        if project == x:
            optvar(rfa=[opt_list, i])
    optvar(sva=[opt_list, project])
    if len(optvar(q=opt_list)) > max_size:
        optvar(rfa=[opt_list, 0])
项目:gozbruh    作者:LumaPictures    | 项目源码 | 文件源码
def _cleanup(name):
    """Removes un-used nodes on import of obj
    """

    # Don't delete the old mesh if gozbruh_delete option var exists and is set to
    #     false, simply rename it
    if cmds.optionVar(ex='gozbruh_delete') and not cmds.optionVar(q='gozbruh_delete'):
        if cmds.objExists(name):
            cmds.rename(name, name + '_old')
    else:
        if cmds.objExists(name):
            cmds.delete(name)

    for node in GARBAGE_NODES:
        node = name + '_' + node
        if cmds.objExists(node):
            cmds.delete(node)

#------------------------------------------------------------------------------
# Helpers
#------------------------------------------------------------------------------
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
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))
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
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('http://mDynamicAnimUIorganloomis.com/download/animationScripts/ml_utilities.py', absolute=True)
            elif result == "Don't Ask Again":
                mc.optionVar(intValue=('ml_utilities_revision', revision))
        return False
    return True
项目:SceneExplorer    作者:mochio326    | 项目源码 | 文件源码
def get_bookmark(ui):
    '''
    ????????????????????
    :param ui: ui???????
    :return: ????????
    '''
    if ui.radio_bookmark_file.isChecked():
        type = 'file'
    elif ui.radio_bookmark_directory.isChecked():
        type = 'directory'
    option_var_name = get_bookmark_option_var_name(type)
    ls = cmds.optionVar(q=option_var_name)
    if ls == 0:
        ls = []
    return ls
项目:SceneExplorer    作者:mochio326    | 项目源码 | 文件源码
def get_history(ui):
    '''
    ???????????????????
    :param ui: ui???????
    :return: ????????
    '''
    ls = []
    if ui.radio_history_file.isChecked():
        ls = cmds.optionVar(q='RecentFilesList')
    elif ui.radio_history_project.isChecked():
        ls = cmds.optionVar(q='RecentProjectsList')

    if ls == 0:
        return []
    return list(reversed(ls))
项目:TACTIC-Handler    作者:listyque    | 项目源码 | 文件源码
def export_selected(project_code, tab_code, wdg_code):

    current_type = cmds.optionVar(q='defaultFileExportActiveType')
    current_ext = cmds.translator(str(current_type), q=True, filter=True)
    current_ext = current_ext.split(';')[0]

    current_checkin_widget = env_inst.get_check_tree(project_code, tab_code, wdg_code)

    current_checkin_widget.save_file(selected_objects=[True, {current_type: current_ext[2:]}])
项目:TACTIC-Handler    作者:listyque    | 项目源码 | 文件源码
def save_as(project_code, tab_code, wdg_code):

    current_type = cmds.optionVar(q='defaultFileSaveType')
    current_ext = cmds.translator(str(current_type), q=True, filter=True)
    current_ext = current_ext.split(';')[0]

    current_checkin_widget = env_inst.get_check_tree(project_code, tab_code, wdg_code)

    current_checkin_widget.save_file(selected_objects=[False, {current_type: current_ext[2:]}])
项目:zoocore    作者:dsparrow27    | 项目源码 | 文件源码
def setChannelShowType(channelBox, value):
    """
    :param channelBox: mainChannelBox
    :type channelBox: str
    :param value:
    :type value: str
    :example::
        setChannelShowType("mainChannelBox", "all")
    """
    cmds.optionVar(stringValue=("cbShowType", value))
    cmds.channelBox(channelBox, edit=True, update=True)
项目:pipeline    作者:liorbenhorin    | 项目源码 | 文件源码
def insert_recent_file(path):
    cmds.optionVar(stringValueAppend=('RecentFilesList', path))
项目:surume    作者:tm8r    | 项目源码 | 文件源码
def get_recent_files():
    u"""???????????????

    :return: ?????????????????????????????
    :rtype: OrderedDict
    """
    files = cmds.optionVar(q="RecentFilesList")
    file_types = cmds.optionVar(q="RecentFilesTypeList")
    files.reverse()
    file_types.reverse()
    return OrderedDict(zip(files, file_types))
项目:OBB    作者:chrisdevito    | 项目源码 | 文件源码
def create_shelf():
    """
    Create the OBB shelf

    Raises:
        None

    Returns:
        None
    """

    tab_layout = mel.eval('$pytmp=$gShelfTopLevel')
    shelf_exists = cmds.shelfLayout('OBB', exists=True)

    if shelf_exists:
        cmds.deleteUI('OBB', layout=True)

    shelf = cmds.shelfLayout('OBB', parent=tab_layout)

    for button, kwargs in buttons.items():

        img = QtGui.QImage(kwargs['image'])
        kwargs['width'] = img.width()
        kwargs['height'] = img.height()

        cmds.shelfButton(label=button, parent=shelf, **kwargs)

    # Fix object 0 error.
    shelves = cmds.shelfTabLayout(tab_layout, query=True, tabLabelIndex=True)

    for index, shelf in enumerate(shelves):
        cmds.optionVar(stringValue=("shelfName%d" % (index+1), str(shelf)))
项目:gozbruh    作者:LumaPictures    | 项目源码 | 文件源码
def load(file_path, obj_name, parent_name):
    """Import a file exported from ZBrush.

    This is the command sent over the Maya command port from ZBrush.

    Parameters
    ----------
    file_path : str
        Path to the file that we are importing
    obj_name : str
        Name of the object being imported
    parent_name : str
        Name of the parent for the object being imported
    """
    file_name = utils.split_file_name(file_path)
    _cleanup(file_name)
    cmds.file(file_path, i=True,
              usingNamespaces=False,
              removeDuplicateNetworks=True)

    # Set smoothing options if necessary
    if cmds.optionVar(ex='gozbruh_smooth') and not cmds.optionVar(q='gozbruh_smooth'):
        cmds.displaySmoothness(obj_name, du=0, dv=0, pw=4, ps=1, po=1)

    if not cmds.attributeQuery("gozbruhParent", n=obj_name, ex=True):
        cmds.addAttr(obj_name, longName='gozbruhParent', dataType='string')
    cmds.setAttr(obj_name + '.gozbruhParent', parent_name, type='string')
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
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))
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def ui():
    '''Launch the UI
    '''
    mc.optionVar( sv=('colorManagementColorPickerColorSpaceSelection','Display Space') )
    win = ColorControlUI()
    win.buildMainLayout()
    win.finish()