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

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

项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def randomSelectionUI(*args):
    if cmds.window("win", exists = True):
        cmds.deleteUI("win")

    widgets["win"] = cmds.window("win", w=280, h=75, t="zbw_randomSelection")

    widgets["mainCLO"] = cmds.columnLayout()
    widgets["text"] = cmds.text("What percent of selection do you want to keep?")
    widgets["keepIFG"] = cmds.intFieldGrp(l=" % to keep:", v1=50, h=40, cw = ([1, 65], [2, 50]), cal = ([1,"left"], [2, "left"]))
    widgets["text2"] = cmds.text("Random: each obj has % chance to be removed")
    widgets["text3"] = cmds.text("Precise: exact num removed, but randomly chosen")
    cmds.separator(h=10)
    widgets["typeRBG"] = cmds.radioButtonGrp(l="Type:", l1 = "Random Remove", l2 = "Precise Remove", nrb = 2, sl = 1, cw = ([1, 30], [2,120], [3, 120], [4, 50]), cal = ([1, "left"], [2,"left"], [3, "left"], [4, "left"]))
    widgets["but"] = cmds.button(l="Reselect", w=280, h=40, bgc = (.6, .8, .6), c = doSel)

    cmds.window(widgets["win"], e=True, w=280, h=75)
    cmds.showWindow(widgets["win"])
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def findScriptUI(*args):

    if cmds.window("findScript", exists = True):
        cmds.deleteUI("findScript")

    widgets["win"] = cmds.window("findScript", t="zbw_findPath", w=300, h=200)
    widgets["mainCLO"] = cmds.columnLayout()

    cmds.separator(h=10)
    widgets["textTx"] = cmds.text(l="Will search your active python paths. \nNo need for suffix (.py or .mel)\nNo wildcards(*). Just string, 3 chars min", al="left")
    cmds.separator(h=20)
    widgets["nameTFG"] = cmds.textFieldGrp(l="search for:", cw = [(1, 75), (2,200)], cal = [(1, "left"),(2, "right")])
    cmds.separator(h=20)
    widgets["searchBut"] = cmds.button(l="Search python paths!", w=300, h=50, bgc=(0,.6, 0), c=searchPaths)
    cmds.separator(h=20)

    widgets["resultTxt"] = cmds.textFieldGrp(l="results:", ed=False, w=300, cw = [(1, 75), (2,200)], bgc = (0,0,0) , cal = [(1, "left"),(2, "right")])

    cmds.showWindow(widgets["win"])
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def getScriptsUI(*args):

    if cmds.window("thisWin", exists = True):
        cmds.deleteUI("thisWin")

    widgets["win"] = cmds.window("thisWin", w=300, h=200)
    widgets["mainFLO"] = cmds.formLayout()

    widgets["list"] = cmds.textScrollList(nr=10, w=300, dcc = executeCommand)

    cmds.formLayout(widgets["mainFLO"], e=1, af = [(widgets["list"], "left", 0), (widgets["list"], "top", 0), (widgets["list"], "bottom", 30), (widgets["list"], "right", 0)])

    widgets["button"] = cmds.button(l="Refresh List!", w=300, h= 30, bgc = (.8, .6, .3), c= getScripts)
    cmds.formLayout(widgets["mainFLO"], e=1, af = [(widgets["button"], "left", 0), (widgets["button"], "right", 0), (widgets["button"], "bottom", 0)])

    cmds.showWindow(widgets["win"])

#populate the list with the contents of the path
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def shadingTransferUI(*args):
    if cmds.window("win", exists=True):
        cmds.deleteUI("win")

    widgets["win"] = cmds.window("win", t="zbw_shadingTransfer", w=200, h=100, s=False)
    widgets["mainCLO"] = cmds.columnLayout()

    cmds.text(l="1. Select the source object (poly/nurbs)", al="left")
    cmds.text(l="2. Select the target object(s)", al="left")
    cmds.text(l="Note: deleteHistory on the transferUV\nwill try to avoid deleting deformers.\nNo promises:)", al="left")
    cmds.separator(h=10)
    widgets["shdBut"] = cmds.button(l="Copy Shaders to targets!", w=200, h=40, bgc=(.4, .7, .4), c=partial(getSelection, "copyShader"))
    cmds.separator(h=10)
    widgets["uvBut"] = cmds.button(l="Transfer UV's to targets!", w=200, h=40, bgc=(.7, .7, .5), c=partial(getSelection, "transferUV"))
    widgets["xferCBG"] = cmds.checkBoxGrp(l="Delete history after transfer?", v1=0, cal=[(1, "left"), (2,"left")], cw=[(1, 150), (2, 50)])
    cmds.window(widgets["win"], e=True, w=200, h=100)
    cmds.showWindow(widgets["win"])
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def getObj(*args):
    #get selection and put it in the widgets["objTFG"]
    clearList()
    sel = cmds.ls(sl=True, type="transform")
    if (sel and (len(sel)==1)):
        cmds.textFieldGrp(widgets["objTFG"], e=True, tx=sel[0])
    else:
        cmds.warning("you must select one object with the \"follow\" attribute")

    #------------maybe add attr onto end of obj text, then you don't have to get it later if you needed to ???

    #now create a button for each value in the "follow" attr
    #channels = cmds.channelBox ('mainChannelBox', query=True, selectedMainAttributes=True)
    enumValueStr = cmds.attributeQuery("follow", node=sel[0], listEnum=True)[0]
    values = enumValueStr.split(":")

    for i in range(0,len(values)):
        #pick a random color?
        r = random.uniform(0.5,1)
        g = random.uniform(0.5,1)
        b = random.uniform(0.5,1)
        color = (r, g, b)

        #here create the button
        cmds.button(l=values[i], w=125, p=widgets["bottomRCLO"], bgc=color, h=50, c=partial(switchMatchSpace, i))
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def snapUI():
    """simple snap UI for snapping"""

    if cmds.window("snapWin", exists=True):
        cmds.deleteUI("snapWin", window=True)
        cmds.windowPref("snapWin", remove=True)

    widgets["win"] = cmds.window("snapWin", t="zbw_snap", w=210, h=100, rtf=True)
    widgets["mainCLO"] = cmds.columnLayout(w=210, h=100)
    cmds.text("Select the target object(s),\nthen the object(s) you want to snap", al="center", w=210)
    cmds.separator(h=5, style="single")
    widgets["cbg"] = cmds.checkBoxGrp(l="Options: ", ncb=2, v1=1, v2=1, l1="Translate", l2="Rotate", cal=[(1,"left"),(2,"left"), (3,"left")], cw=[(1,50),(2,75),(3,75)])
    widgets["avgRBG"] = cmds.radioButtonGrp(nrb=2, l1="Snap all to first", l2="Snap last to avg", cal=[(1,"left"),(2,"left"),(3,"left")], cw=[(1,100),(2,100)],sl=1)
    widgets["rpCB"] = cmds.checkBox(l="Use Rotate Pivot To Query Position?", v=1)
    widgets["snapPivCB"] = cmds.checkBox(l="Snap via pivot? (vs. translate value)", v=1)
    cmds.separator(h=5, style="single")
    widgets["snapButton"] = cmds.button(l="Snap obj(s)!", w=210, h=40, bgc=(.6,.8,.6), c=partial(snapIt, False))
    widgets["snapPivButton"] = cmds.button(l="Snap pivot!", w=210, h=20, bgc=(.8,.6,.6), c=partial(snapIt, True))

    cmds.window(widgets["win"], e=True, w=5, h=5)
    cmds.showWindow(widgets["win"])
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def jointRadiusUI(*args):
    if cmds.window("jntWin", exists=True):
        cmds.deleteUI("jntWin")

    widgets["win"] = cmds.window("jntWin", t="zbw_jointRadius", w=200, h=90, s=False)
    widgets["clo"] = cmds.columnLayout(rs=10)

    widgets["slider"] = cmds.floatSliderGrp(l="radius", min=0.05, max=2, field=True, fieldMinValue=0.01,
                                            fieldMaxValue=2, precision=2, sliderStep=0.1, value=0.5,
                                            cw=([1, 40], [2, 45], [3, 115]),
                                            cal=([1, "left"], [2, "left"], [3, "left"]))
    # radio button group, all or selected
    widgets["rbg"] = cmds.radioButtonGrp(nrb=2, l1="all", l2="selected", cw=([1, 50], [1, 50]), sl=1)
    widgets["but"] = cmds.button(l="Set Radius", w=205, h=50, bgc=(.5, .8, .5), c=adjustRadius)

    cmds.window(widgets["win"], e=True, w=200, h=90)
    cmds.showWindow(widgets["win"])
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def zbw_mmChangeConnectAttrUI(base, attr, obj, *args):
    if (cmds.window('zbw_mmChangeAttrUI', exists=True)):
        cmds.deleteUI('zbw_mmChangeAttrUI', window=True)
        cmds.windowPref('zbw_mmChangeAttrUI', remove=True)
    window=cmds.window('zbw_mmChangeAttrUI', widthHeight=(400,80), title='zbw_messageMapper_changeAttrName')
    cmds.columnLayout()
    #show old attr name
    cmds.text("old attribute name: " + attr)
    #asks for the new attr name
    cmds.textFieldGrp("zbw_mmChangeAttrTFG", l="new attr name (just attr name)")
    #button to do it (pass along attr, obj)
    cmds.button("zbw_mmChangeAttrB", l="change attr!", c=partial(zbw_mmChangeConnectAttr, base, attr, obj))
    cmds.showWindow(window)
    #force window to size
    cmds.window('zbw_mmChangeAttrUI', e=True, widthHeight = (400,80))
    pass
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def zbw_mmChangeConnectObjUI(base, attr, obj, *args):
    if (cmds.window('zbw_mmChangeObjUI', exists=True)):
        cmds.deleteUI('zbw_mmChangeObjUI', window=True)
        cmds.windowPref('zbw_mmChangeObjUI', remove=True)
    window=cmds.window('zbw_mmChangeObjUI', widthHeight=(400,85), title='zbw_messageMapper_changeObjName')
    cmds.columnLayout()
    #show old attr name
    cmds.text("base attribute name: " + attr)
    cmds.text("old connected obj name: " + obj)
    #asks for the new attr name
    cmds.textFieldButtonGrp("zbw_mmChangeObjTFBG", l="select new obj: ", bl="get", bc=partial(zbw_mmAddTarget, "zbw_mmChangeObjTFBG"))
    #button to do it (pass along attr, obj)
    cmds.button("zbw_mmChangeObjB", l="change obj!", c=partial(zbw_mmChangeConnectObj, base, attr, obj))
    cmds.showWindow(window)
    #force window to size
    cmds.window('zbw_mmChangeObjUI', e=True, widthHeight = (420,85))
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def modelSequenceUI(*args):
    if (cmds.window("modSeq", exists=True)):
        cmds.deleteUI("modSeq")

    widgets["win"] = cmds.window("modSeq", w = 300, h = 220, t = "zbw_modelSequence")
    widgets["mainCLO"] = cmds.columnLayout(w = 300,h = 220)

    cmds.separator(h=10)
    cmds.text("Select ONE object to be duplicated \nThis will duplicate it for frames selected and group", al="left")
    cmds.separator(h=20)

    #textFieldGRP - name of objs
    widgets["sufTFG"] = cmds.textFieldGrp(l="Sequence Suffix:", cw = [(1, 100), (2,200)], cal = [(1, "left"),(2, "right")])
    #radioButtonGrp - timeslider or frame range
    widgets["frmRBG"] = cmds.radioButtonGrp(l="Get Frames From:", nrb=2, sl=2, l1="Time Slider", l2="Frame Range", cw = [(1, 120), (2,80), (3,80)], cal = [(1, "left"),(2, "left")], cc=enableFR)
    #textFieldGrp - framerange (enable)
    widgets["frmRngIFG"] = cmds.intFieldGrp(l="Range:", nf=2, en=True, v1=0, v2 = 9, cw = [(1, 120), (2,80), (3,80)], cal = [(1, "left"),(2, "left")])
    #int = by frame step
    widgets["stepIFG"] = cmds.intFieldGrp(l="Step By (frames):", v1 = 1, cw = [(1, 120), (2,80)], cal = [(1, "left"),(2, "right")])

    cmds.separator(h=30)
    widgets["doBut"] = cmds.button(l="Create duplicates of objects!", w= 300, h=40, bgc = (0,.8, 0), c=getValues)


    cmds.showWindow(widgets["win"])
项目: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)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def follicleUI(*args):
    """UI for the script"""

    if cmds.window("folWin", exists=True):
        cmds.deleteUI("folWin")

    widgets["win"] = cmds.window("folWin", t="zbw_makeFollicle", w=300, h=100)
    widgets["mainCLO"] = cmds.columnLayout()
    # widgets["polyFrame"] = cmds.frameLayout(l="Polygon Vert(s) Follicle")
    # widgets["polyCLO"] = cmds.columnLayout()
    widgets["text"] = cmds.text("Select one or two vertices (2 will get avg position) and run")
    widgets["nameTFG"] = cmds.textFieldGrp(l="FollicleName:", cal=([1, "left"],[2,"left"]), cw=([1,100],[2,200]), tx="follicle")
    cmds.separator(h=10)
    widgets["button"] = cmds.button(w=300, h=50, bgc=(0.6,.8,.6), l="Add follicle to vert(s)", c=getUV)
    # cmds.setParent(widgets["mainCLO"])
    # widgets["nurbsFrame"] = cmds.frameLayout(l="Nurbs select")
    cmds.showWindow(widgets["win"])
    cmds.window(widgets["win"], e=True, w=300, h=100)
#-------could also select edit point????
#-------multiple selection and average uv position? Orrrr option to create multiple UV's, one on each vertex
#-------grab an edge and convert to 2 verts and get average. . .
#-------have option for distributed (select 2 verts and number of follicles, spread that num between the two uv positions)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def getAttr(*args):
    """grabs the selected channel from the selected obj and puts the enum values into the list"""
    #--------here could require a channel of a specific name, then you could do it automagically (check for "follow", "spaces", "space", "ss", etc)
    obj = cmds.textFieldGrp(widgets["objTFG"], q=True, tx=True)
    cmds.select(obj, r=True)
    channels = cmds.channelBox ('mainChannelBox', query=True, selectedMainAttributes=True)
    print channels
    if (channels and (len(channels)==1)):
        if (cmds.attributeQuery(channels[0], node=obj, enum=True)):
            enumValue = cmds.attributeQuery(channels[0], node=obj, listEnum=True)
            values = enumValue[0].split(":")
            for value in values:
                cmds.textScrollList(widgets["spacesTSL"], e=True, append=value)
                #----------create a button for each one???
                #----------or have them be double clicked???
    else:
        cmds.warning("select only the enum space switch channel")
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def dupeSwapUI():
    """UI for script"""

    if cmds.window("dupeWin", exists=True):
        cmds.deleteUI("dupeWin")

    cmds.window("dupeWin", t="zbw_dupeSwap", w=250, h=100)
    cmds.columnLayout("dupeCLO")
    cmds.text("Select the initial object. then select the", al="center", w=250)
    cmds.text("duplicates and press button", al="center", w=250)
    cmds.separator(h=5, style ="single")
    cmds.radioButtonGrp("inputsRBG", l="inputs:", nrb=3, l1="none", l2="connect", l3="duplicate", cw=[(1, 50), (2,47), (3,63), (4,40)], cal=[(1,"left"), (2,"left"), (3,"left"), (4,"left")], sl=1)
    cmds.separator(h=5, style ="single")

    cmds.button("dupeButton", l="Swap Elements", w=250, h=50, bgc=(.6, .8,.6), c=dupeIt)

    cmds.showWindow("dupeWin")
    cmds.window("dupeWin", e=True, w=250, h=100)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def animNoiseUI():
    if cmds.window('animNoiseWin', exists=True):
        cmds.deleteUI('animNoiseWin', window=True)
        cmds.windowPref('animNoiseWin', remove=True)

    widgets["win"] = cmds.window('animNoiseWin', widthHeight=(300,200), title='zbw_animNoise')
    widgets["CLO"] = cmds.columnLayout(cal='center')
    widgets["ampFFG"] = cmds.floatFieldGrp(cal=(1, 'left'), nf=2, l="set Min/Max Amp", v1=-1.0, v2=1.0)
    #add gradient?
    widgets["freqIFG"] = cmds.intFieldGrp(cal=(1,'left'), l='frequency(frames)', v1=5)
    #checkbox for random freq
    widgets["randFreqOnCBG"] = cmds.checkBoxGrp(cal=(1,'left'), cw=(1, 175),l='random frequency on', v1=0, cc=animNoiseRandom)
    widgets["randFreqFFG"] = cmds.floatFieldGrp(l='random freq (frames)', v1=1, en=0)
    #checkbox for avoid keys
    widgets["avoidCBG"] = cmds.checkBoxGrp(cal=(1,'left'), cw=(1, 175),l='buffer existing keys (by freq)', v1=0)
    #radiobutton group for tangents
    #checkbox for timeline range
    widgets["rangeRBG"] = cmds.radioButtonGrp(nrb=2,l="Frame Range:", l1="Timeslider", l2="Frame Range", sl=1, cw=[(1,100),(2,75),(3,75)],cc=enableFrameRange)
    #floatFieldGrp for range
    widgets["frameRangeIFG"] = cmds.intFieldGrp(nf=2, l='start/end frames', v1=1, v2=10, en=0)

    widgets["goBut"] = cmds.button(l='Add Noise', width=300, h=30, bgc=(.6,.8,.6), command=addNoise)

    cmds.showWindow(widgets["win"])
项目: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 ui():
    '''
    User interface for stopwatch
    '''

    with utl.MlUi('ml_stopwatch', 'Stopwatch', width=400, height=175, info='''Press the start button to start recording.
Continue pressing to set marks.
When finished, press the stop button and the report will pop up.''') as win:

        mc.checkBoxGrp('ml_stopwatch_round_checkBox',label='Round to nearest frame', value1=True, annotation='Only whole number frames')

        mc.text('ml_stopwatch_countdown_text', label='Ready...')

        mc.button('ml_stopwatch_main_button', label='Start', height=80)
        _setButtonStart()
        mc.button(label='Stop', command=_stopButton, annotation='Stop the recording.')
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def _startButton(*args):
    '''
    Run when the start button is pressed, gathers args and starts the stopwatch.
    '''

    global STOPWATCH
    _setButtonMark()

    rounded = mc.checkBoxGrp('ml_stopwatch_round_checkBox', query=True, value1=True)

    kwargs = dict()
    kwargs['startFrame'], null = utl.frameRange()

    if rounded:
        kwargs['roundTo'] = 0

    STOPWATCH = Stopwatch(**kwargs)
    STOPWATCH.start()
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def __init__(self):

        super(CopySkinUI, self).__init__('ml_copySkin', 'Copy SkinClusters', width=400, height=180, 
                                         info='''Select a skinned mesh to add to the Source Mesh field below.
Select a destination mesh, or vertices to copy the skin to.
Press the button to copy the skin weights.''')

        self.buildWindow()

        self.srcMeshField = self.selectionField(label='Source Mesh', 
                                                annotation='Select the mesh to be used as the source skin.', 
                                                channel=False, 
                                                text='')

        mc.button(label='Copy Skin', command=self.copySkin, annotation='Copy the Source Skin to selection.')

        self.finish()
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def ui():
    '''
    User interface for convert rotation order
    '''

    with utl.MlUi('ml_convertRotationOrder', 'Convert Rotation Order', width=400, height=140, info='''Select objects to convert and press button for desired rotation order.
Use the "Get Tips" button to see suggestions for a single object on the current frame.''') as win:


        mc.button(label='Get tips for selection', command=loadTips, annotation='')
        mc.scrollField('ml_convertRotationOrder_nodeInfo_scrollField', editable=False, wordWrap=True, height=60)

        mc.rowColumnLayout(numberOfColumns=2, columnWidth=[(1,100), (2,400)], columnAttach=[2,'both',1])
        for each in ROTATE_ORDERS:
            _BUTTON[each] = win.buttonWithPopup(label=each, command=globals()[each], annotation='Convert selected object rotate order to '+each+'.', shelfLabel=each)
            mc.textField('ml_convertRotationOrder_'+each+'_textField', editable=False)

    resetTips()
项目: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')
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def __init__(self, label=None, name=None, command=None, annotation='', shelfLabel='', shelfIcon='render_useBackground', readUI_toArgs={}, **kwargs):
            '''
            The fancy part of this object is the readUI_toArgs argument.
            '''

            self.uiArgDict = readUI_toArgs
            self.name = name
            self.command = command
            self.kwargs = kwargs

            self.annotation = annotation
            self.shelfLabel = shelfLabel
            self.shelfIcon = shelfIcon

            if annotation and not annotation.endswith('.'):
                annotation+='.'

            button = mc.button(label=label, command=self.runCommand, annotation=annotation+' Or right click for more options.')

            mc.popupMenu()
            mc.menuItem(label='Create Shelf Button', command=self.createShelfButton, image=shelfIcon)

            mc.menuItem(label='Create Hotkey',
                        command=self.createHotkey, image='commandButton')
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def colorControlLayout(self, label=''):
        mc.rowLayout( numberOfColumns=4, 
                      columnWidth4=(150, 200, 90, 80), 
                      adjustableColumn=2, 
                      columnAlign=(1, 'right'), 
                      columnAttach=[(1, 'both', 0), 
                                    (2, 'both', 0), 
                                    (3, 'both', 0), 
                                    (4, 'both', 0)] )
        mc.text(label=label)
        colorSlider = mc.colorSliderGrp( label='', adj=2, columnWidth=((1,1),(3,1)))
        mc.button(label='From Selected', 
                  ann='Get the color of the selected object.',
                  command=partial(self.setFromSelected, colorSlider)) 
        mc.button(label='Randomize', 
                  ann='Set a random color.', 
                  command=partial(self.randomizeColors, colorSlider))
        controls = mc.layout(colorSlider, query=True, childArray=True)

        mc.setParent('..')

        return colorSlider
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def quickBreakDownUI():
    winName = 'ml_quickBreakdownWin'
    if mc.window(winName, exists=True):
        mc.deleteUI(winName)

    mc.window(winName, title='ml :: QBD', iconName='Quick Breakdown', width=100, height=500)

    mc.columnLayout(adj=True)

    mc.paneLayout(configuration='vertical2', separatorThickness=1)
    mc.text('<<')
    mc.text('>>')
    mc.setParent('..')

    for v in (10,20,50,80,90,100,110,120,150):
        mc.paneLayout(configuration='vertical2',separatorThickness=1)

        mc.button(label=str(v)+' %', command=partial(weightPrevious,v/100.0))
        mc.button(label=str(v)+' %', command=partial(weightNext,v/100.0))
        mc.setParent('..')

    mc.showWindow(winName)

    mc.window(winName, edit=True, width=100, height=250)
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def dragLeft(self):
        '''This is activated by the left mouse button, and weights to the next or previous keys.'''

        #clamp it
        if self.x < -1:
            self.x = -1
        if self.x > 1:
            self.x = 1

        if self.x > 0:
            self.drawString('>> '+str(int(self.x*100))+' %')
            for curve in self.keySel.curves:
                for i,v,n in zip(self.time[curve],self.value[curve],self.next[curve]):
                    mc.keyframe(curve, time=(i,), valueChange=v+((n-v)*self.x))
        elif self.x <0:
            self.drawString('<< '+str(int(self.x*-100))+' %')
            for curve in self.keySel.curves:
                for i,v,p in zip(self.time[curve],self.value[curve],self.prev[curve]):
                    mc.keyframe(curve, time=(i,), valueChange=v+((p-v)*(-1*self.x)))
项目:PythonForMayaSamples    作者:dgovil    | 项目源码 | 文件源码
def buildUI(self):
        # To start with we create a layout to hold our UI objects
        # A layout is a UI object that lays out its children, in this case in a column
        column = cmds.columnLayout()

        # Now we create a text label to tell a user how to use our UI
        cmds.text(label="Use this slider to set the tween amount")

        # We want to put our slider and a button side by side. This is not possible in a columnLayout, so we use a row
        row = cmds.rowLayout(numberOfColumns=2)

        # We create a slider, set its minimum, maximum and default value.
        # The changeCommand needs to be given a function to call, so we give it our tween function
        # We need to hold on to our slider's name so we can edit it later, so we hold it in a variable
        self.slider = cmds.floatSlider(min=0, max=100, value=50, step=1, changeCommand=tween)

        # Now we make a button to reset our UI, and it calls our reset method
        cmds.button(label="Reset", command=self.reset)

        # Finally we don't want to add anymore to our row layout but want to add it to our column again
        # So we must change the active parent layout
        cmds.setParent(column)

        # We add a button to close our UI
        cmds.button(label="Close", command=self.close)

    # *args will be a new concept for you
    # It basically means I do not know how many arguments I will get, so please put them all inside this one list (tuple) called args
项目:PythonForMayaSamples    作者:dgovil    | 项目源码 | 文件源码
def buildUI(self):
        column = cmds.columnLayout()
        cmds.text(label="Use this slider to set the tween amount")

        cmds.rowLayout(numberOfColumns=2)
        self.slider = cmds.floatSlider(min=0, max=100, value=50, step=1, changeCommand=tweener.tween)
        cmds.button(label="Reset", command=self.reset)

        cmds.setParent(column)
        cmds.button(label="Close", command=self.close)

    # And again, we just need to override the reset method
    # We don't need to define the close, or show methods because it gets those from BaseWindow
项目:PythonForMayaSamples    作者:dgovil    | 项目源码 | 文件源码
def buildUI(self):
        column = cmds.columnLayout()
        cmds.text(label="Use the slider to modify the number of teeth the gear will have")

        cmds.rowLayout(numberOfColumns=4)

        # This label will show the number of teeth we've set
        self.label = cmds.text(label="10")
        # Unlike the tweener, we use an integer slider and we set it to run the modifyGear method as it is dragged
        self.slider = cmds.intSlider(min=5, max=30, value=10, step=1, dragCommand=self.modifyGear)
        cmds.button(label="Make Gear", command=self.makeGear)
        cmds.button(label="Reset", command=self.reset)

        cmds.setParent(column)
        cmds.button(label="Close", command=self.close)
项目:cmt    作者:chadmv    | 项目源码 | 文件源码
def about():
    """Displays the CMT About dialog."""
    name = 'cmt_about'
    if cmds.window(name, exists=True):
        cmds.deleteUI(name, window=True)
    if cmds.windowPref(name, exists=True):
        cmds.windowPref(name, remove=True)
    window = cmds.window(name, title='About CMT', widthHeight=(600, 500), sizeable=False)
    form = cmds.formLayout(nd=100)
    text = cmds.scrollField(editable=False, wordWrap=True, text=cmt.__doc__.strip())
    button = cmds.button(label='Documentation', command='import cmt.menu; cmt.menu.documentation()')
    margin = 8
    cmds.formLayout(form, e=True,
                    attachForm=(
                        (text, 'top', margin),
                        (text, 'right', margin),
                        (text, 'left', margin),
                        (text, 'bottom', 40),
                        (button, 'right', margin),
                        (button, 'left', margin),
                        (button, 'bottom', margin),
                    ),
                    attachControl=(
                        (button, 'top', 2, text)
                    ))
    cmds.showWindow(window)
项目:surume    作者:tm8r    | 项目源码 | 文件源码
def show_ui(self):
        u"""Window???"""
        if cmds.window(self._WINDOW_NAME, exists=True):
            cmds.deleteUI(self._WINDOW_NAME)

        self.window = cmds.window(self._WINDOW_NAME,
                                  t=self._WINDOW_TITLE,
                                  width=340,
                                  maximizeButton=False, minimizeButton=False)

        form = cmds.formLayout()
        field_group = cmds.columnLayout(adj=True, cal="center", rs=self._MARGIN)
        cmds.text(u"""???????????????????????????????
????????????????????????????""", al="left")
        self.text_scroll = cmds.textScrollList(append=self.get_windows(), ams=False, dcc=self.check_execute)
        self.text_field = cmds.textFieldGrp(l=u"????", ad2=2, cl2=["left", "left"], cw=[1, 60])
        cmds.setParent("..")

        button_group = cmds.columnLayout(adj=True, cal="center")
        cmds.button(l="Check", c=self.check_execute)
        cmds.setParent("..")

        cmds.formLayout(form, e=True,
                        attachForm=[(field_group, "top", self._MARGIN),
                                    (field_group, "left", self._MARGIN),
                                    (field_group, "right", self._MARGIN),
                                    (button_group, "bottom", self._MARGIN),
                                    (button_group, "left", self._MARGIN),
                                    (button_group, "right", self._MARGIN)],
                        attachControl=[(button_group, "top", self._MARGIN, field_group)])
        cmds.setParent("..")

        cmds.showWindow(self.window)
项目:surume    作者:tm8r    | 项目源码 | 文件源码
def show(self):
        u"""Window???"""
        self.safe_delete_ui(RecentFileWindow._WINDOW_NAME)

        cmds.window(RecentFileWindow._WINDOW_NAME, title=RecentFileWindow._WINDOW_TITLE)
        cmds.frameLayout(label="RecentFiles",
                         marginWidth=6,
                         marginHeight=6,
                         borderStyle="etchedIn")

        for file_path, file_type in get_recent_files().items():
            cmds.button(label=file_path, c=partial(self._open_file, file_path, file_type))
        cmds.showWindow(RecentFileWindow._WINDOW_NAME)
项目:surume    作者:tm8r    | 项目源码 | 文件源码
def _create_ui(self):
        safe_delete_window(self._WINDOW_NAME)

        win = cmds.window(self._WINDOW_NAME)

        form = cmds.formLayout()
        field_group = cmds.columnLayout(adj=True, cal="center", rs=self._MARGIN)
        cmds.text(u"????????focalLength?????Unity?FOV?????????????", al="left")
        self.text_scroll = cmds.textScrollList(append=self._get_cameras(), ams=False, dcc=self._select)
        self.text_field = cmds.textFieldGrp(l=u"FOV", ad2=2, cl2=["left", "left"], cw=[1, 60])
        self.result_field = cmds.textFieldGrp(l=u"Result", ad2=2, cl2=["left", "left"], cw=[1, 60])
        cmds.setParent("..")

        button_group = cmds.columnLayout(adj=True, cal="center")
        cmds.button(l="Apply", c=self._apply)
        cmds.setParent("..")

        cmds.formLayout(form, e=True,
                        attachForm=[(field_group, "top", self._MARGIN),
                                    (field_group, "left", self._MARGIN),
                                    (field_group, "right", self._MARGIN),
                                    (button_group, "bottom", self._MARGIN),
                                    (button_group, "left", self._MARGIN),
                                    (button_group, "right", self._MARGIN)],
                        attachControl=[(button_group, "top", self._MARGIN, field_group)])
        cmds.setParent("..")

        cmds.showWindow(win)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def enableRange(self, *args):
        """toggles the frame range option on/off depending on what's selected in the range radio grp"""
        #get the value of the radio button grp
        sel = cmds.radioButtonGrp(self.widgets["timeRBG"], q=True, sl=True)

        if sel == 3:
            cmds.floatFieldGrp(self.widgets["rangeFFG"], e=True, en=True)
        else:
            cmds.floatFieldGrp(self.widgets["rangeFFG"], e=True, en=False)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def curveJntRigUI(*args):
    if cmds.window("crvRigJntWin", exists=True):
        cmds.deleteUI("crvRigJntWin")

    w, h= 400, 300

    widgets["win"] = cmds.window("crvRigJntWin", t="zbw_curveJntRig", w=w,h=h)
    widgets["mainCLO"] = cmds.columnLayout()


    widgets["numCtrlIFG"] = cmds.intFieldGrp(l="Number of Ctrls:", cal=[(1,"left"), (2,"left")], cw=[(1,120), (2,50)], v1=5)
    widgets["nameTFG"] = cmds.textFieldGrp(l="Rig Name (i.e. lfEye):", cal=[(1,"left"), (2,"left"), (3,"left")], cw=[(1,120), (2,280), (3,30)], tx="eye")
    widgets["cntrPivTFBG"] = cmds.textFieldButtonGrp(l="Center pivot object:", bl="<<<", cal=[(1,"left"), (2,"left"), (3,"left")], cw=[(1,120), (2,280), (3,30)], bc=partial(populateCrvField, "cntrPivTFBG"), cc=partial(secondFill, "center"), tx="centerLoc")
    widgets["upLocTFBG"] = cmds.textFieldButtonGrp(l="Aim up object:", bl="<<<", cal=[(1,"left"), (2,"left"), (3,"left")], cw=[(1,120), (2,280), (3,30)], bc=partial(populateCrvField, "upLocTFBG"), cc=partial(secondFill, "up"), tx="upLoc")
    cmds.separator(h=10)

    widgets["upCrvTFBG"] = cmds.textFieldButtonGrp(l="First Curve", bl="<<<", cal=[(1,"left"), (2,"left"), (3,"left")], cw=[(1,120), (2,280), (3,30)], bc=partial(populateCrvField, "upCrvTFBG"),tx="topCrv")
    widgets["upNameTFG"] = cmds.textFieldGrp(l="1st Suffix (i.e.'Top')", cal=[(1,"left"), (2,"left")], cw=[(1,120), (2,280)], tx="Top")
    cmds.separator(h=10)

    widgets["secondCBG"] = cmds.checkBoxGrp(l="Create Second Curve?", ncb=1, v1=0, cal=[(1,"left"), (2,"left")], cc=toggleSecond, en=True)
    widgets["downCrvTFBG"] = cmds.textFieldButtonGrp(l="Second Curve", bl="<<<", cal=[(1,"left"), (2,"left"), (3,"left")], en=False, cw=[(1,120), (2,280), (3,30)], bc=partial(populateCrvField, "downCrvTFBG"), tx="downCrv")
    widgets["downNameTFG"] = cmds.textFieldGrp(l="2nd Suffix (i.e. 'Dwn')", cal=[(1,"left"), (2,"left")], cw=[(1,120), (2,280)], en=False, tx="Dwn")
    widgets["cntrPiv2TFBG"] = cmds.textFieldButtonGrp(l="Center pivot object:", bl="<<<", cal=[(1,"left"), (2,"left"), (3,"left")], cw=[(1,120), (2,280), (3,30)], bc=partial(populateCrvField, "cntrPivTFBG"), en=False, tx="centerLoc")
    widgets["upLoc2TFBG"] = cmds.textFieldButtonGrp(l="Aim up object:", bl="<<<", cal=[(1,"left"), (2,"left"), (3,"left")], cw=[(1,120), (2,280), (3,30)], bc=partial(populateCrvField, "upLoc2TFBG"), en=False, tx="upLoc")
    cmds.separator(h=10)

    widgets["execBut"] = cmds.button(l="create base rig!", w=w, c=passToExecute)
    widgets["cnctBut"] = cmds.button(l="connect ctrls to jnts", w=w, c=connectProxies)
    widgets["closeBut"] = cmds.button(l="setup smart close", w=w, c=smartClose)

    cmds.separator(h=10)

    # widgets["scCBG"] = cmds.checkBoxGrp(l="Set up smart close?", ncb=1, v1=0, cal=[(1,"left"), (2,"left")], en=True)


    cmds.window(widgets["win"], e=True, w=5, h=5, resizeToFitChildren=True, sizeable=True)
    cmds.showWindow(widgets["win"])
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def toggleSecond(*args):
    state = cmds.checkBoxGrp(widgets["secondCBG"], q=True, v1=True)
    if state:
        cmds.textFieldButtonGrp(widgets["downCrvTFBG"], e=True, en=True)
        cmds.textFieldButtonGrp(widgets['cntrPiv2TFBG'], e=True, en=True)
        cmds.textFieldButtonGrp(widgets['upLoc2TFBG'], e=True, en=True)
        cmds.textFieldGrp(widgets["downNameTFG"], e=True, en=True)
        cmds.button(widgets["closeBut"], e=True, en=True)       
    else:
        cmds.textFieldButtonGrp(widgets['downCrvTFBG'], e=True, en=False)
        cmds.textFieldButtonGrp(widgets['cntrPiv2TFBG'], e=True, en=False)
        cmds.textFieldButtonGrp(widgets['upLoc2TFBG'], e=True, en=False)
        cmds.textFieldGrp(widgets["downNameTFG"], e=True, en=False)     
        cmds.button(widgets["closeBut"], e=True, en=False)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def setPlanes(*args):
    """sets clipping planes for cameras based on float fields in UI. Depending on radio button, it will either do all camera or only selected"""

    all = cmds.radioButtonGrp("camRBG", q=True, sl=True)
    far = cmds.floatFieldGrp("farFFG", q=True, v1=True)
    near = cmds.floatFieldGrp("nearFFG", q=True, v1=True)

    cams = []
    if all==1:
        cams.extend(cmds.ls(type="camera"))
    elif all==2:
        transf = cmds.ls(sl=True, type="transform")
        for each in transf:
            shape = cmds.listRelatives(each, s=True)
            if shape:
                if cmds.objectType(shape) == "camera":
                    cams.extend(shape)
    #for each, set shape.farClipPlane 100000
    if cams:
        print cams
        for cam in cams:
            try:
                cmds.setAttr("%s.farClipPlane"%cam, far)
                cmds.setAttr("%s.nearClipPlane"%cam, near)

            except:
                cmds.warning("Couldn't change the farClipPlane of %s"%cam)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def spaceBufferUI(*args):
    if cmds.window("spaceBufferWin", exists=True):
        cmds.deleteUI("spaceBufferWin")

    widgets["win"] = cmds.window("spaceBufferWin", rtf=True, wh=(200, 20))
    widgets["mainCLO"] = cmds.columnLayout(w=200)

    widgets["jntCreateBut"] = cmds.button(l="Create Joint/Grps at Selection!", w=200, h=30, bgc=(.6, .8,.6), c=createJointFromObj)
    widgets["makeBuffer"] = cmds.button(l="Create Space Buffer!", w=200, h=30, bgc=(.4, .6, .8), c=createSpaceBuffers)

    cmds.window(widgets["win"], e=True, wh=(5, 5), rtf=True)
    cmds.showWindow(widgets["win"])
项目: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 huddleUI(*args):
    if cmds.window("hudWin", exists=True):
        cmds.deleteUI("hudWin")

    widgets["win"] = cmds.window("hudWin", t="zbw_huddle", w=350, h=100, rtf=True)
    widgets["CLO"] = cmds.columnLayout()
    widgets["slider"] = cmds.floatSliderGrp(min=0, max=2, f=True, label="Factor:", cal=([1, "left"], [2,"left"], [3,
                                                                                                                  "left"]), cw=([1,50],[2,50],[3,225]), pre=3, v=1.0)
    cmds.separator(h=20)
    widgets["button"] = cmds.button(l="Move objects aroudnd first selected", w=350, h=30, bgc=(.6,.8, .6), c=huddleExec)

    cmds.window(widgets["win"], e=True, w=5, h=5, rtf=True)
    cmds.showWindow(widgets["win"])
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def grabSel(*args):

    del selection[:]   # empty the variable
    sel = cmds.ls(sl=True, fl=True)
    for obj in sel:
        selection.append(obj)

    if selection:
        cmds.button(widgets["checkBut"], e=True, bgc = (.8, .7, .5),  en = True)
    else:
        cmds.button(widgets["checkBut"], e=True, bgc = (.5, .5, .5), en=False)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def extendUI(*args):
    """UI for the script"""
    #UI
    if cmds.window("curbWin", exists=True):
        cmds.deleteUI("curbWin")

    cmds.window("curbWin", t="zbw_polyExtender", w=200, h=200)
    cmds.columnLayout("colLO")
    cmds.frameLayout("topFrame", l="Covert Edge", cll=True, bgc=(.2,.2,.2))
    cmds.text("Select poly edge to convert")
    cmds.button("convertBut", l="Convert!", w=200, h=30, bgc=(.8, .8,.6), c=convertEdge)
    cmds.separator(h=5)

    cmds.setParent("colLO")

    cmds.frameLayout("midFrame", l="Create Poly", cll=True, bgc=(.2,.2,.2))
    cmds.text("Select curve")
    cmds.separator(h=5)
    cmds.textFieldGrp("name", l="Name", w=200, cw=[(1,30), (2,170)], tx="newPoly")
    cmds.checkBox("curbCB", l="Positive Direction", v=True)
    # cmds.checkBox("bumpCB", l="Add vertical hump?", v=True)
    cmds.floatFieldGrp("curbFFG", l="Curb Width", cal=((1, "left"),(2,"left")), cw=([1,75],[2,50]), v1=10)
    cmds.intFieldGrp("UDivIFG", l="Width Subdivisions", cal=((1, "left"),(2,"left")), cw=([1,75],[2,50]), v1=1)
    cmds.intFieldGrp("VDivIFG", l="Length Subdivisions", cal=((1, "left"),(2,"left")), cw=([1,75],[2,50]), v1=1)
    cmds.checkBox("polyHistory", l="Keep history on final poly?", v=False)
    cmds.checkBox("history", l="Keep history objects?", v=True, cc=enableHistory)

    cmds.separator(h=5)
    cmds.button("curbBut", l="Create Curb", h=40, w=200, bgc=(.6, .8, .6), c=extendPoly)

    cmds.showWindow("curbWin")
    cmds.window("curbWin", e=True, h=150, w=200)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def zbw_playblast():
    pass
#hide all but geo, bckgrnd color, where to save, size, camera, etc
#more of a view/visibility thing with some playblast options added (revert back to previous view?) could have toggle now button AND "when PB" check box to set/reset view when PBing


#random anim shifting
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def zbw_offsetAnim(*args):
    """creates offset from first obj sel to last based on the entered offset value"""
    def zbw_runOffsetAnim(*args):
        #get frame range!!!!!!
        #get selection, check that they are tranforms
        sel = cmds.ls(sl=True,type="transform")
        selSize = int(len(sel))
        #for each selection mult the index by the offset value
        for i in range(0,selSize):
            obj = sel[i]
            offsetRaw = cmds.intFieldGrp('zbw_offsetValue', q=True, v=True)
            offset = offsetRaw[0]
            multFactor = i * offset
            #shift the entire anim curve by the offset mult value
            cmds.keyframe(obj, edit=True,relative=True,timeChange=multFactor,time=(1,24))

    #create UI, get offset value, frame range or all anim
    if (cmds.window('zbw_offsetAnimUI', exists=True)):
        cmds.deleteUI('zbw_offsetAnimUI', window=True)
        cmds.windowPref('zbw_offsetAnimUI', remove=True)
    window=cmds.window('zbw_offsetAnimUI', widthHeight=(350,200), title='zbw_offsetAnim')
    cmds.columnLayout(cal='center')
    cmds.intFieldGrp('zbw_offsetValue', cal=(1,'left'), label='frequency(frames)', value1=5)
    #CREATE FRAME RANGE AREA (WHICH FRAMES ARE WE DOING?)
    #WHEN THAT HAPPENS, WHAT DO WE DO WITH THE FRAMES AFTER THAT? (PROBABLY NOTHING. . . LET USER WORRY ABOUT IT)
    #checkbox for random freq (to give a random amount to offset each object)
    #cmds.checkBoxGrp('zbw_animNoiseRandom', cal=(1,'left'), cw=(1, 175),label='random frequency on', value1=0, cc=zbw_animNoiseRandom)
    cmds.button('zbw_offsetAnimGo', label='offset!', width=75, command=zbw_runOffsetAnim)

    cmds.showWindow(window)

#clean up keys
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def control(type="none", *args):
    """gets teh name from the button pushed and the axis from the radio button group"""
    axisRaw = cmds.radioButtonGrp(widgets["ctrlAxisRBG"], q=True, sl=True)
    if axisRaw == 1:
        axis = "x"
    if axisRaw == 2:
        axis = "y"
    if axisRaw == 3:
        axis = "z"              

    rig.createControl(name = "Ctrl", type = type, axis = axis, color = "yellow")
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def set_parent_object(tfbg, *args):
    """
    gets selection and puts it in the given text field button grp
    :param tfbg: the key for widget dict for the textFieldButtonGrp
    :param args:
    :return:
    """
    ctrl = None
    sel = cmds.ls(sl=True, type="transform", l=True)
    if sel and (len(sel) == 1):
        ctrl = sel[0]

    if ctrl:
        cmds.textFieldButtonGrp(widgets[tfbg], e=True, tx=ctrl)
项目: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')
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def import_anim_UI():
    width = 400

    if cmds.window("impAnimWin", exists=True):
        cmds.deleteUI("impAnimWin")

    widgets["win"] = cmds.window("impAnimWin", t="Import anim files", w=width, h=400, rtf=True)
    # widgets["clo"] = cmds.columnLayout()
    widgets["mainTLO"] = cmds.tabLayout()
    widgets["impCLO"] = cmds.columnLayout("Import Anim")
    cmds.text("1. choose the folder where your anim clips live,\n2. select the objs in scene to apply to\n3. 'random' will start anim in frame range\n4. select anim clips from list to randomly apply to objs\n5. press button to apply",al="left")
    cmds.separator(h=10)    
    widgets["impPathTFG"] = cmds.textFieldButtonGrp(l="Anim Path:", bl="<<<", cal = ([1, "left"], [2, "left"], [3, "right"]), cw=([1, 75], [2, 275], [3, 40]), bc=partial(get_path, "import", "impPathTFG"), cc=populate_tsl)
    widgets["randRBG"] = cmds.radioButtonGrp(l="Insert Placement:", nrb=2, l1="Random Start", l2="At current Frame", sl=1, cal=([1, "left"], [2,"left"], [3,"left"]), cw=([1,100], [2, 100], [3, 100]), cc=partial(toggle_enable, "randRBG", "rangeIFG"))
    widgets["rangeIFG"] = cmds.intFieldGrp(l="Random Start Range:", nf=2, v1=0, v2=100, cw=([1, 120], [2, 50], [3, 50]), cal=([1, "left"], [2, "left"], [3, "left"]))
    widgets["delCBG"] = cmds.checkBoxGrp(l="Delete subsequent keys?", v1=True, cal=([1, "left"], [2, "left"]), cw=([1, 130], [2, 20]))
    cmds.separator(h=10)    
    widgets["animTSL"] = cmds.textScrollList(w=400, h=150, allowMultiSelection=True)
    cmds.separator(h=10)    
    widgets["importBut"] = cmds.button(l="Import random anim from selection", h=40, w=width, bgc=(.5, .8, .5), c=import_animation)

    cmds.setParent(widgets["mainTLO"])
    widgets["expCLO"] = cmds.columnLayout("Export Anim")
    cmds.text("1. Select the obj 2. choose a path and name the anim\n3. choose range and hierarchy 4. press button!", al="left")
    cmds.separator(h=10)
    widgets["expPathTFG"] = cmds.textFieldButtonGrp(l="Export Path:", bl="<<<", cal = ([1, "left"], [2, "left"], [3, "right"]), cw=([1, 75], [2, 275], [3, 40]), bc=partial(get_path, "export", "expPathTFG"))
    widgets["nameTFG"] = cmds.textFieldGrp(l="Animation Name:", cw=([1, 100], [2, 250]), cal=([1, "left"], [2, "left"]))    
    widgets["selRBG"] = cmds.radioButtonGrp(l="Hierarchy:", nrb=2, l1="Selection Only", l2="Below", sl=2, cal=([1, "left"], [2,"left"], [3,"left"]), cw=([1,75], [2, 100], [3, 100]))
    widgets["expRngRBG"] = cmds.radioButtonGrp(l="Time Range:", nrb=2, l1="Start_End", l2="All", sl=2, cal=([1, "left"], [2,"left"], [3,"left"]), cw=([1,75], [2, 100], [3, 100]), cc=partial(toggle_enable, "expRngRBG", "expRngIFG"))
    widgets["expRngIFG"] = cmds.intFieldGrp(nf=2, en=False, l="Start_End", v1=1, v2=10, cal=([1, "left"], [2,"left"], [3,"left"]), cw=([1,75], [2, 100], [3, 100]))
    cmds.separator(h=10)    
    widgets["exportBut"] = cmds.button(l="Export anim from selection", h=40, w=width, bgc=(.5, .8, .5), c=export_animation)

    cmds.window(widgets["win"], e=True, w=5, h=5, rtf=True)
    cmds.showWindow(widgets["win"])
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def toggle_enable(currWidget, toggleWidget, *args):
    """toggles on/off the enabled attr of int field toggleWidget. Currwidget is the radio button grp we look at to get state"""
    onOff = cmds.radioButtonGrp(widgets[currWidget], q=True, sl=True)
    if onOff == 1:
        cmds.intFieldGrp(widgets[toggleWidget], e=True, en=1)
    else:
        cmds.intFieldGrp(widgets[toggleWidget], e=True, en=0)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def wireRigUI (*args):
    if cmds.window("wireRigWin", exists = True):
        cmds.deleteUI("wireRigWin")

    widgets["win"] = cmds.window("wireRigWin", t="zbw_wireRig", w=300, h=250)
    widgets["mainCLO"] = cmds.columnLayout()

    widgets["topFLO"] = cmds.frameLayout(l="Convert Poly Edges",cll=True, cl=True)
    widgets["topCLO"] = cmds.columnLayout()
    widgets["convertBut"] = cmds.button(l="convert selected poly edge to curve", w=300, bgc = (.8,.8,0), c=convertEdge)
    cmds.separator(h=20, style="single")
    widgets["reverseBut"] = cmds.button(l="reverse direction of selected curve", w=300, bgc = (.8,.5,0), c=reverseCrv)

    cmds.setParent(widgets["mainCLO"])
    widgets["botFLO"] = cmds.frameLayout(l="Create Wire Rig", cll=True)
    widgets["botCLO"] = cmds.columnLayout()
    widgets["numCtrlIFG"] = cmds.intFieldGrp(l="Number of Ctrls:", v1=5, cal=[(1, "left"), (2, "left")], cw=[(1, 150),(3, 75)])
    widgets["hierCBG"] = cmds.checkBoxGrp(ncb=1, l1 = "Put Ctrls in hierarchy?", v1=True, en=True)
    widgets["nameTFG"] = cmds.textFieldGrp(l="Wire Rig Name:", w=300, tx="wireCtrl1", cal=[(1, "left")])
    widgets["scaleFFG"] = cmds.floatFieldGrp(l="Control scale:", v1=1.0, cal=[(1, "left"), (2, "left")], cw=[(1, 150),(3, 75)])

    cmds.separator(h=30, style="single")
    widgets["textText"] = cmds.text("Select geo, then curve, then button below", al="center")
    widgets["rigBut"] = cmds.button(l="Create Wire Rig", w= 300, h=40, bgc= (0, .5, 0), c=createWireDef)

    cmds.showWindow(widgets["win"])

#option to pull curve from edges
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def transformBufferUI(*args):
    if cmds.window("tbWin", exists=True):
        cmds.deleteUI("tbWin")

    widgets["win"] = cmds.window("tbWin", t="zbw_tranformBuffer", s=False, w=200)
    widgets["mainCLO"] = cmds.columnLayout(w=200)

######## ------ checkbox to enable/disable these. . . .

    widgets["trnFFG"] = cmds.floatFieldGrp(l="Trns: ", nf=3, cw=[(1, 40), (2, 50), (3, 50), (4,50)], cal = [(1, "left"), (2, "left"), (3, "left"), (4,"left")])
    widgets["rotFFG"] = cmds.floatFieldGrp(l="Rot: ", nf=3, cw=[(1, 40), (2, 50), (3, 50), (4,50)], cal = [(1, "left"), (2, "left"), (3, "left"), (4,"left")])
    widgets["sclFFG"] = cmds.floatFieldGrp(l="Scl: ", nf=3, cw=[(1,40), (2, 50), (3, 50), (4,50)],cal = [(1, "left"), (2, "left"), (3, "left"), (4,"left")])
    cmds.separator(h=10)
    widgets["transCBG"] = cmds.checkBoxGrp(ncb=3, la3 = ("Trns", "Rot", "Scl"), va3=(1, 1, 1), cal=[(1, "left"), (2, "left"), (3, "left")], cw = [(1, 50), (2, 50), (3, 50)])
    cmds.separator(h=10)
    widgets["butFLO"] = cmds.formLayout(w=200, h=50)
    widgets["getBut"] = cmds.button(l="Catch\nValues", bgc = (.8, .5, .5), h=50, w=100, c=getValues)
    widgets["setBut"] = cmds.button(l="Set\nValues", bgc = (.5, .8,.5), h=50, w=100, c=setValues)

    cmds.formLayout(widgets["butFLO"], e=True, af = [
        (widgets["getBut"], "top", 0),
        (widgets["getBut"], "left", 0),
        (widgets["setBut"], "top", 0),
        (widgets["setBut"], "left", 100)
        ])
    cmds.window(widgets["win"], e=True, w=200, h=100)
    cmds.showWindow(widgets["win"])