python类setParent()的实例源码

startup.py 文件源码 项目:surume 作者: tm8r 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def initialize_plugin():
    cmds.setParent("MayaWindow")
    cmds.menu("surume", l=u"surume", to=True)
    cmds.menuItem(l=u"Check Layout",
                  c=CheckLayoutWindow.main)
    cmds.menuItem(l=u"Convert Color Code",
                  c=ConvertColorCode.show_ui)
    cmds.setParent("..")
convert_color_code.py 文件源码 项目:surume 作者: tm8r 项目源码 文件源码 阅读 47 收藏 0 点赞 0 评论 0
def _create_ui(self):
        u"""UI???"""
        safe_delete_window(self._WINDOW_NAME)
        win = cmds.window(self._WINDOW_NAME, t="Convert Color Code", mb=True, w=480, h=128)
        cmds.menu(l="Option")
        cmds.menuItem(l="ColorEditor", c=self.get_color_from_editor)
        cmds.columnLayout(adj=True, rs=2)
        self.color_code_field = cmds.textFieldButtonGrp(l="Color code", bl="Convert", bc=self._convert)
        self.decimal_point_field = cmds.intFieldGrp(l="Decimal point", nf=1, v1=2)
        self.result_field = cmds.textFieldGrp(l="Result")

        cmds.setParent("..")

        cmds.columnLayout(adj=True)
        self.color_preview = cmds.text(l="", h=24)
        cmds.setParent("..")
        cmds.showWindow(win)
burnin.py 文件源码 项目:mayakit 作者: danbradham 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def array_builder(self, attrName):
        frame = attrName.split('.')[-1]

        if pm.frameLayout(frame, exists=True):
            pm.deleteUI(frame)

        pm.frameLayout(frame, collapse=False)
        pm.rowLayout(numberOfColumns=2)
        acmd = partial(self.add_multiInstance, attrName)
        rcmd = partial(self.rem_multiInstance, attrName)
        pm.button(label='New Item', command=acmd)
        pm.button(label='Remove Last Item', command=rcmd)
        pm.setParent('..')

        array_length = pm.getAttr(attrName, s=True)
        for i in xrange(array_length):
            index_attr = '{}[{}]'.format(attrName, i)
            pm.attrControlGrp(
                attribute=index_attr,
                label=index_attr.split('.')[-1])
        pm.setParent('..')
interop.py 文件源码 项目:P4VFX 作者: TomMinor 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def initializeMenu(self, entries):
        try:
            # gMainWindow = MayaInterop.main_parent_window()
            gMainWindow = maya.mel.eval('$temp1=$gMainWindow')
        except RuntimeError as e:
            print e
            print 'Are you running in Batch Python?'
            gMainWindow = None

        try:
            print 'Initialising menu...'
            self.perforceMenu = cmds.menu("PerforceMenu", parent=gMainWindow, tearOff=True, label='Perforce')
            cmds.setParent(self.perforceMenu, menu=True)
        except RuntimeError as e:
            print 'Maya error while trying to create menu:',
            print e
interop.py 文件源码 项目:P4VFX 作者: TomMinor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def initializeMenu(self, entries):
        try:
            # gMainWindow = MayaInterop.main_parent_window()
            gMainWindow = maya.mel.eval('$temp1=$gMainWindow')
        except RuntimeError as e:
            print e
            print 'Are you running in Batch Python?'
            gMainWindow = None

        try:
            print 'Initialising menu...'
            self.perforceMenu = cmds.menu("PerforceMenu", parent=gMainWindow, tearOff=True, label='Perforce')
            cmds.setParent(self.perforceMenu, menu=True)
        except RuntimeError as e:
            print 'Maya error while trying to create menu:',
            print e
zbw_makeFollicle.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)
ml_puppet.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def attributeMenuItem(node, attr):

    plug = node+'.'+attr
    niceName = mc.attributeName(plug, nice=True)

    #get attribute type
    attrType = mc.getAttr(plug, type=True)

    if attrType == 'enum':
        listEnum = mc.attributeQuery(attr, node=node, listEnum=True)[0]
        if not ':' in listEnum:
            return
        listEnum = listEnum.split(':')
        mc.menuItem(label=niceName, subMenu=True)
        for value, label in enumerate(listEnum):
            mc.menuItem(label=label, command=partial(mc.setAttr, plug, value))
        mc.setParent('..', menu=True)
    elif attrType == 'bool':
        value = mc.getAttr(plug)
        label = 'Toggle '+ niceName
        mc.menuItem(label=label, command=partial(mc.setAttr, plug, not value))
ml_centerOfMass.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def buildMainLayout(self):
        '''Build the main part of the ui
        '''
        #self.cbBakeOnes = mc.checkBoxGrp(label='Bake on Ones', 
                                         #annotation='Bake every frame. If deselected, the tool will preserve keytimes.')

        #mc.separator()
        self.ButtonWithPopup(label='Create Live COM', 
                             command=createCenterOfMass, 
                             annotation='Create a constrained COM node based on selected Root Control.')

        mc.paneLayout(configuration='vertical2',separatorThickness=1)
        self.ButtonWithPopup(label='Transfer Root Anim to COM', 
                             command=bakeCenterOfMass, 
                             annotation='Bake out the Root animation to the COM node.')
        self.ButtonWithPopup(label='Transfer COM back to Root', 
                             command=bakeRoot, 
                             annotation='A previously baked COM will be baked back to its corresponding Root.')
        mc.setParent('..')
ml_utilities.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def finish(self):
        '''
        Finalize the UI
        '''

        mc.setParent(self.form)

        frame = mc.frameLayout(labelVisible=False)
        mc.helpLine()

        mc.formLayout( self.form, edit=True,
                       attachForm=((self.column, 'top', 0), (self.column, 'left', 0),
                                   (self.column, 'right', 0), (frame, 'left', 0),
                                   (frame, 'bottom', 0), (frame, 'right', 0)),
                       attachNone=((self.column, 'bottom'), (frame, 'top')) )

        mc.showWindow(self.name)
        mc.window(self.name, edit=True, width=self.width, height=self.height)
ml_breakdown.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
tweener.py 文件源码 项目:PythonForMayaSamples 作者: dgovil 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
reusableUI.py 文件源码 项目:PythonForMayaSamples 作者: dgovil 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
reusableUI.py 文件源码 项目:PythonForMayaSamples 作者: dgovil 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
NinjaRipperMayaImportTools.py 文件源码 项目:NinjaRipperMayaImportTools 作者: T-Maxxx 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def createMenu():
    cmds.setParent(mel.eval("$temp1=$gMainWindow"))

    if cmds.control('NR_ImportMenu', exists=True):
        cmds.deleteUI('NR_ImportMenu', menu=True)

    menu = cmds.menu('NR_ImportMenu', label='Ninja Ripper', tearOff=True)

    cmds.menuItem(
        label='Import RIP v4', c="cmds.showWindow('NR_ImportWindow')"
    )

    cmds.menuItem(
        label="Reload Script", c="reload(NinjaRipperMayaImportTools)"
    )
check_layout.py 文件源码 项目:surume 作者: tm8r 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
fov_converter.py 文件源码 项目:surume 作者: tm8r 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
utils.py 文件源码 项目:pyshell 作者: oglops 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def add_toolbox_menu():
    gridLayout = 'hj_gridLayout'
    if mc.gridLayout(gridLayout, q=1, ex=1):
        mc.deleteUI(gridLayout)

    mc.setParent('flowLayout2')
    size=36
    mc.gridLayout(gridLayout, nc=1, cwh=[size, size])
    mc.setParent(gridLayout)

    global_vars = inspect.getouterframes(
        inspect.currentframe())[-1][0].f_globals
    # global_vars = globals()
    mc.shelfButton(
        i='play.png', c=lambda *x: __import__("pyshell").main(global_vars),w=40)
SEToolsPlugin.py 文件源码 项目:SETools 作者: dtzxporter 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def CreateMenu():
    # Set the diplay's parent
    cmds.setParent(mel.eval("$temp1=$gMainWindow"))

    # Purge old one
    DeleteMenu()

    # Make new menu
    menu = cmds.menu(MENU_DATA['menu'][0], label=MENU_DATA["menu"][1], tearOff=True)    # Recreate the base
    # Add children
    cmds.menuItem(label="Import <- SEAnim", command=lambda x:ImportSEAnim(), annotation="Imports a SEAnim, resetting the scene first")
    cmds.menuItem(label="Import and Blend <- SEAnim", command=lambda x:ImportMergeSEAnim(), annotation="Imports a SEAnim without resetting the scene (Blending the animations together)")
    cmds.menuItem(divider=True)
    cmds.menuItem(label="Export -> SEAnim", command=lambda x:ExportEntireSceneAnim(), annotation="Exports all joints, or all selected joints to a SEAnim file")
    cmds.menuItem(divider=True)
    cmds.menuItem(label="Clean Namespaces", command=lambda x:NamespaceClean(), annotation="Removes all namespaces from the scene")
    cmds.menuItem(label="Place Notetrack", command=lambda x:PlaceNote(), annotation="Places a notetrack at the current scene time")
    cmds.menuItem(label="Select All Joints", command=lambda x:SelectAllJoints(), annotation="Selects all joints")
    cmds.menuItem(label="Select Keyed Joints", command=lambda x:SelectKeyframes(), annotation="Selects keyed joints, this feature does not work with conversion rigs")
    cmds.menuItem(divider=True)
    cmds.menuItem(label="Reset Scene", command=lambda x:ResetSceneAnim(), annotation="Manually reset the scene to bind position")
    cmds.menuItem(label="Clear Curves", command=lambda x:PurgeAllKeyframes(), annotation="Manually delete all cached keyframe curves in the scene")
    cmds.menuItem(divider=True)
    game_menu = cmds.menuItem(label="Game Specific Tools", subMenu=True)    # Make game specific submenu
    cmds.menuItem(label="Call of Duty", subMenu=True)
    cmds.menuItem(label="Attach Weapon to Rig", command=lambda x:WeaponBinder(), annotation="Attatches the weapon to the viewhands, does not work properly with conversion rigs")
    cmds.setParent(game_menu, menu=True)    # Close out menu (Call of Duty)
    cmds.setParent(menu, menu=True)         # Close out menu (Game tools)
    cmds.menuItem(divider=True)
    cmds.menuItem(label="Reload Plugin", command=lambda x:ReloadMayaPlugin(), annotation="Attempts to reload the plugin")
    cmds.menuItem(label="About", command=lambda x:AboutWindow())

# Reloads a maya plugin
burnin.py 文件源码 项目:mayakit 作者: danbradham 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def view_menu_callback(*args):
    '''Callback for global mel proc postModelEditorViewMenuCmd'''

    menu_path = args[0]
    model_panel = args[1]
    menu_item_path = model_panel + 'burnin'

    burnin_enabled = False
    viewport_burnin = get_viewport_burnin()
    if viewport_burnin:
        burnin_enabled = cmds.getAttr(viewport_burnin + '.v')

    cmds.setParent(menu_path, m=True)
    if not cmds.menuItem(menu_item_path, exists=True):
        cmds.menuItem(d=True)
        cmds.menuItem(
            menu_item_path,
            label='Burn In',
            checkBox=burnin_enabled,
            command=toggle_burnin
        )
    else:
        cmds.menuItem(
            menu_item_path,
            edit=True,
            checkBox=burnin_enabled
        )
interop.py 文件源码 项目:P4VFX 作者: TomMinor 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def addMenuSubmenu(self, label, icon, entries):
        try:
            cmds.menuItem(subMenu=True, tearOff=False, label=label, image=icon)
        except RuntimeError as e:
            print 'Maya error while trying to create submenu:',
            print e

        self.fillMenu(entries)

        try:
            cmds.setParent('..', menu=True )
        except RuntimeError as e:
            print 'Maya error while trying to change menu parent:',
            print e
interop.py 文件源码 项目:P4VFX 作者: TomMinor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def addMenuSubmenu(self, label, icon, entries):
        try:
            cmds.menuItem(subMenu=True, tearOff=False, label=label, image=icon)
        except RuntimeError as e:
            print 'Maya error while trying to create submenu:',
            print e

        self.fillMenu(entries)

        try:
            cmds.setParent('..', menu=True )
        except RuntimeError as e:
            print 'Maya error while trying to change menu parent:',
            print e
zbw_spaceMatch.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def spaceMatchUI():
    if (cmds.window("spaceMatchWin", exists=True)):
        cmds.deleteUI("spaceMatchWin", window=True)
    #create window
    widgets["window"] = cmds.window("spaceMatchWin", title="Space Matcher", w=250, h=300)

    #create top frame
    widgets["topFrame"] = cmds.frameLayout(l="Object/Attr Selection", w=250, li=70, bgc=(0,0,0))
    widgets["objCLO"] = cmds.columnLayout()

    #create top controls
    widgets["objTFG"] = cmds.textFieldGrp(l="Selected Obj", cw=([1,70],[2,175]), cal=([1,"left"], [2,"left"]), cc=clearList)
    widgets["matchObjButton"] = cmds.button(l="Select Control Object", w=250, bgc=(.8,.8,.8), c = getObj)

#   #or we could assume the obj has a "follow" enum attr. . . .
#     widgets["attrTFG"] = cmds.textFieldGrp(l="Selected Attr", cw=([1,70],[2,175]), cal=([1,"left"], [2,"left"]), cc=clearList)
#     widgets["matchObjButton"] = cmds.button(l="Select Spaces Enum Attr", w=250, bgc=(.8,.8,.8), c = getAttr)

    #back to window
    cmds.setParent(widgets["window"])

    #create bottom frmae
    widgets["bottomFrame"] = cmds.frameLayout(l="Spaces", li=100, w=250, bgc=(0,0,0))
    widgets["bottomRCLO"] = cmds.rowColumnLayout(nc=2, w=250)

    #get obj and put it in
    sel = cmds.ls(sl=True)
    if (len(sel)) == 1:
        getObj()

    #show window
    cmds.showWindow(widgets["window"])
    cmds.window(widgets["window"], e=True, w=250, h=300)
zbw_polyExtend.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)
zbw_wireRig.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
zbw_audioManager.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def audioUI():
    """UI for the whole thing"""

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

    widgets["win"] = cmds.window("audioWin", t="zbw_audioManager", w=300, h=260)

    widgets["mainCLO"] = cmds.columnLayout()
    widgets["getAudioBut"] = cmds.button(l="Get All Audio In Scene", w=300, h=30, bgc=(.6, .6, .8), c=getAudio)
    cmds.text("Double-click item in list to enable sound and select it", al="left")

    widgets["audioTSL"] = cmds.textScrollList(h=100, w=300, dcc=selectAudio)
    widgets["buttonRCLO"] = cmds.rowColumnLayout(nc=2)
    widgets["deleteSelBut"] = cmds.button(l="Delete Selected", w=150, h=20, bgc=(.8,.6,.6), c=deleteSelected)
    widgets["deleteAllBut"] = cmds.button(l="Delete All Audio", w=150, h=20, bgc=(.8,.4,.4), c=deleteAll)

    cmds.setParent(widgets["mainCLO"])

    cmds.separator(h=20)

    widgets["newAudioBut"] = cmds.button(l="Import New Audio File!", w=300, h=30, bgc=(.6,.8,.6), c=importAudio)
    cmds.separator(h=20)

    widgets["offsetRCLO"] = cmds.rowColumnLayout(nc=2, cw=([1,175], [2, 125]), cal=([1,"left"], [2,"left"]))
    widgets["offsetIFG"] = cmds.intFieldGrp(l="Offset Selected By ", v1=1, cal=([1,"left"], [2,"left"]), cw=([1,100],[2,50]))
    widgets["offsetBut"] = cmds.button(l="Offset!", w=100, h=30, bgc=(.6,.8,.8), c=offsetAudio)

    cmds.showWindow(widgets["win"])
    cmds.window(widgets["win"], e=True, w=300, h=260)
zbw_tangents.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def tanUI(*args):
    """the UI for the clean/tangent functions"""
    if cmds.window("tanWin", exists=True):
        cmds.deleteUI("tanWin")

    widgets["win"] = cmds.window("tanWin", t="zbw_tangents", w=300, h=160)
    widgets["mainCLO"] = cmds.columnLayout()
    # widgets["tabLO"] = cmds.tabLayout()

    #tab for changing all tangent types
    # cmds.setParent(widgets["tabLO"])
    widgets["tangentCLO"] = cmds.columnLayout("Tangents")

    #radioButtons for tangent type (step, linear, auto, spline)
    widgets["tangentType"] = cmds.radioButtonGrp(nrb=4, l1="Step", l2="Linear", l3="Spline", l4="Auto", sl=1, cw=[(1,50),(2,50),(3,50),(4,50)])
    #radio button group for all selected or for hierarchy under selected
    widgets["tanHierRBG"] = cmds.radioButtonGrp(nrb=2, l1="Selected Objs Only", l2="Hierarchy Under Selected", sl=2, cc=enableSelect)
    #radioButtons for time (timeslider, all anim, range)
    widgets["tanTimeRBG"] = cmds.radioButtonGrp(nrb=3,l1="Timeslider", l2="All Anim", l3="Frame Range", sl=2, cw=[(1,100),(2,75),(3,75)],cc=partial(enableFR,"tanTimeRBG","tanFrameRangeIFG"))
    #int field group for frame range
    widgets["tanFrameRangeIFG"] = cmds.intFieldGrp(nf=2, l="Start/End", v1=1, v2=24, en=False, cal=[(1,"left"),(2,"left"),(3,"left")], cw=[(1,75),(2,75),(3,75)])
    #radioButtons for curves only or for all DAG objects
    widgets["tanCurvesRBG"] = cmds.radioButtonGrp(nrb=2, l1="Curves/Volume Primatives Only", l2="All DAG", sl=1, cw=[(1, 190),(2, 110)])
    cmds.separator(h=10)

    #Button for executing the change
    #button to SELECT those objects rather than change the tangents
    widgets["buttonRCLO"] = cmds.rowColumnLayout(w=300, nc=2, cw=[(1,200),(2,100)])
    widgets["tanBut"] = cmds.button(l="Change Tangent Type!", w=200, h=40, bgc=(.6,.6,.8), c=changeTan)
    widgets["selectBut"] = cmds.button(l="Select \nHierarchy", w=100, h=40, bgc=(.8,.6,.6), c=selectHier)

    cmds.showWindow(widgets["win"])
    cmds.window(widgets["win"], e=True, w=300, h=160)
ml_goToKeyframe.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def ui():
    '''
    user interface for ml_goToKeyframe
    '''

    with utl.MlUi('ml_goToKeyframe', 'Go To Keyframe', width=400, height=130, info='''Press Next and Previous to advance time to the next or previous keyframes
within the graph editor or your selection.
Check Round to Nearest Frame to avoid stopping time on non-whole frames.''') as win:

        mc.checkBoxGrp('ml_goToKeyframe_selected_checkBox', 
                       label='Within Selection', 
                       annotation='Only search for next and previous within the selected keys.',
                       changeCommand=uiSetCheckBox)
        mc.checkBoxGrp('ml_goToKeyframe_selectKeys_checkBox', 
                       label='Select Keys', 
                       annotation='Select the keyframe(s) on the frame navigated to.',
                       changeCommand=uiSetCheckBox)
        mc.checkBoxGrp('ml_goToKeyframe_round_checkBox', 
                       label='Round to Nearest Frame', 
                       annotation='Only go to whole-number frames, even if keys are on sub-frames.')
        mc.checkBoxGrp('ml_goToKeyframe_hierarchy_checkBox', 
                       label='Search Hierarchy', 
                       annotation='Go to the next or previous keyframe in the whole hierarchy.')

        mc.paneLayout(configuration='vertical2', separatorThickness=1)

        win.ButtonWithPopup(label='<< Previous', name=win.name, command=previous, 
                            annotation='Go to previous keyframe.', 
                            readUI_toArgs={'roundFrame':'ml_goToKeyframe_round_checkBox',
                                           'selected':'ml_goToKeyframe_selected_checkBox',
                                           'selectKeys':'ml_goToKeyframe_selectKeys_checkBox',
                                           'searchHierarchy':'ml_goToKeyframe_hierarchy_checkBox'})

        win.ButtonWithPopup(label='Next >>', name=win.name, command=next, 
                            annotation='Go to next keyframe.', 
                            readUI_toArgs={'roundFrame':'ml_goToKeyframe_round_checkBox',
                                           'selected':'ml_goToKeyframe_selected_checkBox',
                                           'selectKeys':'ml_goToKeyframe_selectKeys_checkBox',
                                           'searchHierarchy':'ml_goToKeyframe_hierarchy_checkBox'})
        mc.setParent('..')
ml_utilities.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def createMenu(self, *args):
        '''
        Create the main menu for the UI
        '''

        #generate shelf label by removing ml_
        shelfLabel = self.name.replace('ml_','')
        module = self.module
        if not module:
            module = self.name

        #if icon exists, use that
        argString = ''
        if not self.icon:
            argString = ', label="'+shelfLabel+'"'

        mc.menu(label='Tools')
        mc.menuItem(label='Add to shelf', 
                    command='import ml_utilities;ml_utilities.createShelfButton("import '+module+';'+module+'.ui()", name="'+self.name+'", description="Open the UI for '+self.name+'."'+argString+')')
        if not self.icon:
            mc.menuItem(label='Get Icon',
                        command=(_showHelpCommand(websiteURL+'/wp-content/files/'+self.name+'.png')))
        mc.menuItem(label='Get More Tools!', 
                    command=(_showHelpCommand(websiteURL+'/downloads')))
        mc.setParent( '..', menu=True )

        mc.menu(label='Help')
        mc.menuItem(label='About', command=self.about)
        mc.menuItem(label='Documentation', command=(_showHelpCommand(wikiURL+'#'+self.name)))
        mc.menuItem(label='Python Command Documentation', command=(_showHelpCommand(wikiURL+'#\%5B\%5B'+self.name+'\%20Python\%20Documentation\%5D\%5D')))
        mc.menuItem(label='Submit a Bug or Request', command=(_showHelpCommand(websiteURL+'/contact/')))

        mc.setParent( '..', menu=True )
ml_controlLibrary.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def buildMainLayout(self):
        '''Build the main part of the ui
        '''

        tabs = mc.tabLayout()
        tab1 = mc.columnLayout(adj=True)

        mc.scrollLayout(cr=True)
        self.shelfLayout = mc.shelfLayout()

        self.refreshShelfLayout()

        mc.setParent(tabs)

        tab2 = mc.columnLayout(adj=True)

        mc.separator(height=8, style='none')
        mc.text('Select curve(s) to export. Multiple selected curves will be combined.')
        mc.text('Center and fit the curve in the viewport,')
        mc.text('and make sure nothing else is visible for best icon creation.')
        mc.separator(height=16, style='in')

        mc.button('Export Selected Curve', command=self.exportControl, annotation='Select a nurbsCurve to export.')

        mc.tabLayout( tabs, edit=True, tabLabel=((tab1, 'Import'), 
                                                 (tab2, 'Export')
                                                 ))

        if not mc.shelfLayout(self.shelfLayout, query=True, numberOfChildren=True):
            mc.tabLayout( tabs, edit=True, selectTab=tab2)
ml_controlLibrary.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def refreshShelfLayout(self, *args):
        '''Delete and the shelf buttons and remake them
        '''

        shelfButtons = mc.shelfLayout(self.shelfLayout, query=True, childArray=True)
        if shelfButtons:
            for child in shelfButtons:
                mc.deleteUI(child)

        mc.setParent(self.shelfLayout)

        for each in os.listdir(REPOSITORY_PATH):
            if each.endswith('.ctrl'):
                name = os.path.splitext(each)[0]
                icon = None
                imageFile = os.path.join(REPOSITORY_PATH,name+'.png')
                if os.path.isfile(imageFile):
                    icon = imageFile
                filename = os.path.join(REPOSITORY_PATH,each)
                button = mc.shelfButton(command=partial(importControl, name),
                                        image=icon, 
                                        width=70,
                                        height=70,
                                        imageOverlayLabel=name.replace('_',' ').replace('  ',' '),
                                        annotation=name)

                menus = mc.shelfButton(button, query=True, popupMenuArray=True)
                if menus:
                    for menu in menus:
                        mc.deleteUI(menu)
                #mc.popupMenu()
                #mc.menuItem('delete', command=partial(self.deleteShelfButton, name))


问题


面经


文章

微信
公众号

扫码关注公众号