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

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

项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def copyShader(src = "", tgts = [], *args):
    """
    gets the shader from the src and assigns it to the tgt objs

    Args:
        src (string): the object we're getting the shader FROM
        tgts (list[strings]): the objects we're setting the shaders TO
    """
    confirm = confirmDialog("Should I copy shaders?")
    if confirm == "Yes":
        for tgt in tgts:
            shp = cmds.listRelatives(src, s=True)[0]
            sg = cmds.listConnections(shp, t="shadingEngine")[0]
            tshp = cmds.listRelatives(tgt, s=True)[0]
            cmds.sets(tshp, e=True, forceElement=sg)
    else:
        print "Copy shader assignment cancelled"
        return()
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def makeSequence(obj = "", name = "", frameStart = 0, frameEnd = 1, step = 1):
    """duplicate selected geo based on settings from UI"""

    dupes = []

    numCopies = (frameEnd-frameStart)/step
    #check here if we want to create more than 25 duplicates?
    confirm = cmds.confirmDialog(t="Confirm", m= "This will create %d copies of %s. \nFrames: %d to %d\nFor dense meshes, this could get heavy\nAre you sure you want to do this?"%(numCopies, obj, frameStart, frameEnd), button = ["Yes", "No"], cancelButton = "No")

    if confirm == "Yes":
        for frame in range(frameStart, frameEnd + 1, step):
            cmds.currentTime(frame, edit=True)
            dupe = cmds.duplicate(obj, n="%s_%d"%(name, frame), ic = False, un = False)
            dupes.append(dupe)

    if dupes:
        grp = cmds.group(em = True, n = "%s_GRP"%name)
        for dupe in dupes:
            cmds.parent(dupe, grp)

    #cmds.currentTime(currentFrame, e=True)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_cboxReset(box, menuItem, key, *args):
    with sysCmd.Undo(0):
        confirm = cmds.confirmDialog(t="Reset to Default",
                                     m="Delete all saved data and modified settings associated with this Channel Box?",
                                     icon="critical", button=["Reset", "Cancel"])

        if confirm == "Reset":

            default_states = box.menu_default_states

            for k, v in default_states.iteritems():
                # compare keys containing a default state with items that exist in the edit menu or others
                # specified and restore them
                box.saved_states[k] = v

            sysCmd.channelbox_pickle_delete_state(box)
            # box.re_init(box)  # re-initialize to update our changes in the display
            cmds.warning("Please close the ChannelBox UI and re-open it for changes to take effect")
项目: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
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def about(self, *args):
        '''
        This pops up a window which shows the revision number of the current script.
        '''

        text='by Morgan Loomis\n\n'
        try:
            __import__(self.module)
            module = sys.modules[self.module]
            text = text+'Revision: '+str(module.__revision__)+'\n'
        except StandardError:
            pass
        try:
            text = text+'ml_utilities Rev: '+str(__revision__)+'\n'
        except StandardError:
            pass

        mc.confirmDialog(title=self.name, message=text, button='Close')
项目:SETools    作者:dtzxporter    | 项目源码 | 文件源码
def AboutWindow():
    result = cmds.confirmDialog(message="---  SE Tools plugin (v2.3.4)  ---\n\nDeveloped by DTZxPorter", button=['OK'], defaultButton='OK', title="About SE Tools")

# A list (in order of priority) of bone names to automatically search for when determining which bone to use as the root for delta anims
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def confirmDialog(message = "confirm?", *args):
    """
    just returns Yes or No

    Args:
        message(string): the message to display
    Return:
        string: "Yes" or "No"
    """

    dial = cmds.confirmDialog(t="Confirm?", m=message, button=["Yes", "No"], dismissString="No")

    return(dial)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def deformer_check(obj, *args):
    """
    check if there are other deformers on the obj
    :param args:
    :return:
    """
    deformers = rig.get_deformers(obj)
    if deformers:
        cmds.confirmDialog(title='Deformer Alert!',
                           message='Found some deformers on {0}.\nYou may want to put the softmod\n early in the '
                                   'input list\n or check "front of chain"'.format(obj),
                           button=['OK'], defaultButton='OK', cancelButton='OK', dismissString='OK')
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_selectFilterSet(box, menuItem, key, *args):
    with sysCmd.Undo(0):
        state = cmds.menuItem(menuItem, q=1, isOptionBox=1)
        f_set_name = cmds.menuItem(menuItem, q=1, label=1)

        if not state:  # didn't press the option box
            channelbox_command_resetFilters(box)  # resetting filters before applying a new one cleans everything up
            if f_set_name in box.saved_states["savedFilters"][0]:
                saved = box.saved_states["savedFilters"][0][f_set_name][
                        :-2]  # [-1] is invertShown boolean and -2 is the type string, exclude from loop
                box.saved_states["invertShown"][0] = box.saved_states["savedFilters"][0][f_set_name][
                    -1]  # restoring invert state saved with the filter
                # Specific Attribute Filters
                if box.saved_states["savedFilters"][0][f_set_name][-2] == "type=attr":
                    # dict in ["savedFilters"] contains only enabled attributes, so set to 1 always
                    box.filter_attrs = {k: 1 for k in saved}
                    channelBox_filterAttrs(box)  # attributes restored to box.filter_attrs, now apply the filter
                # Pre-defined Filters
                else:
                    for f in saved:
                        box.filter_items.append(f)
                        box.saved_states[f][0] = 1  # set each of the checkbox attributes to 1 to update UI
                    channelBox_Filter_Items(box)
            else:
                cmds.error(
                    "Filter set doesn't exist, potential mismatch between data file and current menu state."
                    " Was something deleted from the drive?")
        else:
            del_conf = cmds.confirmDialog(t="Delete?", icn="warning", message="Delete filter set \"" + f_set_name +
                                                                              "\"?", button=["Delete", "Cancel"])
            if del_conf == "Delete":
                box.saved_states["savedFilters"][0].pop(f_set_name, None)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_createFilterSet(box, menuItem, key, *args):
    with sysCmd.Undo(0):
        attrs = len(box.filter_attrs) >= 1
        fset = []

        if attrs:  # checking if we're dealing with specific attributes or pre-defined items
            for f in box.filter_attrs:  # add the key values in filter_attrs to fset
                fset.append(f)
            fset.append("type=attr")  # append the type to the end of the list, later becomes [-2]
        else:
            for f in box.filter_items:
                fset.append(f)
            fset.append("type=item")

        if fset:
            name_prompt = cmds.promptDialog(t="Save Filter Set", button=["Save", "Cancel"])
            # ask user to enter the set name
        else:
            return

        fset.append(
            box.saved_states["invertShown"][0])  # append the invertShown state to become [-1] pushing fset to [-2]

        if name_prompt == "Save":
            name = cmds.promptDialog(q=1, tx=1)
            confirm = 0
            if name in box.saved_states["savedFilters"][0]:  # check if exists, ask to confirm overwrite
                confirm = cmds.confirmDialog(t="Confirm Overwrite", icn="warning",
                                             message="Filter set \"" + name + "\" already exists. Overwrite?",
                                             button=["Overwrite", "Cancel"])
            if confirm and confirm == "Overwrite" or not confirm:
                box.saved_states["savedFilters"][0][name] = fset
        else:
            return

        sysCmd.channelbox_save_state(box)
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def ui():
    '''Launch the UI
    '''
    if not os.path.exists(REPOSITORY_PATH):
        result = mc.confirmDialog( title='Control Repository Not Found', message='Create a repository directory?', 
                                   button=['Create','Cancel'], defaultButton='Cancel', cancelButton='Cancel', dismissString='Cancel' )

        if result != 'Create':
            return None

        os.mkdir(REPOSITORY_PATH)    

    win = ControlLibraryUI()
    win.buildMainLayout()
    win.finish()
项目:SceneExplorer    作者:mochio326    | 项目源码 | 文件源码
def scene_open(path, set_project):
    '''
    ??????
    :return:
    '''

    def new_open():
        if set_project is True:
            cmds.workspace(project_path, openWorkspace=True)
        io.open(path, file_type, 1)
        add_rectnt_project(project_path)
        add_rectnt_file(path, file_type)

    types = {'.ma': 'mayaAscii', '.mb': 'mayaBinary', '.fbx': 'FBX', '.obj': 'OBJ'}
    if path == '':
        return None
    head, tail = os.path.split(path)
    name, ex = os.path.splitext(path)
    if ex not in types.keys():
        return None
    file_type = types[ex]
    project_path = get_project_dir(path)
    io = om.MFileIO()
    if cmds.file(q=1,sceneName=True) == '':
        new_open()
    else:
        result = cmds.confirmDialog(t='File Open', m='New Scene Open or Import Scene?',
                                    b=['New Scene', 'Import Scene', 'Cancel'],
                                    db='New Scene', cb='Cancel', ds='Cancel')
        if result == 'Cancel':
            return None
        elif result == 'New Scene':
            new_open()
        elif result == 'Import Scene':
            fbx_plugin = 'fbxmaya'
            cmds.loadPlugin('{0:}.mll'.format(fbx_plugin), qt=1)
            if fbx_plugin not in cmds.pluginInfo(q=1, ls=1):
                om.MGlobal.displayError('{0} Plugin in not loaded'.format(fbx_plugin))
                return None
            io.importFile(path, file_type, 1, str(tail.replace('.', '_')))

    # ??????????
    #ls = cmds.ls(typ='file', type='mentalrayTexture')
    #[cmds.setAttr(x + '.ftn', cmds.getAttr(x + '.ftn'), type='string') for x in ls]
    return 0
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def transferUV(src, tgts, deleteHistory=False, *args):
    """
    gets the shader and uv's from the src and assigns to the tgt objs (transfer uv's)

    Args:
        src (string): the object we're getting the shader and uv's FROM
        tgts (list[strings]): the objects we're setting the shaders and uv's Return
        deleteHistory (boolean): delete constructionHistory? Will delete non-deformer history. . . 
    TO:
        None
    """ 
    message = ""
    if deleteHistory:
        message = "Should I copy transfer UV's?\nWarning: 'deleteHistory' will (duh) remove history,\ntho it SHOULD keep deformer history."
    if not deleteHistory:
        message = "Should I copy transfer UV's?"

    confirm = confirmDialog(message)
    if confirm == "Yes":
        if deleteHistory:
            srcShp = [x for x in cmds.listRelatives(src, s=True) if "Orig" not in x][0]

            for t in tgts:
                intObj = ""
                shps = cmds.listRelatives(t, s=True)
                for shp in shps:
                    # ----------- clean this up to only get the upstream-most orig node
                    if cmds.getAttr("{0}.intermediateObject".format(shp)):
                        intObj = shp
                        break
                if intObj:
                    print "transferring uvs to {0}.intermediateObject".format(intObj)
                    cmds.setAttr("{0}.intermediateObject".format(intObj), 0)
                    cmds.transferAttributes(srcShp, intObj, uvs=2, sampleSpace=4)
                    cmds.delete(intObj, constructionHistory=True)
                    cmds.setAttr("{0}.intermediateObject".format(intObj), 1)
                else:
                    print "transferring uvs to {0} shape"
                    cmds.transferAttributes(srcShp, t, uvs=2, sampleSpace=4)
                    cmds.delete(t, ch=True)

        else:
            srcShp = [x for x in cmds.listRelatives(src, s=True) if "Orig" not in x][0]
            for t in tgts:
                cmds.transferAttributes(srcShp, t, uvs=2, sampleSpace=4)

    else:
        print "Transfer UVs cancelled!"
        return()
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def promptExportControl(*args):
    '''Export selection, prompt for name, and create icon as well.
    '''

    sel = mc.ls(sl=True)

    assert sel, 'Select a control curve(s) to export.'

    for each in sel:
        if mc.nodeType(each) == 'nurbsCurve':
            continue
        shapes = mc.listRelatives(each, shapes=True, type='nurbsCurve')
        assert shapes, '{} is not a nurbsCurve'.format(each)

    result = mc.promptDialog(
        title='Export Control Curve',
        message='Enter Name:',
        button=['OK', 'Cancel'],
        defaultButton='OK',
        cancelButton='Cancel',
        dismissString='Cancel')

    if result != 'OK':
        return

    ctrlName = mc.promptDialog(query=True, text=True)
    ctrlName = ''.join(x if x.isalnum() else '_' for x in ctrlName)

    if os.path.exists(controlFilePath(ctrlName)):
        result = mc.confirmDialog(title='Control Exists', 
                                  message='A control of this name already exists.', 
                                  button=['Overwrite','Cancel'], 
                                  defaultButton='Cancel', 
                                  cancelButton='Cancel', 
                                  dismissString='Cancel'
                                  )
        if result != 'Overwrite':
            return 

    ctrl = exportControl(sel, ctrlName)

    strokes = mc.ls(type='stroke')

    #create the icon
    mc.ResetTemplateBrush()
    brush = mc.getDefaultBrush()
    mc.setAttr(brush+'.screenspaceWidth', 1)
    mc.setAttr(brush+'.distanceScaling', 0.01)
    mc.setAttr(brush+'.color1', 0.1, 0.65, 1, type='double3')

    mc.select(ctrl)
    mc.AttachBrushToCurves(ctrl)
    image = utl.renderShelfIcon(name=ctrlName, width=64, height=64)

    imagePath = os.path.join(REPOSITORY_PATH, os.path.basename(image))
    shutil.move(image, imagePath)

    #delete new strokes.
    newStrokes = [x for x in mc.ls(type='stroke') if x not in strokes]
    for each in newStrokes:
        mc.delete(mc.listRelatives(each, parent=True, pa=True))