Ejemplo n.º 1
0
    def __init__(self, *args):
        print 'In RDojo_UI'
        mi = cmds.window('MayaWindow', ma=True, q=True)
        for m in mi:
            if m == 'RDojo_Menu':
                cmds.deleteUI('RDojo_Menu', m=True)
 
        mymenu = cmds.menu('RDojo_Menu', label='RDMenu', to=True, p='MayaWindow')
        cmds.menuItem(label='Rig Tool', parent=mymenu, command=self.ui)

        """ Create a dictionary to store UI elements.
        This will allow us to access these elements later. """
        self.UIElements = {}

        """ This dictionary will store data from the lyout.json files """
        self.layout_info = {}

        """ Call the internal method loadLayoutDefinitions()
            The loadLayoutDefinitions method will read all the json files
            in the layout folder.  Then it will store the data
            in self.part_info.  Remember that we use self when
            calling a method of the class we are in."""

        self.loadLayoutDefinitions()

        # This dictionary will store all of the available rigging modules.
        self.rigmodlst = os.listdir(os.environ["RDOJO"] + 'Modules/Rigging/')
Ejemplo n.º 2
0
    def switch_module(self,dishName,dishFile,*args):
        archive = zipfile.ZipFile(dishFile, 'r')
        jsonFile = archive.read('dish.ini')
        jsondata = json.loads(jsonFile)  
        archive.close()

        #Clear chld
        chldrn = mc.layout( self.InfosTab, query=True, childArray=True )
        for chld in chldrn:
            mc.deleteUI(chld)
        #-------------------------------------------------------------------
        mc.columnLayout( adjustableColumn=True ,p=self.InfosTab ,rs=5)        
        header = """<html>
            <body>
            <h1>%s</h1></body>
            </html>
        """%(dishName )
        
        self.dishType  = dishName
        mc.text( self.module,e=True,l=header,font='boldLabelFont')        
        mc.scrollField( editable=False, wordWrap=True, text=jsondata['moduleInfos'] ,h=140)
        mc.separator()   
        mc.text( l='name bank') 
        mc.columnLayout( adjustableColumn=True)
        LimbMenu = mc.optionMenu( label='',w=224  )
        mc.menuItem( label='NONE')
        mc.setParent('..')
        mc.button(l='Open name composer',h=28)
        mc.optionMenu( LimbMenu ,e=True,changeCommand=partial(self.composePrfX,LimbMenu))

        self.dishPrfx       =  mc.textField()
        mc.button(l='Import', h=42,c=self.validate_dish_before_merge )        
Ejemplo n.º 3
0
 def updateLine(self, nodeName, metadata, index):
     # Attribute controls will be created with the current metadata content
     result = metadata.split(' ', 2 )
     result += [""] * (3-len(result))
     
     # Attribute Name
     attrNameText = cmds.textField("MtoA_exrMAttributeName", text=result[1])
     cmds.textField(attrNameText, edit=True, changeCommand=pm.Callback(self.changeAttrName, nodeName, attrNameText, index))
     
     # Attribute Type
     menu = cmds.optionMenu("MtoA_exrMAttributeType")
     cmds.menuItem( label='INT', data=0)
     cmds.menuItem( label='FLOAT', data=1)
     cmds.menuItem( label='POINT2', data=2)
     cmds.menuItem( label='MATRIX', data=3)
     cmds.menuItem( label='STRING', data=4)
     if result[0] == 'INT':
         cmds.optionMenu(menu, edit=True, select=1)
     elif result[0] == 'FLOAT':
         cmds.optionMenu(menu, edit=True, select=2)
     elif result[0] == 'POINT2':
         cmds.optionMenu(menu, edit=True, select=3)
     elif result[0] == 'MATRIX':
         cmds.optionMenu(menu, edit=True, select=4)
     elif result[0] == 'STRING':
         cmds.optionMenu(menu, edit=True, select=5)
     cmds.optionMenu(menu, edit=True, changeCommand=pm.Callback(self.changeAttrType, nodeName, menu, index))
     
     # Attribute Value
     attrValueText = cmds.textField("MtoA_exrMAttributeValue", text=result[2])
     cmds.textField(attrValueText, edit=True, changeCommand=pm.Callback(self.changeAttrValue, nodeName, attrValueText, index))
     
     # Remove button
     cmds.symbolButton(image="SP_TrashIcon.png", command=pm.Callback(self.removeAttribute, nodeName, index))
Ejemplo n.º 4
0
    def ui(self, *args):
        """ Check to see if the UI exists """
        windowName = "Window"
        if cmds.window(windowName, exists=True):
            cmds.deleteUI(windowName)

        """ Define width and height variables for buttons and windows"""    
        windowWidth = 120
        windowHeight = 60
        buttonWidth = 100
        buttonHeight = 30

        # Define the main ui window and assign it a key in the UIElements dictinary.
        self.UIElements["window"] = cmds.window(windowName, width=windowWidth, height=windowHeight, title="Example_UI", sizeable=True)
        
        # This is a flow layout.
        self.UIElements["guiFlowLayout1"] = cmds.flowLayout(v=False, width=windowWidth, height=windowHeight, wr=True, bgc=[0.2, 0.2, 0.2])

        # Menu listing all the layout files.
        self.UIElements["keyMenu"] = cmds.optionMenu('layouts', label='Layouts',  p=self.UIElements["guiFlowLayout1"])
        
        # Create a menu item for each json file in the Layout directory.
        for key in self.layout_info['Keys']:  
            cmds.menuItem(label=key, p=self.UIElements["keyMenu"])
        
        """ Show the window"""
        cmds.showWindow(windowName)
Ejemplo n.º 5
0
def ui():
	'''
	'''
	# Window
	window = 'transformDrivenBlendUI'
	if mc.window(window,q=True,ex=1): mc.deleteUI(window)
	window = mc.window(window,t='Transform Driven Blend')
	
	# Layout
	cl = mc.columnLayout()
	
	# UI Elements
	driveAttrTFG = mc.textFieldGrp('tdb_driveAttrTFG',label='Drive Attr', text='')
	blendShapeTFG = mc.textFieldGrp('tdb_blendShapeTFG',label='BlendShape', text='')
	target1TFG = mc.textFieldGrp('tdb_target1TFG',label='Target 1', text='',cc='glTools.ui.transformDrivenBlend.refreshUI()')
	target2TFG = mc.textFieldGrp('tdb_target2TFG',label='Target 2', text='',cc='glTools.ui.transformDrivenBlend.refreshUI()')
	weight1FFG = mc.floatFieldGrp('tdb_weight1FFG',numberOfFields=1,label='Weight 1',v1=1.0)
	weight2FFG = mc.floatFieldGrp('tdb_weight2FFG',numberOfFields=1,label='Weight 2',v1=-1.0)
	overlapFFG = mc.floatFieldGrp('tdb_overlapFFG',numberOfFields=1,label='Overlap',v1=0.0)
	prefixTFG = mc.textFieldGrp('tdb_prefixTFG',label='Prefix', text='')
	createB = mc.button('tdb_createB',label='Create',c='glTools.ui.transformDrivenBlend.executeFromUI()')
	refreshB = mc.button('tdb_refreshB',label='Refresh',c='glTools.ui.transformDrivenBlend.refreshUI()')
	cancelB = mc.button('tdb_cancelB',label='Cancel',c='mc.deleteUI('+window+')')
	
	# Popup Menus
	mc.popupMenu('tdb_blendShapePUM',p=blendShapeTFG)
	mc.popupMenu('tdb_target1PUM',p=target1TFG)
	mc.popupMenu('tdb_target2PUM',p=target2TFG)
	mc.popupMenu('tdb_driveAttrPUM',p=driveAttrTFG)
	mc.menuItem(label='Set from selected',c='glTools.ui.utils.loadChannelBoxSel("'+driveAttrTFG+'")')
	
	# Show Window
	refreshUI()
	mc.showWindow(window)
Ejemplo n.º 6
0
    def __init__(s):
        # Build window
        name = "TimelineMarkersMainWindow"
        s.store = Node("Timeline_Markers_Data")

        if cmds.window(name, ex=True):
            cmds.deleteUI(name)
        s.window = cmds.window(name, t="Timeline Markers", rtf=True)

        # Add language changer
        cmds.columnLayout(adj=True)
        s.language_box = cmds.optionMenu(cc=s.build_gui)
        for lang in LANGUAGE:
            cmds.menuItem(l=lang)
        s.outer = cmds.columnLayout(adj=True)
        s.inner = cmds.scrollLayout(cr=True, h=600)

        # Buttons!
        s.current_button = cmds.button(p=s.outer, c=s.add_current)
        s.selected_button = cmds.button(p=s.outer, c=s.add_selected)
        s.save_button = cmds.button(p=s.outer, c=s.save_markers)
        s.load_button = cmds.button(p=s.outer, c=s.load_markers)

        # Lets go!
        s.load_data()
        s.refresh()

        cmds.showWindow(s.window)

        cmds.scriptJob(e=["PostSceneRead", s.load_data], p=s.window)
        cmds.scriptJob(e=["NewSceneOpened", s.load_data], p=s.window)
        cmds.scriptJob(e=["timeChanged", s.update_current], p=s.window)
Ejemplo n.º 7
0
	def createComponent(self, parentContainer):
		layout = cmds.rowLayout (parent= parentContainer, numberOfColumns = 2)
		cmds.text(parent= layout, l=self.description, align="right", w=150)
		self.selector = cmds.optionMenu(parent= layout, w=350)
		for desc in self.descriptions:
			cmds.menuItem(parent=self.selector, label=desc)
		return layout
Ejemplo n.º 8
0
    def _buildCharTypeTFG(self):
        '''
        build character type text field group menu list
        '''
        # check for and clear out any existing popup menu items
        self._clearOutPopupMenu(self._tfg_char_type)
        self._tfg_char_type_popup = mc.popupMenu(parent=self._tfg_char_type)
        ignore_list = list(set(self.IGNORE_LIST
                                        + ['old characters', 'reference_misc']))

        # collect list of valid character type categories
        data_list = [x for x in (os.listdir(self.ASSET_LIB) or [])
                            if not x in ignore_list and not x.startswith('_')]
        data_list.sort()
        default_label = self.CHAR_TYPE_LABEL

        # setup right click menu items
        mc.menuItem(parent=self._tfg_char_type_popup, label=default_label,
                    command=partial(self._updateCharTypeTFG, default_label))

        for data in data_list:
            mc.menuItem('%sMI' % data, parent=self._tfg_char_type_popup,
                        label=data,
                        command=partial(self._updateCharTypeTFG, data))

        mc.textFieldGrp(self._tfg_char_type, edit=True, text=default_label)
        def populate_render_layer_layout(self, attr):
            if self.render_layer_layout is not None:
                node = attr.split('.')[0]  
                # delete old ui
                children = cmds.columnLayout(self.render_layer_layout, q=True, childArray=True)
                if children is not None:
                    for name in children:
                        cmds.deleteUI(name)

                for i in range(50):
                    i += 1

                    layer_name = 'render_layer_{0}_name'.format(i)

                    if cmds.attributeQuery(layer_name, exists=True, node=node):
                        cmds.setParent(self.render_layer_layout)
                        current_render_layer_layout = cmds.rowLayout(nc=5)
                        for n, width in enumerate(self.render_layer_layout_widths):
                            cmds.rowLayout(current_render_layer_layout, e=True, cw=[n + 1, width])
                        cmds.textField(cc=partial(self.set_render_layer_name, node, i), text=cmds.getAttr('{0}.render_layer_{1}_name'.format(node, i)))
                        entity_type_menu = cmds.optionMenu(cc=partial(self.set_render_layer_type, node, i))
                        for entity_type in ms_commands.RENDER_LAYER_ENTITY_TYPES:
                            cmds.menuItem(label=entity_type)
                        cmds.optionMenu(entity_type_menu, e=True, v=cmds.getAttr('{0}.render_layer_{1}_type'.format(node, i)))
                        pattern_text_field = cmds.textField(cc=partial(self.set_render_layer_pattern, node, i), text=cmds.getAttr('{0}.render_layer_{1}_pattern'.format(node, i)))
                        cmds.textField(cc=partial(self.set_render_layer_order, node, i), text=cmds.getAttr('{0}.render_layer_{1}_order'.format(node, i)))
                        cmds.button(' - ', height=20, command=partial(self.remove_render_layer, node, i))
                
                cmds.setParent(self.render_layer_layout)
                current_render_layer_layout = cmds.rowLayout(nc=2)
                cmds.button(' + ', command=partial(self.add_render_layer, node))
Ejemplo n.º 10
0
    def expose_component(self,tabAnchor,rootData):
        attrib_link = rootData[0]
        ctrlHgt = 24
        nodeData = attrib_link.split('.') 
        typeChk = mc.attributeQuery(  nodeData[-1], node=nodeData[0], attributeType=True  )
        numericType = ['float','double','short','long','int','bool','enum','string']
        clm = mc.columnLayout( adjustableColumn=True, rs=5 ,p=tabAnchor, w=420 -30 )
        
        stringType = mc.getAttr(attrib_link,type=True)
        fildCaption = mc.textField(  tx=rootData[1],ed=False,w=410 -30 ,p=clm , font="boldLabelFont",bgc=[0.8,0.8,0.8])    
        mc.popupMenu( button=3 ,p=fildCaption)
        mc.menuItem(l='Open in connection Editor' )


        if stringType == 'string':  
            attrFld = mc.textField(  ed=True,w=410 -30 ,p=clm )              
            mc.connectControl( attrFld, attrib_link )

        else:
            if typeChk in numericType:
                mc.attrFieldSliderGrp( attribute=rootData[0],p=clm )
            else:        
                flw = mc.flowLayout( columnSpacing=4  , p=clm )
                fldLnk = mc.textField(  tx=rootData[0],ed=False ,w=385,h=ctrlHgt,p=flw)
                mc.button( label='<',p=flw)
Ejemplo n.º 11
0
def create_Menu(*args):
	maya_Window = cmds.window('MayaWindow', ma=True, q=True)
	for m in maya_Window:
		if m == 'RDojo_Menu':
			cmds.deleteUI('RDojo_Menu', m=True)
	cmds.menu('RDojo_Menu', label='RDMenu', to=True, p='MayaWindow')
	cmds.menuItem(label="arm", command="run_Script()")
Ejemplo n.º 12
0
 def conAndDisconMenu(self):
     if self.target == self.other and not cmds.objExists( self.getNamespace( self.target )+'All_Init' ): return None
     if self.initCtlCmd.isConnect( self.target ):
         cmds.menuItem( l='Disonnect Init', rp='S', parent = self.parentUi, c= partial( self.initCtlCmd.disConnect, self.target ) )
     else:
         cmds.menuItem( l='Connect Init', rp='S', parent = self.parentUi, c= partial( self.initCtlCmd.connect, self.target, self.other ) )
     #cmds.menuItem( l='Create Mocap Joint', parent = self.parentUi, c=partial( self.initCtlCmd))
Ejemplo n.º 13
0
def locatorParticlesUI():
    """
    """
    # Define window
    locParticleUI = 'locatorParticleWindow'
    if cmds.window(locParticleUI, q=True, ex=True): cmds.deleteUI(locParticleUI)
    locParticleUI = cmds.window(locParticleUI, t='Generate Particles')

    # UI Layout
    cmds.columnLayout(adj=False, cal='left')
    partiTFG = cmds.textFieldGrp('locParticle_particleTFG', label='Particle', text='', cw=[(1, 100)])
    radiusFFG = cmds.floatSliderGrp('locParticle_radiusFSG', label='radius', f=True, min=0.1, max=10.0, fmn=0.01,
                                  fmx=100.0, pre=2, v=1.0, cw=[(1, 100)])
    rotateLocCBG = cmds.checkBoxGrp('locParticle_rotateCBG', label='Add rotatePP', ncb=1, v1=0, cw=[(1, 100)])
    scaleLocCBG = cmds.checkBoxGrp('locParticle_scaleCBG', label='Add scalePP', ncb=1, v1=0, cw=[(1, 100)])
    selfCollideCBG = cmds.checkBoxGrp('locParticle_selfCollideCBG', label='self collide', ncb=1, v1=0, cw=[(1, 100)])

    cmds.button(l='Create Particles', c='glTools.tools.generateParticles.locatorParticlesFromUI()')

    # Popup menu
    cmds.popupMenu(parent=partiTFG)
    for p in cmds.ls(type=['particle', 'nParticle']):
        cmds.menuItem(p, c='cmds.textFieldGrp("' + partiTFG + '",e=True,text="' + p + '")')

    # Show Window
    cmds.showWindow(locParticleUI)
Ejemplo n.º 14
0
def add_button(item, parent):
    """ add button to the shelf """

    # create the button itself
    button = cmds.iconTextButton('dmptools_shelf_button_'+item['name'],
                parent=parent,
                enable=True,
                w=35, h=35,
                annotation=item['annotation'],
                image1=item['icon'],
                command=item['command'],
                sourceType='mel')
    # add right click popup items if exists
    if item['menu']:
        # create the popup menu with the name "popup_<name>"
        popMenu = cmds.popupMenu('dmptools_popup_'+item['name'], parent=button, b=3)
        for menuI in item['menuItems']:
            menuI_name = menuI['name']
            # add popup menu items
            if 'divider' in menuI_name:
                # in case it's a divider
                cmds.menuItem('dmptools_popup_item_'+menuI_name, parent=popMenu, divider=True)
            else:
                # in case it's a menu item
                menuI_command = menuI['command']
                cmds.menuItem(parent=popMenu,
                                label=menuI_name,
                                command=menuI_command,
                                sourceType='mel')
Ejemplo n.º 15
0
 def buildFilter(self):
     self.opt = cmds.optionMenuGrp(self.opt, label='Filter:', cc=self.cmdFilter, cw2=[40, 75], height=20)
     for i, item in enumerate(self.filters):
         itm = (item + '_%02d_menuItem' % i)
         cmds.menuItem(itm, l=item)
     attachForm = [(self.opt, 'bottom', 5), (self.opt, 'left', 0)]
     cmds.formLayout(self.form, edit=True, attachForm=attachForm)
Ejemplo n.º 16
0
    def populateMenu(self, menu, *args):

        cmds.radioMenuItemCollection(parent=menu)
        for loopOption in self.multiplierValues:
            radioSelected   = (self.multiplier == loopOption["value"])
            option          = loopOption["name"]
            cmds.menuItem (label=utilMod.toTitle(loopOption["name"]), radioButton=radioSelected, command=lambda x, option=option, *args: self.setMultiplier(option),  parent=menu)
Ejemplo n.º 17
0
def ruMainWindow():
	ruWin = "riggUtils"
	if mc.window(ruWin,q=True,ex=True):
		mc.deleteUI(ruWin)

	mc.window(ruWin,title = "Rigging Utilities")
	mc.scrollLayout(horizontalScrollBarThickness=16)
	ruMainColumn = mc.columnLayout(columnAttach=("both",5),rowSpacing=10,columnWidth=320)
	mc.frameLayout(label="General",bs="etchedOut",w=300,mw=5,cll=1)
	mc.button(label='Show Axis',command='mc.toggle(state=True, localAxis=True)')
	mc.button(label='Hide Axis',command='mc.toggle(state=False, localAxis=True)')
		
	mc.frameLayout(label="Non T-Pose joint placer",bs="etchedOut",w=300,mw=5,cll=1,p=ruMainColumn)
	mc.columnLayout(rs=5,adj=1)
	mc.button(l="Create Helper Locator",c =ruCreateLocator)
	mc.button(l="Create Joint on Helper Locator",c =ruCreateJointLocator)
	mc.floatSliderGrp("ruJointRadius",en=1,label="Joint Radius",field=True,minValue=0,maxValue=5,fieldMinValue=0,fieldMaxValue=5,value=0.5,cw3=(70,30,10),dc=ruJointRadius)
	
	mc.frameLayout(label="Fingers Utils",bs="etchedOut",w=300,mw=5,cll=1,p=ruMainColumn)
	mc.columnLayout(rs=5,adj=1)
	mc.floatSliderGrp("ruJointOrientation",en=1,label="Finger Orient",field=True,minValue=0,maxValue=5,fieldMinValue=0,fieldMaxValue=5,value=0.5,cw3=(70,30,10),dc=ruOrientJoint)
	mc.frameLayout(label="Finger Renaming",bs="etchedOut",w=300,mw=5,cll=1)
	mc.optionMenu('ruFinger',l='Choose finger')
	mc.menuItem(l='Thumb')
	mc.menuItem(l='Index')
	mc.menuItem(l='Middle')
	mc.menuItem(l='Ring')
	mc.menuItem(l='Pinky')
	mc.textFieldButtonGrp( label='Template string', text='', buttonLabel='Rename', bc=ruRenameFinger, cw3=[120,70,70],ct3=['left','left','left'],co3=[2,2,2] )
	
	mc.showWindow(ruWin)
Ejemplo n.º 18
0
Archivo: mayaUI.py Proyecto: gj210/upy
    def createMenu(self,menuDic,menuOrder=None):
        """ Define and draw the window/widget top file menu
        @type  menuDic: dictionary
        @param menuDic: the menu elements, ie entry, callback and submenu
        @type  menuOrder: array
        @param menuOrder: the menu keys oredered
        """        
        
        if menuOrder : 
            lookat = menuOrder
        else :
            lookat = menuDic.keys()
        for mitem in lookat:
            cmds.menu( label=mitem, tearOff=True , parent = self.winName)
            for elem in menuDic[mitem]:            
                if elem["sub"] is not None:
                    elem['id']=cmds.menuItem(subMenu=True, label=elem["name"])
                    for sub in elem['sub'].keys():
                        checkBox = False#elem['sub'][sub]['checkBox']
                        if elem['sub'][sub]["action"] is not None :
                            elem['sub'][sub]['id']=cmds.menuItem( label=elem['sub'][sub]["name"],
#                                                            checkBox=checkBox,
                                                            c=partial(elem['sub'][sub]["action"],sub))
                        else :
                            elem['sub'][sub]['id']=cmds.menuItem( label=elem['sub'][sub]["name"],)
#                                                            checkBox=checkBox,)
#                        if checkBox and elem['sub'][sub].has_key("var"):
#                            cmds.menuItem(elem['sub'][sub]['id'],e=1,checkBox=bool(elem['sub'][sub]['var']))
                    cmds.setParent( '..', menu=True )
                else:
                    if elem["action"] is not None :
                        elem['id']=cmds.menuItem( label=elem["name"],c=elem["action"])
                    else :
                        elem['id']=cmds.menuItem( label=elem["name"])
 def menu_item_comments(self, *args):
     cmds.popupMenu(parent=self.mainScroll)
     for comment in self.comments:
         if comment == 'Custom':
             cmds.menuItem(l=comment, c=self.create_comment)
         else:
             cmds.menuItem(l=comment, c=pm.Callback(self.adding_text, comment))
Ejemplo n.º 20
0
def setOptionMenuList(OMG,itemList,add=False):
	'''
	Set the list of items for the specified optionMenuGrp control
	@param OMG: OptionMenuGrp to set the item list for
	@type OMG: str
	@param itemList: List of items to add to optionMenuGrp
	@type itemList: list
	@param add: Add to existing menu items
	@type add: bool
	'''
	# Check optionMenuGrp
	if not mc.optionMenuGrp(OMG,q=True,ex=True):
		raise UIError('OptionMenu "'+OMG+'" does not exist!')
	
	# Get existing items
	exItemList = mc.optionMenuGrp(OMG,q=True,ill=True)
	
	# Add items
	for item in itemList:
		mc.setParent(OMG)
		mc.menuItem(l=item)
	
	# Remove previous items
	if exItemList:
		for item in exItemList:
			mc.deleteUI(item)
Ejemplo n.º 21
0
Archivo: mayaUI.py Proyecto: gj210/upy
 def drawPMenu(self,elem,x,y,w=None,h=None):
     """ Draw a pulldown menu 
     @type  elem: dictionary
     @param elem: the pulldown dictionary
     @type  x: int
     @param x: position on x in the gui windows
     @type  y: int
     @param y: position on y in the gui windows
     @type  w: int
     @param w: force the width of the item
     @type  h: int
     @param h: force the height of the item
     """                    
     #currently use the popupMenu, so this always follow another widget
     val = ""
     if elem["value"] is not None :
        if type(elem["value"]) is list or type(elem["value"]) is tuple:
            if len(elem["value"]):
                val = elem["value"][0]
     else :
         val= ""
     print ("pMenu",val)
     elem["variable"] = cmds.text( label=val, bgc=[0.38,0.38,0.38],
                 w=elem["width"]*self.scale,#*2,
                 h=elem["height"]*self.scale,
                 align="left",
                 recomputeSize=False)#bgc=97,97,97?
     elem["id"]=cmds.popupMenu( button=1 )
     for item in elem["value"] :
         print ("menu",item)
         cmds.menuItem(item,c=partial(self.c_updatePMenu,
                                 elem["variable"],item,elem["action"]))
Ejemplo n.º 22
0
def makeRelativeUI():
	'''
	User Interface for skinCluster.makeRelative()
	'''
	# Window
	win = 'makeRelativeUI'
	if mc.window(win,q=True,ex=True): mc.deleteUI(win)
	win = mc.window(win,t='SkinCluster - Make Relative')
	# Form Layout
	makeRelativeFL = mc.formLayout(numberOfDivisions=100)
	
	# SkinCluster option menu
	skinClusterOMG = mc.optionMenuGrp('makeRelativeSkinClusterOMG',label='SkinCluster')
	for skin in mc.ls(type='skinCluster'): mc.menuItem(label=skin)
	
	# Relative To TextField
	makeRelativeTFB = mc.textFieldButtonGrp('makeRelativeToTFB',label='RelativeTo',text='',buttonLabel='Load Selected')
	
	# Button
	makeRelativeBTN = mc.button(l='Make Relative',c='glTools.ui.skinCluster.makeRelativeFromUI()')
	
	# UI Callbacks
	mc.textFieldButtonGrp(makeRelativeTFB,e=True,bc='glTools.ui.utils.loadTypeSel("'+makeRelativeTFB+'","transform")')
	
	# Form Layout - MAIN
	mc.formLayout(makeRelativeFL,e=True,af=[(skinClusterOMG,'left',5),(skinClusterOMG,'top',5),(skinClusterOMG,'right',5)])
	mc.formLayout(makeRelativeFL,e=True,af=[(makeRelativeTFB,'left',5),(makeRelativeTFB,'right',5)])
	mc.formLayout(makeRelativeFL,e=True,ac=[(makeRelativeTFB,'top',5,skinClusterOMG)])
	mc.formLayout(makeRelativeFL,e=True,af=[(makeRelativeBTN,'left',5),(makeRelativeBTN,'right',5),(makeRelativeBTN,'bottom',5)])
	mc.formLayout(makeRelativeFL,e=True,ac=[(makeRelativeBTN,'top',5,makeRelativeTFB)])
	
	# Open window
	mc.showWindow(win)
Ejemplo n.º 23
0
def setup():
    print ("bamboo user setup")

    mainFileMenu = mel.eval("string $f=$gMainFileMenu")
    mel.eval("buildFileMenu")
    cmds.menuItem(dividerLabel="Bamboo Tools", divider=True)
    cmds.menuItem(label="Export...", parent=mainFileMenu, command="openExporterUI()")
Ejemplo n.º 24
0
 def create(self):
     
     form = cmds.formLayout()
     text  = cmds.text( l= self._label, al='right', h=20, width = self._textWidth )
     field = cmds.textField(h=21)
     cmds.popupMenu()
     cmds.menuItem( l=self._popup, c=self.cmdPopup )
     
     cmds.formLayout( form, e=1,
                      af=[(text,'top',0), (text,'left',0),
                          (field,'top',0),(field,'right',0)],
                      ac=[(field, 'left', 0, text)] )
     
     if self._position:
         cmds.formLayout( form, e=1,
                          ap=[(text,'right',0,self._position)])
         
     cmds.setParent( '..' )
     
     self._text = text
     self._field = field
     self._form = form
     
     self._globalForm = form
     self._globalField = field
     
     return form
Ejemplo n.º 25
0
	def dpaf_refreshLayerMenu(self, *args):

		global dpaf_unRenderableLayers
		
		# if I don't print something, scriptJob [renderLayerChange] may not work sometimes, ex: deleting the only (v)renderLayer except (x)masterLayer 
		print 'dpaf_Afanasy: Refreshing layer optionMenu...'

		if cmds.optionMenu('af_layerMenu',q= 1, ni= 1):
			for item in cmds.optionMenu('af_layerMenu', q= 1, ils= 1):
				cmds.deleteUI(item)

		for layer in cmds.ls(et= 'renderLayer'):
			if cmds.getAttr(layer + '.renderable'):
				if layer in dpaf_unRenderableLayers: dpaf_unRenderableLayers.remove(layer)
				cmds.menuItem('af_layerMenuItem_' + layer, l= layer if layer != 'defaultRenderLayer' else 'masterLayer', p= 'af_layerMenu')
				if layer != 'defaultRenderLayer':
					cmds.scriptJob(ro= 1, ac= [layer + '.renderable', partial(self.dpaf_layerRenderableTracker, layer)], p= 'af_layerMenuItem_' + layer)
					cmds.scriptJob(nodeNameChanged= [layer, partial(self.dpaf_layerReNameTracker, layer)], p= 'af_layerMenuItem_' + layer)
			else:
				if layer not in dpaf_unRenderableLayers: dpaf_unRenderableLayers.append(layer)
				if layer != 'defaultRenderLayer':
					cmds.scriptJob(ro= 1, ac= [layer + '.renderable', partial(self.dpaf_layerRenderableTracker, layer)], p= 'cgru_afanasy_wnd')

		currentLayer = cmds.editRenderLayerGlobals(q= 1, currentRenderLayer= 1)
		if cmds.optionMenu('af_layerMenu', q= 1, ni= 1):
			if 'af_layerMenuItem_' + currentLayer in cmds.optionMenu('af_layerMenu', q= 1, ils= 1):
				cmds.optionMenu('af_layerMenu', e= 1, v= currentLayer if currentLayer != 'defaultRenderLayer' else 'masterLayer')
			cmds.optionMenu('af_layerMenu', e= 1, en= 1)
		else:
			cmds.menuItem('af_layerMenuItem_NoRenderableLayer', l= 'No Renderable Layer', p= 'af_layerMenu')
			cmds.optionMenu('af_layerMenu', e= 1, en= 0)

		self.dpaf_layerMenuSync()
Ejemplo n.º 26
0
def particleLocatorsUI():
    """
    """
    # Get current frame range
    start = cmds.playbackOptions(q=True, min=True)
    end = cmds.playbackOptions(q=True, max=True)

    # Define window
    particleLocatorsUI = 'particleLocatorsWindow'
    if cmds.window(particleLocatorsUI, q=True, ex=True): cmds.deleteUI(particleLocatorsUI)
    particleLocatorsUI = cmds.window(particleLocatorsUI, t='Generate Locators')

    # UI Layout
    cmds.columnLayout(adj=False, cal='left')
    partiTFG = cmds.textFieldGrp('partiLoc_particleTFG', label='Particle', text='', cw=[(1, 120)])
    prefixTFG = cmds.textFieldGrp('partiLoc_prefixTFG', label='Prefix', text='', cw=[(1, 120)])
    bakeAnicmdsBG = cmds.checkBoxGrp('partiLoc_bakeAnicmdsBG', label='Bake Animation', ncb=1, v1=0, cw=[(1, 120)])
    startEndIFG = cmds.intFieldGrp('partiLoc_startEndISG', nf=2, label='Frame Range', v1=start, v2=end, cw=[(1, 120)])

    rotateLocCBG = cmds.checkBoxGrp('partiLoc_rotateCBG', label='Rotate (rotatePP)', ncb=1, v1=0, cw=[(1, 120)])
    scaleLocCBG = cmds.checkBoxGrp('partiLoc_scaleCBG', label='Scale (scalePP)', ncb=1, v1=0, cw=[(1, 120)])

    cmds.button(l='Create Locators', c='glTools.tools.generateParticles.particleLocatorsFromUI()')

    # Popup menu
    cmds.popupMenu(parent=partiTFG)
    for p in cmds.ls(type=['particle', 'nParticle']):
        cmds.menuItem(p, c='cmds.textFieldGrp("' + partiTFG + '",e=True,text="' + p + '")')

    # Show Window
    cmds.showWindow(particleLocatorsUI)
Ejemplo n.º 27
0
def savefolder(savepathini):
    newpath=mc.fileDialog2(ds = 1, fm = 3)
    if newpath:
        chkpath= newpath[0]+'/'
        counts=mc.getFileList (folder=chkpath)
        nc=counts.count('SavePose')
        if not nc:
            cofirm_but=mc.confirmDialog( title='Confirm', message='Do u want to create a new library in '+newpath[0]+ '   ??', button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' )
            if cofirm_but=='Yes':
                getMnuItms=mc.menu('chgFld',q=1,ia=1)
                if len(getMnuItms) >= 7:
                    mc.deleteUI(getMnuItms[3],mi=1)
                getMnuItms=mc.menu('chgFld',q=1,ia=1)    
                getItmLab=[]
                for each in getMnuItms:
                    lab=mc.menuItem(each,q=1,l=1)
                    getItmLab.append(lab)  
                if newpath:
                    if newpath[0] not in getItmLab:
                        mc.menuItem(label=newpath[0],p='chgFld',c=partial(changepath,newpath))
                savepathini=newpath[0]
            else:
                return
        else:
            savepathini=newpath[0]      
    else:
        return 
    Refresh_UI(savepathini)
    temp_path(savepathini)
def loadSelectedObj():
    cmds.file(new=True, pm=False, force=True)
    selected = cmds.optionMenu(loadComponentsMenu, q=True, v=True)
    global furniture
    global furnitureFilePath
    path = os.path.split(furnitureFilePath)[0] + "/meshes/furniture/"
    menuItems = cmds.optionMenu(componentsMenu, q=True, itemListLong=True)
    cmds.textField(objNameInput, tx=selected.split(".")[0].split("/")[1], e=True)
    if menuItems:
        cmds.deleteUI(menuItems)
    for comp in furniture["components"] :
        if comp["src"] == selected :
            global currentComponent
            componentDef = ""

            with open(os.path.split(furnitureFilePath)[0]+"/"+comp["src"], "r") as componentFile:
                componentDef = componentFile.read()
            currentComponent = json.loads(componentDef)

            cmds.file(path + currentComponent["src"], i=True)
            for con in currentComponent["connectors"]: #for connectors in the current objects connectors
                for types in con["componentTypes"]:
                    cmds.menuItem(p=componentsMenu, label=types)
                for jnt in con["out"]:
                    loc = cmds.spaceLocator()
                    cmds.move(jnt["position"][0], jnt["position"][1], jnt["position"][2], loc)
                    cmds.scale(jnt["scale"][0], jnt["scale"][1], jnt["scale"][2], loc)
                    cmds.rotate(jnt["rotation"][0], jnt["rotation"][1], jnt["rotation"][2], loc)
    updateJson()
    selectLocators()
    cmds.textField(typeInput, tx=currentComponent["type"], e=True)
Ejemplo n.º 29
0
    def addBaseBtn(s, joint, parent):

        def addNew():
            s.setAttr(joint, POSITION)
            s.setAttr(joint, ROTATION)
            s.setAttr(joint, SCALE)

        def addExisting():
            if position: s.setAttr(joint, POSITION, [position])
            if rotation: s.setAttr(joint, ROTATION, [rotation])
            if scale: s.setAttr(joint, SCALE, [scale])

        position = joint.get(POSITION, "")
        rotation = joint.get(ROTATION, "")
        scale = joint.get(SCALE, "")
        position = position if cmds.objExists(position) else None
        rotation = rotation if cmds.objExists(rotation) else None
        scale = scale if cmds.objExists(scale) else None

        btn = joint.btn["joint"] = cmds.button(
            h=30,
            bgc=COLOUR["blue"],
            l=shorten(joint.name),
            p=parent,
            c=Callback(addNew)
            )
        cmds.popupMenu(p=btn)
        if position or rotation or scale:
            cmds.menuItem(l="Use existing targets", c=Callback(addExisting))
        else:
            cmds.menuItem(l="Select a target to pick it", en=False)
Ejemplo n.º 30
0
def scanScene():
    global util, charnames, propnames, setnames, adcharnames, adpropnames, adsetnames, charopt, propopt, setopt
    util = Utils.utils()
    #declaring and initialising variables
    charnames, propnames, setnames, miscnames, charopt, propopt, setopt = [], [], [], [], [], [], []

    #find rim/key light folder path from config.xml

    rmkyfldr = "%s/%s/Location" % (util.path, util.litePath)
    rmkyfiles = os.listdir(rmkyfldr)
    ltbgs = [x.replace('', '') for x in rmkyfiles]
    unrefs = []

    #find time  folder path from config.xml
    try:
        litefldr = "%s/%s/Location/%s" % (util.path, util.litePath,
                                          rmkyfiles[0])
    except:
        mc.error("Please set the correct project")
        return
    Litefiles = os.listdir(litefldr)
    ltlites = [x.replace('_rimkey.ma', '') for x in Litefiles]

    #list all reference nodes in scene and list all unloaded references

    refs = mc.ls(type="reference")
    if refs:
        for each in refs:
            if each != "sharedReferenceNode" and each != "_UNKNOWN_REF_NODE_":
                try:
                    nodes = mc.referenceQuery(each, nodes=True)
                    if not nodes:
                        unrefs.append(each)
                except:
                    pass
    else:
        print '\nNo valid References found.\n'

    #prompt to load all unloaded references for the scan to proceed, cancel will still show assets but setup will not work

    if unrefs:
        nonrefassets = "Following references are unloaded\nLoad all the references?\n\n" + "\n".join(
            unrefs) + "\n"
        rslt = mc.confirmDialog(t='Warning',
                                m=nonrefassets,
                                b=['Continue', 'Cancel'],
                                db='Continue',
                                cb='Cancel',
                                ds='Cancel',
                                ma='center')
        if rslt == 'Cancel':
            pass
        else:
            for refs in unrefs:
                refpath = mc.referenceQuery(refs, f=True)
                mc.file(refpath, lr=True)

    #list all assets in the scenes using Utils.listAssets()

    charnames, propnames, setnames, miscnames = Utils.listAssets()
    if adcharnames:
        for each in adcharnames:
            if not each in charnames:
                charnames.append(each)
    if adpropnames:
        for each in adpropnames:
            if not each in propnames:
                propnames.append(each)
    if adsetnames:
        for each in adsetnames:
            if not each in setnames:
                setnames.append(each)

    #set the scroll menu placeholder in main UI as the parent menu of the dynamic that we're about to create

    mc.setParent('scrll')
    numlayers = mc.intFieldGrp("numgrps", q=True, v1=True)

    #column layout for the dynamic menu

    if mc.columnLayout("assetcol", ex=True):
        mc.deleteUI("assetcol")
    mc.columnLayout("assetcol")

    #listing the characters in the scene
    mc.separator(h=5, w=470, st='in')
    mc.text(l="         CHARACTERS  ", fn="boldLabelFont")
    mc.separator(h=5, w=470, st='in')
    mc.columnLayout(co=('left', 10))
    mc.separator(h=5, w=470, st='none')

    #creating the menu for each of the characters in the scene

    for i in range(len(charnames)):
        mc.rowLayout(nc=3, cw3=(200, 150, 50))
        #name of the character
        mc.text(l=charnames[i])
        #select button command
        com = "mc.select(\"%s\", r = True)" % charnames[i]
        menulabel = "chmenu%s" % str(i).zfill(2)
        charopt.append(menulabel)
        #dropdown list for selecting the render layer group that the character will go into
        mc.optionMenu(menulabel, label='Render Grp : ')
        for ii in range(numlayers):
            mc.menuItem(label="ch%s" % str(ii + 1).zfill(2))
        mc.menuItem(label="None")
        #button for selecting the character
        mc.button(l="Select", c=com)
        mc.setParent('..')
    mc.separator(h=5, w=470, st='none')
    mc.rowLayout(nc=2, cw2=(100, 300))
    #button to add a character that didn't show up in the scan
    mc.button(l=" Add Character",
              w=80,
              al="center",
              c=lambda event: addAsset(0))
    mc.text(label="Select a group and press button to add the character")
    mc.setParent('..')
    mc.separator(h=5, w=400, st='none')
    mc.setParent('..')

    #listing the props in the scene

    mc.separator(h=5, w=470, st='in')
    mc.text(l="          PROPS  ", fn="boldLabelFont")
    mc.separator(h=5, w=470, st='in')
    mc.columnLayout(co=('left', 10))
    mc.separator(h=5, w=470, st='none')

    #creating the menu for each of the props in the scene

    for k in range(len(propnames)):
        mc.rowLayout(nc=3, cw3=(200, 150, 50))
        #name of the prop
        mc.text(l=propnames[k])
        #select button command
        com = "mc.select(\"%s\", r = True)" % propnames[k]
        menulabel = "prmenu%s" % str(k).zfill(2)
        propopt.append(menulabel)
        #dropdown list for selecting the render layer group that the prop will go into
        mc.optionMenu(menulabel, label='Render Grp : ')
        for kk in range(numlayers):
            mc.menuItem(label="ch%s" % str(kk + 1).zfill(2))
        mc.menuItem(label="None")
        #button for selecting the prop
        mc.button(l="Select", c=com)
        mc.setParent('..')
    mc.separator(h=5, w=470, st='none')
    mc.rowLayout(nc=2, cw2=(100, 300))
    #button to add a prop that didn't show up in the scan
    mc.button(l="     Add Prop",
              w=80,
              al="center",
              c=lambda event: addAsset(1))
    mc.text(label="Select a group and press button to add the prop")
    mc.setParent('..')
    mc.separator(h=5, w=470, st='none')
    mc.setParent('..')

    #listing the bgs in the scene

    mc.separator(h=5, w=470, st='in')
    mc.text(l="          SETS  ", fn="boldLabelFont")
    mc.separator(h=5, w=470, st='in')
    mc.columnLayout(co=('left', 10))
    mc.separator(h=5, w=470, st='none')

    #creating the menu for each of the bgs in the scene

    for l in range(len(setnames)):
        mc.rowLayout(nc=3, cw3=(200, 150, 50))
        #name of the bg
        mc.text(l=setnames[l])
        #select button command
        com = "mc.select(\"%s\", r = True)" % setnames[l]
        menulabel = "bgmenu%s" % str(l).zfill(2)
        setopt.append(menulabel)
        #dropdown list for selecting the render layer group that the bg will go into
        mc.optionMenu(menulabel, label='Render Grp : ')
        for ll in range(numlayers):
            mc.menuItem(label="ch%s" % str(ll + 1).zfill(2))
        mc.menuItem(label="None")
        #button for selecting the bg
        mc.button(l="Select", c=com)
        mc.setParent('..')
    mc.separator(h=5, w=470, st='none')
    mc.rowLayout(nc=2, cw2=(100, 300))
    #button to add a bg that didn't show up in the scan
    mc.button(l="       Add Set",
              w=80,
              al="center",
              c=lambda event: addAsset(2))
    mc.text(label="Select a group and press button to add the set")
    mc.setParent('..')
    mc.separator(h=5, w=470, st='none')
    mc.setParent('..')
    mc.separator(h=5, w=470, st='in')

    #creating the light options menu

    mc.setParent('ltopts')
    if mc.columnLayout("ltopscol", ex=True):
        mc.deleteUI("ltopscol")
    mc.columnLayout('ltopscol')
    mc.rowLayout(nc=2)
    mc.rowLayout(nc=4, cw4=(39, 39, 39, 39))
    mc.checkBox("selchk", label="all", v=1, w=50, cc=lambda event: chkchange())
    mc.checkBox("keychk", label="key", v=1, w=39)
    mc.checkBox("rimchk", label="rim", v=1, w=39)
    mc.checkBox("colchk", label="col", v=1, w=39)

    mc.setParent('..')
    mc.rowLayout(nc=4, cw4=(39, 39, 39, 39))
    mc.checkBox("occchk", label="occ", v=1, w=39)
    mc.checkBox("rgbachk", label="rgba", v=1, w=43)
    mc.checkBox("gshchk", label="gsh", v=1, w=39)
    mc.checkBox("matchk", label="mat", v=1, w=39)
    mc.setParent('..')
    mc.setParent('..')
    mc.separator(h=15, w=470, st='none')
    mc.rowLayout(nc=3, cw3=(30, 250, 150))
    mc.text(label='')
    #checkbox to query whether the references need to be cut
    mc.checkBox("refchk",
                label="Import all references(Cut the references)",
                v=0)
    #checkbox to query whether the cameras need to be exported
    mc.checkBox("camchk", label="Export cameras", v=0)
    mc.setParent('..')
    mc.separator(h=15, w=470, st='none')
    mc.rowLayout(nc=4, cw4=(80, 90, 110, 125))
    mc.text(label="Ambient Light")
    mc.text(label="     Location")
    mc.text(label="       Time")
    mc.text(label="   Render Scene Camera")
    mc.setParent('..')
    mc.separator(h=5, w=470, st='none')
    mc.rowLayout(nc=4, cw4=(80, 100, 110, 145))
    #dropdown to query what kind of ambient light to use
    mc.optionMenu('amblite', label='')
    mc.menuItem(label="None")
    mc.menuItem(label="GI")
    mc.menuItem(label="ambient")

    #mc.menuItem( label="GILight")
    #dropdown to query which rim/key file to use
    mc.optionMenu('Location', label='', cc=lambda event: locc())
    for each in ltbgs:
        mc.menuItem(label=each)
    #dropdown to query which time lights to use
    mc.optionMenu('Time', label='')
    for each in ltlites:
        mc.menuItem(label=each)
    #list all cameras in the scene to find out renderable camera
    cams = mc.ls(type="camera")
    rencams = []
    epcams = []
    #list all cameras that are children of 'CAMERAS' group
    if mc.objExists('CAMERAS'):
        epcams = mc.listRelatives('CAMERAS', c=True, ad=True, type='camera')
    #find out the scene camera and set it to renderable
    if epcams:
        for each in cams:
            if each in epcams:
                rencams.append(each)
                mc.setAttr((each + ".renderable"), 1)
    if not rencams:
        rencams = cams
    #dropdown to show renderable cameras in the scene. the scene camera will be selected by default
    mc.optionMenu(
        'camlite',
        label='',
    )
    renParentCams = [mc.listRelatives(x, p=True)[0] for x in rencams]
    for each in renParentCams:
        mc.menuItem(label=each)
    mc.optionMenu('camlite', e=True, v=(renParentCams[0]))
    mc.setParent('..')
    #calculate optimum height of UI window based on the number of assets to be processed
    numasts = len(charnames) + len(propnames) + len(setnames)
    if numasts > 12:
        numasts = 12
    scrht = 300 + numasts * 25
    winht = 590 + numasts * 25
    #edit the window and scrolllayout heights to be the optimum value
    mc.window('liteshot', e=True, wh=(483, winht))
    mc.scrollLayout('scrll', e=True, h=scrht, w=450, vis=True)
Ejemplo n.º 31
0
    def comRenUI(self, _=False):

        # C H E C K  W I N D O W

        if (cmds.window("comRenWin", exists=True)):
            cmds.deleteUI("comRenWin", wnd=True)
            cmds.windowPref("comRenWin", r=True)

        # U I

        cmds.window("comRenWin",
                    s=False,
                    tlb=True,
                    rtf=True,
                    t="Compact Renamer")

        cmds.columnLayout(adj=True)

        # R A D I O  B U T T O N S

        cmds.rowLayout(numberOfColumns=5, columnWidth5=(100, 150, 50, 100, 50))

        comRenRC = cmds.radioCollection()
        cmds.radioButton('comRenPreRB', l="Prefix", cl=comRenRC)
        cmds.radioButton('comRenNamRB', l="Name", cl=comRenRC)
        cmds.text("Pad", align='left')
        cmds.radioButton('comRenSufRB', l="Suffix", cl=comRenRC)
        cmds.radioButton('comRenAllRB', l="All", cl=comRenRC, select=True)

        cmds.setParent("..")

        # T E X T  F I E L D S

        cmds.rowLayout(numberOfColumns=5)

        cmds.textField("tFcR_Prefix", height=30, width=100)
        cmds.textField("tFcR_Name", height=30, width=150)
        cmds.optionMenu(cc=self.changePaddingMenuItem,
                        w=50,
                        h=28,
                        ebg=False,
                        bgc=(0.18, 0.18, 0.18))
        cmds.menuItem(l="3")
        cmds.menuItem(l="2", ia="")
        cmds.menuItem(l="1", ia="")
        cmds.menuItem(l="4")
        cmds.menuItem(l="5")
        cmds.menuItem(l="6")
        cmds.menuItem(l="7")
        cmds.menuItem(l="8")
        cmds.menuItem(l="9")
        cmds.textField("tFcR_Suffix", height=30, width=100)
        cmds.button(l="Ren",
                    bgc=(0.24, 0.72, 0.46),
                    ebg=False,
                    height=30,
                    width=50,
                    c=self.comRenRename)

        cmds.setParent("..")

        # S H O W  W I N D O W

        cmds.showWindow("comRenWin")
Ejemplo n.º 32
0
def build():
    """build zfused maya menu 
    """
    # ===============================================================
    # main menu
    cmds.menu("zfused_outsource",
              parent="MayaWindow",
              label="zFused outsource",
              tearOff=True)
    _menu_data = menu.get_menu_data()
    cmds.menuItem(label=u"", divider=True, parent="zfused_outsource")
    _company_id = record.current_company_id()
    if _company_id:
        _company_name = zfused_api.company.Company(_company_id).name()
    else:
        _company_name = u"未设置公司"
    cmds.menuItem(
        "zfused_company",
        label=u"{}".format(_company_name),
        command=
        "from zfused_maya.interface import menubar;menubar.change_company();",
        parent="zfused_outsource")
    cmds.menuItem(label=u"", divider=True, parent="zfused_outsource")

    for _menu_title in menu.MENU_KEY:
        cmds.menuItem(_menu_title,
                      label=_menu_title,
                      parent="zfused_outsource",
                      subMenu=True,
                      tearOff=True)
        if _menu_title in _menu_data.keys():
            # load menu
            category = []
            category_cmds = {}
            menu_data = _menu_data[_menu_title]
            for data in menu_data:
                cate = data["category"]
                if not cate in category:
                    category.append(cate)
                if not cate in category_cmds:
                    category_cmds[cate] = []
                category_cmds[cate].append(data)
            for ca in category:
                cmds.menuItem(label=ca, divider=True, parent=_menu_title)
                for data in category_cmds[ca]:
                    cmds.menuItem(data["name"],
                                  label=data["title"],
                                  parent=_menu_title,
                                  command=data["cmd"])
        cmds.menuItem(divider=True, parent="zfused_outsource")
    cmds.menuItem("about",
                  label=u"关于zFused",
                  command="",
                  parent="zfused_outsource")

    # project menu
    _build_project_menu()
Ejemplo n.º 33
0
def jpmLayerHarvest():
    currentSort = 1
    currentSort = cmds.optionVar(q="jpmLHalpha")

    #Handle path
    path = cmds.optionVar(q="jpmLHpath")
    if path == 0:
        jpmLH_setPathDialog()
        path = cmds.optionVar(q="jpmLHpath")

    winName = "jpmLayerHarvest"
    if (cmds.window(winName, exists=True)):
        cmds.deleteUI(winName)
    cmds.window(winName, t="Layer Harvest", rtf=True, mb=1)

    fileMenu = cmds.menu("jpmLH_fileMenu", l="File")
    cmds.menuItem("jpmLH_setPathMenuItem",
                  l="Set Path...",
                  c="jpmLH_setPathDialog()")
    cmds.menuItem("jpmLH_printPathMenuItem",
                  l="Print Path",
                  c=("print \"" + str(path) + "\""))
    cmds.menuItem("jpmLH_batchMenuItem",
                  l="Batch...",
                  p=fileMenu,
                  c="jpmLH_batchDialog()")
    cmds.menuItem("jpmLH_writeMenuItem",
                  l="Write...",
                  p=fileMenu,
                  c="jpmLH_writeDialog()")
    cmds.menuItem("jpmLH_harvestMenuItem",
                  l="Harvest...",
                  p=fileMenu,
                  c="jpmLH_harvest()")

    sortMenu = cmds.menu("jpmLH_sortMenu", l="Sort")
    cmds.radioMenuItemCollection("jpmLH_sortMethod")
    cmds.menuItem("jpmLH_listAlpha",
                  l="Alpha",
                  rb=currentSort,
                  cl="jpmLH_sortMethod",
                  c="jpmLH_populateFileList(1)",
                  p=sortMenu)
    cmds.menuItem("jpmLH_listCreation",
                  l="Creation",
                  rb=(not currentSort),
                  cl="jpmLH_sortMethod",
                  c="jpmLH_populateFileList(0)",
                  p=sortMenu)

    #form and layout
    jpmLH_form = cmds.formLayout("jpmLH_form", nd=100)
    cmds.rowColumnLayout("jpmLH_topLayout", nc=1, cw=[1, 300])

    #name field and write new file button
    nameField = cmds.rowColumnLayout(nc=2, cw=([1, 190], [2, 100]))
    cmds.textFieldGrp("jpmLH_layerNameGrp",
                      l="Harvest Name",
                      cw=([1, 80], [2, 110]),
                      cal=([1, "left"], [2, "left"]),
                      tx="...Harvest Name...")
    cmds.button(w=100, l="Harvest", c="jpmLH_collectAndCall()")

    #file list
    cmds.setParent(jpmLH_form)
    fileList = cmds.textScrollList("jpmLH_fileList",
                                   ams=0,
                                   w=165,
                                   dcc="jpmLH_applyHarvestFile()",
                                   dkc="jpmLH_deleteFile()")

    #RMB pop up menu for the file list
    cmds.popupMenu(b=3, p=fileList)
    cmds.menuItem(l="Apply Selected", c="jpmLH_applyHarvestFile()")
    cmds.menuItem(l="Rename Selected...", c="jpmLH_renameFileWin()")
    cmds.menuItem(l="Name --->", c="jpmLH_popUpName()")
    cmds.menuItem(divider=1)
    cmds.menuItem(l="Delete Selected", c="jpmLH_deleteFile()")

    #attach the file list to the re-sizing window
    cmds.formLayout(jpmLH_form,
                    e=1,
                    af=([fileList, "top",
                         25], [fileList, "left",
                               0], [fileList, "bottom",
                                    0], [fileList, "right", 0]))

    #re-populate the file list
    jpmLH_populateFileList(currentSort)

    cmds.showWindow(winName)
Ejemplo n.º 34
0
    def popup_filemenu(self, parent, *args):
        cmd.menu(parent, e=True, dai=True)
        cmd.setParent(parent, m=True)

        other = self.otherLocale()
        items = self.selected()
        numItems = len(items)
        if numItems:
            cmd.menuItem(l='copy to %s' % other, c=self.copy)
            cmd.menuItem(l='move to %s' % other, c=self.move)

            if len(items) == 1:
                filepath = items[0].resolve()
                cmd.menuItem(d=True)
                cmd.menuItem(l='open in notepad',
                             c=lambda *x: self.on_notepad(filepath))

                cmd.menuItem(d=True)
                addExploreToMenuItems(filepath)

            cmd.menuItem(d=True)
            cmd.menuItem(l='delete', c=self.delete)

        #if no files are selected, prompt the user to select files
        if numItems == 0:
            cmd.menuItem(en=False, l='select a preset file')
Ejemplo n.º 35
0
    def createMyLayout(self):
        '''
        Basic window for render parameters. It's minimalistic, as most scene settings we derive stright
        from Maya.
        '''
        # Check if an instance of Ha Render Settings window already exists
        if cmds.window('haRenderWnd', ex=True):
            cmds.deleteUI('haRenderWnd')

        # Create window
        self.window = cmds.window('haRenderWnd',
                                  title='HA Render Settings',
                                  width=500,
                                  height=300,
                                  sizeable=True)
        fieldWidth = 60
        checkboxHeight = 20

        # COMMON

        # Create menu
        cmds.columnLayout(adjustableColumn=True)
        cmds.frameLayout(label='Settings',
                         borderStyle='etchedIn',
                         lv=0,
                         mh=5,
                         mw=5)
        cmds.frameLayout(label='Common', collapsable=True, borderStyle='out')
        cmds.rowColumnLayout(numberOfColumns=2,
                             columnWidth=[(1, 150), (2, 200)],
                             columnAttach=(1, 'right', 5))

        # Create render queue list
        cmds.text(label='Render queues:')
        self.queue_list = cmds.optionMenu(cc=self.change_queue)
        for q in self.farm.manager.get_queue_list():
            cmds.menuItem(label=q)
            cmds.setParent(menu=True)

        # Create host groups list
        cmds.text(label='Host group:')
        self.group_list = cmds.optionMenu(cc=self.change_group)
        for q in self.farm.manager.get_group_list():
            cmds.menuItem(label=q)
            cmds.setParent(menu=True)

        # Create renderers list
        cmds.text(label='Renderer:')
        self.group_list = cmds.optionMenu(cc=self.change_renderer)
        for q in self.get_renderers_list():
            cmds.menuItem(label=q)
            cmds.setParent(menu=True)

        # Create cameras list
        cmds.text(label='Renderable camera:')
        cmds.optionMenu(cc=self.change_camera)
        for q in self.get_camera_list():
            cmds.menuItem(label=q)
            cmds.setParent(menu=True)

        # Create renderable layers list
        cmds.text(label='Renderable layer:')
        layers = self.get_layer_list()
        self.layer_list = cmds.textScrollList(numberOfRows=5,
                                              ams=True,
                                              append=layers,
                                              sc=self.change_layers)

        # Hold toggle
        cmds.text(label='')
        self.holdcheckBox = cmds.checkBox(label='Submit job on hold',
                                          height=checkboxHeight,
                                          cc=self.change_hold)

        cmds.setParent('..')
        cmds.setParent('..')

        # MEMORY

        cmds.frameLayout(label='Memory', collapsable=True, borderStyle='out')
        cmds.rowColumnLayout(numberOfColumns=2,
                             columnWidth=[(1, 150), (2, 200)],
                             columnAttach=(1, 'right', 5))

        # Priority, slots, memory:
        cmds.text(label='Render priority:')
        cmds.intSliderGrp(value=self.farm.parms['priority'],
                          field=True,
                          min=-1023,
                          max=0,
                          step=100,
                          columnWidth=(1, fieldWidth),
                          cc=self.change_priority)

        cmds.text(label='Number of slots:')
        self.slotsSld = cmds.intSliderGrp(value=self.farm.parms['slots'],
                                          field=True,
                                          enable=True,
                                          min=1,
                                          max=24,
                                          step=1,
                                          columnWidth=(1, fieldWidth),
                                          cc=self.change_slots)

        cmds.text(label='')
        cmds.checkBox(label='Set CPU share',
                      height=checkboxHeight,
                      cc=self.set_cpu)

        cmds.text(label='CPU share:')
        self.cpuSld = cmds.floatSliderGrp(value=self.farm.parms['cpu_share'],
                                          field=True,
                                          enable=False,
                                          min=0.01,
                                          max=1.0,
                                          step=0.01,
                                          columnWidth=(1, fieldWidth),
                                          cc=self.change_cpu)

        cmds.text(label='Required memory (in GB):')
        cmds.intSliderGrp(value=self.farm.parms['req_memory'],
                          field=True,
                          min=1,
                          max=16,
                          step=1,
                          columnWidth=(1, fieldWidth),
                          cc=self.change_memory)

        cmds.setParent('..')
        cmds.setParent('..')

        # FRAME RANGE

        cmds.frameLayout(label='Frame Range',
                         collapsable=True,
                         borderStyle='out')
        cmds.rowColumnLayout(numberOfColumns=2,
                             columnWidth=[(1, 150), (2, 60)],
                             columnAttach=(1, 'right', 5))

        cmds.text(label='Start frame:')
        cmds.intField(value=int(cmds.playbackOptions(query=True, min=True)),
                      cc=self.change_startFrame)

        cmds.text(label='End frame:')
        cmds.intField(value=int(cmds.playbackOptions(query=True, max=True)),
                      cc=self.change_endFrame)

        # MISCELLANEOUS

        cmds.setParent('..')
        cmds.setParent('..')
        cmds.frameLayout(label='Miscellaneous',
                         borderStyle='out',
                         collapsable=True,
                         collapse=False)
        cmds.rowColumnLayout(numberOfColumns=2,
                             columnWidth=[(1, 150), (2, 200)],
                             columnAttach=(1, 'right', 5))

        cmds.text(label='Delay:')
        cmds.textField(cc=self.set_delay)

        cmds.text(label='')
        cmds.checkBox(label='Make proxy',
                      height=checkboxHeight,
                      cc=self.make_proxy)

        cmds.setParent('..')
        cmds.setParent('..')
        cmds.setParent('..')
        cmds.setParent('..')

        # RENDER

        form = cmds.formLayout()
        self.renderButton = cmds.button(label='Render',
                                        command=self.renderButton_pressed,
                                        height=27)

        cmds.formLayout(form,
                        edit=True,
                        attachForm=[(self.renderButton, 'bottom', 5),
                                    (self.renderButton, 'left', 5),
                                    (self.renderButton, 'right', 5)])

        # Show window
        cmds.showWindow(self.window)
Ejemplo n.º 36
0
def createMenu(*args):
    #Get all the cameras available in the scene
    cameras = cmds.listCameras(perspective=True)

    #Check to see if the menu exists (only for refreshing cameras - adding/removing cameras and still keep the same menu order)
    if cmds.optionMenu('opCamera', exists=True):
        cmds.deleteUI('opCamera')
        cmds.deleteUI('viz')
        cmds.deleteUI('wireframe')
        cmds.deleteUI('points')
        cmds.deleteUI('bound')
        cmds.deleteUI('smooth')
        cmds.deleteUI('flat')
        cmds.deleteUI('reload')

    #Populate the cameras for selection
    opCamera = cmds.optionMenu('opCamera',
                               label='Camera: ',
                               changeCommand=changeCamera,
                               parent='column')
    for each in range(len(cameras)):
        cmds.menuItem(label=cameras[each], parent='opCamera')
    #Checkbox option to change visualization options on the selected camera
    cmds.checkBox('viz',
                  label='Viz',
                  parent='column',
                  onCommand=toggleGate,
                  offCommand=toggleGate)

    #Add buttons to change display type
    cmds.button(
        'wireframe',
        label='Wireframe',
        command=
        "cmds.modelEditor('editor', edit=True, displayAppearance='wireframe')",
        parent='column')
    cmds.button(
        'points',
        label='Points',
        command=
        "cmds.modelEditor('editor', edit=True, displayAppearance='points')",
        parent='column')
    cmds.button(
        'bound',
        label='Bounding Box',
        command=
        "cmds.modelEditor('editor', edit=True, displayAppearance='boundingBox')",
        parent='column')
    cmds.button(
        'smooth',
        label='Smooth Shaded',
        command=
        "cmds.modelEditor('editor', edit=True, displayAppearance='smoothShaded')",
        parent='column')
    cmds.button(
        'flat',
        label='Flat Shaded',
        command=
        "cmds.modelEditor('editor', edit=True, displayAppearance='flatShaded')",
        parent='column')
    cmds.button('reload',
                label='Reload Cameras',
                command=createMenu,
                parent='column')
Ejemplo n.º 37
0
 def refreshJointList(self, refresh, search=''):
     seltyp = 0 if cmds.selectType(q=1, ocm=1, pv=1) or cmds.selectType(q=1, ocm=1, lp=1) or cmds.selectType(q=1, ocm=1, cv=1) else 1
     if seltyp:
         self.refreshBoxChange(9)
         return
     sel = cmds.ls(sl=1, fl=1)
     # ▽ copy权重后会触发刷新, 列表中的第一个可能是shape节点, 所以过滤一下mesh, 但是感觉可能会出现一些问题?
     #    点的Type也是mesh, 如果出问题可能在这.
     errorsel = cmds.ls(sl=1, typ=('transform', 'mesh'))
     if not sel or errorsel:
         return
     selobj = cmds.ls(sl=1, o=1)[0]
     clusterName = mel.eval('findRelatedSkinCluster("%s")' % selobj)
     if not clusterName:
         self.refreshBoxChange(9)
         return
     self.tempcluster = clusterName
     jointList = cmds.skinCluster(selobj, q=1, inf=1)  # cmds.skinCluster(selobj, q=1, wi=1)
     siItem = cmds.treeView('JointTV_JellyBean', q=1, si=1)
     _zero = cmds.menuItem('FImeunItem_JellyBean', q=1, cb=1)
     saveData = cmds.text('saveData_JellyBean', q=1, l=1).split('|')
     if refresh or _zero or saveData[0] != clusterName or saveData[1] != str(len(jointList)) or not cmds.treeView('JointTV_JellyBean', q=1, ch=''):
         cmds.treeView('JointTV_JellyBean', e=1, ra=1)
         if search:
             text = cmds.textField('searchText_JellyBean', q=1, tx=1)
             getList = [i for i in jointList if text in i]
             if getList:
                 jointList = getList
         jointList.sort()
         _jointList = []
         _valueList = []
         for i in jointList:
             Value = '%.3f' % cmds.skinPercent(clusterName, sel[0], ib=.000000001, q=1, t=i)
             if _zero:
                 if float(Value):
                     _jointList.append(i)
                     _valueList.append(Value)
             else:
                 _jointList.append(i)
                 _valueList.append(Value)
         for j, v in zip(_jointList, _valueList):
             if cmds.menuItem('HImeunItem_JellyBean', q=1, rb=1):
                 self.addHItoList(j, _jointList)
             else:
                 cmds.treeView('JointTV_JellyBean', e=1, ai=[j, ''])
             if cmds.getAttr(j + '.liw'):
                 cmds.treeView('JointTV_JellyBean', e=1, i=(j, 1, 'Lock_ON.png'))
             else:
                 cmds.treeView('JointTV_JellyBean', e=1, i=(j, 1, 'Lock_OFF_grey.png'))
             if not cmds.treeView('JointTV_JellyBean', q=1, dls=1):
                 cmds.treeView('JointTV_JellyBean', e=1, dls=(j, ''))
             if float(v):
                 cmds.treeView('JointTV_JellyBean', e=1, dls=(j, '   |   %s' % v))
         if siItem:
             allItem = cmds.treeView('JointTV_JellyBean', q=1, ch='')
             _Temp_ = list(set(siItem).intersection(set(allItem)))  # 求并集
             for i in _Temp_:
                 cmds.treeView('JointTV_JellyBean', e=1, si=(i, 1))
     else:
         allItem = cmds.treeView('JointTV_JellyBean', q=1, ch='')
         for j in allItem:
             if cmds.getAttr(j + '.liw'):
                 cmds.treeView('JointTV_JellyBean', e=1, i=(j, 1, 'Lock_ON.png'))
             else:
                 cmds.treeView('JointTV_JellyBean', e=1, i=(j, 1, 'Lock_OFF_grey.png'))
             Value = '%.3f' % cmds.skinPercent(clusterName, sel[0], ib=.000000001, q=1, t=j)
             if not cmds.treeView('JointTV_JellyBean', q=1, dls=1):
                 cmds.treeView('JointTV_JellyBean', e=1, dls=(j, ''))
             if not float(Value):
                 continue
             cmds.treeView('JointTV_JellyBean', e=1, dls=(j, '   |   %s' % Value))
     cmds.text('saveData_JellyBean', e=1, l='%s|%s' % (clusterName, len(jointList)))
Ejemplo n.º 38
0
    def ToolUi(self):
        ToolUi = 'WeightTool_JellyBean'
        if cmds.window(ToolUi, q=1, ex=1):
            cmds.deleteUI(ToolUi)
        cmds.window(ToolUi, t='WeightTool', rtf=1, mb=1, mxb=0, wh=(230, 500))
        cmds.menu(l='SkinT', to=1)
        cmds.menuItem(d=1, dl="S/L")
        cmds.menuItem(l='Save', c=lambda *args: self.vtxSave_api())
        cmds.menuItem(l='Load', c=lambda *args: self.vtxLoad_api())
        cmds.menuItem(d=1)
        cmds.menuItem(l='WeightCheck', c=lambda *args: WeightCheckTool_JellyBean().ToolUi())
        cmds.menuItem(l='reset SkinPose', c=lambda *args: self.resetSkinPose())
        cmds.menu(l='RigT', to=1)
        cmds.menuItem(l='Create', c=lambda *args: self.createSelect())
        cmds.menuItem(l='Get', c=lambda *args: self.getSelect())
        cmds.columnLayout('FiristcL_JellyBean', cat=('both', 2), rs=2, cw=220, adj=1)
        cmds.text('spJobchangeVtx_JellyBean', p='FiristcL_JellyBean', vis=0)
        cmds.scriptJob(e=['SelectTypeChanged', 'WeightTool_JellyBean().refreshBoxChange(None)'], p='spJobchangeVtx_JellyBean')
        cmds.rowLayout(nc=6, adj=2)
        cmds.iconTextCheckBox('refresh_JellyBean', i='refresh.png', w=20, h=20,
                              onc=lambda *args: self.spJobStart(), ofc=lambda *args: self.refreshBoxChange(9))
        cmds.popupMenu()
        cmds.menuItem('OFFmeunItem_JellyBean', l='OFF', cb=0)
        cmds.textField('searchText_JellyBean', h=22, tcc=lambda *args: self.refreshJointList(1, cmds.textField('searchText_JellyBean', q=1, tx=1)))
        cmds.popupMenu()
        cmds.radioMenuItemCollection()
        cmds.menuItem('HImeunItem_JellyBean', l='Hierarchy', rb=1, c=lambda *args: self.refreshJointList(1))
        cmds.menuItem('AImeunItem_JellyBean', l='Alphabetically', rb=0, c=lambda *args: self.refreshJointList(1))
        cmds.menuItem('FImeunItem_JellyBean', l='Filter Zero', cb=0, c=lambda *args: self.refreshJointList(1))
        # cmds.iconTextButton(i='expandInfluenceList.png', w=20, h=20,
        #    c=lambda *args: cmds.treeView('JointTV_JellyBean', e=1, h=cmds.treeView('JointTV_JellyBean', q=1, h=1) + 20))
        # cmds.iconTextButton(i='retractInfluenceList.png', w=20, h=20,
        #    c=lambda *args: cmds.treeView('JointTV_JellyBean', e=1, h=cmds.treeView('JointTV_JellyBean', q=1, h=1) - 20))
        # invertSelection.png
        cmds.iconTextButton(i='invertSelection.png', w=20, h=20, c=self.reSelect)
        cmds.setParent('..')
        cmds.setParent('..')
        cmds.formLayout('JointTVLayout_JellyBean')
        cmds.treeView('JointTV_JellyBean', nb=1, h=100, scc=self._weightView, pc=(1, self.lock_unLock))
        cmds.text('saveData_JellyBean', l='', vis=0)
        cmds.popupMenu()
        #cmds.menuItem(l='Lock All')
        #cmds.menuItem(l='Unlock All')
        cmds.menuItem(l='Select Vtx', c=lambda *args: self.slVtx())
        cmds.formLayout('JointTVLayout_JellyBean', e=1, af=[('JointTV_JellyBean', 'top', 0), ('JointTV_JellyBean', 'bottom', 0),
                                                            ('JointTV_JellyBean', 'left', 3), ('JointTV_JellyBean', 'right', 3)])
        cmds.setParent('..')
        cmds.columnLayout(cat=('both', 2), rs=2, cw=225)
        cmds.rowLayout(nc=4, cw4=(50, 50, 50, 65))
        cmds.floatField('weighrfloat_JellyBean', w=52, h=26, pre=4, min=0, max=1,
                        ec=lambda *args: self.editVtxWeight(cmds.floatField('weighrfloat_JellyBean', q=1, v=1)))
        cmds.button(w=50, h=26, l='Copy', c=lambda *args: self.copyVtxWeight())
        cmds.button(w=50, h=26, l='Paste', c=lambda *args: self.pasteVtxWeight())
        cmds.popupMenu()
        cmds.menuItem(l='PasteAll', c=lambda *args: mel.eval("polyConvertToShell;artAttrSkinWeightPaste;"))
        cmds.button(w=65, h=26, l='Hammer', c=lambda *args: (mel.eval('weightHammerVerts'), self.refreshJointList(0)))
        cmds.setParent('..')
        cmds.rowLayout(nc=5, cw5=(43, 43, 43, 43, 43))
        cmds.button(w=43, h=26, l='Loop', c=lambda *args: cmds.polySelectSp(loop=1))
        cmds.button(w=43, h=26, l='Ring',
                    c=lambda *args: mel.eval("PolySelectConvert 2;PolySelectTraverse 2;polySelectEdges edgeRing;PolySelectConvert 3;"))
        cmds.button(w=43, h=26, l='Shell', c=lambda *args: mel.eval("polyConvertToShell"))
        cmds.button(w=43, h=26, l='Shrink', c=lambda *args: cmds.polySelectConstraint(pp=2))
        cmds.button(w=43, h=26, l='Grow', c=lambda *args: cmds.polySelectConstraint(pp=1))
        cmds.setParent('..')
        cmds.rowLayout(nc=7, cw=[(1, 30), (2, 30), (3, 30), (4, 30), (5, 30), (6, 30), (7, 30)])
        cmds.button(w=30, h=26, l='0', c=lambda *args: self.editVtxWeight(0))
        cmds.button(w=30, h=26, l='.1', c=lambda *args: self.editVtxWeight(.1))
        cmds.button(w=30, h=26, l='.25', c=lambda *args: self.editVtxWeight(.25))
        cmds.button(w=30, h=26, l='.5', c=lambda *args: self.editVtxWeight(.5))
        cmds.button(w=30, h=26, l='.75', c=lambda *args: self.editVtxWeight(.75))
        cmds.button(w=30, h=26, l='.9', c=lambda *args: self.editVtxWeight(.9))
        cmds.button(w=30, h=26, l='1', c=lambda *args: self.editVtxWeight(1))
        cmds.setParent('..')
        cmds.rowLayout(nc=4, cw4=(80, 60, 38, 38))
        cmds.text(l='A/S Weight', w=80)
        cmds.floatField('ASFloat_JellyBean', v=0.05, h=26, w=50, pre=3, min=0, max=1)
        cmds.button(w=38, h=26, l='+', c=lambda *args: self.editVtxWeight('+'))
        cmds.button(w=38, h=26, l='-', c=lambda *args: self.editVtxWeight('-'))
        cmds.setParent('..')
        cmds.rowLayout(nc=4, cw4=(80, 60, 38, 38))
        cmds.text(l='M/D Weight', w=80)
        cmds.floatField('MDFloat_JellyBean', v=0.95, h=26, w=50, pre=3, min=0, max=1)
        cmds.button(w=38, h=26, l='*', c=lambda *args: self.editVtxWeight('*'))
        cmds.button(w=38, h=26, l='/', c=lambda *args: self.editVtxWeight('/'))
        cmds.setParent('..')

        cmds.showWindow(ToolUi)
import maya.cmds as cmds
import random as rnd

if 'myWin' in globals():
    if cmds.window(myWin, exists=True):
        cmds.deleteUI(myWin, window=True)

if 'nextBlockId' not in globals():
    nextBlockId = 1000

myWin = cmds.window(title="Lego Blocks",
                    menuBar=True,
                    topLeftCorner=(100, 1000))

cmds.menu(label="Basic Options")
cmds.menuItem(label="New Scene", command=('cmds.file(new=True, force=True)'))
cmds.menuItem(label="Delete Selected", command=('cmds.delete()'))

##STANDARD BLOCK
cmds.frameLayout(collapsable=True,
                 label="Standard Block",
                 width=475,
                 height=130)
cmds.columnLayout()
cmds.intSliderGrp('blockHeight', l="Height", f=True, min=1, max=20, value=3)
cmds.intSliderGrp('blockWidth',
                  l="Width (Bumps)",
                  f=True,
                  min=1,
                  max=20,
                  value=2)
Ejemplo n.º 40
0
def _refrTimeForm(obj):
    '''Aggiorna il form della timeline window.'''

    timeForm = obj + _timeFormSfx
    min = cmds.playbackOptions(q=True, min=True)
    max = cmds.playbackOptions(q=True, max=True)
    rng = max - min + 1.0
    currentFrame = cmds.currentTime(q=True)

    # rimuovi gli elementi del time form
    children = cmds.formLayout(timeForm, q=True, ca=True)
    if children:
        cmds.deleteUI(children)

    # rintraccia il nodo di parent
    pcNode = cmds.ls(_getParentConstraint(obj))
    if pcNode:
        pcNode = pcNode[0]
    else:
        # aggiorna le label
        cmds.text(obj + _labelSfx[0], e=True, l='%d' % currentFrame, w=50)
        cmds.text(obj + _labelSfx[1], e=True, l='')
        return

    # il main form e' il parent
    cmds.setParent(timeForm)

    # parametri per l'edit del form
    attachPositions = []
    attachForms = []

    # lista dei target
    targets = cmds.parentConstraint(pcNode, q=True, tl=True)
    for tid in range(len(targets)):
        times = cmds.keyframe('%s.w%d' % (pcNode, tid), q=True, tc=True)
        values = cmds.keyframe('%s.w%d' % (pcNode, tid), q=True, vc=True)

        # nessuna chiave, lista nulla e passa al successivo
        if not times:
            continue

        # indici dei tempi delle chiavi di attach/detach
        idxList = []
        check = True
        for v in range(len(values)):
            if values[v] == check:
                idxList.append(v)
                check = not check

        # deve funzionare anche se l'ultima chiave e' attached (quindi numero chiavi dispari)
        times.append(cmds.playbackOptions(q=True, aet=True) + 1.0)

        # ogni elemento di attach times e' relativo ad un particolare target ed e' una lista di questo tipo [[3,10], [12, 20]]
        timeRanges = [
            times[idxList[i]:idxList[i] + 2]
            for i in range(0, len(idxList), 2)
        ]

        hsvCol = _getColor(tid)

        # aggiungi i nuovi controlli
        for timeRange in timeRanges:
            # normalizza il timeRange
            normRange = [
                _timeFormDiv * (_crop(tr, min, max + 1) - min) / rng
                for tr in timeRange
            ]

            # se l'elemento e' stato croppato dal timerange passa al successivo
            if normRange[0] == normRange[1]:
                continue

            control = cmds.canvas(
                hsvValue=hsvCol,
                w=1,
                h=1,
                ann='%s [%d, %d]' %
                (targets[tid], timeRange[0], timeRange[1] - 1.0))
            for button in [1, 3]:
                cmds.popupMenu(mm=True, b=button)
                cmds.menuItem(l='[%s]' % targets[tid],
                              c='cmds.select(\'%s\')' % targets[tid],
                              rp='N')
                cmds.menuItem(l='Select child',
                              c='cmds.select(\'%s\')' % obj,
                              rp='S')
                cmds.menuItem(l='Fix snaps',
                              c='cmds.select(\'%s\')\n%s.fixSnap(True)' %
                              (obj, __name__),
                              rp='E')

            attachForms.extend([(control, 'top', 0), (control, 'bottom', 0)])
            attachPositions.extend([(control, 'left', 0, normRange[0]),
                                    (control, 'right', 0, normRange[1])])

    # current frame
    if currentFrame >= min and currentFrame <= max:
        frameSize = _timeFormDiv / rng
        normCf = frameSize * (currentFrame - min)
        currentTarget = _getActiveAttachTarget(pcNode)
        if not currentTarget:
            hsvCol = (0.0, 0.0, 0.85)
        else:
            hsvCol = _getColor(targets.index(currentTarget), 0.15)
        cf = cmds.canvas(hsvValue=hsvCol, w=1, h=1)

        attachForms.extend([(cf, 'top', 0), (cf, 'bottom', 0)])
        attachPositions.extend([(cf, 'left', 0, normCf),
                                (cf, 'right', 0, normCf + frameSize)])

    # setta i parametri del form
    cmds.formLayout(timeForm,
                    e=True,
                    attachForm=attachForms,
                    attachPosition=attachPositions)

    # aggiorna le label
    cmds.text(obj + _labelSfx[0], e=True, l='%d' % currentFrame, w=50)
    cmds.text(obj + _labelSfx[1],
              e=True,
              l='[%s]' % _getActiveAttachTarget(pcNode))
Ejemplo n.º 41
0
    def createUI(self):
        # DW : only put *args if you are using maya command flags, otherwise no need
        #check if window and prefs exist. If yes, delete

        if cmds.window(self.window, ex=True):
            cmds.deleteUI(self.window, wnd=True)
        elif cmds.windowPref(self.window, ex=True):
            cmds.windowPref(self.window, r=True)

        self.window = cmds.window(self.window,
                                  t=self.title,
                                  wh=self.winSize,
                                  s=1,
                                  mnb=1,
                                  mxb=1)
        self.mainForm = cmds.formLayout(nd=100)
        self.tagLine = cmds.text(label="Rig Tool")
        cmds.frameLayout(label="1. Choose the root joint")
        self.Layout = cmds.columnLayout(adj=1)

        #Add a saparator to the window
        cmds.separator()

        # button to select the first joint
        cmds.rowColumnLayout(nc=2, cs=[(1, 6), (2, 6)])
        self.tf_rootBt = cmds.textField('rootJnt',
                                        tx='First joint of your Arm chain',
                                        w=250)
        #cmds.textFieldButtonGrp('rootJnt', width=380, cal=(8, "center"), cw3=(100, 200, 75), h=40, pht="First joint of your Arm chain", l="First Joint", bl="Select", bc = lambda x: findJnt(), p=self.Layout)
        # DW : use lambda only to parse arguments, the better way to not make confusion is to use partial module
        cmds.button(l='Select', c=self.findJnt)

        cmds.setParent(self.Layout)
        frame = cmds.frameLayout("2. Name options", lv=1, li=1, w=250)

        #cmds.text(label="", align = "left")
        cmds.rowColumnLayout(nc=4, cs=[(1, 6), (2, 6), (3, 6), (4, 6)])
        #cmds.text('Side', l='Side:')
        # DW : string naming can be dangerous, if another script create this type of name, it will conflict
        #      put your ctrl name into a variable or a class variable if you are using it somewhere else
        #      Same don't use lambda if you are not parsing arguments
        self.om_partside = cmds.optionMenu('Part_Side',
                                           l='Side:',
                                           cc=self.colorChange,
                                           acc=1,
                                           ni=1)
        cmds.menuItem(label='L_')
        cmds.menuItem(label='R_')
        cmds.menuItem(label='_')
        cmds.text('Part', l='Part:')
        cmds.optionMenu('part_Body')
        cmds.menuItem(label='Arm')
        cmds.menuItem(label='Leg')
        cmds.menuItem(label='Spine')

        cmds.setParent(self.Layout)
        frame2 = cmds.frameLayout("3. Type of rig", lv=True, li=1, w=250)
        cmds.rowColumnLayout(nc=3, cs=[(1, 6), (2, 6), (3, 6)])
        # DW :conforming to the default user settings on top of the class
        # demonstrate property in class
        self.rc_ikfk = cmds.radioCollection("limb side")
        for x, lb in enumerate(['IK/FK', 'IK', 'FK']):
            if x == self.ikfkPick:
                defvalue = True
            else:
                defvalue = False
            cmds.radioButton(label=lb, select=defvalue)

        cmds.setParent(self.Layout)
        frame3 = cmds.frameLayout("4. Thick if you want to apply stretch",
                                  lv=True,
                                  li=1,
                                  w=250)
        cmds.rowColumnLayout(nc=1, cs=[(1, 6)])
        # DW : adding default value, class variable naming
        self.ckb_stretch = cmds.checkBox(label='Stretchy limb',
                                         align='center',
                                         value=self.isStretch,
                                         cc=self.getStretch)

        cmds.setParent(self.Layout)

        cmds.setParent(self.Layout)
        frame4 = cmds.frameLayout("5. Pick icon color", lv=True, li=1, w=250)
        cmds.gridLayout(nr=1, nc=5, cwh=[62, 20])
        cmds.iconTextButton('darkBlue_Btn', bgc=[.000, .016, .373])
        cmds.iconTextButton('lightBlue_Btn', bgc=[0, 0, 1])
        cmds.iconTextButton('Brown_Btn', bgc=[.537, .278, .2])
        cmds.iconTextButton('red_Btn', bgc=[1, 0, 0])
        cmds.iconTextButton('Yellow_Btn', bgc=[1, 1, 0])
        cmds.setParent(self.Layout)

        self.sl_colorBt = cmds.colorIndexSliderGrp('rigColor',
                                                   w=250,
                                                   h=50,
                                                   cw2=(150, 0),
                                                   min=0,
                                                   max=31,
                                                   v=self.sideColor)
        # This button will creat the chain of joins with streatch and squach
        # DW : never use comma for executing some function, if you use this script as a module afterward,
        #      you will have problems dealing with python namespacing
        #      maya is always passing a default argument True, so put *args in any command that is used by your ui controls
        cmds.button('b_create',
                    label='Create',
                    h=30,
                    c=partial(create, self.rigType, self.sideColor,
                              self.getStretch))

        #show the window
        cmds.showWindow(self.window)
Ejemplo n.º 42
0
def ZvParentMaster(posX=56,
                   posY=180,
                   width=_defaultSize[0],
                   height=_defaultSize[1]):
    '''Main UI.'''

    winName = 'ZvParentMasterWin'
    if cmds.window(winName, exists=True):
        cmds.deleteUI(winName, window=True)

    cmds.window(winName, title='ZV', tlb=True)
    cmds.columnLayout(adj=True, rs=0, bgc=(0.3, 0.3, 0.3))

    #### PULSANTI ####
    cmds.iconTextButton(
        style='iconOnly',
        h=34,
        bgc=(0.3, 0.3, 0.3),
        image=_pmpath + 'pm_attach.xpm',
        c='import Tapp.Maya.utils as mu;mu.ZvParentMaster.attach()',
        ann='Attach objects')
    cmds.popupMenu(mm=True)
    cmds.menuItem(
        l='Create parent groups - translation',
        c=lambda x: mu.ZvParentMaster.createParentGroups(True, False),
        rp='NE')
    cmds.menuItem(l='Create parent groups - available attrs',
                  c=lambda x: mu.ZvParentMaster.createParentGroups(),
                  rp='E')
    cmds.menuItem(
        l='Create parent groups - rotation',
        c=lambda x: mu.ZvParentMaster.createParentGroups(False, True),
        rp='SE')
    cmds.iconTextButton(style='iconOnly',
                        h=34,
                        bgc=(0.3, 0.3, 0.3),
                        image=_pmpath + 'pm_detach.xpm',
                        c=lambda: mu.ZvParentMaster.detach(),
                        ann='Detach objects')
    cmds.iconTextButton(style='iconOnly',
                        h=34,
                        bgc=(0.3, 0.3, 0.3),
                        image=_pmpath + 'pm_destroy.xpm',
                        c=lambda: mu.ZvParentMaster.destroy(),
                        ann='Destroy constraints')
    cmds.iconTextButton(style='iconOnly',
                        h=34,
                        bgc=(0.3, 0.3, 0.3),
                        image=_pmpath + 'pm_fixsnap.xpm',
                        c=lambda: mu.ZvParentMaster.fixSnap(),
                        ann='Fix snap')
    cmds.popupMenu(mm=True)
    cmds.menuItem(l='Fix snaps in the active range',
                  c=lambda: mu.ZvParentMaster.fixSnap(True),
                  rp='E')
    cmds.iconTextButton(style='iconOnly',
                        h=34,
                        bgc=(0.3, 0.3, 0.3),
                        image=_pmpath + 'pm_select.xpm',
                        c=lambda: mu.ZvParentMaster.selectConstraintNodes(),
                        ann='Select constraints and snap groups')
    cmds.iconTextButton(style='iconOnly',
                        h=34,
                        bgc=(0.3, 0.3, 0.3),
                        image=_pmpath + 'pm_timeline.xpm',
                        c=lambda: mu.ZvParentMaster.timeline(),
                        ann='Constraint timeline')
    cmds.popupMenu(mm=True)
    cmds.menuItem(l='<- Prev',
                  c=lambda: mu.ZvParentMaster.navigate(-1),
                  rp='W')
    cmds.menuItem(l='Next ->', c=lambda: mu.ZvParentMaster.navigate(1), rp='E')
    cmds.setParent('..')

    cmds.showWindow(winName)
    cmds.window(winName,
                edit=True,
                widthHeight=(width, height),
                topLeftCorner=(posY, posX))

    sys.stdout.write(
        'ZV Parent Master %s          http://www.paolodominici.com          [email protected]\n'
        % __version__)
Ejemplo n.º 43
0
def macGUI():
    '''
	create the GUI for Mac format
	'''

    # check to see if the GUI exists
    checkGUI()

    # create a variable to set the width of the window
    width = 430

    # create the window
    win1 = Window(winName, 'Quick SDK GUI', width, 480)

    # create columnLayout as main layout
    cmds.formLayout('mainForm')

    # create a frameLayout to encapsulate and label the window elements
    cmds.frameLayout('mainFrame',
                     label="Quick SDK",
                     borderStyle='etchedIn',
                     w=370)

    # create formLayout as a sub layout
    cmds.formLayout('subForm', h=300)

    # create a frameLayout to encapsulate and label the window elements
    drvrFr = cmds.frameLayout('drvrFrame',
                              label="Driver:",
                              borderStyle='etchedIn')

    # create variable for the textField widths
    tFld1W = 120
    tFld2W = 60
    tFld3W = 80

    # create a rowColumnLayout for the Driver
    cmds.rowColumnLayout(nc=3, cw=([1, tFld1W], [2, tFld2W], [3, tFld3W]))

    # create GUI elements for Driver

    nTxt = Text('nameTxt', "Name:", 50)
    aTxt = Text('attrTxt', "Attr:", 50)
    bTxt1 = Text('blankTxt1', " ", 50)

    drvr1 = TextField('drvrNameFld', tFld1W, "Driver")
    drvr2 = TextField('drvrAttrFld', tFld2W, "Attribute")
    lBtn1 = Button('drvrBtn', "Load Selected", tFld3W,
                   scriptName + ".loadSel()")

    # close the driver rowColumnLayout
    cmds.setParent("..")

    # close the driver frameLayout
    cmds.setParent("..")

    # create a frameLayout to encapsulate and label the window elements
    drvnFr = cmds.frameLayout('drvnFrame',
                              label="Driven:",
                              borderStyle='etchedIn')

    # create a columnLayout
    cmds.columnLayout()

    # create variable for the tsl selectCommand
    selCmd = scriptName + ".changeAnim('drvnTSL','keyOutline', 'keyOutFrame')"

    # create a textScrollList for the driven objects and attrs
    dTSL = TSL('drvnTSL', 1, 100, selCmd)
    #cmds.textScrollList( 'drvnTSL', ams=True, h=100, selectCommand=scriptName + ".changeAnim2('drvnTSL','keyOutline')" )

    # create variables for width values
    tslBtnW1 = 50
    tslBtnW2 = 70

    # create a rowLayout to eonclose the TSL buttons
    cmds.rowLayout(nc=3, cw3=(tslBtnW1, tslBtnW2, tslBtnW2))

    addBtn1 = Button('addBtn', "Add", tslBtnW1,
                     scriptName + ".addObj('drvnTSL')")
    rAllBtn1 = Button('remAllBtn', "Remove All", tslBtnW2,
                      scriptName + ".clearAll('drvnTSL')")
    rSelBtn1 = Button('remSelBtn', "Remove Sel", tslBtnW2,
                      scriptName + ".clearSel('drvnTSL')")

    # close the button rowLayout
    cmds.setParent("..")

    # close the driven columnLayout
    cmds.setParent("..")
    # close the driven frameLayout
    cmds.setParent("..")

    # create a frameLayout to encapsulate and label the window elements
    valFr = cmds.frameLayout('valFrame',
                             label="Values:",
                             borderStyle='etchedIn')

    # create a columnLayout
    cmds.columnLayout()

    # create optionMenu to determine # of SDKs to perform
    cmds.optionMenu('sdkOpt', w=50)
    cmds.menuItem(label='1')
    cmds.menuItem(label='2')
    cmds.menuItem(label='3')
    cmds.menuItem(label='4')
    cmds.menuItem(label='5')

    fldVal1 = 40
    fldVal2 = 60
    '''
	flt1 = cmds.floatFieldGrp( 'fld1Grp', nf=5, value1=0.0, 
		value2=0.0, value3=0.0, value4=0.0, value5=0.0,
		pre=2, cw=( [1, fldVal1], [2, fldVal1], [3, fldVal1],
		[4, fldVal1], [5, fldVal1]) )
	'''

    # create a rowColumnLayout for the text and value fields
    cmds.rowColumnLayout(nc=5,
                         cw=([1, fldVal1], [2, fldVal1], [3, fldVal1],
                             [4, fldVal1], [5, fldVal1]))

    # create text to describe the floatFields using the Text class
    valTxt1 = Text('valTxt1', "1:", fldVal1)
    valTxt2 = Text('valTxt2', "2:", fldVal1)
    valTxt3 = Text('valTxt3', "3:", fldVal1)
    valTxt4 = Text('valTxt4', "4:", fldVal1)
    valTxt5 = Text('valTxt5', "5:", fldVal1)

    # create floatFields for the driver using the FloatField class
    drFlt1 = FloatField('drFltFld1', fldVal1, 0.0, 2)
    drFlt2 = FloatField('drFltFld2', fldVal1, 0.0, 2)
    drFlt3 = FloatField('drFltFld3', fldVal1, 0.0, 2)
    drFlt4 = FloatField('drFltFld4', fldVal1, 0.0, 2)
    drFlt5 = FloatField('drFltFld5', fldVal1, 0.0, 2)

    # create floatFields for the driven using the FloatField class
    dnFlt1 = FloatField('dnFltFld1', fldVal1, 0.0, 2)
    dnFlt2 = FloatField('dnFltFld2', fldVal1, 0.0, 2)
    dnFlt3 = FloatField('dnFltFld3', fldVal1, 0.0, 2)
    dnFlt4 = FloatField('dnFltFld4', fldVal1, 0.0, 2)
    dnFlt5 = FloatField('dnFltFld5', fldVal1, 0.0, 2)

    # close the rowColumnLayout
    cmds.setParent("..")

    # create variable for the sdk command
    sdkCmd = scriptName + ".makeSdk( 'drFltFld1', 'drFltFld2', 'drFltFld3', 'drFltFld4', 'drFltFld5', 'dnFltFld1', 'dnFltFld2', 'dnFltFld3', 'dnFltFld4', 'dnFltFld5' )"
    sdkCmd = scriptName + ".makeSdk()"

    # create button to run sdk function
    sdkBtn = Button('sdkBtn', "Create SDK", 80, sdkCmd)

    # close the columnLayout
    cmds.setParent("..")

    # close the frameLayout
    cmds.setParent("..")

    # create a frameLayout to encapsulate and label the window elements
    keyFr = cmds.frameLayout('keyOutFrame',
                             l="Driven Key Values:",
                             borderStyle='etchedIn',
                             collapsable=True,
                             h=150)

    # create a formLayout to contain the keyframeOutliner
    cmds.formLayout('keyForm')

    # create a keyframeOutliner
    keyOut = cmds.keyframeOutliner('keyOutline',
                                   dsp="narrow",
                                   animCurve='animCurve1')

    # close the formLayout
    cmds.setParent("..")

    # close the frameLayout
    cmds.setParent("..")

    # edit the main formLayout
    cmds.formLayout('mainForm',
                    e=True,
                    af=[('mainFrame', "left", 5), ('mainFrame', "top", 5)])

    # edit the sub formLayout
    cmds.formLayout('subForm',
                    e=True,
                    af=[(drvrFr, "left", 5), (drvrFr, "top", 5),
                        (drvrFr, "right", 5)],
                    ac=[(drvnFr, "top", 5, drvrFr), (valFr, "top", 5, drvnFr),
                        (keyFr, "top", 5, valFr)],
                    aoc=[(drvnFr, "left", 0, drvrFr),
                         (drvnFr, "right", 0, drvrFr),
                         (valFr, "left", 0, drvrFr), (valFr, "right", 0,
                                                      drvrFr),
                         (keyFr, "left", 0, drvnFr),
                         (keyFr, "right", 0, drvnFr)])

    # edit the keyOutline formLayout
    cmds.formLayout('keyForm',
                    e=True,
                    af=[(keyOut, 'top', 0), (keyOut, 'left', 0),
                        (keyOut, 'bottom', 0), (keyOut, 'right', 0)])

    # show the window
    win1.show(winName)
Ejemplo n.º 44
0
def puppetContextMenu(parent, node):
    
    nodes = mc.ls(sl=True)
    if not nodes:
        nodes = [node]
    
    element = None
    elements = getElementsAbove(nodes)
    if elements:
        element = elements[0]
        
    
    #create menu
    mc.setParent(parent, menu=True)
    
    #build the radial menu
    #east, element selection controls
    mc.menuItem(label='Select Top', radialPosition='N', command=partial(selectPuppets,nodes))
    mc.menuItem(label='All Controls', radialPosition='S', command=partial(selectControls,nodes))
    #mc.menuItem(label='SE', radialPosition='SE')
    
    mc.menuItem(label='Keyed', radialPosition='SE', command=partial(selectKeyed, nodes))
    
    if element:
        mc.menuItem(label='Select Element', radialPosition='NE', command=partial(selectElements,nodes))
        mc.menuItem(label='Select Elem Controls', radialPosition='E', command=partial(selectElementControls,nodes))
        
        #west: visibility controls
        for visAttr,shortName,cardinal in zip(('geoVisibility','controlVisibility','secondaryControlVisibility'),('Geo','Controls','Secondary'),('NW','W','SW')):
        
            if mc.attributeQuery(visAttr, exists=True, node=element):
                if mc.getAttr(element+'.'+visAttr):
                    mc.menuItem(label='Hide '+shortName, 
                                radialPosition=cardinal, 
                                command=partial(mc.setAttr, element+'.'+visAttr, 0))
                else:
                    mc.menuItem(label='Show '+shortName, 
                                radialPosition=cardinal, 
                                command=partial(mc.setAttr, element+'.'+visAttr, 1))
    
    #main menu items
    
    #optional, check for gui. 
    #mc.menuItem(label='Launch GUI (if it exists)')
    
    if ml_resetChannels:
        append = ''
        if len(nodes) > 1:
            append = 's'
        mc.menuItem(label='Reset Control'+append, command=ml_resetChannels.resetPuppetControl)
        mc.menuItem(divider=True)
    
    #selection
    if element:
        mc.menuItem(label='Selection', subMenu=True)
        
        #select parent element
        
        #select all worldspace controls
        mc.menuItem(label='Select World Space Controls', command=partial(selectWorldSpaceControls, nodes))
        mc.menuItem(label='Select Ik Controls', command=partial(selectIkControls, nodes))
        mc.menuItem(label='Select Fk Controls', command=partial(selectFkControls, nodes))
        #invert control selection
        mc.menuItem(label='Invert Selection', command=partial(invertSelection, nodes))
        #select all keyed
        
        mc.setParent('..', menu=True)
        mc.menuItem(divider=True)
    
    #== custom by node type ===============================
    #fkIkSwitching
    if element:
        if mc.attributeQuery('fkIkSwitch', exists=True, node=element):
            state = mc.getAttr(element+'.fkIkSwitch')
            
            if state > 0:
                mc.menuItem(label='Toggle to FK', command=partial(fkIkSwitch, nodes))
            if state < 1:
                mc.menuItem(label='Toggle to IK', command=partial(fkIkSwitch, nodes))
                
            mc.menuItem(label='Bake To', subMenu=True)
            mc.menuItem(label='FK', command=partial(fkIkSwitch, nodes, 0, True))
            mc.menuItem(label='IK', command=partial(fkIkSwitch, nodes, 1, True))
            mc.setParent('..', menu=True)
            mc.menuItem(divider=True)
    
    
    #space switching
    #attrs = mc.listAttr(node, userDefined=True, keyable=True)
    ssData = getSpaceSwitchData(node)
    if ssData:
        for key, value in ssData.items():
            mc.menuItem(label='Switch '+key, subMenu=True)
            for each in value['enumValues']:
                if each == value['currentValue']:
                    continue
                mc.menuItem(label=each, command=partial(switchSpace, nodes, each))
            mc.setParent('..', menu=True)
            mc.menuItem(label='Bake '+key, subMenu=True)
            for each in value['enumValues']:
                if each == value['currentValue']:
                    continue
                mc.menuItem(label=each, command=partial(switchSpace, nodes, each, True))
            mc.setParent('..', menu=True)
            mc.menuItem(divider=True)
            
    #rotate order
    if ml_convertRotationOrder:
        if mc.getAttr(node+'.rotateOrder', channelBox=True):
            roo = mc.getAttr(node+'.rotateOrder')
            #rotOrders = ('xyz')
            mc.menuItem(label='Rotate Order', subMenu=True)
            mc.menuItem(label='Convert Rotate Order UI', command=partial(convertRotateOrderUI, nodes))
Ejemplo n.º 45
0
    def createUI(self):
        cmds.scrollLayout(childResizable=True, )
        cmds.columnLayout(adjustableColumn=True)
        #cmds.setParent("..")
        cmds.rowLayout(numberOfColumns=1, columnAlign1='left')
        cmds.textFieldButtonGrp(
            'outputFolder',
            label='Output Folder',
            cw3=(90, 320, 50),
            text="",
            buttonLabel='...',
            buttonCommand=lambda *args: self.browseObjFilename())

        cmds.setParent("..")
        cmds.rowLayout(numberOfColumns=2, columnAlign2=('left', 'right'))
        cmds.intFieldGrp('resolution',
                         label='Resolution',
                         value1=512,
                         ct2=('left', 'left'),
                         cw2=(90, 110),
                         w=230)
        cmds.intFieldGrp('aa_samples',
                         label='Camera Samples (AA)',
                         cw2=(150, 60),
                         value1=3,
                         w=200)
        cmds.setParent("..")

        cmds.rowLayout(numberOfColumns=2, columnAlign2=('left', 'right'))
        cmds.optionMenuGrp('filter', label='Filter ')
        cmds.menuItem(label='blackman_harris')
        cmds.menuItem(label='box')
        cmds.menuItem(label='catrom')
        cmds.menuItem(label='catrom2d')
        cmds.menuItem(label='closest')
        cmds.menuItem(label='cone')
        cmds.menuItem(label='cook')
        cmds.menuItem(label='cubic')
        cmds.menuItem(label='disk')
        cmds.menuItem(label='farthest')
        cmds.menuItem(label='gaussian')
        cmds.menuItem(label='heatmap')
        cmds.menuItem(label='mitnet')
        cmds.menuItem(label='sync')
        cmds.menuItem(label='triangle')
        cmds.menuItem(label='variance')
        cmds.menuItem(label='video')

        cmds.optionMenuGrp('filter',
                           e=True,
                           w=230,
                           ct2=('left', 'left'),
                           cw2=(90, 110),
                           v='gaussian')

        cmds.floatFieldGrp('filterWidth',
                           label='Filter Width',
                           w=200,
                           ct2=('left', 'left'),
                           cw2=(150, 60),
                           value1=2.0)
        cmds.setParent("..")
        cmds.rowLayout(numberOfColumns=1, columnAlign1='both')
        cmds.textFieldGrp('shader',
                          label='Shader Override',
                          ct2=('left', 'left'),
                          cw2=(90, 110),
                          text="",
                          w=400)
        cmds.setParent("..")

        cmds.rowLayout(numberOfColumns=4,
                       columnAlign4=('left', 'left', 'left', 'right'))
        cmds.text('                                             ')

        cmds.button(label='Render',
                    al='right',
                    w=85,
                    h=25,
                    command=lambda *args: self.doExport())
        cmds.text('              ')
        cmds.button(label='Cancel',
                    al='right',
                    w=85,
                    h=25,
                    command=lambda *args: self.doCancel())
        cmds.setParent("..")
Ejemplo n.º 46
0
    def initUI(self, parent):
        tab = cmds.formLayout('TabUserAttributes', parent=parent)
        cmds.columnLayout(adjustableColumn=True)

        # Frame for the current selection
        selection_frame = cmds.frameLayout('ua_selectionFrame',
                                           label='Current Selection',
                                           parent=tab,
                                           w=390,
                                           cll=False,
                                           mh=2,
                                           mw=2)
        current_node_layout = cmds.columnLayout(adjustableColumn=True,
                                                parent=selection_frame)

        self.addTextFieldElement(current_node_layout,
                                 'Node Name',
                                 UI_CONTROL_USERATTRIBUTES_STRING_NODE_NAME,
                                 '',
                                 '',
                                 editable=False,
                                 width=245)
        self.addTextFieldElement(current_node_layout,
                                 'Node Index',
                                 UI_CONTROL_USERATTRIBUTES_STRING_NODE_INDEX,
                                 '',
                                 '',
                                 editable=False,
                                 width=245)

        attributes_main_frame = cmds.frameLayout(parent=tab,
                                                 label='Attributes',
                                                 w=390,
                                                 cll=False,
                                                 mh=2,
                                                 mw=2)
        attributes_scroll_layout = cmds.scrollLayout(
            'scrollAttributes',
            parent=attributes_main_frame,
            cr=True,
            verticalScrollBarAlwaysVisible=False)

        # Add user attribute
        new_attributes_layout = cmds.frameLayout(
            UI_CONTROL_LAYOUT_USERATTRIBUTES_ADD_ATTRIBUTE,
            parent=attributes_scroll_layout,
            label='Add new attribute',
            w=390,
            cll=False,
            mh=2,
            mw=2)

        # Type of new attribute
        attributes_type_row_layout = cmds.rowLayout(
            adjustableColumn=2,
            numberOfColumns=2,
            parent=new_attributes_layout)
        cmds.text(parent=attributes_type_row_layout,
                  label='Type',
                  width=TEXT_WIDTH,
                  align='left',
                  annotation='')

        type_option_menu = cmds.optionMenu(
            UI_OPTIONS_PREDEFINED_USERATTRIBUTETYPES,
            parent=attributes_type_row_layout,
            annotation='Type',
            changeCommand=self.onChangeUserAttributeType)

        for k, _ in UI_MENU_USERATTRIBUTES.iteritems():
            cmds.menuItem(parent=type_option_menu, label=k)

        self.onChangeUserAttributeType(UI_MENU_USERATTRIBUTES['bool'])

        attributes_frame = cmds.frameLayout(UI_CONTROL_LAYOUT_USERATTRIBUTES,
                                            label='Current attributes',
                                            parent=attributes_scroll_layout,
                                            w=390,
                                            cll=True,
                                            mh=2,
                                            mw=2)
        attributes_layout = cmds.columnLayout(adjustableColumn=True,
                                              parent=attributes_frame)

        attributes_row_layout = cmds.rowLayout(
            UI_CONTROL_LAYOUT_USERATTRIBUTES_ROWS,
            parent=attributes_layout,
            columnWidth4=(TEXT_WIDTH, TEXT_WIDTH * 2, TEXT_WIDTH, 10),
            adjustableColumn=4,
            numberOfColumns=4,
        )
        cmds.text(parent=attributes_row_layout,
                  label='Name',
                  width=TEXT_WIDTH,
                  align='left',
                  annotation='')
        cmds.text(parent=attributes_row_layout,
                  label='Value',
                  width=TEXT_WIDTH * 2,
                  align='left',
                  annotation='')
        cmds.text(parent=attributes_row_layout,
                  label='Type',
                  width=TEXT_WIDTH,
                  align='right',
                  annotation='')

        attribute_button_items = cmds.formLayout('AttributeButtons',
                                                 parent=tab)

        button_load = cmds.button(parent=attribute_button_items,
                                  label='Load',
                                  height=30,
                                  width=150,
                                  align='right',
                                  command=self.loadObjectUserAttribute)
        button_save = cmds.button(parent=attribute_button_items,
                                  label='Save',
                                  height=30,
                                  width=150,
                                  align='left',
                                  command=self.updateObjectUserAttribute)
        cmds.formLayout(attribute_button_items,
                        edit=True,
                        attachPosition=((button_load, 'left', 0,
                                         0), (button_load, 'right', 5, 50),
                                        (button_save, 'left', 0,
                                         50), (button_save, 'right', 5, 100)))
        cmds.formLayout(tab,
                        edit=True,
                        attachForm=((selection_frame, 'top',
                                     2), (selection_frame, 'left',
                                          2), (selection_frame, 'right', 2),
                                    (attributes_main_frame, 'top',
                                     74), (attributes_main_frame, 'left', 2),
                                    (attributes_main_frame, 'right',
                                     2), (attributes_main_frame, 'bottom', 32),
                                    (attribute_button_items, 'bottom',
                                     2), (attribute_button_items, 'left', 2),
                                    (attribute_button_items, 'right', 2)))

        return tab
Ejemplo n.º 47
0
    def populateMenu(self, menu, *args):
        uiMod.clearMenuItems(menu)
        #cmds.menuItem(label="Camera Relative", parent=menu, checkBox=self.cameraRelativeOnOff, command=self.cameraRelativeSwitch)

        if cmds.objExists(self.mainGroupNode):
            cmds.menuItem(label="Add Selection",
                          parent=menu,
                          command=self.addSelection)
            cmds.menuItem(label="Remove Selection",
                          parent=menu,
                          command=self.removeSelection)
            cmds.menuItem(label="Set Frame Range",
                          parent=menu,
                          command=self.setFrameRange)
            cmds.menuItem(divider=True, parent=menu)

        if cmds.objExists(self.mainGroupNode):
            for loopMotionTrail in self.nodeInfo.keys():
                ctrl = self.nodeInfo[loopMotionTrail]["ctrlNode"]
                cmds.menuItem(
                    label="Grab Offset Ctrl (%s)" % ctrl,
                    parent=menu,
                    command=lambda x, loopMotionTrail=loopMotionTrail, *args:
                    self.grabOffsetCtrl(loopMotionTrail))

            cmds.menuItem(divider=True, parent=menu)

        subMenu = cmds.menuItem(label="Preferences",
                                subMenu=True,
                                parent=menu,
                                tearOff=True)

        #Pre pos range
        cmds.radioMenuItemCollection(parent=subMenu)
        rangeSelected = self.getPrePosRange()
        for loopPref in self.prePosRanges:
            radioSelected = (str(rangeSelected) == str(loopPref))
            cmds.menuItem(label="%s" % loopPref,
                          radioButton=radioSelected,
                          command=lambda x, loopPref=loopPref, *args: self.
                          savePrePosRange(loopPref),
                          parent=subMenu)

        #Size
        cmds.menuItem(divider=True, parent=subMenu)
        cmds.radioMenuItemCollection(parent=subMenu)
        sizeSelected = self.getPrefSize()
        for loopSize in self.customSizes:
            sizeName = loopSize[0]
            radioSelected = (str(sizeSelected) == str(sizeName))
            cmds.menuItem(label=utilMod.toTitle(sizeName),
                          radioButton=radioSelected,
                          command=lambda x, sizeName=sizeName, *args: self.
                          savePrefSize(sizeName),
                          parent=subMenu)

        # Keys
        cmds.menuItem(divider=True, parent=subMenu)
        cmds.radioMenuItemCollection(parent=subMenu)
        keySelected = self.getPrefKey()
        for loopPref in self.prefKeys:
            radioSelected = (str(keySelected) == str(loopPref))
            cmds.menuItem(label="Show %s Keys" % utilMod.toTitle(loopPref),
                          radioButton=radioSelected,
                          command=lambda x, loopPref=loopPref, *args: self.
                          savePrefKey(loopPref),
                          parent=subMenu)

        # Camera Relative
        cmds.menuItem(divider=True, parent=subMenu)
        cmds.menuItem(label="Camera Relative",
                      checkBox=self.cameraRelativeMode,
                      command=self.setCameraRelativeMode,
                      parent=subMenu)

        cmds.menuItem(divider=True, parent=menu)
        cmds.menuItem(label="Refresh",
                      parent=menu,
                      command=self.refreshMotionTrail)
Ejemplo n.º 48
0
def parentListUI():
	'''
	UI for parentList()
	'''
	# Window
	window = 'parentListUI'
	if mc.window(window,q=True,ex=1): mc.deleteUI(window)
	window = mc.window(window,t='Parent List')
	
	# Layout
	fl = mc.formLayout(numberOfDivisions=100)
	
	# UI Elements
	childTXT = mc.text(l='Child List:',al='left')
	childTSL = mc.textScrollList('parentList_childListTSL', allowMultiSelection=True )
	
	parentTXT = mc.text(l='Parent List:',al='left')
	parentTSL = mc.textScrollList('parentList_parentListTSL', allowMultiSelection=True )
	
	parentB = mc.button(label='Parent', c='glTools.ui.base.parentListFromUI()' )
	cancelB = mc.button(label='Cancel', c='mc.deleteUI("'+window+'")' )
	
	# Layout
	mc.formLayout(fl,e=True,af=[(childTXT,'left',5),(childTXT,'top',5)],ap=[(childTXT,'right',5,50)])
	mc.formLayout(fl,e=True,af=[(childTSL,'left',5)],ap=[(childTSL,'right',5,50)],ac=[(childTSL,'top',5,childTXT),(childTSL,'bottom',5,parentB)])
	
	mc.formLayout(fl,e=True,af=[(parentTXT,'right',5),(parentTXT,'top',5)],ap=[(parentTXT,'left',5,50)])
	mc.formLayout(fl,e=True,af=[(parentTSL,'right',5)],ap=[(parentTSL,'left',5,50)],ac=[(parentTSL,'top',5,parentTXT),(parentTSL,'bottom',5,cancelB)])
	
	mc.formLayout(fl,e=True,af=[(parentB,'left',5),(parentB,'bottom',5)],ap=[(parentB,'right',5,50)])
	mc.formLayout(fl,e=True,af=[(cancelB,'right',5),(cancelB,'bottom',5)],ap=[(cancelB,'left',5,50)])
	
	# UI Callbacks
	
	mc.textScrollList(childTSL,e=True,dcc='glTools.ui.utils.selectFromTSL("'+childTSL+'")')
	mc.textScrollList(childTSL,e=True,dkc='glTools.ui.utils.removeFromTSL("'+childTSL+'")')
	
	mc.textScrollList(parentTSL,e=True,dcc='glTools.ui.utils.selectFromTSL("'+parentTSL+'")')
	mc.textScrollList(parentTSL,e=True,dkc='glTools.ui.utils.removeFromTSL("'+parentTSL+'")')
	
	# Popup menu
	
	childPUM = mc.popupMenu(parent=childTSL)
	mc.menuItem(l='Add Selected',c='glTools.ui.utils.addToTSL("'+childTSL+'")')
	mc.menuItem(l='Remove Selected',c='glTools.ui.utils.removeFromTSL("'+childTSL+'")')
	mc.menuItem(l='Clear List',c='mc.textScrollList("'+childTSL+'",e=True,ra=True)')
	mc.menuItem(l='Select Hilited',c='glTools.ui.utils.selectFromTSL("'+childTSL+'")')
	
	parentPUM = mc.popupMenu(parent=parentTSL)
	mc.menuItem(l='Add Selected',c='glTools.ui.utils.addToTSL("'+parentTSL+'")')
	mc.menuItem(l='Remove Selected',c='glTools.ui.utils.removeFromTSL("'+parentTSL+'")')
	mc.menuItem(l='Clear List',c='mc.textScrollList("'+parentTSL+'",e=True,ra=True)')
	mc.menuItem(l='Select Hilited',c='glTools.ui.utils.selectFromTSL("'+parentTSL+'")')
	
	# Display UI 
	mc.showWindow(window)
Ejemplo n.º 49
0
def file_UI_create(*args):
    """
    ui
    """
    if cmds.window("fileWin", exists=True):
        cmds.deleteUI("fileWin")

    w = 740
    h = 480
    widgets["win"] = cmds.window("fileWin",
                                 t="File Manager",
                                 w=w,
                                 h=h,
                                 s=False)
    widgets["menu"] = cmds.menuBarLayout()
    widgets["menuFile"] = cmds.menu(label="Presets")
    cmds.menuItem(l='Save Layout', c=save_layout)
    cmds.menuItem(l="Delete Layout", c=delete_layout)

    cmds.setParent(widgets["win"])
    widgets["mainCLO"] = cmds.columnLayout(w=w, h=h)
    widgets["mainFLO"] = cmds.formLayout(w=w, h=h, bgc=(.2, .2, .2))

    aw = 220
    widgets["assetsFLO"] = cmds.formLayout(w=aw, h=430)
    widgets["assetsTab"] = cmds.tabLayout(w=aw, h=430, cc=change_stage_tab)
    widgets["charCLO"] = cmds.columnLayout("CHARS", w=aw, h=400)
    widgets["charTSL"] = cmds.textScrollList(w=aw, h=400)
    cmds.setParent(widgets["assetsTab"])
    widgets["propCLO"] = cmds.columnLayout("PROPS", w=aw, h=400)
    widgets["propTSL"] = cmds.textScrollList(w=aw, h=400)
    cmds.setParent(widgets["assetsTab"])
    widgets["setCLO"] = cmds.columnLayout("SETS", w=aw, h=400)
    widgets["setTSL"] = cmds.textScrollList(w=aw, h=400)
    cmds.setParent(widgets["assetsTab"])
    widgets["stageCLO"] = cmds.columnLayout("STGS", w=aw, h=400)
    widgets["stageTSL"] = cmds.textScrollList(w=aw, h=400)
    cmds.formLayout(widgets["assetsFLO"],
                    e=True,
                    af=[
                        (widgets["assetsTab"], "top", 10),
                        (widgets["assetsTab"], "left", 0),
                    ])

    cmds.setParent(widgets["mainFLO"])
    widgets["filesFLO"] = cmds.formLayout(w=350, h=450)

    widgets["filesTSL"] = cmds.textScrollList(w=350, h=400, dcc=open_selected)
    widgets["phaseOM"] = cmds.optionMenu(label='Phase: ',
                                         changeCommand=populate_files)
    cmds.menuItem(label="Modeling")
    cmds.menuItem(label="Rigging")
    cmds.menuItem(label="Animation")
    cmds.menuItem(label="Lighting")
    cmds.menuItem(label="Texturing")
    cmds.formLayout(widgets["filesFLO"],
                    e=True,
                    af=[(widgets["filesTSL"], "top", 23),
                        (widgets["filesTSL"], "left", 0),
                        (widgets["phaseOM"], "top", 0),
                        (widgets["phaseOM"], "left", 10)])

    cmds.setParent(widgets["mainFLO"])

    widgets["openBut"] = cmds.button(l="Open Selected",
                                     w=125,
                                     h=30,
                                     bgc=(.3, .3, .3),
                                     c=open_selected)
    widgets["versionBut"] = cmds.button(l="Version Up Current",
                                        w=125,
                                        h=30,
                                        bgc=(.3, .3, .3),
                                        c=version_up)
    widgets["saveAsBut"] = cmds.button(l="Save Scene To New File",
                                       w=125,
                                       h=30,
                                       bgc=(.3, .3, .3),
                                       c=partial(save_as_new, False))
    widgets["saveSelBut"] = cmds.button(l="Save Selection To New",
                                        w=125,
                                        h=20,
                                        bgc=(.3, .3, .3),
                                        c=partial(save_as_new, True))
    widgets["refreshBut"] = cmds.button(l="Refresh Window",
                                        w=125,
                                        h=30,
                                        bgc=(.3, .3, .3),
                                        c=load_asset_info)

    cmds.formLayout(widgets["mainFLO"],
                    e=True,
                    af=[
                        (widgets["assetsFLO"], "top", 25),
                        (widgets["assetsFLO"], "left", 5),
                        (widgets["filesFLO"], "top", 35),
                        (widgets["filesFLO"], "left", 240),
                        (widgets["openBut"], "top", 60),
                        (widgets["openBut"], "left", 600),
                        (widgets["versionBut"], "top", 110),
                        (widgets["versionBut"], "left", 600),
                        (widgets["saveAsBut"], "top", 260),
                        (widgets["saveAsBut"], "left", 600),
                        (widgets["saveSelBut"], "top", 375),
                        (widgets["saveSelBut"], "left", 600),
                        (widgets["refreshBut"], "top", 420),
                        (widgets["refreshBut"], "left", 600),
                    ])

    cmds.window(widgets["win"], e=True, w=5, h=5, rtf=True)
    cmds.showWindow(widgets["win"])

    load_asset_info("first")
Ejemplo n.º 50
0
    def create(self, *args):

        if cmds.menu(self.uiName, ex=1):
            cmds.deleteUI(self.uiName)
        cmds.menu(self.uiName, l=self.title, p=self.parentUIName, to=1)

        beforeSplits = []
        checkPath = self.path + '/' + self.title
        checkPath = checkPath.replace('\\', '/')

        if not checkPath in sys.path:
            sys.path.append(checkPath)

        for root, dirs, names in os.walk(checkPath):

            root = root.replace('\\', '/')

            if checkPath == root: continue

            splits = root.replace(checkPath, '')[1:].split('/')
            folderName = splits[-1]

            mainCommand = None

            for name in names:
                if name == 'MainCommand.py':
                    isCommandFolder = True
                    importString = root.replace(checkPath + '/', '').replace(
                        '/', '.') + '.' + name.split('.')[0]
                    mainCommand = name
                    break
                elif name == 'MainCommand.mel':
                    isCommandFolder = True
                    commandPath = root + '/' + name
                    mainCommand = name
                    break

            reloadTargets = []
            sourceTargets = []
            for name in names:
                if name.find('MainCommand') != -1:
                    continue
                if name.find('.py') != -1:
                    reloadTargets.append(
                        root.replace(checkPath + '/', '').replace('/', '.') +
                        '.' + name.split('.')[0])
                elif name.find('.mel') != -1:
                    mel.eval('source "%s";' % (root + '/' + name))
                    sourceTargets.append(root + '.' + name)

            if mainCommand:
                if mainCommand == 'MainCommand.py':
                    cmds.menuItem(l=folderName,
                                  c=partial(self.pyCommand, importString))
                    if cmdModel.checkHostIsMine(root):
                        cmds.menuItem(ob=1,
                                      c=partial(self.optionMenuCommand, root))
                elif mainCommand == 'MainCommand.mel':
                    cmds.menuItem(l=folderName,
                                  c=partial(self.melCommand, commandPath))
                    if cmdModel.checkHostIsMine(root):
                        cmds.menuItem(ob=1,
                                      c=partial(self.optionMenuCommand, root))
            else:
                setParentNum = 0
                for i in range(len(beforeSplits)):
                    if i >= len(splits):
                        setParentNum += 1
                        continue
                    if beforeSplits[i] != splits[i]:
                        setParentNum += 1
                for num in range(setParentNum):
                    cmds.setParent('..', menu=1)
                if not names: continue
                cmds.menuItem(l=folderName, sm=1, to=1)
                beforeSplits = splits
        return self.uiName
Ejemplo n.º 51
0
def create():
	'''
	This generates the menu for all rigTools.
	'''
	# This is a temporary hack to get maya to evaluate $gMainWindow
	gMainWindow = mm.eval('string $temp = $gMainWindow')
	if mc.menu('rigToolsMenu',q=True,ex=True): mc.deleteUI('rigToolsMenu')
	
	if (len(gMainWindow)):
		mc.setParent(gMainWindow)
		mc.menu('rigToolsMenu', label='Rig Tools', tearOff=True, allowOptionBoxes=True)
		
		#----------------------------------------#
		
		mc.menuItem(label='Checks', subMenu=True, tearOff=True)
		mc.menuItem(label='Namespaces', command='mm.eval("mCleanerNamespaces(0)")')
		
		mc.setParent('..', menu=True)
		
		#----------------------------------------#
		
		mc.menuItem(label='Fixes', subMenu=True, tearOff=True)
		mc.menuItem(label='Namespaces', command='mm.eval("mCleanerNamespaces(1)")')
		
		mc.setParent('..', menu=True)
		
		#----------------------------------------#
		
		mc.menuItem(divider=True)
		
		mc.menuItem(allowOptionBoxes=True, label= 'Rig Propagation', subMenu=True, tearOff=True)
		
		mc.menuItem(label= 'Blengine', command='mm.eval("blengine")')
		mc.menuItem(label= 'Blend Installer', command='mm.eval("blendInstaller(0)")')
		
		mc.setParent('..', menu=True)
		
		#----------------------------------------#
		mc.menuItem(divider=True)
		
		mc.menuItem(allowOptionBoxes=True, label= 'Rig', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Create Base Rig', command='glTools.builder.BaseRig().build()')
		mc.menuItem(label='Control Builder', command='glTools.ui.controlBuilder.controlBuilderUI()')
		mc.menuItem(label='Group', command='for i in mc.ls(sl=True,type="transform"): glTools.utils.base.group(i,0,True,True)',ann='Create a centered and oriented transform group for the selected object/s')
		mc.menuItem(label='Buffer', command='for i in mc.ls(sl=True,type="transform"): glTools.utils.base.group(i,1,True,True)',ann='Create a centered and oriented transform buffer for the selected object/s')
		mc.menuItem(label='Channel State', command='glTools.utils.ChannelState().ui()')
		mc.menuItem(label='Toggle Override', command='glTools.utils.toggleOverride.ui()')
		mc.menuItem(label='Colorize', command='mm.eval("colorize")')
		mc.menuItem(label='Replace Geometry', command='glTools.ui.replaceGeometry.replaceGeometryFromUI()', ann='First select the replacement geometry and then the geometry to be replaced.')
		mc.menuItem(label='Create Surface Skin Menu', command='glTools.surfaceSkin.SurfaceSkinUI().menu()')
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='General', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Namespacer', command='mm.eval("namespacer")')
		mc.menuItem(label='Renamer', command='mm.eval("renamer")')
		mc.menuItem(label='Dag Sort', command='mm.eval("quicksort")')
		mc.menuItem(label='Dk Anim', command='mm.eval("dkAnim")')
		mc.menuItem(label='Parent List', command='glTools.ui.base.parentListUI()')
		mc.menuItem(label='Reorder Attributes', command='glTools.tools.reorderAttr.reorderAttrUI()')
		mc.menuItem(label='Rename History Nodes', command='glTools.ui.base.renameHistoryNodesUI()')
		mc.menuItem(label='Create Intermediate Shape', command='glTools.utils.shape.createIntermediate(mc.listRelatives(mc.ls(sl=1)[0],s=True,pa=True)[0])')
		mc.menuItem(label='Attribute Presets', command='glTools.ui.attrPreset.ui()')
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='Animation', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Graph Editor Filter', command='glTools.tools.graphFilter.ui()')
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='Joint', subMenu=True, tearOff=True)
		mc.menuItem(label='Joint Orient Tool', command='glTools.ui.joint.jointOrientUI()')
		mc.menuItem(label='Joint Match Orient', command='glTools.utils.joint.orientTo(mc.ls(sl=1)[1],mc.ls(sl=1)[0])')
		mc.menuItem(label='Freeze Joint Transform', command='mc.makeIdentity(mc.ls(sl=True,type="joint"),apply=True,t=True,r=True,s=True,n=False)')
		
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='IK', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Create IK Handle', command='glTools.ui.ik.ikHandleUI()')
		mc.menuItem(label='Stretchy IK Chain', command='glTools.ui.ik.stretchyIkChainUI()')
		mc.menuItem(label='Stretchy IK Limb', command='glTools.ui.ik.stretchyIkLimbUI()')
		mc.menuItem(label='Stretchy IK Spline', command='glTools.ui.ik.stretchyIkSplineUI()')
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='Curve', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Locator Curve', command='glTools.ui.curve.locatorCurveUI()')
		mc.menuItem(label='Attach To Curve', command='glTools.ui.curve.attachToCurveUI()')
		mc.menuItem(label='Curve To Locators', command='glTools.ui.curve.curveToLocatorsUI()')
		mc.menuItem(label='Create Along Curve', command='glTools.ui.curve.createAlongCurveUI()')
		mc.menuItem(label='Curve From Edge Loop', command='glTools.ui.curve.edgeLoopCurveUI()')
		mc.menuItem(label='Uniform Rebuild', command='glTools.ui.curve.uniformRebuildCurveUI()')
		
		mc.menuItem(allowOptionBoxes=True, label='LidRails', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Create LidSurface', command='glTools.ui.lidRails.lidSurfaceCreateUI()')
		mc.menuItem(label='3 Control Setup', command='glTools.ui.lidRails.threeCtrlSetupUI()')
		mc.menuItem(label='4 Control Setup', command='glTools.ui.lidRails.fourCtrlSetupUI()')
		
		mc.setParent('..', menu=True)
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='Surface', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Locator Surface', command='glTools.ui.surface.locatorSurfaceUI()')
		mc.menuItem(label='Snap To Surface', command='glTools.ui.surface.snapToSurfaceUI()')
		mc.menuItem(label='Attach To Surface', command='glTools.ui.surface.attachToSurfaceUI()')
		mc.menuItem(label='Surface Points', command='glTools.ui.surface.surfacePointsUI()')
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='Mesh', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Snap To Mesh', command='glTools.ui.mesh.snapToMeshUI()')
		mc.menuItem(label='Interactive Snap Tool', command='glTools.ui.mesh.interactiveSnapToMeshUI()')
		mc.menuItem(label='Attach To Mesh', command='glTools.ui.mesh.attachToMeshUI()')
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='SkinCluster', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Make Relative', command='glTools.ui.skinCluster.makeRelativeUI()')
		mc.menuItem(label='Reset', command='glTools.ui.skinCluster.resetFromUI()')
		mc.menuItem(label='Clear Weights', command='glTools.utils.skinCluster.clearWeights()')
		mc.menuItem(label='Delete BindPose Nodes', command='mc.delete(mc.ls(type="dagPose"))')
		mc.menuItem(label='Rename SkinCluster', command='for i in mc.ls(sl=1): glTools.utils.skinCluster.rename(i)')
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='nDynamics', subMenu=True, tearOff=True)
		
		mc.menuItem(label='UI', command='glTools.ui.nDynamics.create()')
		mc.menuItem(divider=True)
		mc.menuItem(label='Create nucleus', command='glTools.utils.nDynamics.createNucleus()')
		mc.menuItem(label='Create nCloth', command='for i in mc.ls(sl=1): glTools.utils.nDynamics.createNCloth(i)')
		mc.menuItem(label='Create nRigid', command='for i in mc.ls(sl=1): glTools.utils.nDynamics.createNRigid(i)')
		mc.menuItem(divider=True)
		mc.menuItem(label='Delete nCloth', command='for i in mc.ls(sl=1): glTools.utils.nDynamics.deleteNCloth(i)')
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='Spaces', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Create/Add', command='glTools.ui.spaces.createAddUI()')
		mc.menuItem(label='Spaces UI', command='glTools.tools.spaces.Spaces().ui()')
		
		mc.menuItem(ob=True, command='glTools.ui.spaces.charUI()')
		
		mc.setParent('..', menu=True)
		
		mc.menuItem(allowOptionBoxes=True, label='Pose Match Setup', subMenu=True, tearOff=True)
		
		mc.menuItem(label='Evaluation Order', command='glTools.ui.poseMatch.evaluationOrderUI()')
		mc.menuItem(label='Match Rules', command='glTools.ui.poseMatch.matchRulesUI()')
		
		mc.setParent('..', menu=True)
		
		mc.setParent('..', menu=True)
		
		#----------------------------------------#
		
		mc.menuItem(divider=True)
		
		mc.menuItem(allowOptionBoxes=True, label= 'Aci Utilities', subMenu=True, tearOff=False)
		
		mc.menuItem(label='Load Default Page', command='stage.editAciFile("/home/r/rgomez/Desktop/ACI/prop.aci",actorName="")')
		mc.menuItem(label='Build Prop Aci', command='import glTools.utils.propAci;glTools.utils.propAci.PropAci().addControls(mc.ls(sl=1))')
				
		mc.setParent('..', menu=True)
		
		#----------------------------------------#
		
		mc.menuItem(divider=True)
		
		mc.menuItem(allowOptionBoxes=True, label= 'Resolution Utilities', subMenu=True, tearOff=False)
		
		mc.menuItem(label='Add Char Res', command='glTools.ui.resolution.addResAttr(isProp=False);glTools.common.SmoothMeshUtilities().smoothWrapper()')
		mc.menuItem(label='Add Prop Res', command='glTools.ui.resolution.addResAttr(isProp=True);glTools.common.SmoothMeshUtilities().smoothWrapper()')
		
		mc.setParent('..', menu=True)
		
		#----------------------------------------#
				
		mc.menuItem(divider=True)
		
		mc.menuItem(allowOptionBoxes=True, label= 'Display Utilities', subMenu=True, tearOff=False)
		
		mc.menuItem(label='Connect Control Vis', command='glTools.common.VisibilityUtilities().connectControls()')
				
		mc.setParent('..', menu=True)
		
		#----------------------------------------#
		
		mc.menuItem(divider =True)
		
		mc.menuItem(label='Refresh Menu', command='reload(glTools.ui.menu);glTools.ui.menu.create()')
		
		mc.setParent('..')
Ejemplo n.º 52
0
    def _UI(self):
        if cmds.window(self.win, exists=True):
            cmds.deleteUI(self.win, window=True)
        cmds.window(self.win,
                    title=self.win,
                    menuBar=True,
                    sizeable=True,
                    widthHeight=(300, 380))

        cmds.menu(label='Help')
        cmds.menuItem(label='Watch MasterClass Video',
                      c=lambda x: self._contactDetails(opentype='vimeo'))
        cmds.menuItem(label='Contact', c=r9Setup.red9ContactInfo)
        # cmds.menuItem(label='Contact', c=lambda x:self._contactDetails(opentype='email'))
        cmds.menuItem(label='Blog', c=r9Setup.red9_blog)
        cmds.menuItem(label='Red9HomePage', c=r9Setup.red9_website_home)

        cmds.columnLayout(adjustableColumn=True)
        cmds.text(fn="boldLabelFont", label="Advanced Bind Options")
        cmds.separator(h=15, style="none")
        cmds.rowColumnLayout(numberOfColumns=2,
                             cw=((1, 150), (2, 150)),
                             cs=((1, 10)))
        cmds.checkBox(
            value=self.settings.bind_rots,
            label="bind_rots",
            ann="Bind only the Rotates of the given Controller",
            al="left",
            onc=lambda x: self.settings.__setattr__('bind_rots', True),
            ofc=lambda x: self.settings.__setattr__('bind_rots', False))
        cmds.checkBox(
            value=self.settings.bind_trans,
            label="bind_trans",
            ann="Bind only the Translates of the given Controller",
            al="left",
            onc=lambda x: self.settings.__setattr__('bind_trans', True),
            ofc=lambda x: self.settings.__setattr__('bind_trans', False))
        cmds.checkBox(
            value=1,
            label="AlignRots CtrSpace",
            ann="Force the BindLocator to the position of the Controller",
            al="left",
            onc=lambda x: self.settings.__setattr__('align_to_control_rots',
                                                    True),
            ofc=lambda x: self.settings.__setattr__('align_to_source_rots',
                                                    True))
        cmds.checkBox(
            value=1,
            label="AlignTrans CtrSpace",
            ann="Force the BindLocator to the position of the Controller",
            al="left",
            onc=lambda x: self.settings.__setattr__('align_to_control_trans',
                                                    True),
            ofc=lambda x: self.settings.__setattr__('align_to_source_trans',
                                                    True))
        cmds.checkBox(
            value=self.settings.reset_rots,
            label="Reset Rots Offsets",
            ann="Reset any Offset during bind, snapping the systems together",
            al="left",
            onc=lambda x: self.settings.__setattr__('reset_rots', True),
            ofc=lambda x: self.settings.__setattr__('reset_rots', False))
        cmds.checkBox(
            value=self.settings.reset_trans,
            label="Reset Trans Offsets",
            ann="Reset any Offset during bind, snapping the systems together",
            al="left",
            onc=lambda x: self.settings.__setattr__('reset_trans', True),
            ofc=lambda x: self.settings.__setattr__('reset_trans', False))

        cmds.setParent('..')
        cmds.separator(h=10, style="none")
        cmds.button(
            label="BasicBind",
            al="center",
            ann=
            "Select the Joint on the driving Skeleton then the Controller to be driven",
            c=lambda x: BindNodeBase(cmds.ls(sl=True, l=True)[0],
                                     cmds.ls(sl=True, l=True)[1],
                                     settings=self.settings).add_binder_node())
        cmds.button(
            label="ComplexBind",
            al="center",
            ann=
            "Select the Joint on the driving Skeleton then the Controller to be driven",
            c=lambda x: BindNodeTwin(cmds.ls(sl=True, l=True)[0],
                                     cmds.ls(sl=True, l=True)[1],
                                     settings=self.settings).add_binder_node())
        cmds.button(
            label="AimerBind",
            al="center",
            ann=
            "Select the Joint on the driving Skeleton to AIM at, then the Controller to be driven, finally a node on the driven skeleton to use as UpVector",
            c=lambda x: BindNodeAim(cmds.ls(sl=True, l=True)[0],
                                    cmds.ls(sl=True, l=True)[1],
                                    cmds.ls(sl=True, l=True)[2],
                                    settings=self.settings).add_binder_node())
        cmds.separator(h=15, style="none")
        cmds.rowColumnLayout(numberOfColumns=2,
                             columnWidth=[(1, 147), (2, 147)])

        cmds.button(
            label="Add BakeMarker",
            al="center",
            ann="Add the BoundCtrl / Bake Marker to the selected nodes",
            c=lambda x: add_bind_markers(cmds.ls(sl=True, l=True)))
        cmds.button(
            label="remove BakeMarker",
            al="center",
            ann="Remove the BoundCtrl / Bake Marker from the selected nodes",
            c=lambda x: removeBindMarker(cmds.ls(sl=True, l=True)))

        cmds.button(
            label="Select BindNodes",
            al="center",
            ann="Select Top Group Node of the Source Binder",
            c=lambda x: pm.select(get_bind_nodes(cmds.ls(sl=True, l=True))))
        cmds.button(label="Select BoundControls",
                    al="center",
                    ann="Select Top Group Node of the Bound Rig",
                    c=lambda x: pm.select(
                        get_bound_controls(cmds.ls(sl=True, l=True))))
        cmds.setParent('..')
        cmds.rowColumnLayout(numberOfColumns=2,
                             columnWidth=[(1, 200), (2, 74)],
                             columnSpacing=[(2, 5)])
        cmds.button(label="Bake Binder",
                    al="center",
                    ann="Select Top Group Node of the Bound Rig",
                    c=lambda x: bake_binder_data(cmds.ls(sl=True, l=True), self
                                                 .settings.bake_debug))
        cmds.checkBox(
            value=self.settings.bake_debug,
            label="Debug View",
            ann="Keep viewport active to observe the baking process",
            al="left",
            onc=lambda x: self.settings.__setattr__('bake_debug', True),
            ofc=lambda x: self.settings.__setattr__('bake_debug', False))
        cmds.setParent('..')
        cmds.separator(h=10, style="none")
        cmds.button(
            label="Link Skeleton Hierarchies - Direct Connect",
            al="center",
            ann=
            "Select Root joints of the source and destination skeletons to be connected - connect via attrs",
            c=lambda x: bind_skeletons(cmds.ls(sl=True)[0],
                                       cmds.ls(sl=True)[1],
                                       method='connect',
                                       verbose=True))
        cmds.button(
            label="Link Skeleton Hierarchies - Constraints",
            al="center",
            ann=
            "Select Root joints of the source and destination skeletons to be connected - connect via parentConstraints",
            c=lambda x: bind_skeletons(cmds.ls(sl=True)[0],
                                       cmds.ls(sl=True)[1],
                                       method='constrain',
                                       verbose=True))
        cmds.separator(h=10, style="none")
        cmds.button(
            label="MakeStabilizer",
            al="center",
            ann="Select the nodes you want to extract the motion data from",
            c=lambda x: make_stabilized_node())

        cmds.separator(h=20, style="none")
        cmds.iconTextButton(style='iconOnly',
                            bgc=(0.7, 0, 0),
                            image1='Rocket9_buttonStrap2.bmp',
                            c=lambda *args: (r9Setup.red9ContactInfo()),
                            h=22,
                            w=200)
        cmds.showWindow(self.win)
        cmds.window(self.win, e=True, h=400)
Ejemplo n.º 53
0
    def add_time_slider_menu(self):
        _original_menu = 'AnimMemoTimeSliderMenu'
        _option_menu = 'AnimMemoTimeSliderMenu_Option'

        if cmds.menuItem(_original_menu, q=True, ex=True):
            cmds.deleteUI(_original_menu, mi=True)

        if _lib.maya_api_version() >= 201100:
            mel.eval('updateTimeSliderMenu TimeSliderMenu')

        _menu_name = 'TimeSliderMenu'
        cmds.menuItem(divider=True, p=_menu_name)

        _m = cmds.menuItem(_original_menu,
                           subMenu=True,
                           label='AnimMemo Menu',
                           p=_menu_name,
                           to=True)

        cmds.menuItem(label='Create',
                      ann='Create Mew Memo',
                      c=self.memo_cls.new_memo,
                      p=_m)

        cmds.menuItem(label='Edit',
                      ann='Edit Mew Memo',
                      c=self.memo_cls.edit_memo,
                      p=_m)

        cmds.menuItem(divider=True, p=_original_menu)

        cmds.menuItem(label='DeleteAll',
                      ann='Delete All Memo',
                      c=self.memo_cls.delete_all_memo,
                      p=_m)

        cmds.menuItem(divider=True, p=_m)

        cmds.menuItem(label='ExportFile',
                      ann='ExportFile',
                      c=self.export_data,
                      p=_m)

        cmds.menuItem(label='ImportFile',
                      ann='ImportFile',
                      c=self.import_data,
                      p=_m)

        cmds.menuItem(divider=True, p=_m)

        cmds.menuItem(label='ExportFile(Scnes SameName File)',
                      ann='Export the same name file',
                      c=self.memo_cls.export_data_samename_file,
                      p=_m)

        cmds.menuItem(label='ImportFile(Scnes SameName File)',
                      ann='Import the same name file',
                      c=self.memo_cls.import_data_samename_file,
                      p=_m)

        _o = cmds.menuItem(_option_menu,
                           subMenu=True,
                           label='Option',
                           p=_m,
                           to=True)

        self.imp_smf = cmds.menuItem(
            label='Import SameName File',
            checkBox=self.get_import_samename_file(),
            ann='Import the same name file when opening a scene',
            c=self._change_option,
            p=_o)

        self.save2scene = cmds.menuItem(
            label='Save to CurrentScene',
            checkBox=self.get_save_to_current_scene(),
            ann='Save to CurrentScene',
            c=self._change_option,
            p=_o)
Ejemplo n.º 54
0
def gui():
    if (cmds.window(newWindow, q=True, exists=True)):
        cmds.deleteUI(newWindow)
    if (cmds.windowPref(newWindow, q=True, exists=True)):
        cmds.windowPref(newWindow, r=True)

    myWindow = cmds.window(newWindow, t='Auto Arm Rig', w=180, h=320)
    main_Layout = cmds.columnLayout('Main Header')

    # naming options (option menu)
    cmds.text('naming_Text', l='Step 1: Set name options ')
    cmds.rowColumnLayout(nc=4, cw=[(1, 20), (2, 70), (3, 40), (4, 50)])
    cmds.text('oriText', label='Ori:')
    cmds.optionMenu('ori_Menu', changeCommand=scriptName + '.colorChange()')
    cmds.menuItem(label='left_')
    cmds.menuItem(label='right_')
    cmds.menuItem(label='centre_')

    cmds.text('labelText', label='Label:')
    cmds.optionMenu('Label_Menu')
    cmds.menuItem(label="arm")
    cmds.menuItem(label="leg")
    cmds.setParent(main_Layout)
    cmds.separator('name_sep', w=180, h=5)

    # set the rig type (radio button)
    cmds.text('rigType_Text', l='Step 2: Set rig type')
    cmds.radioButtonGrp("armType_Btn", labelArray3=('IK', 'FK', 'IK/FK'), numberOfRadioButtons=3,
                        columnWidth3=[50, 50, 50], select=3, cc=scriptName + '.armTypeVis()')
    cmds.separator("type_Sep", w=150, h=5)

    # set icon options (options menu)
    cmds.text('conSet_Text', l='Step 3: Set icon options ')
    cmds.rowColumnLayout(nc=2, cw=[(1, 90), (2, 80)])
    cmds.text('ikStyle_Text', label='IK Icon Style: ')
    cmds.optionMenu('ikIcon_Menu', cc=scriptName + '.iconChanger("ik")')
    cmds.menuItem(label="Box")
    cmds.menuItem(label="4 Arrows")
    cmds.menuItem(label="4 Pin")

    cmds.text('fkStyle_Text', label='FK Icon Style: ')
    cmds.optionMenu('fkIcon_Menu', cc=scriptName + '.iconChanger("fk")')
    cmds.menuItem(label="Circle")
    cmds.menuItem(label="Turn Arrows")

    cmds.text('handStyle_Text', label='Hand Icon Style: ')
    cmds.optionMenu('handIcon_Menu', cc=scriptName + '.iconChanger("hand")')
    cmds.menuItem(label="Circle")
    cmds.menuItem(label="COG")

    cmds.text('pvStyle_Text', label='PV Icon Style: ')
    cmds.optionMenu('pvIcon_Menu', cc=scriptName + '.iconChanger("pv")')
    cmds.menuItem(label="Diamond")
    cmds.menuItem(label="Arrow")

    cmds.setParent(main_Layout)
    cmds.button('testIcon_Btn', l="Make test icons to set scale", w=180, c=scriptName + ".armIconScale()")
    cmds.separator('style_Sep', w=180, h=5)

    # pick the color (iconTextButton and colorSlider)
    cmds.text('armSet_Text', l='Step 4: pick icon color ')
    cmds.gridLayout(nr=1, nc=5, cellWidthHeight=[35, 20])
    cmds.iconTextButton('darkBlue_Btn', bgc=[.000, .016, .373])
    cmds.iconTextButton('lightBlue_Btn', bgc=[0, 0, 1])
    cmds.iconTextButton('brown_Btn', bgc=[0.537, 0.278, .2])
    cmds.iconTextButton('red_Btn', bgc=[1, 0, 0])
    cmds.iconTextButton('yellow_Btn', bgc=[1, 1, 0])

    cmds.setParent(main_Layout)
    cmds.colorIndexSliderGrp('armColor', w=180, h=20, cw2=(150, 0), min=0, max=31, value=7)
    cmds.separator('color_Sep', w=180, h=5)

    # pole Vector options ( radio button)
    cmds.text('pv_Text', label='Step 5: Set IK elbow options')
    cmds.radioButtonGrp('addPVElbow_Btn', labelArray2=('Twist', 'PoleVector'), numberOfRadioButtons=2,
                        columnWidth2=[65, 85], select=2, cc=scriptName + ".pvChange()")
    cmds.separator('pv_Sep', w=180, h=5)

    cmds.button('final_Btn', l="Finalize the Rig", w=180, c=scriptName + ".armRigFinalize()")

    # displaying Window
    cmds.showWindow()
Ejemplo n.º 55
0
    def show(self, *args):
        verNum = 2.0
        winName = "jpmAnimWriter"
        if (cmds.window(winName, exists=True)):
            cmds.deleteUI(winName)
        cmds.window(winName,
                    menuBar=1,
                    t=("jpmAnimWriter v" + str(verNum) + "  --  James Parks"),
                    rtf=True)

        if not cmds.optionVar(exists="jpmAWpath"):
            self.path = cmds.optionVar(q="jpmAWpath") + "/"
        if self.path == 0:
            self.setPathDialog()
            cmds.optionVar(self.path, sv="jpmAWpath")

        poMin = cmds.playbackOptions(q=1, min=1)
        poMax = cmds.playbackOptions(q=1, max=1)

        #Window menus
        fileMenu = cmds.menu("fileMenu", l="File")
        cmds.menuItem("setPathMenuItem", l="Set Path...", c=self.setPathDialog)
        cmds.menuItem("printPathMenuItem",
                      l="Print Path",
                      c=("print \"" + self.path + "\""))
        cmds.menuItem("writeNewMenuItem",
                      l="Write New File",
                      c=self.writeNewFile,
                      p=fileMenu)
        cmds.menuItem("applyMenuItem",
                      l="Apply Selected",
                      c=self.applyFile,
                      p=fileMenu)
        cmds.menuItem("refreshMenuItem",
                      l="Refresh Window",
                      c=self.show,
                      p=fileMenu)

        sortMenu = cmds.menu("sortMenu", l="Sort")
        cmds.radioMenuItemCollection("sortMethod")
        cmds.menuItem("listAlpha",
                      l="Alpha",
                      rb=self.currentSort,
                      cl="sortMethod",
                      c=functools.partial(self.populateFileList, True),
                      p=sortMenu)
        cmds.menuItem("listCreation",
                      l="Creation",
                      rb=(not self.currentSort),
                      cl="sortMethod",
                      c=functools.partial(self.populateFileList, False),
                      p=sortMenu)

        #form and layout
        form = cmds.formLayout("form", nd=100)
        tabs = cmds.tabLayout("tabs",
                              innerMarginWidth=5,
                              innerMarginHeight=5,
                              cc=self.fieldsOnOff)

        cmds.setParent(form)
        #name field and write new file button
        nameField = cmds.rowColumnLayout(nc=2, cw=([1, 200], [2, 80]))
        cmds.textFieldGrp("nameGrp",
                          l="Name",
                          cal=[1, "left"],
                          tx="...File Name...",
                          cw=([1, 50], [2, 150]))
        cmds.button("writeButton",
                    l="Write New File",
                    w=100,
                    c=self.writeNewFile)

        #min/max range fields
        cmds.floatFieldGrp("animRange",
                           nf=2,
                           en=1,
                           l="min/max",
                           v1=poMin,
                           v2=poMax,
                           cal=[1, "left"],
                           cw=([1, 50], [2, 75], [3, 75]))
        cmds.button("refreshAnimRange",
                    l="<--",
                    ann="Refresh",
                    en=1,
                    w=20,
                    c=self.refreshRange)

        cmds.setParent(tabs)
        #anim file list
        animFileForm = cmds.formLayout("animFileForm", nd=100)
        animFileList = cmds.textScrollList("animFileList",
                                           ams=0,
                                           dcc=self.applyFile,
                                           dkc=self.deleteFile)

        #RMB pop up menu for the anim file list
        cmds.popupMenu(b=3, p=animFileList)
        cmds.menuItem(l="Apply Selected", c=self.applyFile)
        cmds.menuItem(l="Rename Selected...", c=self.renameFileWin)
        cmds.menuItem(l="Name --->",
                      c=functools.partial(self.popUpName, "animFileList"))
        cmds.menuItem(divider=1)
        cmds.menuItem(l="Delete Selected", c=self.deleteFile)

        cmds.setParent(tabs)
        #pose file list
        poseFileForm = cmds.formLayout("poseFileForm", nd=100)
        poseFileList = cmds.textScrollList("poseFileList",
                                           ams=0,
                                           dcc=self.applyFile,
                                           dkc=self.deleteFile)

        #RMB pop up menu for the pose file list
        cmds.popupMenu(b=3, p=poseFileList)
        cmds.menuItem(l="Apply Selected", c=self.applyFile)
        cmds.menuItem(l="Rename Selected...", c=self.renameFileWin)
        cmds.menuItem(l="Name --->",
                      c=functools.partial(self.popUpName, "poseFileList"))
        cmds.menuItem(divider=1)
        cmds.menuItem(l="Delete Selected", c=self.deleteFile)

        cmds.setParent(tabs)
        #sel file list
        selFileForm = cmds.formLayout("selFileForm", nd=100)
        selFileList = cmds.textScrollList("selFileList",
                                          ams=0,
                                          dcc=self.applyFile,
                                          dkc=self.deleteFile)

        #RMB pop up menu for the sel file list
        cmds.popupMenu(b=3, p=selFileList)
        cmds.menuItem(l="Apply Selected", c=self.applyFile)
        cmds.menuItem(l="Rename Selected...", c=self.renameFileWin)
        cmds.menuItem(l="Name --->",
                      c=functools.partial(self.popUpName, "selFileList"))
        cmds.menuItem(divider=1)
        cmds.menuItem(l="Delete Selected", c=self.deleteFile)

        selRadio = cmds.radioButtonGrp(
            "selectionRadio",
            nrb=4,
            cw=([1, 60], [2, 60], [3, 60], [4, 60]),
            la4=["replace", "add", "toggle", "subtract"],
            sl=1)

        cmds.setParent(tabs)
        #settings tab
        settingsForm = cmds.formLayout("settingsForm", nd=100)
        settingsLayout = cmds.rowColumnLayout(nc=1, cw=[1, 175])
        refReTargetCheck = cmds.checkBox("refReTargetCheck",
                                         l="Reference Re-Targeting",
                                         v=1,
                                         al="left")
        nodeNamesRadio = cmds.radioButtonGrp("nodeNamesRadio",
                                             nrb=2,
                                             cal=([1, "left"], [2, "left"]),
                                             cw=([1, 75], [2, 50], [3, 50]),
                                             la2=["Short", "Long"],
                                             l="Node Names",
                                             sl=1)
        overwriteCheck = cmds.checkBox("overwriteCheck",
                                       l="Overwrite Protection",
                                       v=0,
                                       al="left")
        deleteStaticCheck = cmds.checkBox("deleteStaticCheck",
                                          l="Delete Static Channels",
                                          v=0,
                                          al="left")

        cmds.setParent(form)
        #apply selected button
        applyButton = cmds.button("applyButton",
                                  l="Apply Selected",
                                  w=100,
                                  c=self.applyFile)

        cmds.tabLayout(tabs,
                       edit=True,
                       tabLabel=((animFileForm, 'Anim'),
                                 (poseFileForm, 'Pose'), (selFileForm, 'Sel'),
                                 (settingsForm, "Settings")))
        ##form attaches
        cmds.formLayout(form,
                        e=1,
                        af=([tabs, "top", 50], [tabs, "left",
                                                0], [tabs, "bottom",
                                                     25], [tabs, "right", 0]))
        cmds.formLayout(form,
                        e=1,
                        af=([nameField, "top",
                             0], [nameField, "left",
                                  0], [nameField, "right", 0]))
        cmds.formLayout(animFileForm,
                        e=1,
                        af=([animFileList, "top",
                             0], [animFileList, "left",
                                  0], [animFileList, "bottom",
                                       0], [animFileList, "right", 0]))
        cmds.formLayout(poseFileForm,
                        e=1,
                        af=([poseFileList, "top",
                             0], [poseFileList, "left",
                                  0], [poseFileList, "bottom",
                                       0], [poseFileList, "right", 0]))
        cmds.formLayout(selFileForm,
                        e=1,
                        af=([selFileList, "top",
                             0], [selFileList, "left",
                                  0], [selFileList, "bottom",
                                       25], [selFileList, "right", 0]))
        cmds.formLayout(selFileForm,
                        e=1,
                        af=([selRadio, "bottom",
                             0], [selRadio, "left", 0], [selRadio, "right",
                                                         0]))
        cmds.formLayout(settingsForm,
                        e=1,
                        af=([settingsLayout, "top",
                             0], [settingsLayout, "left",
                                  0], [settingsLayout, "bottom",
                                       0], [settingsLayout, "right", 0]))
        cmds.formLayout(form,
                        e=1,
                        af=([applyButton, "left",
                             0], [applyButton, "bottom",
                                  0], [applyButton, "right", 0]))

        self.populateFileList(self.currentSort)

        cmds.showWindow(winName)
Ejemplo n.º 56
0
	def buildLayout( self ):
		"""
		Build a new multi-rig template UI. 
		"""
		curParent = cmds.setParent( query=True )

		self._frameName = cmds.frameLayout( collapsable=True,
											label=self._template.rigName() )

		self.setControl( self._frameName )
		cmds.columnLayout( adjustableColumn=True )

		labelL10N = maya.stringTable[ 'y_cameraSetTool.kMultiRigName'  ]
		self._templateCamSetField = cmds.textFieldGrp( label=labelL10N,
													   text=self._template.rigName(),
													   changeCommand=self.multiRigNameChanged )
		labelL10N = maya.stringTable[ 'y_cameraSetTool.kMultiRigPrefix'  ]
		self._camSetPrefix = cmds.textFieldGrp( label=labelL10N,
												text=self._template.camSetPrefix(),
												changeCommand=self.namingPrefixChanged )

		camSetTemplate = self._template.cameraSetNodeType()
		availCameraSets = ['cameraSet']
		camSet = cmds.pluginInfo( query=True,
								  dependNodeByType='kCameraSetNode' )
		if camSet and len(camSet):
			availCameraSets = availCameraSets + camSet
		if camSetTemplate not in availCameraSets:
			availCameraSets = availCameraSets + [camSetTemplate]
			
		if len(availCameraSets) > 1: 
			labelL10N = maya.stringTable[ 'y_cameraSetTool.kCameraSetNodeType'  ]
			self._cameraSetName = cmds.optionMenuGrp( label=labelL10N )
			for c in availCameraSets:
				cmds.menuItem( label=c )

			callback = self.cameraSetNameChanged
			cmds.optionMenuGrp( self._cameraSetName, edit=True, 
								changeCommand=callback )
			cmds.optionMenuGrp( self._cameraSetName, edit=True,
								value=camSetTemplate )

		cmds.scrollLayout( childResizable=True,
						   minChildWidth=200 )
		self._layerParent = cmds.columnLayout( adjustableColumn=True )
		# Build the layout for each of the layers.
		# 
		for i in range( self._template.layers() ):
			self.layoutForLayer( i )
		cmds.setParent('..')
		cmds.setParent('..')
		form = cmds.formLayout()
		b1 = cmds.button( label=maya.stringTable['y_cameraSetTool.kCreateIt' ],
						  command=self.createIt )
		b2 = cmds.button( label=maya.stringTable['y_cameraSetTool.kRemoveIt' ],
						  command=self.removeDef )
		b3 = cmds.button( label=maya.stringTable['y_cameraSetTool.kAddIt' ],
						  command=self.addLayer)
		attachForm = [(b1, "top", 0),
					  (b1, "bottom", 0),
					  (b1, "left", 0),
					  (b2, "top", 0),
					  (b2, "bottom", 0),
					  (b3, "right", 0),
					  (b3, "top", 0),
					  (b3, "bottom", 0)]
		attachControl = [(b2, "right", 5, b3)]
		attachNone= [(b1,"right"),
					 (b3,"left")]
		cmds.formLayout( form, edit=True, attachForm=attachForm,
						 attachNone=attachNone, attachControl=attachControl)

		cmds.setParent(curParent)
Ejemplo n.º 57
0
    def reCreateEditSelectedModuleLayout(self, bSelect=True, *args):
        """ Select the moduleGuide, clear the selectedModuleLayout and re-create the mirrorLayout.
        """
        # verify the integrity of the guideModule:
        if self.verifyGuideModuleIntegrity():
            # select the module to be re-build the selectedLayout:
            if (bSelect):
                cmds.select(self.moduleGrp)
            self.clearSelectedModuleLayout(self)
            try:
                # edit label of frame layout:
                cmds.frameLayout(
                    'editSelectedModuleLayoutA',
                    edit=True,
                    label=self.langDic[self.langName]['i011_selectedModule'] +
                    " :  " + self.langDic[self.langName][self.title] + " - " +
                    self.userGuideName)
                # edit button with "S" letter indicating it is selected:
                cmds.button(self.selectButton,
                            edit=True,
                            label="S",
                            backgroundColor=(1.0, 1.0, 1.0))
                cmds.columnLayout("selectedColumn",
                                  adjustableColumn=True,
                                  parent="selectedModuleLayout")
                # re-create segment layout:
                self.segDelColumn = cmds.rowLayout(numberOfColumns=4,
                                                   columnWidth4=(100, 140, 50,
                                                                 75),
                                                   columnAlign=[(1, 'right'),
                                                                (2, 'left'),
                                                                (3, 'left'),
                                                                (4, 'right')],
                                                   adjustableColumn=4,
                                                   columnAttach=[
                                                       (1, 'both', 2),
                                                       (2, 'left', 2),
                                                       (3, 'both', 2),
                                                       (4, 'both', 10)
                                                   ],
                                                   parent="selectedColumn")
                self.flipAttrExists = cmds.objExists(self.moduleGrp + ".flip")
                self.nJointsAttrExists = cmds.objExists(self.moduleGrp +
                                                        ".nJoints")
                self.IndirectSkinAttrExists = cmds.objExists(self.moduleGrp +
                                                             ".indirectSkin")
                if self.nJointsAttrExists:
                    nJointsAttr = cmds.getAttr(self.moduleGrp + ".nJoints")
                    if nJointsAttr > 0:
                        self.nSegmentsText = cmds.text(
                            label=self.langDic[self.langName]['m003_segments'],
                            parent=self.segDelColumn)
                        self.nJointsIF = cmds.intField(
                            value=nJointsAttr,
                            minValue=1,
                            changeCommand=partial(self.changeJointNumber, 0),
                            parent=self.segDelColumn)
                    else:
                        self.nSegmentsText = cmds.text(
                            label=self.langDic[self.langName]['m003_segments'],
                            parent=self.segDelColumn)
                        self.nJointsIF = cmds.intField(
                            value=nJointsAttr,
                            minValue=0,
                            editable=False,
                            parent=self.segDelColumn)
                else:
                    cmds.text(" ", parent=self.segDelColumn)
                    cmds.text(" ", parent=self.segDelColumn)
                # create Delete button:
                self.deleteButton = cmds.button(
                    label=self.langDic[self.langName]['m005_delete'],
                    command=self.deleteModule,
                    backgroundColor=(1.0, 0.7, 0.7),
                    parent=self.segDelColumn)
                self.duplicateButton = cmds.button(
                    label=self.langDic[self.langName]['m070_duplicate'],
                    command=self.duplicateModule,
                    backgroundColor=(0.7, 0.6, 0.8),
                    annotation=self.langDic[self.langName]['i068_CtrlD'],
                    parent=self.segDelColumn)

                # reCreate mirror layout:
                self.doubleRigColumn = cmds.rowLayout(
                    numberOfColumns=4,
                    columnWidth4=(100, 50, 80, 70),
                    columnAlign=[(1, 'right'), (4, 'right')],
                    adjustableColumn=4,
                    columnAttach=[(1, 'both', 2), (2, 'both', 2),
                                  (3, 'both', 2), (4, 'both', 10)],
                    parent="selectedColumn")
                cmds.text(self.langDic[self.langName]['m010_Mirror'],
                          parent=self.doubleRigColumn)
                self.mirrorMenu = cmds.optionMenu(
                    "mirrorMenu",
                    label='',
                    changeCommand=self.changeMirror,
                    parent=self.doubleRigColumn)
                mirrorMenuItemList = [
                    'off', 'X', 'Y', 'Z', 'XY', 'XZ', 'YZ', 'XYZ'
                ]
                for item in mirrorMenuItemList:
                    cmds.menuItem(label=item, parent=self.mirrorMenu)
                # verify if there are a list of mirrorNames to menuOption:
                currentMirrorNameList = cmds.getAttr(self.moduleGrp +
                                                     ".mirrorNameList")
                if currentMirrorNameList:
                    menuNameItemList = str(currentMirrorNameList).split(';')
                else:
                    L = self.langDic[self.langName]['p002_left']
                    R = self.langDic[self.langName]['p003_right']
                    T = self.langDic[self.langName]['p006_top']
                    B = self.langDic[self.langName]['p007_bottom']
                    F = self.langDic[self.langName]['p008_front']
                    Bk = self.langDic[self.langName]['p009_back']
                    menuNameItemList = [
                        L + ' --> ' + R, R + ' --> ' + L, T + ' --> ' + B,
                        B + ' --> ' + T, F + ' --> ' + Bk, Bk + ' --> ' + F
                    ]
                # create items for mirrorName menu:
                self.mirrorNameMenu = cmds.optionMenu(
                    "mirrorNameMenu",
                    label='',
                    changeCommand=self.changeMirrorName,
                    parent=self.doubleRigColumn)
                menuNameItemText = ""
                for item in menuNameItemList:
                    if item != "":
                        cmds.menuItem(label=item, parent=self.mirrorNameMenu)
                        menuNameItemText += item + ";"
                cmds.setAttr(self.moduleGrp + ".mirrorNameList",
                             menuNameItemText,
                             type='string')
                # verify if it is the first time to creation this instance or re-loading an existing guide:
                firstTime = cmds.getAttr(self.moduleGrp + ".mirrorAxis")
                if firstTime == "" or firstTime == None:
                    # set initial values to guide base:
                    cmds.setAttr(self.moduleGrp + ".mirrorAxis",
                                 mirrorMenuItemList[0],
                                 type='string')
                    cmds.setAttr(self.moduleGrp + ".mirrorName",
                                 menuNameItemList[0],
                                 type='string')
                else:
                    # get initial values from guide base:
                    initialMirror = cmds.getAttr(self.moduleGrp +
                                                 ".mirrorAxis")
                    initialMirrorName = cmds.getAttr(self.moduleGrp +
                                                     ".mirrorName")
                    # set layout with theses values:
                    cmds.optionMenu(self.mirrorMenu,
                                    edit=True,
                                    value=initialMirror)
                    cmds.optionMenu(self.mirrorNameMenu,
                                    edit=True,
                                    value=initialMirrorName)
                    # verify if there is a mirror in a father maybe:
                    self.checkFatherMirror()

                # create Rig button:
                self.rigButton = cmds.button(label="Rig",
                                             command=self.rigModule,
                                             backgroundColor=(1.0, 1.0, 0.7),
                                             parent=self.doubleRigColumn)

                # create a flip layout:
                if self.flipAttrExists:
                    self.doubleFlipColumn = cmds.rowLayout(
                        numberOfColumns=4,
                        columnWidth4=(100, 50, 80, 70),
                        columnAlign=[(1, 'right'), (4, 'right')],
                        adjustableColumn=4,
                        columnAttach=[(1, 'both', 2), (2, 'both', 2),
                                      (3, 'both', 2), (4, 'both', 10)],
                        parent="selectedColumn")
                    cmds.text(" ", parent=self.doubleFlipColumn)
                    flipValue = cmds.getAttr(self.moduleGrp + ".flip")
                    self.flipCB = cmds.checkBox(label="flip",
                                                value=flipValue,
                                                changeCommand=self.changeFlip,
                                                parent=self.doubleFlipColumn)

                # create an indirectSkin layout:
                if self.IndirectSkinAttrExists:
                    self.doubleIndirectSkinColumn = cmds.rowLayout(
                        numberOfColumns=4,
                        columnWidth4=(100, 150, 10, 40),
                        columnAlign=[(1, 'right'), (4, 'right')],
                        adjustableColumn=4,
                        columnAttach=[(1, 'both', 2), (2, 'both', 2),
                                      (3, 'both', 2), (4, 'both', 10)],
                        parent="selectedColumn")
                    cmds.text(" ", parent=self.doubleIndirectSkinColumn)
                    indirectSkinValue = cmds.getAttr(self.moduleGrp +
                                                     ".indirectSkin")
                    self.indirectSkinCB = cmds.checkBox(
                        label="Indirect Skinning",
                        value=indirectSkinValue,
                        changeCommand=self.changeIndirectSkin,
                        parent=self.doubleIndirectSkinColumn)
            except:
                pass
Ejemplo n.º 58
0
def hyperShadePanelBuildCreateMenuCallback():
    mc.menuItem(label="Appleseed")
    mc.menuItem(divider=True)
Ejemplo n.º 59
0
def mgear_dagmenu_fill(parent_menu, current_control):
    """Fill the given menu with mGear's custom animation menu

    Args:
        parent_menu(str): Parent Menu path name
        current_control(str): current selected mGear control
    """

    # gets current selection to use later on
    _current_selection = cmds.ls(selection=True)

    # get child controls
    child_controls = []
    for ctl in _current_selection:
        [
            child_controls.append(x) for x in get_all_tag_children(ctl)
            if x not in child_controls
        ]
        # [child_controls.append(x)
        #  for x in get_all_tag_children(cmds.ls(cmds.listConnections(ctl),
        #                                        type="controller"))
        #  if x not in child_controls]

    child_controls.append(current_control)

    # handles ik fk blend attributes
    for attr in cmds.listAttr(current_control, userDefined=True,
                              keyable=True) or []:
        if (not attr.endswith("_blend")
                or cmds.addAttr("{}.{}".format(current_control, attr),
                                query=True,
                                usedAsProxy=True)):
            continue
        # found attribute so get current state
        current_state = cmds.getAttr("{}.{}".format(current_control, attr))
        states = {0: "Fk", 1: "Ik"}

        rvs_state = states[int(not (current_state))]

        cmds.menuItem(parent=parent_menu,
                      label="Switch {} to {}".format(
                          attr.split("_blend")[0], rvs_state),
                      command=partial(__switch_fkik_callback, current_control,
                                      False, attr),
                      image="kinReroot.png")

        cmds.menuItem(parent=parent_menu,
                      label="Switch {} to {} + Key".format(
                          attr.split("_blend")[0], rvs_state),
                      command=partial(__switch_fkik_callback, current_control,
                                      True, attr),
                      image="character.svg")

        cmds.menuItem(parent=parent_menu,
                      label="Range switch",
                      command=partial(__range_switch_callback, current_control,
                                      attr))

        # divider
        cmds.menuItem(parent=parent_menu, divider=True)

    # check is given control is an mGear control
    if cmds.objExists("{}.uiHost".format(current_control)):
        # select ui host
        cmds.menuItem(parent=parent_menu,
                      label="Select host",
                      command=partial(__select_host_callback, current_control),
                      image="hotkeySetSettings.png")

    # select all function
    cmds.menuItem(parent=parent_menu,
                  label="Select child controls",
                  command=partial(__select_nodes_callback, child_controls),
                  image="dagNode.svg")

    # divider
    cmds.menuItem(parent=parent_menu, divider=True)

    # reset selected
    cmds.menuItem(parent=parent_menu,
                  label="Reset",
                  command=partial(reset_all_keyable_attributes,
                                  _current_selection),
                  image="holder.svg")

    # reset all bellow
    cmds.menuItem(parent=parent_menu,
                  label="Reset all bellow",
                  command=partial(reset_all_keyable_attributes,
                                  child_controls))

    # add transform resets
    k_attrs = cmds.listAttr(current_control, keyable=True)
    for attr in ("translate", "rotate", "scale"):
        # checks if the attribute is a maya transform attribute
        if [x for x in k_attrs if attr in x and len(x) == len(attr) + 1]:
            icon = "{}_M.png".format(attr)
            if attr == "translate":
                icon = "move_M.png"
            cmds.menuItem(parent=parent_menu,
                          label="Reset {}".format(attr),
                          command=partial(__reset_attributes_callback,
                                          _current_selection, attr),
                          image=icon)

    # divider
    cmds.menuItem(parent=parent_menu, divider=True)

    # add mirror
    cmds.menuItem(parent=parent_menu,
                  label="Mirror",
                  command=partial(__mirror_flip_pose_callback,
                                  _current_selection, False),
                  image="redrawPaintEffects.png")
    cmds.menuItem(parent=parent_menu,
                  label="Mirror all bellow",
                  command=partial(__mirror_flip_pose_callback, child_controls,
                                  False))

    # add flip
    cmds.menuItem(parent=parent_menu,
                  label="Flip",
                  command=partial(__mirror_flip_pose_callback,
                                  _current_selection, True),
                  image="redo.png")
    cmds.menuItem(parent=parent_menu,
                  label="Flip all bellow",
                  command=partial(__mirror_flip_pose_callback, child_controls,
                                  True))

    # divider
    cmds.menuItem(parent=parent_menu, divider=True)

    # rotate order
    if (cmds.getAttr("{}.rotateOrder".format(current_control), channelBox=True)
            or cmds.getAttr("{}.rotateOrder".format(current_control),
                            keyable=True)
            and not cmds.getAttr("{}.rotateOrder".format(current_control),
                                 lock=True)):
        _current_r_order = cmds.getAttr(
            "{}.rotateOrder".format(current_control))
        _rot_men = cmds.menuItem(parent=parent_menu,
                                 subMenu=True,
                                 tearOff=False,
                                 label="Rotate Order switch")
        cmds.radioMenuItemCollection(parent=_rot_men)
        orders = ("xyz", "yzx", "zxy", "xzy", "yxz", "zyx")
        for idx, order in enumerate(orders):
            if idx == _current_r_order:
                state = True
            else:
                state = False
            cmds.menuItem(parent=_rot_men,
                          label=order,
                          radioButton=state,
                          command=partial(__change_rotate_order_callback,
                                          current_control, order))

    # divider
    cmds.menuItem(parent=parent_menu, divider=True)

    # handles constrains attributes (constrain switches)
    for attr in cmds.listAttr(current_control, userDefined=True,
                              keyable=True) or []:

        # filters switch reference attributes
        if (cmds.addAttr("{}.{}".format(current_control, attr),
                         query=True,
                         usedAsProxy=True)
                or not attr.endswith("ref") and not attr.endswith("Ref")):
            continue

        part, ctl = (attr.split("_")[0],
                     attr.split("_")[-1].split("Ref")[0].split("ref")[0])
        _p_switch_menu = cmds.menuItem(parent=parent_menu,
                                       subMenu=True,
                                       tearOff=False,
                                       label="Parent {} {}".format(part, ctl),
                                       image="dynamicConstraint.svg")
        cmds.radioMenuItemCollection(parent=_p_switch_menu)
        k_values = cmds.addAttr("{}.{}".format(current_control, attr),
                                query=True,
                                enumName=True).split(":")
        current_state = cmds.getAttr("{}.{}".format(current_control, attr))

        for idx, k_val in enumerate(k_values):
            if idx == current_state:
                state = True
            else:
                state = False
            cmds.menuItem(parent=_p_switch_menu,
                          label=k_val,
                          radioButton=state,
                          command=partial(__switch_parent_callback,
                                          current_control, attr, idx, k_val))

    # divider
    cmds.menuItem(parent=parent_menu, divider=True)

    # select all rig controls
    selection_set = cmds.ls(cmds.listConnections(current_control),
                            type="objectSet")
    all_rig_controls = cmds.sets(selection_set, query=True)
    cmds.menuItem(parent=parent_menu,
                  label="Select all controls",
                  command=partial(__select_nodes_callback, all_rig_controls))

    # key all bellow function
    cmds.menuItem(parent=parent_menu,
                  label="Keyframe child controls",
                  command=partial(__keyframe_nodes_callback, child_controls),
                  image="setKeyframe.png")
Ejemplo n.º 60
-2
    def __enter__(self):
        '''
        Initialize the UI
        '''
        if mc.window(self.name, exists=True):
            mc.deleteUI(self.name)

        mc.window(self.name, title='ml :: '+self.title, iconName=self.title, width=self.width, height=self.height, menuBar=self.menu)
        
        
        if self.menu:
            self.createMenu()
        
        self.form = mc.formLayout()
        self.column = mc.columnLayout(adj=True)

        
        mc.rowLayout( numberOfColumns=2, columnWidth2=(34, self.width-34), adjustableColumn=2, 
                    columnAlign2=('right','left'),
                    columnAttach=[(1, 'both', 0), (2, 'both', 8)] )

        #if we can find an icon, use that, otherwise do the text version
        if self.icon:
            mc.iconTextStaticLabel(style='iconOnly', image1=self.icon)
        else:
            mc.text(label=' _ _ |\n| | | |')
            
        if not self.menu:
            mc.popupMenu(button=1)
            mc.menuItem(label='Help', command=(_showHelpCommand(wikiURL+'#'+self.name)))
        
        mc.text(label=self.info)
        mc.setParent('..')
        mc.separator(height=8, style='single')
        return self