Beispiel #1
0
    def __init__(self):
        self.customColor = [1.0, 1.0, 1.0]
        self._colorChangeObjs = []

        with rowColumnLayout('Post_Control_Edit', nc=2):
            with columnLayout():
                self.shapeMenu = optionMenu(
                    l='')  # , cc=core.alt.Callback(self.setOverrides) )
                for shape in controller.control.listShapes():
                    menuItem(l=shape)

                button('Copy Shape', c=core.alt.Callback(self.copyShape))
                button('Mirror Shape',
                       c=core.alt.Callback(self.copyShape, True))
                button('Copy Colors', c=core.alt.Callback(self.copyColor))

                self.shapeMenu.changeCommand(
                    core.alt.Callback(self.changeShape))

                with rowColumnLayout(nc=2):
                    button(l='+10%', c=core.alt.Callback(self.scaleCvs, 1.10))
                    button(l='+ 1%', c=core.alt.Callback(self.scaleCvs, 1.01))

                    button(l='-10%', c=core.alt.Callback(self.scaleCvs, 0.90))
                    button(l='- 1%', c=core.alt.Callback(self.scaleCvs, 0.99))

                ShapeEditor()

            with columnLayout():
                text(l='Surface Color')

                self.surfacePalette = palettePort(dim=(7, 4),
                                                  w=(7 * 20),
                                                  h=(4 * 20),
                                                  td=True,
                                                  colorEditable=False)
                self.surfacePalette.changeCommand(
                    core.alt.Callback(self.changeSurfaceColor))

                self.surfacePalette.setRgbValue([0] + self.customColor)
                for i, (name, c) in enumerate(core.shader.namedColors.items()):
                    self.surfacePalette.setRgbValue([i + 1] + list(c))

                text(l='')

                text(l='Curve Color')
                self.palette = palettePort(dim=(8, 4),
                                           w=(8 * 20),
                                           h=(4 * 20),
                                           td=True,
                                           colorEditable=False,
                                           transparent=0)
                self.palette.changeCommand(
                    core.alt.Callback(self.changeCurveColor))

                for i in range(1, 32):
                    param = [i] + colorIndex(i, q=True)
                    self.palette.setRgbValue(param)

                self.palette.setRgbValue((0, .6, .6, .6))
Beispiel #2
0
 def defineSurfaceColor(self):
     val = colorEditor(rgb=self.customColor)
     if val[-1] == '1':  # Control has strange returns, see maya docs
         self.customColor = [float(f) for f in val.split()][:-1]
         self.surfacePalette.setRgbValue([0] + self.customColor)
         palettePort(self.surfacePalette, e=True, redraw=True)
         return True
     return False
Beispiel #3
0
def fill_color_palette(color_palette):
    """ This module is to fill the color palette of the UI
    :param color_palette: this is the maya's default colors
    :return: None
    """
    for i in range(1, 32):
        color_component = pm.colorIndex(i, q=True)
        pm.palettePort(color_palette,
                       e=True,
                       rgb=(i, color_component[0], color_component[1],
                            color_component[2]))
    pm.palettePort(color_palette, e=True, rgb=(0, 0.6, 0.6, 0.6))
Beispiel #4
0
    def cCommand(self):
        """Change or updates the color of the RGB palette case when there is a change state """
        rbgV = (pm.palettePort('scenePalette', q=True, rgbValue=True))
        (pm.colorInputWidgetGrp('RGB', e = True, rgbValue=(rbgV[0],rbgV[1],rbgV[2])))

        if rbgV != [0.16099999845027924, 0.16099999845027924, 0.16099999845027924]:
            print '('+ str('{:.3f}'.format(rbgV[0])) + ', ' + str('{:.3f}'.format(rbgV[1])) + ', ' + str('{:.3f}'.format(rbgV[2]))+')'
        else:
            pass
        self.allgrey()
Beispiel #5
0
    def __init__(self):
        self.customColor = [1.0, 1.0, 1.0]
        columnLayout(w=100, h=100)
        self.surfacePalette = palettePort(dim=(7, 4),
                                          w=(7 * 20),
                                          h=(4 * 20),
                                          td=True,
                                          colorEditable=False)
        self.surfacePalette.changeCommand(
            core.alt.Callback(self.changeSurfaceColor))

        self.surfacePalette.setRgbValue([0] + self.customColor)
        for i, (name, c) in enumerate(core.shader.namedColors.items()):
            self.surfacePalette.setRgbValue([i + 1] + list(c))
Beispiel #6
0
    def __init__(self):
        self._colorChangeObjs = []

        columnLayout()
        self.curvePalette = palettePort(dim=(8, 4),
                                        w=(8 * 20),
                                        h=(4 * 20),
                                        td=True,
                                        colorEditable=False,
                                        transparent=0)
        self.curvePalette.changeCommand(
            core.alt.Callback(self.changeCurveColor))

        for i in range(1, 32):
            param = [i] + colorIndex(i, q=True)
            self.curvePalette.setRgbValue(param)

        self.curvePalette.setRgbValue((0, .6, .6, .6))
    def initialiseLayout(self):
        
        #=======================================================================
        # Top Level Layout
        #=======================================================================
        self.widgets['top_level_layout'] = pm.verticalLayout()
        self.widgets['top_level_column'] = pm.columnLayout(adj=True, rowSpacing=2, columnAttach = ['both', 5])

        #=======================================================================
        # NAME
        #=======================================================================
        #------------------------------------------------------------- Separator
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Name ')
        pm.separator(style='out')
        h.redistribute(1,1,1)           

        #------------------------------------------------------- Prefix / Suffix
        pm.setParent(self.widgets['top_level_column'])
        self.widgets["suffix_TFG"] = pm.textFieldGrp(label='Suffix :', cw=[1,50], adj=2, text='ctrl')

        #=======================================================================
        # CONTROL
        #=======================================================================
        #------------------------------------------------------------- Separator
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Control ')
        pm.separator(style='out')
        h.redistribute(1,1,1)        

        #----------------------------------------------------------- Offset Node
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        self.widgets['offsetNode_CB'] = pm.checkBox( label = 'Offset Node ', value=True)
        self.widgets['offsetNode_TF'] = pm.textField(text='Offset')
        h.redistribute(1,2)
        
        #--------------------------------------------------------------- Cluster
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        self.widgets['cluster_CB'] = pm.checkBox( label = 'Control Cluster', value=False)
        self.widgets['clusterGroup_RBG'] = pm.radioButtonGrp( labelArray2=['Each', 'All'], 
                                                              numberOfRadioButtons=2 , 
                                                              cw=[1,100], 
                                                              adj=3, 
                                                              select=1)
        h.redistribute(1,2)
        
        #------------------------------------------------------------- ShapeNode
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        self.widgets['shape_CB'] = pm.checkBox( label = 'Shape Node ', value=True)
        self.widgets['shape_TSL'] = pm.textScrollList( numberOfRows=5, 
                                                       allowMultiSelection=False, 
                                                       append = self.shapeList, 
                                                       selectIndexedItem=1)
        h.redistribute(1,2)
        
        #------------------------------------------------------------ Shape Axis
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.text(label = 'Shape Axis')
        self.widgets['shapeAxis_OM'] = pm.optionMenu()
        pm.menuItem(label = "+x")
        pm.menuItem(label = "+y")
        pm.menuItem(label = "+z")
        pm.menuItem(label = "-x")
        pm.menuItem(label = "-y")
        pm.menuItem(label = "-z")        
        h.redistribute(1,2)
        
        #------------------------------------------------------------- Hierarchy
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()  
        pm.text(label='Parent')      
        self.widgets['hierarchry_RB'] = pm.radioButtonGrp( labelArray2=['World', 'Selection Order'], 
                                                           numberOfRadioButtons=2 , 
                                                           cw=[1,100], 
                                                           adj=3, 
                                                           select=1)
        h.redistribute(1,2)        
        
        #------------------------------------------------------- Constraint Type
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.text(label='Constraint Type:')
        self.widgets['tConst_CB'] = pm.checkBox(label='Point', value=False)
        self.widgets['rConst_CB'] = pm.checkBox(label='Orient', value=False)
        h.redistribute(1,1,1)
        
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.text(label="")
        self.widgets['pConst_CB'] = pm.checkBox(label='Parent', value=True)
        self.widgets['sConst_CB'] = pm.checkBox(label='Scale', value=True)
        h.redistribute(1,1,1)   
        
        #--------------------------------------------------------- Create Button
        pm.setParent(self.widgets['top_level_column'])
        self.widgets['create_BTN'] = pm.button( label="Create Control(s)",
                                                h=50, 
                                                c=pm.Callback(self.create_BTN_pressed))
        
        
        #=======================================================================
        # EDIT
        #=======================================================================

        #------------------------------------------------------------- Separator
        pm.setParent(self.widgets['top_level_column'])
        pm.separator(style="none", h=10)
                
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Edit Color')
        pm.separator(style='out')
        h.redistribute(1,1,1)            
        
        #----------------------------------------------------------------- Color
        pm.setParent(self.widgets['top_level_column'])
        main_layout = pm.formLayout()
        columns = 32 / 2
        rows = 2
        cell_width = 24
        cell_height = 24

        self.widgets['color_palette'] = pm.palettePort( dimensions=(columns, rows), 
                                                        transparent=0,
                                                        width=(columns*cell_width),
                                                        height=(rows*cell_height),
                                                        topDown=True,
                                                        colorEditable=False,
                                                        changeCommand=pm.Callback(self.color_palette_changed));
        for index in range(1, 32):
            color_component = pm.colorIndex(index, q=True)
            pm.palettePort( self.widgets['color_palette'],
                            edit=True,
                            rgbValue=(index, color_component[0], color_component[1], color_component[2]))


        #------------------------------------------------------------- Separator
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Edit Channels')
        pm.separator(style='out')
        h.redistribute(1,1,1)     
        
        #--------------------------------------------------------------- Channel
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.text(label='Translate')
        self.widgets['tHide_BTN'] = pm.button(label='Hide', command=pm.Callback(self.tHide_BTN_pressed))        
        self.widgets['tShow_BTN'] = pm.button(label='Show', command=pm.Callback(self.tShow_BTN_pressed))
        pm.text(label='Rotate')
        self.widgets['rHide_BTN'] = pm.button(label='Hide', command=pm.Callback(self.rHide_BTN_pressed))        
        self.widgets['rShow_BTN'] = pm.button(label='Show', command=pm.Callback(self.rShow_BTN_pressed))
        h.redistribute(1,1,1,1,1,1)

        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.text(label='Scale')
        self.widgets['sHide_BTN'] = pm.button(label='Hide', command=pm.Callback(self.sHide_BTN_pressed))        
        self.widgets['sShow_BTN'] = pm.button(label='Show', command=pm.Callback(self.sShow_BTN_pressed))
        pm.text(label='Visibility')
        self.widgets['vHide_BTN'] = pm.button(label='Hide', command=pm.Callback(self.vHide_BTN_pressed))        
        self.widgets['vShow_BTN'] = pm.button(label='Show', command=pm.Callback(self.vShow_BTN_pressed))
        h.redistribute(1,1,1,1,1,1)        

        #------------------------------------------------------------ Separator
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Pivot Offset Control')
        pm.separator(style='out')
        h.redistribute(1,1,1)     
        
        #---------------------------------------------------------- Pivot Offset
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        self.widgets['pivotOffset_IFG'] = pm.intFieldGrp( numberOfFields=1, 
                                                          value1=1, 
                                                          label='Control Size :', 
                                                          cw2=[100, 50], 
                                                          adj=2)        
        self.widgets['add_pivotOffset_BTN'] = pm.button( label = 'Add', command=pm.Callback(self.add_pivotOffset_BTN_pressed))
        self.widgets['remove_pivotOffset_BTN'] = pm.button( label = 'Remove', command=pm.Callback(self.remove_pivotOffset_BTN_pressed))
        h.redistribute(3,1,1)
        
        #------------------------------------------------------------ Separator
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Text Shape')
        pm.separator(style='out')
        h.redistribute(1,1,1)     
                
        #------------------------------------------------------------ Text Shape
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        self.widgets['textShape_TFG'] = pm.textFieldGrp(  label='Text :', 
                                                          cw2=[100, 50], 
                                                          adj=2)        
        self.widgets['add_textShape_BTN'] = pm.button( label = 'Add', command=pm.Callback(self.add_textShape_BTN_pressed))
        h.redistribute(3,2)        
        
        #=======================================================================
        # Redistribute
        #=======================================================================
        self.widgets['top_level_layout'].redistribute()                           
Beispiel #8
0
    def ui(self):
        template = uiTemplate('ExampleTemplate', force = True )
        template.define( button, width=250, height = 25)
        template.define( frameLayout, borderVisible = False, labelVisible = False)

        with template:
            with formLayout():
                pm.dockControl("adb_AutoRig", content=self.win, a="right")
                with columnLayout(adj=True, rs = 4):
                    with rowLayout(numberOfColumns=2):
                        text(label='Name: ')
                        self.namespace_txt = textField(pht = 'Untilted', w=215)

                    button(l='Add Namespace',  bgc = colordic['grey'], c = pm.Callback(self.createNamespace))
                    button(l='Namespace Editor',  bgc = colordic['grey'], c = pm.Callback(mc.NamespaceEditor))

                    with rowLayout(adj=True, numberOfColumns = 3):
                        separator(w=5, vis=True, bgc = colordic['grey4'], h = 1)
                        text(label=' NUMBER OF JOINTS : ', fn = 'boldLabelFont')
                        separator(w=90, vis=True, bgc = colordic['grey4'], h = 1)

                    with rowLayout( numberOfColumns=4):
                        text(label="Spine")
                        self.spine_float = floatField(v = 5, precision=1, showTrailingZeros=0)
                        text(label=" Neck ")
                        self.neck_float  = floatField(v = 4, precision=2,  showTrailingZeros=0)

                    with rowLayout(adj=True, numberOfColumns = 3):
                        separator(w=5, vis=True, bgc = colordic['grey4'], h = 1)
                        text(label=' CREATE GUIDE : ', fn = 'boldLabelFont')
                        separator(w=120, vis=True, bgc = colordic['grey4'], h = 1)

                    with columnLayout(rs=5):
                        button(l='BUILD GUIDE',  bgc = colordic['green'], c = pm.Callback(self.build_guide))

                    with rowLayout(adj=True, numberOfColumns = 3):
                        separator(w=5, vis=True, bgc = colordic['grey4'], h = 1)
                        text(label=' CREATE RIG : ', fn = 'boldLabelFont')
                        separator(w=120, vis=True, bgc = colordic['grey4'], h = 1)
                    with columnLayout(rs=5):
                        button(l='BUILD ALL RIG',  bgc = colordic['green3'], c = pm.Callback(self.build_all_rig))

                    with frameLayout( cll = True, nbg=False, bgc=colordic['grey1'], labelVisible=True , cl = True, label = " BY PART"):
                        # with frameLayout( cll = True, nbg=False, labelVisible=True , cl = True, label = "LEG"):
                        #     with rowLayout(numberOfColumns=2):
                        #         checkBox("leg_cbx", l = "leg", h = 20)
                        #         checkBox("foot_cbx", l = "foot", h = 20)
                        # with frameLayout( cll = True, nbg=False, labelVisible=True , cl = True, label = "ARM"):
                        #     with rowLayout(numberOfColumns=2):
                        #         checkBox("arm_cbx", l = "arm", h = 20)
                        #         checkBox("hand_cbx", l = "hand", h = 20)
                        # with frameLayout( cll = True, nbg=False, labelVisible=True , cl = True, label = "SPINE"):
                        #     with rowLayout(adj=True, numberOfColumns=3):
                        #         button(l='Guide', w = 50)
                        # with frameLayout( cll = True, nbg=False, labelVisible=True , cl = True, label = "NECK"):
                        #     with rowLayout(adj=True, numberOfColumns=3):
                        #         button(l='Guide', w = 50)

                        button(l='GUIDE CUSTOM RIG',  bgc = colordic['green'])

                    with rowLayout(adj=True, numberOfColumns = 3):
                        separator(w=5, vis=True, bgc = colordic['grey4'], h = 1)
                        text(label=' RIG OPTIONS : ', fn = 'boldLabelFont')
                        separator(w=120, vis=True, bgc = colordic['grey4'], h = 1)
                    with columnLayout(rs=5):
                        button(l='Show / Hide Feet Locators',  bgc = colordic['grey'], c = pm.Callback(self.show_hide_foot_locs))
                        button(l='Show / Hide Proxy Plane',  bgc = colordic['grey'], c = pm.Callback(self.show_hide_proxy_planes))

                    with frameLayout( cll = True, bgc=colordic['grey1'], labelVisible=True , cl = False, label = "CONTROLS OPTIONS"):

                        with columnLayout(rs=5):
                            text(label=' Control size : ')

                        with rowLayout( numberOfColumns = 3):
                            button(l='Reduce Size',  bgc = colordic['grey'], w=124, c = pm.Callback(self.ScaleVertex,'-'))
                            button(l='Increase Size',  bgc = colordic['grey'], w=124, c = pm.Callback(self.ScaleVertex,'+'))

                        with columnLayout(rs=5):
                            text(label=' Control axis : ')
                        with rowLayout( numberOfColumns = 3):
                            button(l='Rotate X',  bgc = colordic['grey'], w=82, c = pm.Callback(self.RotateVertex,'x'))
                            button(l='Rotate Y',  bgc = colordic['grey'], w=82, c = pm.Callback(self.RotateVertex,'y'))
                            button(l='Rotate Z',  bgc = colordic['grey'], w=82, c = pm.Callback(self.RotateVertex,'z'))

                        with columnLayout(rs=5):
                            text(label=' Control Shape : ')
                            with rowLayout(adj=True, numberOfColumns = 4):
                                pm.checkBox('myChBxX', l = "X", h = 20, v = True, cc = pm.Callback(self.cCommand_axis,'x'))
                                pm.checkBox('myChBxY', l = "Y", h = 20, cc = pm.Callback(self.cCommand_axis,'y'))
                                pm.checkBox('myChBxZ',  l = "Z", h = 20,cc = pm.Callback(self.cCommand_axis,'z'))

                            pm.optionMenu(w=220, cc = self.createctrl)
                            pm.menuItem( "- Choose Shape -")

                            pm.menuItem(label = "Circle")
                            pm.menuItem(label = "Square")
                            pm.menuItem(label = "Cube")
                            pm.menuItem(label = "Ball")
                            pm.menuItem(label = "Diamond")
                            pm.menuItem(label = "Double_Pin")
                            pm.menuItem(label = "Pin")
                            pm.menuItem(label = "Cylinder")
                            pm.menuItem(label = "Circle_Cross")
                            pm.menuItem(label = "Cog")
                            pm.menuItem(label = "Arrow")
                            pm.menuItem(label = "Main")
                            pm.menuItem(label = "Double_fleches_ctrl")
                            pm.menuItem(label = "Arc_fleches_ctrl")
                            pm.menuItem(label = "Fleches")
                            pm.menuItem(label = "Locator_shape")


                        with tabLayout('indexRGBTab',innerMarginWidth=5, innerMarginHeight=5) as tabs:
                            with rowColumnLayout(numberOfColumns=2) as child1:

                                """Index"""

                                with gridLayout(numberOfColumns=7, cellWidthHeight=(35, 20)):
                                    pm.iconTextButton(bgc=(.000, .000, .000), command= pm.Callback(self.shapeColor,1))
                                    pm.iconTextButton(bgc=(.247, .247, .247), command= pm.Callback(self.shapeColor,2))
                                    pm.iconTextButton(bgc=(.498, .498, .498), command= pm.Callback(self.shapeColor,3))
                                    pm.iconTextButton(bgc=(0.608, 0, 0.157), command= pm.Callback(self.shapeColor,4))
                                    pm.iconTextButton( bgc=(0, 0.016, 0.373), command= pm.Callback(self.shapeColor,5))
                                    pm.iconTextButton(bgc=(0, 0, 1), command= pm.Callback(self.shapeColor,6))

                                    pm.iconTextButton(bgc=(0, 0.275, 0.094), command= pm.Callback(self.shapeColor,7))
                                    pm.iconTextButton(bgc=(0.145, 0, 0.263), command= pm.Callback(self.shapeColor,8)) #
                                    pm.iconTextButton(bgc=(0.78, 0, 0.78), command= pm.Callback(self.shapeColor,9))
                                    pm.iconTextButton(bgc=(0.537, 0.278, 0.2), command= pm.Callback(self.shapeColor,10))
                                    pm.iconTextButton(bgc=(0.243, 0.133, 0.122), command= pm.Callback(self.shapeColor,11))
                                    pm.iconTextButton(bgc=(0.6, 0.145, 0), command= pm.Callback(self.shapeColor,12)) #

                                    pm.iconTextButton(bgc=(1, 0, 0), command= pm.Callback(self.shapeColor,13))
                                    pm.iconTextButton(bgc=(0, 1, 0), command= pm.Callback(self.shapeColor,14))
                                    pm.iconTextButton(bgc=(0, 0.255, 0.6), command= pm.Callback(self.shapeColor,15)) #
                                    pm.iconTextButton(bgc=(1, 1, 1), command= pm.Callback(self.shapeColor,16)) #
                                    pm.iconTextButton(bgc=(1, 1, 0), command= pm.Callback(self.shapeColor,17))
                                    pm.iconTextButton(bgc=(0.388, 0.863, 1), command= pm.Callback(self.shapeColor,18))

                                    pm.iconTextButton(bgc=(0.263, 1, 0.635), command= pm.Callback(self.shapeColor,19)) #
                                    pm.iconTextButton(bgc=(1, 0.686, 0.686), command= pm.Callback(self.shapeColor,20))
                                    pm.iconTextButton(bgc=(0.89, 0.675, 0.475), command= pm.Callback(self.shapeColor,21))
                                    pm.iconTextButton(bgc=(1, 1, 0.384), command= pm.Callback(self.shapeColor,22))
                                    pm.iconTextButton(bgc=(0, 0.6, 0.325), command= pm.Callback(self.shapeColor,23))
                                    pm.iconTextButton(bgc=(0.627, 0.412, 0.188), command= pm.Callback(self.shapeColor,24)) #

                                    pm.iconTextButton(bgc=(0.62, 0.627, 0.188), command= pm.Callback(self.shapeColor,25))
                                    pm.iconTextButton(bgc=(0.408, 0.627, 0.188), command= pm.Callback(self.shapeColor,26)) #
                                    pm.iconTextButton(bgc=(0.188, 0.627, 0.365), command= pm.Callback(self.shapeColor,27)) #
                                    pm.iconTextButton(bgc=(0.188, 0.627, 0.627), command= pm.Callback(self.shapeColor,28))
                                    pm.iconTextButton(bgc=(0.188, 0.404, 0.627), command= pm.Callback(self.shapeColor,29))
                                    pm.iconTextButton(bgc=(0.435, 0.188, 0.627), command= pm.Callback(self.shapeColor,30))

                                    pm.iconTextButton(bgc=(0.507, 0.041, 0.277), command= pm.Callback(self.shapeColor,31))

                            """ RGB """
                            with frameLayout() as child2:
                                with rowLayout(numberOfColumns=2):
                                    colorInputWidgetGrp('RGB', label='Color', rgb=(1, 0, 0), cw3=(0, 30, 162))
                            tabLayout( tabs, edit=True, tabLabel=((child1, 'Index'), (child2, 'RGB')) )

                        with rowLayout(numberOfColumns=2):
                            pm.button(l = "Default color", w =124, backgroundColor = colordic['grey'], c = pm.Callback(self.colordefault))
                            pm.button(l = "Set RGB Color", w =124, backgroundColor = colordic['grey'])

                        with frameLayout():
                            pm.palettePort( 'scenePalette', dim=(10, 1), h =20, ced= True, r= True, scc = 0, cc = self.cCommand)
Beispiel #9
0
    def allgrey(self):
        """ Puts all the unused case of the RGB Palette grey """
        allNurbs = pm.ls(type="nurbsCurve")
        allColors = list(set([pm.PyNode(x).overrideColorRGB.get(x) for x in allNurbs]))
        nub = len(allColors)
        if nub ==0:
            for each in range(0,10):
                pm.palettePort( 'scenePalette', edit=True, rgb=(each, 0.161, 0.161, 0.161) )

        elif nub > 10:
            nub = 10
            for i in range(0,nub):
                pos1 = allColors[i][0]
                pos2 = allColors[i][1]
                pos3 = allColors[i][2]

                if pos1 == 0.0 and pos2 == 0.0 and pos3 == 0.0:
                    pm.palettePort( 'scenePalette', edit=True, rgb=(i, 0.161, 0.161, 0.161) )

                else:
                    pm.palettePort( 'scenePalette', r = True, edit=True, rgb=(i, pos1 , pos2 , pos3 ,) )

                for each in range(nub,10):
                    pm.palettePort( 'scenePalette', edit=True, rgb=(each, 0.161, 0.161, 0.161) )

        else:
            for i in range(0,nub):
                pos1 = allColors[i][0]
                pos2 = allColors[i][1]
                pos3 = allColors[i][2]
                if pos1 == 0.0 and pos2 == 0.0 and pos3 == 0.0:
                    pm.palettePort( 'scenePalette', edit=True, rgb=(i, 0.161, 0.161, 0.161) )
                else:
                    pm.palettePort( 'scenePalette', r = True, edit=True, rgb=(i, pos1 , pos2 , pos3 ,) )
                for each in range(nub,10):
                    pm.palettePort( 'scenePalette', edit=True, rgb=(each, 0.161, 0.161, 0.161) )
Beispiel #10
0
 def do_selection_cmd(self, *args):
     """Runs the code with the collected data from the buttons, locators and menus of the UI.
     Gathers the number for the ctrls, type of the ctrl crvs, and color of the ctrl crvs.
     :param args:
     :return: None
     """
     # ctrl number menu gives the number of ctrls between the locators
     self.number = pm.optionMenuGrp(self.ctrl_number_menu, q=True, v=True)
     # crv types menu provides the choice of crv types only
     self.crv_type = pm.optionMenuGrp(self.crv_types_menu, q=True, v=True)
     # palette port provides the selected crv color
     self.color_index = pm.palettePort(self.color_palette,
                                       q=True,
                                       setCurCell=True)
     # right now fk ctrls scale of ikd is divided by 2.
     fk_scale = (self.ik_ctrl_s_scale[0] / 2, self.ik_ctrl_s_scale[1] / 2,
                 self.ik_ctrl_s_scale[2] / 2)
     # if the selection is FK
     if self.type_selection == 0:
         self.check = True
         # fk ctrl creation
         # create jnt chain
         self.jnt_chain = self.create_jnt_chain()
         pm.select(self.jnt_chain[0], r=1)
         root_jnt = pm.ls(sl=1)
         self.ctrl_list = ctrl_chain(root_jnt, "", self.crv_type,
                                     self.color_index, fk_scale, self.check)
         pm.group(root_jnt,
                  n='{}{}setup'.format(self.name, self.infix),
                  w=True)
         pm.delete(self.ref_jnt, self.ref_jntend)
     # if the selection is IK
     if self.type_selection == 1:
         # ik ctrl creation
         self.jnt_chain = self.create_jnt_chain()
         self.create_ik_spline()
         pm.select(pm.listRelatives(self.ref_jnt, children=True, path=True),
                   r=True)
         pm.select(self.ref_jntend, d=True)
         pm.select('{}_iks'.format(self.name), add=True)
         pm.group(n='{}_setup'.format(self.name), w=True)
         pm.group(self.top_start_grp,
                  self.top_end_grp,
                  n='{}_ctrl_setup'.format(self.name))
         pm.delete(self.ref_jnt, self.ref_jntend)
         # strechy option
         self.stretchy = True
         if self.stretchy:
             stretchy(self.name, self.jnt_chain, self.distance)
     # if the selection is IKD
     if self.type_selection == 2:
         self.check = False
         # ik driver ctrl creation
         self.jnt_chain = self.create_jnt_chain()
         pm.select(self.jnt_chain[0], r=1)
         root_jnt = pm.ls(sl=1)
         self.ctrl_list = ctrl_chain(root_jnt, "", self.crv_type,
                                     self.color_index, fk_scale, False)
         self.create_ik_spline()
         pm.parent(self.top_start_grp, self.ctrl_list[0])
         pm.parent(self.top_end_grp, self.ctrl_list[int(self.number) - 1])
         pm.group(root_jnt,
                  n='{}{}_jnt_setup'.format(self.name, self.infix),
                  w=True)
         pm.select(pm.listRelatives(self.ref_jnt, children=True, path=True),
                   r=True)
         pm.select(self.ref_jntend, d=True)
         pm.select('{}_iks'.format(self.name), add=True)
         pm.group(n='{}{}_setup'.format(self.name, self.infix), w=True)
         pm.delete(self.ref_jnt, self.ref_jntend)
         # strechy option
         self.stretchy = True
         if self.stretchy:
             stretchy(self.name, self.jnt_chain, self.distance)
Beispiel #11
0
 def create(self):
     """Main UI function
     @ usage: AO2PRigSetup.ui()
     :return: None
     """
     # check the window exists before creating the new one
     if pm.window(self.window, exists=True):
         pm.deleteUI(self.window, window=True)
     # window UI
     self.window = pm.window(self.window,
                             title=self.title,
                             wh=self.size,
                             s=False)
     # main from is formLayout
     self.main_form = pm.formLayout()
     # first frameLayout for locators panel
     self.locators_frame = pm.frameLayout(label='Locators')
     pm.columnLayout(w=self.size[0] / 2 - 2,
                     h=self.size[1] / 2 - 2,
                     cw=self.size[0] / 2 - 2)
     pm.separator(h=5)
     # start locator panels
     pm.text(label='Start Locator', w=self.size[0] / 2 - 2, h=30)
     self.select_sloc_field = pm.textFieldButtonGrp(
         ed=False,
         w=self.size[0] / 2 - 2,
         h=30,
         bl='Select',
         cl3=['left', 'left', 'left'],
         cw=[1, self.size[0] / 2 - 50],
         bc=self._select_start_loc)
     # end locator panels
     pm.text(label='End Locator', w=self.size[0] / 2 - 2, h=30)
     self.select_eloc_field = pm.textFieldButtonGrp(
         ed=False,
         w=self.size[0] / 2 - 2,
         h=30,
         bl='Select',
         cl3=['left', 'left', 'left'],
         cw=[1, self.size[0] / 2 - 50],
         bc=self._select_end_loc)
     pm.setParent(self.main_form)
     # second part and type frameLayout
     self.part_n_type_frame = pm.frameLayout(label='Part & Type')
     pm.columnLayout(w=self.size[0] / 2 - 2,
                     h=self.size[1] / 2 - 2,
                     cw=self.size[0] / 2 - 2)
     pm.separator(h=5)
     # part radio button panel
     self.part_radio_btn = pm.radioButtonGrp(
         label='Part',
         labelArray3=['Neck', 'Spine', 'Tail'],
         nrb=3,
         vr=True,
         w=self.size[0] / 2 - 2,
         cl2=['center', 'left'],
         cw2=[self.size[0] / 4 - 20, self.size[0] / 4],
         cc=self.get_parts_cmd)
     pm.separator(h=5)
     # type radio button panel
     self.type_radio_btn = pm.radioButtonGrp(
         label='Type',
         labelArray3=['FK', 'IK', 'IK DRIVER'],
         nrb=3,
         vr=True,
         w=self.size[0] / 2 - 2,
         cl2=['center', 'left'],
         cw2=[self.size[0] / 4 - 20, self.size[0] / 4],
         cc=self.get_types_cmd)
     # third ctrl numbers and crv types frameLayout
     pm.setParent(self.main_form)
     self.sub_selection_frame = pm.frameLayout(
         label='Ctrl Numbers & Crv Types')
     pm.columnLayout(adj=True)
     pm.separator(h=5)
     # ctrl numbers menu panel
     self.ctrl_number_menu = pm.optionMenuGrp('Ctrl Numbers Menu',
                                              label='Ctrl Numbers Menu:',
                                              w=self.size[0] - 2,
                                              h=30)
     fill_menu(self.ctrl_nums)
     # ctrl types menu panel
     self.crv_types_menu = pm.optionMenuGrp('Crv Types Menu',
                                            label='Curve Types Menu:',
                                            w=self.size[0] - 2,
                                            h=30)
     fill_menu(self.crv_types)
     pm.separator(h=5)
     # color palette panel
     self.color_palette = pm.palettePort(dim=(16, 2),
                                         t=0,
                                         w=self.size[0] - 2,
                                         h=30,
                                         topDown=True,
                                         ced=True)
     fill_color_palette(self.color_palette)
     pm.separator(h=5)
     # run button
     pm.button(label='Run', w=self.size[0], h=30, c=self.do_selection_cmd)
     pm.separator(h=5)
     # quit button
     pm.button(label='QUIT', w=self.size[0], h=30, c=self.quit_btn_cmd)
     # organize all the layouts together under the mainForm of the window
     ac = []
     af = []
     ac.append([self.part_n_type_frame, 'left', 0, self.locators_frame])
     ac.append([self.locators_frame, 'bottom', 0, self.sub_selection_frame])
     af.append([self.locators_frame, 'left', 0])
     af.append([self.locators_frame, 'top', 0])
     af.append([self.part_n_type_frame, 'right', 0])
     af.append([self.part_n_type_frame, 'top', 0])
     af.append([self.sub_selection_frame, 'left', 0])
     af.append([self.sub_selection_frame, 'right', 0])
     af.append([self.sub_selection_frame, 'bottom', 0])
     pm.formLayout(self.main_form, e=True, attachControl=ac, attachForm=af)
     # create the window
     pm.showWindow(self.window)
     # resize it
     pm.window(self.window, e=True, wh=self.size)