我们从Python开源项目中,提取了以下45个代码示例,用于说明如何使用maya.cmds.setParent()。
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("..")
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)
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('..')
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
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)
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))
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('..')
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)
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)
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
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
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)
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)" )
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)
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)
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)
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
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 )
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
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)
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)
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
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)
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)
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('..')
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 )
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)
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))
def buildMainLayout(self): '''Build the main part of the ui ''' #tabs = mc.tabLayout() #tab1 = mc.columnLayout(adj=True) #self.swatch_selected = self.colorControlLayout() #mc.button(label='Color Selected', command=self.colorSelected) #mc.setParent('..') #tab2 = mc.columnLayout(adj=True) self.swatch_range1 = self.colorControlLayout(label='First Selected') self.swatch_range2 = self.colorControlLayout(label='Last Selected') mc.separator(horizontal=True, height=10) mc.button(label='Color Selected Nodes', command=self.colorSelectedRange) #mc.setParent('..') #tab3 = mc.columnLayout(adj=True) #self.positionWidgets = {} #for xyz in 'XYZ': #for m in ['Min','Max']: #self.positionWidgets[m+xyz] = self.colorControlLayout(label='{} {}'.format(m,xyz)) mc.setParent('..') #mc.tabLayout( tabs, edit=True, tabLabel=((tab1, 'Color Control'), (tab2, 'Color Range')) )
def __init__(self): window = cmds.window( title="Chain Maker", iconName='ChnMk', widthHeight=(300, 100) ) cmds.columnLayout( adjustableColumn=True ) cmds.separator( style='single' ) self.curve_sel_name = cmds.textFieldGrp( label = 'Curve Selection' ) cmds.separator( style='single' ) cmds.button( label='Run', command=partial(self.run_command, 1) ) cmds.separator( style='single' ) cmds.button( label='Exit', command=('cmds.deleteUI(\"' + window + '\", window=True)') ) cmds.setParent( '..' ) cmds.showWindow( window )
def install(): from . import interactive, tools def deferred(): # Append to Avalon's menu cmds.menuItem(divider=True) # Modeling sub-menu cmds.menuItem("Modeling", label="Modeling", tearOff=True, subMenu=True, parent=self._menu) cmds.menuItem("Combine", command=interactive.combine) # Rigging sub-menu cmds.menuItem("Rigging", label="Rigging", tearOff=True, subMenu=True, parent=self._menu) cmds.menuItem("Auto Connect", command=interactive.auto_connect) cmds.menuItem("Clone (Local)", command=interactive.clone_localspace) cmds.menuItem("Clone (World)", command=interactive.clone_worldspace) cmds.menuItem("Clone (Special)", command=interactive.clone_special) cmds.menuItem("Create Follicle", command=interactive.follicle) # Animation sub-menu cmds.menuItem("Animation", label="Animation", tearOff=True, subMenu=True, parent=self._menu) cmds.menuItem("Set Defaults", command=interactive.set_defaults) # Rendering sub-menu cmds.menuItem("Rendering", label="Rendering", tearOff=True, subMenu=True, parent=self._menu) cmds.menuItem("Edit Render Globals", command=tools.render_globals_editor) cmds.setParent("..", menu=True) cmds.menuItem(divider=True) cmds.menuItem("Auto Connect", command=interactive.auto_connect_assets) # Allow time for uninstallation to finish. QtCore.QTimer.singleShot(200, deferred)
def __init__(self): name = 'cmt_orientjoints' if cmds.window(name, exists=True): cmds.deleteUI(name, window=True) if cmds.windowPref(name, exists=True): cmds.windowPref(name, remove=True) self.window = cmds.window(name, title='CMT Orient Joints', widthHeight=(358, 330)) cmds.columnLayout(adjustableColumn=True) margin_width = 4 cmds.frameLayout(bv=False, label='Quick Actions', collapsable=True, mw=margin_width) cmds.gridLayout(numberOfColumns=2, cellWidthHeight=(175, 65)) cmds.button(label='Make Planar Orientation', command=self.make_planar) cmds.button(label='Project to Planar Position', command=partial(make_position_planar)) cmds.button(label='Align Up With Child', command=self.align_with_child) cmds.button(label='Zero Orient', command=self.zero_orient) cmds.button(label='Orient to World', command=self.orient_to_world) cmds.rowColumnLayout(numberOfColumns=4) height = 20 label_width = 60 icon_left = 'nudgeLeft.png' icon_right = 'nudgeRight.png' cmds.text(label='Offset X', align='right', width=label_width) cmds.iconTextButton(style='iconOnly', image1=icon_left, label='spotlight', h=height, w=height, c=partial(self.offset_orient_x, direction=-1)) self.offset_x = cmds.floatField(value=90.0) cmds.iconTextButton(style='iconOnly', image1=icon_right, label='spotlight', h=height, w=height, c=partial(self.offset_orient_x, direction=1)) cmds.text(label='Offset Y', align='right', width=label_width) cmds.iconTextButton(style='iconOnly', image1=icon_left, label='spotlight', h=height, w=height, c=partial(self.offset_orient_y, direction=-1)) self.offset_y = cmds.floatField(value=90.0) cmds.iconTextButton(style='iconOnly', image1=icon_right, label='spotlight', h=height, w=height, c=partial(self.offset_orient_y, direction=1)) cmds.text(label='Offset Z', align='right', width=label_width) cmds.iconTextButton(style='iconOnly', image1=icon_left, label='spotlight', h=height, w=height, c=partial(self.offset_orient_z, direction=-1)) self.offset_z = cmds.floatField(value=90.0) cmds.iconTextButton(style='iconOnly', image1=icon_right, label='spotlight', h=height, w=height, c=partial(self.offset_orient_z, direction=1)) cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') cmds.frameLayout(bv=False, label='Manual Orient', collapsable=True, mw=margin_width) cmds.columnLayout(adj=True) cmds.rowLayout(numberOfColumns=2, cw2=(150, 150)) self.reorient_children = cmds.checkBox(label='Reorient children', value=True, align='left') self.reset_orientation = cmds.checkBox(label='Reset orientation', value=True, align='left') cmds.setParent('..') cmds.gridLayout(numberOfColumns=2, cellWidthHeight=(175, 65)) cmds.button(label='Template Joints', command=partial(self.template_joints)) cmds.button(label='Rebuild Joints', command=partial(rebuild_joints)) cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') cmds.showWindow(self.window)
def add_menu(location='Window->General Editors', label='xxx', command='print "xxx"'): ''' Add menu to specified location in main menu. Args: location: Window->General Editors. label: the label on the menu. command: the command ''' # gMainWindowMenu='mainWindowMenu' import maya.cmds as mc menu_path = location.split('->') def get_menu_item(label, parent_menu=None): 'returns menu item with label in parent_menu' menu_item = None # if it is top level menu for m in mc.lsUI(type='menu'): if mc.objectTypeUI(m) != 'commandMenuItem' and mc.menu(m, q=1, l=1) == label: menu_item = m if parent_menu: if not menu_item in mc.menu(parent_menu, q=1, ia=1) or []: continue else: break pmc = mc.menu(menu_item, q=1, pmc=1) if pmc: mm.eval(pmc) return menu_item parent_menu = None for m in menu_path: menu_item = get_menu_item(m, parent_menu) parent_menu = menu_item print parent_menu # delete existing menuItem if mc.menu(parent_menu, q=1, ia=1): for m in mc.menu(parent_menu, q=1, ia=1): if mc.menuItem(m, q=1, l=1) == label: mc.deleteUI(m) break mc.setParent(menu_item, m=1) mc.menuItem(l=label, c=command)
def text_array_builder(self, attrName): frame = 'text_array_frame' if pm.columnLayout(frame, exists=True): pm.deleteUI(frame) pm.columnLayout(frame) pm.rowLayout(numberOfColumns=2) text_array_length = pm.getAttr(attrName, s=True) next_attr = '{}[{}]'.format(attrName, text_array_length) add_command = partial(self.add_text_multiInstance, next_attr) pm.button(label='New Item', command=add_command) last_attr = '{}[{}]'.format(attrName, text_array_length - 1) remove_command = partial(self.rem_text_multiInstance, last_attr) pm.button(label='Remove Last Item', command=remove_command) pm.setParent('..') self.textfields = [] for i in xrange(text_array_length): index_attr = '{}[{}]'.format(attrName, i) textString_attr = index_attr + '.textString' textAlign_attr = index_attr + '.textAlign' textOffset_attr = index_attr + '.textOffset' textScale_attr = index_attr + '.textScale' textColor_attr = index_attr + '.textColor' textAlpha_attr = index_attr + '.textAlpha' textFamily_attr = index_attr + '.textFamily' textWeight_attr = index_attr + '.textWeight' textStretch_attr = index_attr + '.textStretch' pm.frameLayout(label=index_attr, collapse=False) pm.columnLayout(adj=True) text_field = pm.scrollField() self.textfields.append(text_field) text_field_cmd = partial(self.set_string_attr, text_field, textString_attr) text_field.changeCommand(text_field_cmd) text_field.keyPressCommand(text_field_cmd) text_field.setText(pm.getAttr(textString_attr)) text_field.setEditable(True) pm.attrEnumOptionMenuGrp( attribute=textAlign_attr, label='textAlign') pm.attrFieldGrp(attribute=textOffset_attr, label='textOffset') pm.attrControlGrp(attribute=textScale_attr, label='textScale') pm.attrControlGrp(attribute=textColor_attr, label='textColor') pm.attrControlGrp(attribute=textAlpha_attr, label='textAlpha') pm.attrEnumOptionMenuGrp( attribute=textFamily_attr, label='textFamily') pm.attrEnumOptionMenuGrp( attribute=textWeight_attr, label='textWeight') pm.attrEnumOptionMenuGrp( attribute=textStretch_attr, label='textStretch') pm.setParent('..') pm.setParent('..')
def createUI(self): """creates the UI """ self.widgets = {} width = self.windowSize[0] height = self.windowSize[1] if (cmds.window("zbw_win", exists=True)): cmds.deleteUI("zbw_win") self.widgets["window"] = cmds.window("zbw_win", title=self.windowName, w=width, h=height, s=self.sizeable) #menus for future self.menus() cmds.setParent(self.widgets["window"]) self.widgets['formLO'] = cmds.formLayout(nd=100, w=width) # self.widgets["topColumnLO"] = cmds.columnLayout(w=width) self.widgets["scrollLO"] = cmds.scrollLayout(vst=10) self.widgets["lowColumnLO"] = cmds.columnLayout(w=width) cmds.formLayout(self.widgets["formLO"], e=True, attachForm = [(self.widgets["scrollLO"], "top", 0), (self.widgets["scrollLO"], "left", 0), (self.widgets["scrollLO"], 'right', 0), (self.widgets["scrollLO"], 'bottom', 35)]) self.commonUI() self.customUI() #get to buttons bit cmds.setParent(self.widgets["formLO"]) butWidth = width/3 - 10 #add buttons self.widgets["applyCloseButton"] = cmds.button(w=butWidth, h=30, l='Apply and Close', c=partial(self.action, 1)) self.widgets["applyButton"] = cmds.button(w=butWidth, h= 30, l='Apply', c=partial(self.action, 0)) self.widgets['closeButton'] = cmds.button(w=butWidth, h=30, l="close window", c=self.closeWindow) cmds.formLayout(self.widgets["formLO"], e=True, attachForm=[(self.widgets["applyCloseButton"], 'bottom', 5), (self.widgets["applyCloseButton"], 'left', 5)]) cmds.formLayout(self.widgets["formLO"], e=True, attachForm=[(self.widgets["closeButton"], 'bottom', 5), (self.widgets["closeButton"], 'right', 5)]) cmds.formLayout(self.widgets["formLO"], e=True, attachForm=[(self.widgets["applyButton"], 'bottom', 5)]) cmds.formLayout(self.widgets["formLO"], e=True, attachControl=[(self.widgets["applyButton"], 'left', 5, self.widgets["applyCloseButton"]),(self.widgets["applyButton"], 'right', 5, self.widgets["closeButton"])]) cmds.showWindow(self.widgets["window"]) cmds.window(self.widgets["window"], e=True, w=width, h=height)
def softDeformerUI(): """UI for the whole thing""" # TODO - add some kind of help text to each tab if cmds.window("softModWin", exists=True): cmds.deleteUI("softModWin") widgets["window"] = cmds.window("softModWin", t="zbw_softDeformer", w=300, h=130) widgets["tabLO"] = cmds.tabLayout() widgets["smCLO"] = cmds.columnLayout("SoftMod", w=300) cmds.separator(h=10) widgets["smdTFG"] = cmds.textFieldGrp(l="Deformer Name", w=300, cw=[(1, 100), (2, 190)], cal=[(1, "left"), (2, "left")], tx="softMod_DEF") widgets["checkCBG"] = cmds.checkBoxGrp(l="AutoCheck if there are deformers?", v1=1, cw=[(1, 200)], cal=[(1, "left"), (2, "left")]) widgets["frontCBG"] = cmds.checkBoxGrp(l="Auto move to front of chain", v1=1, cw=[(1, 200)], cal=[(1, "left"), (2, "left")]) widgets["scaleFFG"] = cmds.floatFieldGrp(l="Control Scale", v1=1, pre=2, cw=[(1, 150), (2, 50)], cal=[(1, "left"), (2, "left")]) widgets["autoscaleCBG"] = cmds.checkBoxGrp(l="autoscale control?", v1=1, cw=[(1, 200)], cal=[(1, "left"), (2, "left")]) widgets["bpFrameIFG"] = cmds.intFieldGrp(l="BindPose/origin Frame", cw=[(1, 150), (2, 50)], cal=[(1, "left"), (2, "left")]) widgets["mainCtrlTFBG"] = cmds.textFieldButtonGrp(l="Parent Object:", cw=[(1, 75), (2, 175), (3, 75)], cal=[(1, "left"), (2, "left"), (3, "left")], bl="<<<", bc=partial(set_parent_object, "mainCtrlTFBG")) cmds.separator(h=10, style="single") widgets["smbutton"] = cmds.button(l="Create Deformer", w=300, h=40, bgc=(.6, .8, .6), c=partial(create_soft_mod_deformer, False)) cmds.separator(h=5) widgets["wavebutton"] = cmds.button(l="Soft Wave (use falloff to scale wave)", w=300, h=30, bgc=(.8, .8, .6), c=partial(create_soft_mod_deformer, True)) # third tab to do softselect to joint cmds.setParent(widgets["tabLO"]) widgets["jointCLO"] = cmds.columnLayout("softJoint", w=300) widgets["jntNameTFG"] = cmds.textFieldGrp(l="Joint Name", w=300, cw=[(1, 100), (2, 190)], cal=[(1, "left"), (2, "left")], tx="softSelect_JNT") widgets["jntCPOMCBG"] = cmds.checkBoxGrp(l="Joint to closest point on mesh?", v1=1, cw=[(1, 200)], cal=[(1, "left"), (2, "left")]) widgets["jntRotCBG"] = cmds.checkBoxGrp(l="Joint orient to surface?", v1=1, cw=[(1, 200)], cal=[(1, "left"), (2, "left")]) widgets["jntAutoCBG"] = cmds.checkBoxGrp(l="Create initial jnt if not bound?", v1=1, cw=[(1, 200)], cal=[(1, "left"), (2, "left")]) cmds.separator(h=10) widgets["jntbutton"] = cmds.button(l="Create Joint", w=300, h=40, bgc=(.6, .8, .6), c=soft_selection_to_joint) cmds.window(widgets["window"], e=True, w=5, h=5, rtf=True) cmds.showWindow(widgets["window"]) # -------------------------- # softMod deformer # -------------------------- # TODO - Add 'wave' to name . . .
def zbw_mmUI(): """the UI for the script""" if (cmds.window('`UI', exists=True)): cmds.deleteUI('zbw_messageMapperUI', window=True) cmds.windowPref('zbw_messageMapperUI', remove=True) window=cmds.window('zbw_messageMapperUI', widthHeight=(600,400), title='zbw_messageMapper') cmds.tabLayout(h=400) cmds.columnLayout("mmAddNewConnections", h=400) #2nd small column for the persistant UI cmds.columnLayout(w=400, h=100) cmds.textFieldButtonGrp('zbw_tfbg_baseObj', cal=(1, "left"), cw3=(75, 200, 75), label="base object", w=400, bl="choose object", bc=partial(zbw_mmAddBase, "zbw_tfbg_baseObj", "clear")) #button to create new message/obj field groups cmds.separator(h=20, st="single") cmds.button(w=150, l="add new message attr/obj", c=zbw_mmAddMObjs) cmds.separator(h=20, st="single") cmds.setParent(u=True) cmds.rowColumnLayout("mmRCLayout", nc=2, co=(2, "left", 30)) #back up to the 2nd columnLayout cmds.setParent(u=True) cmds.separator(h=20, st="single") #create button to delete last pair of text fields cmds.button("deleteLastButton", w=150, bgc=(.5,0,0), l="delete last attr/obj pair", c=zbw_mmDeleteLast) cmds.separator(h=20, st="double") #button to do connect all the attr/messages cmds.button("createMessageButton", w=150, bgc=(0,.5,0), l="create messages", c=zbw_mmConnectM) #back up to the main column cmds.setParent(u=True) #back up to the tab cmds.setParent(u=True) #new tab cmds.columnLayout("existingMessages", w=600, h=400) #Here we add stuff to the second tab cmds.textFieldButtonGrp("mmListMessages", cal=(1, "left"), cw3=(75,200,75), label="baseObject", w=400, bl="choose object", bc=partial(zbw_mmAddBase,"mmListMessages", "noClear")) cmds.separator(h=20, st="double") #button to create list of message attrs cmds.button(w=200, l="list all message attr for base", bgc = (0,.5,0), c=partial(zbw_mmListCurrentMessages, "mmListMessages")) cmds.separator(h=20, st="double") cmds.text("rt-click on the attr or object to change the connection") cmds.separator(h=20, st="double") cmds.rowColumnLayout("mmRCTextLayout", w=600, nc=3, cw=[(1, 200),(2,290),(3,100)]) cmds.text("ATTR") cmds.text("OBJECT") cmds.text("DELETE") cmds.showWindow(window)
def spaceMatchUI(): if (cmds.window("spaceMatchWin", exists=True)): cmds.deleteUI("spaceMatchWin", window=True) widgets["window"] = cmds.window("spaceMatchWin", title="Space Matcher", w=250, h=300) widgets["mainLO"] = cmds.columnLayout() widgets["tabLO"] = cmds.tabLayout() widgets["getObjCLO"] = cmds.columnLayout() widgets["instruct"] = cmds.text("get obj, then attr, then space then do it") cmds.separator(h=10) #----------fill with selection automatically? widgets["objTFG"] = cmds.textFieldGrp(l="select obj", cw=([1,50],[2,150],[3,50]), cal=([1,"left"], [2,"left"],[3,"left"]), cc=clearList) widgets["matchObjButton"] = cmds.button(l="select object", c=partial(getObj, widgets["objTFG"])) cmds.separator(h=10) #-----------maybe here have it catch the selected obj by default #-----------and/or have a field for the attribute (default to "follow") widgets["getAttrButton"] = cmds.button(w=250, al="center", h=20, l="select enum space attr from obj", bgc= (.5, .5, 0), c=getAttr) #-----------when the attr is selected list the attrs automagically, widgets["spacesTSL"] = cmds.textScrollList(w=250, h=200, nr=8, ams=False, bgc=(.2, .2, .2)) widgets["matchButton"] = cmds.button(w=250, al="center", h=40, bgc= (0,.5,0), l="space switch/match", c= doSpaceMatch) #tab for creation/setup of matching cmds.setParent(widgets["tabLO"]) #----------in this tab, create frames. One (closable) to create constraint and fill items, check boxes for orient, position (with user selecting objects), one frame (maybe already filled out) (always open) for setting up attrs (message, strings) widgets["setupCLO"] = cmds.columnLayout() #frame layout for creating the constraints widgets["createFrameLO"] = cmds.frameLayout(l="create Constrants", collapsable=True, w=250) cmds.text("have em select for constraint") widgets["posRotCBG"] = cmds.checkBoxGrp(ncb=2, l1="translation", v1=True, l2="rotation", v2=True) #----------this button should just create the constraints on the objects in question, but then fill in what parts of the lower half it can widgets["createSetupButton"] = cmds.button(l="create constraints") cmds.setParent(widgets["setupCLO"]) #frameLayout for setting up the attrs widgets["setupFrameLO"] = cmds.frameLayout(l="setup matching", collapsable=False, w=250, h=250) widgets["setupObjTFG"] = cmds.textFieldGrp(l="select ctrl obj", cw=([1,100],[2,150]), cal=([1,"left"], [2,"left"])) widgets["setupObjButton"] = cmds.button(l="get ctrl object", h=40, c= partial(getObj, widgets["setupObjTFG"])) widgets["setupConstrTFG"] = cmds.textFieldGrp(l="constraint", cw=([1,100],[2,150]), cal=([1,"left"], [2,"left"])) widgets["setupConstrButton"] = cmds.button(l="get constraint", h=40, c= partial(getObj, widgets["setupConstrTFG"])) #create list of attrs on constraint #attr = cmds.listAttr(sel,ud=True ) #create list of spaces on obj attr cmds.tabLayout(widgets["tabLO"], e=True, tabLabel = ((widgets["getObjCLO"], "change spaces"),(widgets["setupCLO"], "setup matching"))) cmds.showWindow(widgets["window"]) cmds.window(widgets["window"], e=True, w=250, h=300)
def _install_menu(): from ..tools import ( creator, loader, publish, cbloader, cbsceneinventory ) from . import interactive _uninstall_menu() def deferred(): cmds.menu(self._menu, label=api.Session["AVALON_LABEL"], tearOff=True, parent="MayaWindow") cmds.menuItem("Create...", command=lambda *args: creator.show(parent=self._parent)) if api.Session.get("AVALON_EARLY_ADOPTER"): cmds.menuItem("Load...", command=lambda *args: cbloader.show(parent=self._parent, use_context=True)) else: cmds.menuItem("Load...", command=lambda *args: loader.show(parent=self._parent)) cmds.menuItem("Publish...", command=lambda *args: publish.show(parent=self._parent), image=publish.ICON) cmds.menuItem("Manage...", command=lambda *args: cbsceneinventory.show( parent=self._parent)) cmds.menuItem(divider=True) cmds.menuItem("System", label="System", tearOff=True, subMenu=True, parent=self._menu) cmds.menuItem("Reload Pipeline", command=reload_pipeline) cmds.setParent("..", menu=True) cmds.menuItem("Reset Frame Range", command=interactive.reset_frame_range) cmds.menuItem("Reset Resolution", command=interactive.reset_resolution) # Allow time for uninstallation to finish. QtCore.QTimer.singleShot(100, deferred)
def __initUI(self): self.lyName = 'nOutlinerPaneLayout' self.outlinerPanelName = 'nOutlinerPanel' if not cmds.paneLayout(self.lyName, query = True, exists = True): ## Create the pane to parent the outliner to self.outlinerPanelLayout = cmds.paneLayout(self.lyName) cmds.setParent() self.outlinerPaneLayout_Ptr = mui.MQtUtil.findLayout(self.outlinerPanelLayout) ## Wrap the maya paneLayout as a QWidget self.outlinerPaneWidget = shiboken.wrapInstance(long(self.outlinerPaneLayout_Ptr), QWidget) self.outlinerPaneWidget.setObjectName('CustomOutlinerWidget') ## Check to see if the custom outliner panel already exists existPanels = [pnl for pnl in cmds.lsUI(panels = True) if self.outlinerPanelName in pnl] if existPanels: self.outlinerPanel = mui.MQtUtil.findLayout(self.outlinerPanelName) cmds.outlinerPanel(self.outlinerPanelName, edit = True, p = self.outlinerPanelLayout) else: self.outlinerPanel = cmds.outlinerPanel(self.outlinerPanelName, l = self.outlinerPanelName, to = False, init = False, mbv = True, p = self.outlinerPanelLayout) ## Set up the defaults for the view self.fixEditor = cmds.outlinerEditor(self.outlinerPanelName, edit = True, mainListConnection='worldList', selectionConnection='modelList', showShapes=False, showAttributes=False, showConnected=False, showAnimCurvesOnly=False, autoExpand=False, showDagOnly=True, ignoreDagHierarchy=False, expandConnections=False, showCompounds=True, showNumericAttrsOnly=False, highlightActive=True, autoSelectNewObjects=False, doNotSelectNewObjects=False, transmitFilters=False, showSetMembers=True, setFilter='defaultSetFilter' ) else: self.outlinerPaneLayout_Ptr = mui.MQtUtil.findLayout(self.lyName) self.outlinerPaneWidget = shiboken.wrapInstance(long(self.outlinerPaneLayout_Ptr), QWidget) self.outlinerPaneWidget.setObjectName('nOutlinerWidget') self.mainLayout.addWidget(self.outlinerPaneWidget, 1, 0) self.mainLayout.setContentsMargins(1,1,1,1) self.setContentsMargins(1,1,1,1)
def ui(self): ''' Launch a UI to display the marks that were recorded. ''' with utl.MlUi('ml_stopwatchReport', 'Stopwatch Report', width=400, height=400, info='''This is the report from the stopwatch you just ran. Adjust the start frame, and then press the frame buttons to jump to that frame. The fields on the right can be used for notes.''', menu=False) as win: self.uiSlider = mc.intSliderGrp(field=True, label='Start Frame', value=self.startFrame, minValue=((-0.5*self.frameMarks[-1])+self.startFrame), maxValue=(self.frameMarks[-1]/2)+self.startFrame, fieldMinValue=-1000, fieldMaxValue=1000, changeCommand=self.uiUpdateStartFrame) self.frameRateField = mc.intFieldGrp(label='Frame Rate', value1=self.frameRate, enable1=False, extraLabel='fps', annotation='') mc.scrollLayout() mc.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 50), (2, 80), (3, 340)]) mc.text('Frame') mc.text('Duration') mc.text('Notes') for i in range(3): mc.separator(style='single', height=15) self.uiButton = list() for i in range(len(self.frameMarks)): #frame button frame = self.frameMarks[i]+self.startFrame self.uiButton.append(mc.button(label=str(frame), annotation='Go to frame %i' % frame,command='import maya.cmds;maya.cmds.currentTime(%i,edit=True)' % frame)) #duration text if i: mc.text(label=str(self.frameMarks[i]-self.frameMarks[i-1])) else: mc.text(label='Start') #notes field mc.textField() #add the stop mc.text(label='') mc.text(label='Stop') mc.setParent('..') mc.setParent('..') #next and prev buttons! mc.paneLayout(configuration='vertical2',separatorThickness=1) mc.button(label='<< Previous', command=self.previousFrame, annotation='Go to the previous frame in the list.') mc.button(label='Next >>', command=self.nextFrame, annotation='Go to the next frame in the list.')
def createMenuItem(self, parent=None, labelPrefix='', italicized=False): if self.isPython: menuName = 'mlMenu_'+self.module.__name__.replace('.','_') else: menuName = 'mlMenu_'+self.name #Create the label and print the tool label = labelPrefix+self.label #keyword args for the menu command kwargs = {'italicized':italicized} if self.hotkey: if len(self.hotkey.keys) == 1: kwargs['altModifier'] = self.hotkey.altModifier[0] kwargs['ctrlModifier'] = self.hotkey.ctrlModifier[0] if self.hotkey.keys[0].isupper(): kwargs['shiftModifier'] = True kwargs['keyEquivalent'] = self.hotkey.keys[0] if self.verbose: print self.depth*'\t'+label if mc.menuItem(menuName, exists=True): mc.deleteUI(menuName) insertAfter = None if self.isPython and hasattr(self.module,'insertAfter'): menuItemArray = mc.menu(parent, query=True, itemArray=True) if menuItemArray: menuItems = dict() for each in menuItemArray: eachLabel = mc.menuItem(each, query=True, label=True) menuItems[eachLabel] = each if self.module.insertAfter in menuItems: kwargs['insertAfter'] = menuItems[self.module.insertAfter] mc.setParent(parent, menu=True) menuName = mc.menuItem(menuName, label=label, command=self.command, **kwargs)
def ui(): ''' User interface for world bake ''' with utl.MlUi('ml_worldBake', 'World Bake', width=400, height=175, info='''Select objects, bake to locators in world, camera, or custom space. When you're ready to bake back, select locators and bake "from locators" to re-apply your animation.''') as win: mc.checkBoxGrp('ml_worldBake_bakeOnOnes_checkBox',label='Bake on Ones', annotation='Bake every frame. If deselected, the tool will preserve keytimes.') tabs = mc.tabLayout() tab1 = mc.columnLayout(adj=True) mc.radioButtonGrp('ml_worldBake_space_radioButton', label='Bake To Space', numberOfRadioButtons=3, labelArray3=('World','Camera','Last Selected'), select=1, annotation='The locators will be parented to world, the current camera, or the last selection.') mc.checkBoxGrp('ml_worldBake_constrain_checkBox',label='Maintain Constraints', annotation='Constrain source nodes to the created locators, after baking.') win.ButtonWithPopup(label='Bake Selection To Locators', command=toLocators, annotation='Bake selected object to locators specified space.', readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox', 'spaceInt':'ml_worldBake_space_radioButton', 'constrainSource':'ml_worldBake_constrain_checkBox'}, name=win.name)#this last arg is temp.. mc.setParent('..') tab2 = mc.columnLayout(adj=True) win.ButtonWithPopup(label='Bake Selected Locators Back To Objects', command=fromLocators, annotation='Bake from selected locators back to their source objects.', readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox'}, name=win.name)#this last arg is temp.. mc.setParent('..') tab3 = mc.columnLayout(adj=True) mc.checkBoxGrp('ml_worldBake_maintainOffset_checkBox',label='Maintain Offset', annotation='Maintain the offset between nodes, rather than snapping.') win.ButtonWithPopup(label='Bake Selected', command=utl.matchBake, annotation='Bake from the first selected object directly to the second.', readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox', 'maintainOffset':'ml_worldBake_maintainOffset_checkBox'}, name=win.name)#this last arg is temp.. mc.tabLayout( tabs, edit=True, tabLabel=((tab1, 'Bake To Locators'), (tab2, 'Bake From Locators'), (tab3, 'Bake Selection')) ) # win.ButtonWithPopup(label='Bake Selected With Offset', command=matchBake, annotation='Bake from the first selected object directly to the second, maintaining offset.', # readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox'}, name=win.name)#this last arg is temp..