Example #1
0
	def assignCustomMateColorUI( self, colorMat = 'RL_SOMECOLOR', col = (1,1,1)):
		mc.columnLayout()
		mc.colorSliderGrp( 'customColorColorSlider', rgb = col )
		mc.checkBox( 'customAlpha_chb', l = 'With Alpha', v = True )
		mc.rowColumnLayout( nc = 2 )
		mc.button( l = 'Create', w = 120, c = self.assignNewMateColorUi )
		mc.button( l = 'Cancel', w = 120, c = self.dismissCustomColorUI )
Example #2
0
def createGeometryButtonAction(*pArgs):
    """ Queries all the fields related to the geometry interpretation and calls the procedure. """
    pAngle = cmds.floatSliderGrp( "angle", q=True, v=True )
    pStep = cmds.floatSliderGrp( "length", q=True, v=True )
    pRad = cmds.floatSliderGrp( "radius", q=True, v=True )
    subDivs = cmds.intSliderGrp( "cylSubdivs", q=True, v=True )
    length_atenuation = cmds.intSliderGrp( "length_atenuation", q=True, v=True )
    radius_atenuation = cmds.intSliderGrp( "radius_atenuation", q=True, v=True )
    turtleSpeed = cmds.floatSliderGrp( "turtleSpeed", q=True, v=True)
    rgb_blossom = cmds.colorSliderGrp( "rgb_blossomField", q=True, rgb=True )
    rgb_leaf = cmds.colorSliderGrp( "rgb_leafField", q=True, rgb=True )
    rgb_branch = cmds.colorSliderGrp( "rgb_branchField", q=True, rgb=True )

    if pAngle == 0 or pStep == 0 or pRad == 0 or subDivs == 0 or LStringVar == '':
        cmds.textField('warningsTextField', edit=True, tx='Please, revise all the fields again')  
    else:
        import globalVar
        reload(globalVar)
        globalVar.plantNumber += 1
        cmds.textField('warningsTextField', edit=True, tx='None.')
        createBranchShader(rgb_branch)
        createLeafShader(rgb_leaf)
        createBlossomShader(rgb_blossom)
        createGeometry(LStringVar, pRad, pStep, pAngle, subDivs, length_atenuation/100.0, radius_atenuation/100.0,
            turtleSpeed, rgb_branch, rgb_leaf, rgb_blossom)
Example #3
0
 def setFromSelected(self, widget, *args):
     sel = mc.ls(sl=True)
     if not sel:
         mc.warning('Please make a selection')
         return
     if mc.getAttr('{}.overrideRGBColors'.format(sel[0])):
         color = mc.getAttr('{}.overrideColorRGB'.format(sel[0]))
         mc.colorSliderGrp(widget, edit=True, rgb=color[0])
     else:
         mc.warning('Selected node is not in RGB color mode.')
Example #4
0
def createGUI(): 
    '''
    Creates a user interface for the city generator script.
    
    On exit: A window with the user interface has been created.
    '''    
    GUIwindow = cmds.window( title = "City Generator")
    layout0 = cmds.columnLayout()
    imageNum = random.randint(1,19)
    cmds.image("cityImage", image="cityImages/dayImage" + str(imageNum) + ".jpg", width = 800, height = 288 )
    layout1 = cmds.rowLayout(nc = 2, parent = layout0)
    layout2 = cmds.columnLayout(parent = layout1, rs = 3)
    cmds.rowLayout(nc = 2, parent = layout2, cw2 = [140,250])
    cmds.text(label = "City name")
    cmds.textField("cityName", width = 240)
    cmds.intSliderGrp("cityWidth", field=True, label="City width", minValue=50, maxValue=200, fieldMinValue=50, fieldMaxValue=200, value=100, cal = [1,"left"],parent = layout2)
    cmds.intSliderGrp("cityDepth", field=True, label="City depth", minValue=50, maxValue=200, fieldMinValue=50, fieldMaxValue=200, value=100, cal = [1,"left"],parent = layout2)
    cmds.intSliderGrp("minHeight", field=True, label="Minimum house height", minValue=4, maxValue=40, fieldMinValue=4, fieldMaxValue=40, value=4, cal = [1,"left"],parent = layout2, dc = changeMaxHeight)
    cmds.intSliderGrp("maxHeight", field=True, label="Maximum house height", minValue=4, maxValue=40, fieldMinValue=4, fieldMaxValue=40, value=30, cal = [1,"left"],parent = layout2, dc = changeMinHeight)
    cmds.intSliderGrp("minWidth", field=True, label="Minimum house width", minValue=2, maxValue=20, fieldMinValue=2, fieldMaxValue=20, value=5, cal = [1,"left"],parent = layout2, dc = changeMaxWidth)
    cmds.intSliderGrp("maxWidth", field=True, label="Maximum house width", minValue=12, maxValue=30, fieldMinValue=12, fieldMaxValue=30, value=20, cal = [1,"left"],parent = layout2, dc = changeMinWidth)
    cmds.checkBoxGrp("features", numberOfCheckBoxes=3, label1="Windows", label2 = "Booleans", label3="Deformers", v1=True, v2 = False, v3 = True, cc1 =  windows, cc2 = booleans, cal = [1,"left"],parent = layout2,cw = [1,140])
    cmds.checkBoxGrp("time", numberOfCheckBoxes=3, label1="Daytime", label2="Nighttime", label3 = "All windows glow", v1=True, v2 = False, v3 = False, enable3 = False, cal = [1,"left"], parent = layout2,cw = [1,140], cc1 = daytime, cc2 = nighttime )
    cmds.colorSliderGrp("environment", label="Environment colour", hsv=(204, 0.451, 1), parent = layout2, cal = [1,"left"] )
    layout3 = cmds.columnLayout(parent = layout1)
    cmds.text("Set the colour range for the houses by selecting the ranges separately for hue,\nsaturation and value.", align  = "left")
    cmds.text("\nStart of range:", align = "left")
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("hueCanvas1", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.intSliderGrp("hue1", field=True, label="Hue", minValue=0, maxValue=360, fieldMinValue=0, fieldMaxValue=360, value=0,cw3 = [70,70,170], dc = hueChange1 )
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("saturationCanvas1", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.floatSliderGrp("saturation1", field=True, label="Saturation", minValue=0, maxValue=1, fieldMinValue=0, fieldMaxValue=1, value=1,cw3 = [70,70,170], dc = saturationChange1, step = 0.01)
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("valueCanvas1", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.floatSliderGrp("value1", field=True, label="Value", minValue=0, maxValue=1, fieldMinValue=0, fieldMaxValue=1, value=1,cw3 = [70,70,170], dc = valueChange1, step = 0.01)
    cmds.text("End of range:", align =  "left", parent = layout3)
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("hueCanvas2", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.intSliderGrp("hue2", field=True, label="Hue", minValue=0, maxValue=360, fieldMinValue=0, fieldMaxValue=360, value=0,cw3 = [70,70,170], dc = hueChange2 )
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("saturationCanvas2", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.floatSliderGrp("saturation2", field=True, label="Saturation", minValue=0, maxValue=1, fieldMinValue=0, fieldMaxValue=1, value=1,cw3 = [70,70,170], dc = saturationChange2, step = 0.01)
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("valueCanvas2", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.floatSliderGrp("value2", field=True, label="Value", minValue=0, maxValue=1, fieldMinValue=0, fieldMaxValue=1, value=1,cw3 = [70,70,170], dc = valueChange2, step = 0.01)
    cmds.button(label = "Randomize", command = randomize, parent = layout3)
    layout4 = cmds.rowLayout(numberOfColumns=2, parent = layout0, cw2 = [690,110])
    cmds.button(label="Generate City", command = defaultButtonPush, parent = layout4, w = 685, h = 50)
    cmds.button(label="Clear Scene", command = clearScene, parent = layout4, w = 110, h = 50)
    cmds.showWindow()
Example #5
0
	def assignCustomColorUI( self, colorMat = 'RL_SOMECOLOR', col = (1,1,1)):
		mc.columnLayout()
		mc.textFieldGrp( 'customColorTextField',
						 l   = 'Shader Name:',
						 tx  = colorMat,
						 ct2 = ['left','left'],
						 cl2 = ['left','left'],
						 cw2 = [80,160]
						 )
		mc.colorSliderGrp( 'customColorColorSlider', rgb = col )
		mc.checkBox( 'customAlpha_chb', l = 'With Alpha', v = True )
		mc.rowColumnLayout( nc = 2 )
		mc.button( l = 'Create', w = 120, c = self.assignNewColor )
		mc.button( l = 'Cancel', w = 120, c = self.dismissCustomColorUI )
Example #6
0
def resetAllFactors(*argv):  
    # Reset scale factor
    setScaleFactor(1)
    
    # Reset color selector
    setColor([1, 0.4, 1])
    cmds.colorSliderGrp("GalaxyColor", e = True, rgbValue = (1, 0.4, 1))
    
    # Reset other factors
    setFactorFunc("Galaxy_StarShape.multiCount", 10, 10)
    setFactorFunc("Galaxy_StarShape.multiRadius", 1.7, 1.7)
    setFactorFunc("Galaxy_CloudShape.radius", 0.1, 0.1)
    setFactorFunc("Galaxy_StarShape.opacity", 0.3, 0.3)
    setFactorFunc("Galaxy_CloudShape.opacity", 0.6, 0.6)    
Example #7
0
def defaultButtonPush(args):
    '''
    Calls the procedure cityGenerator.city(...) with the user specified 
    arguments.
    
    args: Dummy argument needed to satisfy the command interface.
    On exit: The cityGenerator.city(...) procedure has been called with
             the arguments specified by the user. 
    '''
    Name_ = cmds.textField("cityName", query = True, text = True)
    if Name_ == "":
        Name_ = "Helsinki"
    cityWidth = cmds.intSliderGrp("cityWidth", query = True, value = True)
    cityDepth = cmds.intSliderGrp("cityDepth", query = True, value = True)
    minHeight = cmds.intSliderGrp("minHeight", query = True, value = True)
    maxHeight = cmds.intSliderGrp("maxHeight", query = True, value = True)
    minWidth = cmds.intSliderGrp("minWidth", query = True, value = True)
    maxWidth = cmds.intSliderGrp("maxWidth", query = True, value = True)
    windows = cmds.checkBoxGrp("features", query = True, v1 = True)
    booleans = cmds.checkBoxGrp("features", query = True, v2 = True)
    deformers = cmds.checkBoxGrp("features", query = True, v3 = True)
    dayTime = cmds.checkBoxGrp("time", query = True, v1=True)
    glow = cmds.checkBoxGrp("time", query = True, v3=True)
    environment = cmds.colorSliderGrp("environment", query = True, rgbValue = True)
    colourRangeStart = (cmds.intSliderGrp("hue1", query = True, value = True),
    cmds.floatSliderGrp("saturation1", query = True, value = True), 
    cmds.floatSliderGrp("value1", query = True, value = True))
    colourRangeEnd = (cmds.intSliderGrp("hue2", query = True, value = True),
    cmds.floatSliderGrp("saturation2", query = True, value = True), 
    cmds.floatSliderGrp("value2", query = True, value = True))
    cityGenerator.city(Name_, (cityWidth,cityDepth),(minHeight,maxHeight),
    (minWidth,maxWidth), windows, booleans, deformers, dayTime, glow, environment,(colourRangeStart,colourRangeEnd))    
  def generate(cls, *args):
    components = []
    boolean = []
    width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True)
    rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)

    block_width = width * Constants["block_width_unit"]
    block_height = Constants["block_height_unit"]
    block_depth = Constants["block_depth_unit"]

    for x in range(0, width):
      stub = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Stub"), radius=Constants["stub_radius"], height = Constants["stub_height"])
      components.append(stub[0])
      cmds.move(Constants["block_width_unit"] * x + half(Constants["block_width_unit"]), half(Constants["block_height_unit"]) + half(Constants["stub_height"]), half(Constants["block_depth_unit"]), stub[0])
      
    for x in range(0, width-1):
      hole = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Hole"), radius=Constants["perforation_radius"], height=Constants["block_depth_unit"] + 0.2)
      boolean.append(hole[0])
      cmds.rotate('90deg', 0, 0, hole[0])
      cmds.move(Constants["block_width_unit"] * x + Constants["block_width_unit"], 0, half(Constants["block_depth_unit"]), hole[0])

    cube = cmds.polyCube(sx=5,sy=2,sz=2,name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=block_depth)
    components.append(cube[0])
    cmds.move(half(width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube)
    solid = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), ""))
    boolean_group = cmds.polyUnite(boolean, name=get_unique_name(cls.get_prefix(),"boolean"))
    final = cmds.polyBoolOp( solid[0], boolean_group[0], op=2, n=get_unique_name(cls.get_prefix(), "") )

    shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat"))
    cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3')
    cmds.select(final[0], r=True)
    cmds.hyperShade(assign=shader)
def roundPlate():
    
    #get values from UI
    rgb = cmds.colorSliderGrp('brickColour', query=True, rgbValue=True)
    transparent = cmds.checkBox('makeTransparent', query = True, value = True)
    
    base = cmds.polyCylinder( h = 0.18, r = 0.3 )
    cmds.rotate( 90, rotateY = True )
    cmds.move( 0.18/2, moveY = True)
    
    wide = cmds.polyCylinder( h = 0.14, r = 0.4 )
    cmds.rotate( 90, rotateY = True )
    cmds.move( 0.18 + (0.14/2), moveY = True)
    
    stud = cmds.polyCylinder( h = 0.18, r = 0.24 )
    cmds.rotate( 90, rotateY = True )
    cmds.move( 0.18 + 0.14 + (0.18/2), moveY = True)
    
    rp = cmds.polyUnite( base, wide, stud )
    
    myShader = cmds.shadingNode( 'phong', asShader=True )
    cmds.setAttr( myShader+".color", rgb[0], rgb[1], rgb[2], type='double3')
    cmds.setAttr( myShader+".reflectivity", 0 )
    
    if( transparent == True ):
       cmds.setAttr( myShader+".transparency", 0.5, 0.5, 0.5, type = 'double3' ) 
    
    cmds.select( rp )
    cmds.hyperShade( assign = myShader )
    
    cmds.delete( ch = True )
Example #10
0
 def setShadowColor(self):
     v = mc.colorSliderGrp(self.shadowcolor, q = True, rgb = True)
     for l in mc.ls(sl = True):
         if mc.objExists(l+'.aiShadowColor'):
             mc.setAttr(l+'.aiShadowColor', v[0], v[1], v[2], type = "double3")
         elif mc.objExists(l+'.shadowColor'):
             mc.setAttr(l+'.shadowColor', v[0], v[1], v[2], type = "double3")
  def generate(cls, *args):
    components = []
    width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True)
    height = cmds.intSliderGrp(cls.get_prefix() + Labels["height_label"], query=True, value=True)
    depth = cmds.intSliderGrp(cls.get_prefix() + Labels["depth_label"], query=True, value=True)
    rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)

    block_width = width * Constants["block_width_unit"]
    block_height = height * Constants["block_height_unit"]
    block_depth = depth * Constants["block_depth_unit"]

    #stubs
    for x in range(0, width):
      for z in range(0, depth):
        stub = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Stub"), radius=Constants["stub_radius"], height = Constants["stub_height"])
        components.append(stub[0])
        cmds.move(Constants["block_width_unit"] * x + half(Constants["block_width_unit"]), half(Constants["block_height_unit"]) * height + half(Constants["stub_height"]), Constants["block_depth_unit"] * z + half(Constants["block_depth_unit"]), stub[0])

    cube = cmds.polyCube(name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=block_depth)
    components.append(cube[0])
    cmds.move(half(width * Constants["block_width_unit"]), 0, half(depth * Constants["block_depth_unit"]), cube)
    if components.count > 1:
      final = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), ""))
    else:
      final = components[0]

    shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat"))
    cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3')
    cmds.select(final[0], r=True)
    cmds.hyperShade(assign=shader)
  def generate(cls, *args):
    components = []
    radius = cmds.intSliderGrp(cls.get_prefix() + Labels["radius_label"], query=True, value=True)
    height = cmds.intSliderGrp(cls.get_prefix() + Labels["height_label"], query=True, value=True)
    subdivs = cmds.intSliderGrp(cls.get_prefix() + Labels["subdivs_label"], query=True, value=True)
    rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)
    wheel_radius = radius * Constants["wheel_radius_unit"]
    wheel_height = height * Constants["wheel_height_unit"]
    
    wheel_component = cmds.polyPipe(name=get_unique_name(cls.get_prefix(), "cylender"), sh=4, sc=subdivs, h=wheel_height, r=wheel_radius)
    wheel_extrusion_faces = []
    cmds.select(r=True)

    for i in range(0, subdivs):
      if i % 2 == 1:
        facet_title = wheel_component[0] + ".f[" + str(i) + "]"
        wheel_extrusion_faces.append(facet_title)

    #cmds.polyExtrudeFacet(wheel_extrusion_faces, ltz=Constants["wheel_ridge_depth"])
    cmds.delete(ch=1)
    cmds.lattice(wheel_component[0],divisions=[2,3,2], name=get_unique_name(cls.get_prefix(),"lattice"), cp=wheel_component[0])
    shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat"))
    cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3')
    cmds.select(wheel_component[0], r=True)
    cmds.hyperShade(assign=shader)
Example #13
0
def colorAdjust():
    GalaxyColor = cmds.colorSliderGrp("GalaxyColor", label="Galaxy Color: ", w = 280, 
                                      columnWidth = [(1, 80), (2, 80)], 
                                      columnAttach = [(1, "right", 10), (3, "left", 10)], 
                                      rgbValue = (1, 0.4, 1),
                                      columnAlign = [(1, "left"), (2, "left"), (3, "right")], 
                                      cc = setColor)
Example #14
0
def placeDisks( pDiskNumUIField, *Args ):
    """
    Will place the initial disks into the peg A. But it will check if there are any before, in case 
    that there were some, it will delete them (calling the clearTowers procedure). The created ob-
    jects will be placed in the pegA list, so that we can access each disk using [] (pegA[0] would
    be the bottom larger peg[1] the one one step above, until the last one peg[n] being the smallest
    and highest one. I give an example about what the pegA list would look like if we had 3 disks: 
          pegA[0] (1st element) will be called 'disk3'
          pegA[1] (2nd element) will be called 'disk2'
          pegA[2] (3rd element) will be called 'disk1'
    """

    # Creates board and pegs with their relative materials. This just runs the first time the code is executed.
    
    if not board: # If board exists.
        tableSetup() 

    nDisks = cmds.intSliderGrp( diskNumUIField, q=True, v=True )
        
    if len(pegA) != 0:
        cmds.text( warnings, e=True, bgc=(0.85,0,0) )
        cmds.text( warnings, e=True, l="Please, first press 'CLEAR ALL', thanks." )
    else:
        cmds.text( warnings, e=True, bgc=(0,0.66,0.05) )
        cmds.text( warnings, e=True, l="None." )
        j = nDisks
        it = 0
        while j > 0:
            # Records the disks to the pegA list. Will look like disk3 (bottom/largest) disk2 (middle/medium), 
            # disk1 (top/smallest)"...
            disk = cmds.polyCylinder( n='disk'+`j`, h=0.2, r=1.5-(0.1*it) )[0]
            pegA.append(disk)
            cmds.xform( t=pLeft )
            cmds.xform( t=[0,0.6+(nDisks-j)*0.2,0], r=True )
            
            # Apply the materials to the disks
            import materials
            reload(materials)
            colourArrayDisks = cmds.colorSliderGrp( 'rgb_disks', q=True, rgb=True)
            shadingObjs = materials.applyShaderDisk( disk, colourArrayDisks )
            global superList
            superList += shadingObjs[0], shadingObjs[1]
            print shadingObjs[0], shadingObjs[1],"(374) have been added to superList. Now superList contains:", superList

            print pegA[it], "has been created and placed in pegA"
            
            # Set the keyframe
            global KFTime
            anim.setKeyframeToDisk( pegA[it], KFTime )
            it = it + 1
            j = j - 1
                
        print "The pegA list contains: ", pegA
def build():
        if mc.window( 'CreatParticleWin', ex=1 ): mc.deleteUI( 'CreatParticleWin' )
        if mc.windowPref( 'CreatParticleWin', ex=1 ): mc.windowPref( 'CreatParticleWin', remove=1 )
        mc.window( 'CreatParticleWin', t=u'快速创建尾随粒子', wh=(320, 65), menuBar=True)
        mc.frameLayout( lv=0, borderStyle='etchedIn' )
        mc.formLayout('myFormLayout', numberOfDivisions=100)
        #mc.columnLayout(columnAttach=('both', 5), adj=0)
        mc.button('creatButton', l=u'创建粒子', c=creatSphere)
        #mc.colorIndexSliderGrp( 'myColorIndex', label=u'拾取颜色', min=0, max=1, value=.5 )
        #mc.separator( h=5 )
        mc.colorSliderGrp( 'myColorIndex', label=u'粒子颜色', rgb=(1, 0, 0), columnWidth=(5, 25))
        mc.rowLayout( 'myRowLayout', w=250, numberOfColumns=4, columnWidth2=(10, 135 ), adjustableColumn=1, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 30), (2, 'left', 0), (1, 'both', 0), (2, 'left', 0)] )
        mc.text('numParticle', l=u'粒子数量')
        mc.intField('numText', w=55)
        mc.text('lifeParticle', l=u'粒子寿命')
        mc.floatField('lifeText', w=55, precision=1)
        mc.setParent('..')
        mc.setParent('..')
        mc.formLayout('myFormLayout', e=1, attachForm=[('creatButton', 'top', 5), ('creatButton', 'left', 5), ('myColorIndex', 'left', -90), ('myColorIndex', 'bottom', 5),('myColorIndex', 'right', 5), ('myRowLayout', 'top', 130) ], attachControl=[('creatButton', 'bottom', 10, 'myColorIndex'), ('myRowLayout', 'bottom', 10, 'myColorIndex'), ('myRowLayout', 'left', -15, 'creatButton')], attachPosition=[('creatButton', 'right', 5, 25), ('myRowLayout', 'left', 10, 10)],attachNone=('myRowLayout', 'top') )
        #mc.setParent( '..' )
        #mc.setParent( '..' )
        mc.showWindow('CreatParticleWin')
 def generate(cls, *args):
   
   before_kink = cmds.intSliderGrp(cls.get_prefix() + Labels["before_kink_label"], query=True, value=True)
   after_kink = cmds.intSliderGrp(cls.get_prefix() + Labels["after_kink_label"], query=True, value=True)
   rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)
   before = cls.generate_kink_peice(before_kink)
   after = cls.generate_kink_peice(after_kink)
   cmds.rotate(0,0,'90deg', after[0])
   final = cmds.polyUnite(before[0], after[0])
   shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat"))
   cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3')
   cmds.select(final[0], r=True)
   cmds.hyperShade(assign=shader)
Example #17
0
	def assignNewColor(self, *args):
		colorMat = mc.textFieldGrp( 'customColorTextField', q = 1, tx = 1 )
		col = mc.colorSliderGrp( 'customColorColorSlider', q = 1, rgb = 1 )
		alph = mc.checkBox( 'customAlpha_chb', q = True, v = True )
		col.append( alph )
		mc.layoutDialog( dismiss="Cancel" )
		if mc.objExists( colorMat ):
			res = mc.confirmDialog( title='Confirm', message='There is a shader with this name, do you want to use it?', button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' )
			if res == 'Yes':
				self.createAssignColor( [colorMat, col] ) #ASSIGN COLOR
			else:
				self.assignCustomColorUI( [colorMat, col] ) #GO BACK TO SELECT COLOR
		else:
			self.createAssignColor( [colorMat, col] ) #ASSIGN COLOR
Example #18
0
def daytime(args):
    '''
    Changes the city image and the environment colour to match the daytime/nighttime 
    checkboxes. Also uncheckes the nighttime checkbox when daytime is checked and checkes
    it when daytime is unchecked.
    
    args: Dummy argument needed to satisfy the command interface.
    On exit: If daytime was checked, the  nighttime checkbox has been unchecked. The cityimage 
             has also been changed to a daytime image and the environment colour updated to
             suit a daytime city.
             If daytime was unchecked, nighttime has been checked and the image and environment
             colour has been updated accordingly.
    '''
    day = cmds.checkBoxGrp("time", query = True, v1 = True)
    if day == True:
        cmds.checkBoxGrp("time", edit = True, v2 = False, v3 = False,  enable3 = False)
        imageNum = random.randint(1,19)
        cmds.image("cityImage", edit = True, image = "cityImages/dayImage" + str(imageNum) + ".jpg")
        cmds.colorSliderGrp("environment", edit = True, hsv = (204, 0.451, 1))
    else: 
        cmds.checkBoxGrp("time", edit = True, v2 = True,  enable3 = True)
        imageNum = random.randint(1,15)
        cmds.image("cityImage", edit = True, image = "cityImages/nightImage" + str(imageNum) + ".jpg")
        cmds.colorSliderGrp("environment", edit = True, hsv = (204, 0.451, 0.054))
 def draw_ui(cls, *args):
   if cmds.window(cls.get_prefix(), exists=True):
     cmds.deleteUI(cls.get_prefix())
   cmds.window(cls.get_prefix())
   cmds.columnLayout(adjustableColumn=True, width=Constants["window_width"], height=Constants["window_height"])
   cmds.frameLayout(collapsable=True, width=Constants["window_width"], label=Labels["dimensions_label"])
   cmds.columnLayout(width=Constants["window_width"])
   
   cmds.text(Labels["width_label"])
   width_slider = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], annotation=Labels["width_label"], width=Constants["window_width"], minValue=Constants["min_block_width"], maxValue=Constants["max_block_width"], field=True)
   cmds.text(Labels["color_label"])
   color_slider = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], annotation=Labels["color_label"], width=Constants["window_width"])
   cmds.setParent('..')
   cmds.button(command=cls.generate, label="Generate")
   cmds.setParent('..')
   cmds.showWindow(cls.__name__)
def connector():
    rgb = cmds.colorSliderGrp('miscColour', query=True, rgbValue=True)
    
    cX = 1.6
    cY = 0.6
    cZ = 0.6
    
    cMiddle = cmds.polyCylinder( h = 1.6/2, r = 0.5/2, sz = 1 )
    cmds.rotate( 90, rotateZ = True )
    cmds.move( (1.6/2)/2, moveX = True )
    
    cInsideRidge = cmds.polyCylinder( h = 0.1, r = cY/2, sz = 1 )
    cmds.rotate( 90, rotateZ = True )
    cmds.move( 0.1/2, moveX = True )
    
    cOutsideRidge = cmds.polyTorus( sr = 0.05, r = (cY/2.6))
    cmds.rotate( 90, rotateZ = True )
    cmds.move( (cX/2) - (0.08/2), moveX = True )
    
    connector = cmds.polyCBoolOp( cMiddle, cInsideRidge, op = 1 )
    connector = cmds.polyCBoolOp( connector, cOutsideRidge, op = 1 )
    
    cCut = createRoundedBlock( cY * 0.6, cY * 0.2, 5, 2 )
    cmds.move( cY + 0.1, moveX = True )
    
    connector = cmds.polyCBoolOp( connector, cCut, op = 2 )
    
    cMCut = cmds.polyCylinder( h = 1.6, r = 0.45/2, sz = 1 )
    cmds.rotate( 90, rotateZ = True )
    cmds.move( (1.6/2)/2, moveX = True )
    
    connector = cmds.polyCBoolOp( connector, cMCut, op = 2 )
    
    connectorL = cmds.duplicate( connector )
    cmds.scale( -1, scaleX = True )
    cmds.move( -(1.6/2), moveX = True )
    
    connector = cmds.polyUnite( connector, connectorL)
    
    myShader = cmds.shadingNode( 'phong', asShader=True )
    cmds.setAttr( myShader+".color", rgb[0], rgb[1], rgb[2], type='double3')
    cmds.setAttr( myShader+".reflectivity", 0 )
    
    cmds.select( connector )
    cmds.hyperShade( assign = myShader )
    
    cmds.delete( ch = True )
    def applyBtnCmd(self, *args):
            """
            Overridden from base class
            """
            # determine the type of object to create from radio button index
            self.objIndAsCmd = {1:cmds.polyCube, 2:cmds.polyCone, 
                                3:cmds.polyCylinder, 4:cmds.polySphere}
            # determine the selected radio button from radioButtonGrp self.objType
            objIndex = cmds.radioButtonGrp(self.objType, query=True, select=True)
            # create the selected new poly object
            newObject = self.objIndAsCmd[objIndex]()
            # From this point, you can apply transformation using the float field
            # in an absolute (relative to parent) or as initial transformation at creation

            # Absolute transformation
            # Connecting the translates
            # index 1 is the label, so it begins from index=2
            cmds.connectControl(self.position, '%s.translateX' % newObject[0], index=2) 
            cmds.connectControl(self.position, '%s.translateY' % newObject[0], index=3)
            cmds.connectControl(self.position, '%s.translateZ' % newObject[0], index=4)
            # Connecting the rotations
            cmds.connectControl(self.rotation, '%s.rotateX' % newObject[0], index=2) 
            cmds.connectControl(self.rotation, '%s.rotateY' % newObject[0], index=3)
            cmds.connectControl(self.rotation, '%s.rotateZ' % newObject[0], index=4)
            # Connecting the scales
            cmds.connectControl(self.scale, '%s.scaleX' % newObject[0], index=2) 
            cmds.connectControl(self.scale, '%s.scaleY' % newObject[0], index=3)
            cmds.connectControl(self.scale, '%s.scaleZ' % newObject[0], index=4)
            
            # Initial transformation
#            # Query the values from the fields
#            pos = cmds.floatFieldGrp(self.position, query=True, value=True)
#            rot = cmds.floatFieldGrp(self.rotation, query=True, value=True)
#            scale = cmds.floatFieldGrp(self.scale, query=True, value=True)
#            # apply the transformation
#            cmds.xform(newObject[0], translation=pos, rotation=rot, scale=scale)
            
            # apply vertex colours to the new object, from the color picker of 
            # colorSliderGrp, self.color
            # First, query the colour from self.color
            col = cmds.colorSliderGrp(self.color, query=True, rgbValue=True)
            # Then apply the color to the new object. 
            cmds.polyColorPerVertex(newObject[0], colorRGB=col, 
                                    # enable the mesh to display vertex colors
                                    colorDisplayOption=True)
  def generate(cls, *args):
    components = []
    boolean = []
    width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True)
    rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)

    block_width = width * Constants["block_width_unit"]
    block_height = Constants["block_height_unit"]
    block_depth = Constants["block_depth_unit"]

    for x in range(0, width + 1):
      hole = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Hole"), radius=Constants["perforation_radius"], height=Constants["block_depth_unit"] + 0.2)
      boolean.append(hole[0])
      cmds.rotate('90deg', 0, 0, hole[0])
      cmds.move(Constants["block_width_unit"] * x , 0, half(Constants["block_depth_unit"]), hole[0])

    cube = cmds.polyCube(sx=5,sy=2,sz=2,name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=block_depth)
    components.append(cube[0])
    cmds.delete(cube[0] + ".f[40:47]")
    cmds.move(half(width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube)

    #caps
    cap_one = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"],name=get_unique_name(cls.get_prefix(), "cap"))
    cmds.rotate('90deg',0,0,cap_one[0])
    cmds.move(0,0,half(Constants["block_depth_unit"]),cap_one[0])
    cmds.delete(cap_one[0] + ".f[0:3]", cap_one[0] + ".f[14:23]", cap_one[0] + ".f[34:43]", cap_one[0] + ".f[54:63]", cap_one[0] + ".f[74:79]")
    components.append(cap_one[0])

    #caps
    cap_two = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"])
    cmds.rotate('90deg','180deg',0,cap_two[0])
    cmds.delete(cap_two[0] + ".f[0:3]", cap_two[0] + ".f[14:23]", cap_two[0] + ".f[34:43]", cap_two[0] + ".f[54:63]", cap_two[0] + ".f[74:79]")
    cmds.move(block_width,0,half(Constants["block_depth_unit"]),cap_two[0])
    components.append(cap_two[0])

    solid = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), ""))
    boolean_group = cmds.polyUnite(boolean, name=get_unique_name(cls.get_prefix(),"boolean"))
    cmds.polyMergeVertex( solid[0], d=0.15 )
    cmds.delete(solid[0],ch=1)
    final = cmds.polyBoolOp( solid[0], boolean_group[0], op=2, n=get_unique_name(cls.get_prefix(), "") )

    shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat"))
    cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3')
    cmds.select(final[0], r=True)
    cmds.hyperShade(assign=shader)
Example #23
0
    def __init__(*args):
        ''' Edits all the fields related to the string generation and calls the procedure. ''' 
        import maya.cmds as cmds
        cmds.textField( "axiomTextField", e=True, tx='F' )
        cmds.intSliderGrp( "depthIntField", e=True, v=4 )

        cmds.intField( "prodRuleProb1", e=True, v=100 )
        cmds.textField( "prodRulePred1", e=True, tx='F' )
        cmds.textField("prodRuleSucc1", e=True, tx='F+R++R-F--FF-R+')

        cmds.checkBox( "prodRuleCheckBox2", e=True, value=True )
        cmds.intField( "prodRuleProb2", e=True, v=100 )
        cmds.intField( "prodRuleProb2", e=True, en=True )
        cmds.text( "prodRule2Text_A", edit=True, en=True )
        cmds.textField( "prodRulePred2", e=True, en=True )
        cmds.textField( "prodRulePred2", e=True, tx='R' )
        cmds.text( "prodRule2Text_B", edit=True, en=True )
        cmds.textField("prodRuleSucc2", e=True, en=True)
        cmds.textField("prodRuleSucc2", e=True, tx='-F+RR++R+F--F-R')

        cmds.checkBox( "prodRuleCheckBox3", e=True, value=False )
        cmds.intField( "prodRuleProb3", e=True, v=0 )
        cmds.intField( "prodRuleProb3", e=True, en=False )
        cmds.text( "prodRule3Text_A", edit=True, en=False )
        cmds.textField( "prodRulePred3", e=True, en=False )
        cmds.textField( "prodRulePred3", e=True, tx='' )
        cmds.text( "prodRule3Text_B", edit=True, en=False )
        cmds.textField( "prodRuleSucc3", e=True, en=False )
        cmds.textField( "prodRuleSucc3", e=True, tx='' )

        cmds.checkBox( "prodRuleCheckBox4", e=True, value=False )
        cmds.intField( "prodRuleProb4", e=True, v=0 )
        cmds.intField( "prodRuleProb4", e=True, en=False )
        cmds.text( "prodRule4Text_A", edit=True, en=False )
        cmds.textField( "prodRulePred4", e=True, en=False )
        cmds.textField( "prodRulePred4", e=True, tx='' )
        cmds.text( "prodRule4Text_B", edit=True, en=False )
        cmds.textField( "prodRuleSucc4", e=True, en=False )
        cmds.textField( "prodRuleSucc4", e=True, tx='' )

        cmds.textField( "output", e=True, tx='Press Generate String, please.' )
        cmds.textField( "warningsTextField", e=True, tx='Preset loaded, generate the LSystem String, please.' )
        cmds.floatSliderGrp( "angle", e=True, v=60)
        cmds.floatSliderGrp( "length", e=True, v=2)
        cmds.floatSliderGrp("radius", e=True, v=0.39)
        cmds.intSliderGrp( "cylSubdivs", e=True, v=8)
        cmds.intSliderGrp( "length_atenuation", e=True, v=77 )
        cmds.intSliderGrp( "radius_atenuation", e=True, v=80 )
        cmds.floatSliderGrp("turtleSpeed", e=True, v=0)
        cmds.colorSliderGrp( 'rgb_branchField', e=True, rgb=(1.0,1.0,1.0) )
        cmds.colorSliderGrp( 'rgb_leafField', e=True, rgb=(0,0,0) )
        cmds.colorSliderGrp( 'rgb_blossomField', e=True, rgb=(0,0,0) )
Example #24
0
    def __init__(*args):
        ''' Edits all the fields related to the string generation and calls the procedure. ''' 
        import maya.cmds as cmds
        cmds.textField( "axiomTextField", e=True, tx='S' )
        cmds.intSliderGrp( "depthIntField", e=True, v=6 )

        cmds.intField( "prodRuleProb1", e=True, v=33 )
        cmds.textField( "prodRulePred1", e=True, tx='S' )
        cmds.textField("prodRuleSucc1", e=True, tx='S[>>&&FL][>>^^FL]S')

        cmds.checkBox( "prodRuleCheckBox2", e=True, value=True )
        cmds.intField( "prodRuleProb2", e=True, v=33 )
        cmds.intField( "prodRuleProb2", e=True, en=True )
        cmds.text( "prodRule2Text_A", edit=True, en=True )
        cmds.textField( "prodRulePred2", e=True, en=True )
        cmds.textField( "prodRulePred2", e=True, tx='S' )
        cmds.text( "prodRule2Text_B", edit=True, en=True )
        cmds.textField("prodRuleSucc2", e=True, en=True)
        cmds.textField("prodRuleSucc2", e=True, tx='S[-FL]F[S[-F-FB-&&>S][&>F][+S]]')

        cmds.checkBox( "prodRuleCheckBox3", e=True, value=True )
        cmds.intField( "prodRuleProb3", e=True, v=34 )
        cmds.intField( "prodRuleProb3", e=True, en=True )
        cmds.text( "prodRule3Text_A", edit=True, en=True )
        cmds.textField( "prodRulePred3", e=True, en=True )
        cmds.textField( "prodRulePred3", e=True, tx='S' )
        cmds.text( "prodRule3Text_B", edit=True, en=True )
        cmds.textField( "prodRuleSucc3", e=True, en=True)
        cmds.textField( "prodRuleSucc3", e=True, tx='S[+S[-FB][&>S]]' )

        cmds.checkBox( "prodRuleCheckBox4", e=True, value=False )
        cmds.intField( "prodRuleProb4", e=True, v=0 )
        cmds.intField( "prodRuleProb4", e=True, en=False )
        cmds.text( "prodRule4Text_A", edit=True, en=False )
        cmds.textField( "prodRulePred4", e=True, en=False )
        cmds.textField( "prodRulePred4", e=True, tx='' )
        cmds.text( "prodRule4Text_B", edit=True, en=False )
        cmds.textField( "prodRuleSucc4", e=True, en=False )
        cmds.textField( "prodRuleSucc4", e=True, tx='' )

        cmds.textField( "output", e=True, tx='Press Generate String, please.' )
        cmds.textField( "warningsTextField", e=True, tx='Preset loaded, generate the LSystem String, please.' )
        cmds.floatSliderGrp( "angle", e=True, v=26.5)
        cmds.floatSliderGrp( "length", e=True, v=1.20)
        cmds.floatSliderGrp("radius", e=True, v=0.20)
        cmds.intSliderGrp( "cylSubdivs", e=True, v=8)
        cmds.intSliderGrp( "length_atenuation", e=True, v=94 )
        cmds.intSliderGrp( "radius_atenuation", e=True, v=86 )
        cmds.floatSliderGrp("turtleSpeed", e=True, v=0)
        cmds.colorSliderGrp( 'rgb_branchField', e=True, rgb=(0.629,0.565,0.526) )
        cmds.colorSliderGrp( 'rgb_leafField', e=True, rgb=(0.904,0.335,0) )
        cmds.colorSliderGrp( 'rgb_blossomField', e=True, rgb=(0,0.247,0.725) )
Example #25
0
    def __init__(*args):
        ''' Edits all the fields related to the string generation and calls the procedure. ''' 
        import maya.cmds as cmds
        cmds.textField( "axiomTextField", e=True, tx='F' )
        cmds.intSliderGrp( "depthIntField", e=True, v=4 )

        cmds.intField( "prodRuleProb1", e=True, v=100 )
        cmds.textField( "prodRulePred1", e=True, tx='F' )
        cmds.textField("prodRuleSucc1", e=True, tx='F[&+F]F[->FL][&FB]')

        cmds.checkBox( "prodRuleCheckBox2", e=True, value=False )
        cmds.intField( "prodRuleProb2", e=True, v=0 )
        cmds.intField( "prodRuleProb2", e=True, en=False )
        cmds.text( "prodRule2Text_A", edit=True, en=False )
        cmds.textField( "prodRulePred2", e=True, en=False )
        cmds.textField( "prodRulePred2", e=True, tx='' )
        cmds.text( "prodRule2Text_B", edit=True, en=False )
        cmds.textField( "prodRuleSucc2", e=True, en=False )
        cmds.textField( "prodRuleSucc2", e=True, tx='' )

        cmds.checkBox( "prodRuleCheckBox3", e=True, value=False )
        cmds.intField( "prodRuleProb3", e=True, v=0 )
        cmds.intField( "prodRuleProb3", e=True, en=False )
        cmds.text( "prodRule3Text_A", edit=True, en=False )
        cmds.textField( "prodRulePred3", e=True, en=False )
        cmds.textField( "prodRulePred3", e=True, tx='' )
        cmds.text( "prodRule3Text_B", edit=True, en=False )
        cmds.textField( "prodRuleSucc3", e=True, en=False )
        cmds.textField( "prodRuleSucc3", e=True, tx='' )

        cmds.checkBox( "prodRuleCheckBox4", e=True, value=False )
        cmds.intField( "prodRuleProb4", e=True, v=0 )
        cmds.intField( "prodRuleProb4", e=True, en=False )
        cmds.text( "prodRule4Text_A", edit=True, en=False )
        cmds.textField( "prodRulePred4", e=True, en=False )
        cmds.textField( "prodRulePred4", e=True, tx='' )
        cmds.text( "prodRule4Text_B", edit=True, en=False )
        cmds.textField( "prodRuleSucc4", e=True, en=False )
        cmds.textField( "prodRuleSucc4", e=True, tx='' )

        cmds.textField( "output", e=True, tx='Press Generate String, please.' )
        cmds.floatSliderGrp("angle", e=True, v=28)
        cmds.floatSliderGrp("length", e=True, v=1.20)
        cmds.floatSliderGrp("radius", e=True, v=0.20)
        cmds.intSliderGrp("cylSubdivs", e=True, v=5)
        cmds.intSliderGrp( "length_atenuation", e=True, v=95 )
        cmds.intSliderGrp( "radius_atenuation", e=True, v=85 )
        cmds.floatSliderGrp("turtleSpeed", e=True, v=0)
        cmds.colorSliderGrp( 'rgb_blossomField', e=True, rgb=(0.624,0,0) )
        cmds.colorSliderGrp( 'rgb_leafField', e=True, rgb=(0,0.624,0) )
        cmds.colorSliderGrp( 'rgb_branchField', e=True, rgb=(0.430,0.230,0.11) )
Example #26
0
    def __init__(*args):
        ''' Edits all the fields related to the string generation and calls the procedure. ''' 
        import maya.cmds as cmds
        cmds.textField( "axiomTextField", e=True, tx='F' )
        cmds.intSliderGrp( "depthIntField", e=True, v=3 )
        cmds.intField( "prodRuleProb1", e=True, v=70 )
        cmds.textField( "prodRulePred1", e=True, tx='F' )
        cmds.textField("prodRuleSucc1", e=True, tx='F[+FL][-FB][&FL][^FB]F')

        cmds.checkBox( "prodRuleCheckBox2", e=True, value=True )
        cmds.intField( "prodRuleProb2", e=True, v=30 )
        cmds.intField( "prodRuleProb2", e=True, en=True )
        cmds.textField( "prodRulePred2", e=True, en=True )
        cmds.textField( "prodRulePred2", e=True, tx='F' )
        cmds.textField("prodRuleSucc2", e=True, en=True )
        cmds.textField("prodRuleSucc2", e=True, tx='[-FL]F[F[-FB-&&>F][&>F]]')

        cmds.checkBox( "prodRuleCheckBox3", e=True, value=False )
        cmds.intField( "prodRuleProb3", e=True, v=0 )
        cmds.intField( "prodRuleProb3", e=True, en=False )
        cmds.text( "prodRule3Text_A", edit=True, en=False )
        cmds.textField( "prodRulePred3", e=True, en=False )
        cmds.textField( "prodRulePred3", e=True, tx='' )
        cmds.text( "prodRule3Text_B", edit=True, en=False )
        cmds.textField( "prodRuleSucc3", e=True, en=False )
        cmds.textField( "prodRuleSucc3", e=True, tx='' )

        cmds.checkBox( "prodRuleCheckBox4", e=True, value=False )
        cmds.intField( "prodRuleProb4", e=True, v=0 )
        cmds.intField( "prodRuleProb4", e=True, en=False )
        cmds.text( "prodRule4Text_A", edit=True, en=False )
        cmds.textField( "prodRulePred4", e=True, en=False )
        cmds.textField( "prodRulePred4", e=True, tx='' )
        cmds.text( "prodRule4Text_B", edit=True, en=False )
        cmds.textField( "prodRuleSucc4", e=True, en=False )
        cmds.textField( "prodRuleSucc4", e=True, tx='' )

        cmds.textField( "output", e=True, tx='Press Generate String, please.' )
        cmds.textField( "warningsTextField", e=True, tx='Preset loaded, generate the LSystem String, please.' )
        cmds.floatSliderGrp("angle", e=True, v=25.7)
        cmds.floatSliderGrp("length", e=True, v=3.32)
        cmds.floatSliderGrp("radius", e=True, v=0.50)
        cmds.intSliderGrp("cylSubdivs", e=True, v=6)
        cmds.intSliderGrp( "length_atenuation", e=True, v=90 )
        cmds.intSliderGrp( "radius_atenuation", e=True, v=70 )
        cmds.floatSliderGrp("turtleSpeed", e=True, v=0)
        cmds.colorSliderGrp( 'rgb_branchField', e=True, rgb=(0.242,0.129,0.070) )
        cmds.colorSliderGrp( 'rgb_leafField', e=True, rgb=(0,0.427,0) )
        cmds.colorSliderGrp( 'rgb_blossomField', e=True, rgb=(1.0,1.0,1.0) )
def axle():
    axleLength = cmds.intSliderGrp( 'axleLength', query = True, value = True)
    rgb = cmds.colorSliderGrp('miscColour', query=True, rgbValue=True)
    
    axleX = axleLength * 0.8
    axleY = 0.4
    axleZ = 0.4
    
    hAxle = cmds.polyCube( w = axleX, h = axleY/2, d = axleZ )
    vAxle = cmds.polyCube( w = axleX, h = axleY, d = axleZ/2 )
    
    axle = cmds.polyCBoolOp( hAxle, vAxle, op = 1 )[0]
    
    myShader = cmds.shadingNode( 'phong', asShader=True )
    cmds.setAttr( myShader+".color", rgb[0], rgb[1], rgb[2], type='double3')
    cmds.setAttr( myShader+".reflectivity", 0 )
    
    cmds.select( axle )
    cmds.hyperShade( assign = myShader )
    
    cmds.delete( ch = True )
  def generate(cls, *args):
    components = []
    width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True)
    rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)
    block_width = width * Constants["block_width_unit"]
    block_height = twice(Constants["perforation_radius"])
    block_depth = twice(Constants["perforation_radius"])

    cube_one = cmds.polyCube(name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=half(block_height), depth=block_depth)
    components.append(cube_one[0])
    cmds.move(half(width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube_one[0])

    cube_two = cmds.polyCube(name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=half(block_depth))
    components.append(cube_two[0])
    cmds.move(half(width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube_two[0])
    final = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), ""))

    shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat"))
    cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3')
    cmds.select(final[0], r=True)
    cmds.hyperShade(assign=shader)
    def displayOptions(self):
            """
            Overridden from base class
            """
            # primitive type selector
            self.objType = cmds.radioButtonGrp(label='Object Type: ', 
                                               labelArray4=['Cube', 'Cone', 'Cylinder', 'Sphere'],
                                               numberOfRadioButtons=4,
                                               select=1) # selected radio button
            # a group of transform controls. Create a frameLayout to hold the controls
            self.xformGrp = cmds.frameLayout(label='Transformations', collapsable=True)
            # self.optionForm (empty formLayout) is from superclass
            cmds.formLayout(self.optionForm, edit=True, attachControl=
                            # attach the formLayout below radio buttons
                            ([self.xformGrp, 'top', 2, self.objType]),
                            attachForm=
                            ([self.xformGrp, 'left', 0],
                             [self.xformGrp, 'right', 0]))
            # create a columnLayout below formLayout. Placing too many children under
            # self.xformGrp would throw an exception in maya versions before 2011.
            self.xformCol = cmds.columnLayout()
            # create floatFieldGrp for translate, rotate and scale transform
            self.position = cmds.floatFieldGrp(label='Position: ', numberOfFields=3)
            self.rotation = cmds.floatFieldGrp(label='Rotation (XYZ): ', numberOfFields=3)
            self.scale = cmds.floatFieldGrp(label='Scale: ', numberOfFields=3,
                                            value=[1.0, 1.0, 1.0, 1.0])

            # parent is set to self.xformGrp
            cmds.setParent('..')
            # parent is set to self.optionForm
            cmds.setParent('..')

            # a vertex color picker under self.optionForm
            self.color = cmds.colorSliderGrp(label='Vertex Colors: ')
            # edit the placement of self.color under self.optionForm
            cmds.formLayout(self.optionForm, edit=True, attachControl=
                            ([self.color, 'top', 0, self.xformGrp]),
                                                         attachForm=
                                                         ([self.color, 'left', 0]))
Example #30
0
 def colorControlLayout(self, label=''):
     mc.rowLayout( numberOfColumns=4, 
                   columnWidth4=(150, 200, 90, 80), 
                   adjustableColumn=2, 
                   columnAlign=(1, 'right'), 
                   columnAttach=[(1, 'both', 0), 
                                 (2, 'both', 0), 
                                 (3, 'both', 0), 
                                 (4, 'both', 0)] )
     mc.text(label=label)
     colorSlider = mc.colorSliderGrp( label='', adj=2, columnWidth=((1,1),(3,1)))
     mc.button(label='From Selected', 
               ann='Get the color of the selected object.',
               command=partial(self.setFromSelected, colorSlider)) 
     mc.button(label='Randomize', 
               ann='Set a random color.', 
               command=partial(self.randomizeColors, colorSlider))
     controls = mc.layout(colorSlider, query=True, childArray=True)
     
     mc.setParent('..')
     
     return colorSlider
    def update_mask(cls):
        if not cmds.window(cls.WINDOW_NAME, exists=True):
            return

        ZShotMask.set_camera_name(
            cmds.textFieldButtonGrp(cls.camera_name, q=True, text=True))

        text_array = []
        for i in range(len(cls.LABELS)):
            text_array.append(
                cmds.textFieldGrp(cls.label_text_ctrls[i], q=True, text=True))

        ZShotMask.set_label_text(text_array)
        ZShotMask.set_label_font(
            cmds.textFieldButtonGrp(cls.label_font_tfg, q=True, text=True))

        label_color = cmds.colorSliderGrp(cls.label_color_csg,
                                          q=True,
                                          rgbValue=True)
        label_alpha = cmds.colorSliderGrp(cls.label_trans_csg,
                                          q=True,
                                          rgbValue=True)
        ZShotMask.set_label_color(label_color[0], label_color[1],
                                  label_color[2], label_alpha[0])
        ZShotMask.set_label_scale(
            cmds.floatField(cls.label_scale, q=True, value=True))

        borderTopEnabled = cmds.checkBoxGrp(cls.border_vis_cbg,
                                            q=True,
                                            value1=True)
        borderBottomEnabled = cmds.checkBoxGrp(cls.border_vis_cbg,
                                               q=True,
                                               value2=True)
        ZShotMask.set_border_visible(borderTopEnabled, borderBottomEnabled)

        border_color = cmds.colorSliderGrp(cls.border_color_csg,
                                           q=True,
                                           rgbValue=True)
        border_alpha = cmds.colorSliderGrp(cls.border_trans_csg,
                                           q=True,
                                           rgbValue=True)
        ZShotMask.set_border_color(border_color[0], border_color[1],
                                   border_color[2], border_alpha[0])
        ZShotMask.set_border_scale(
            cmds.floatField(cls.border_scale, q=True, value=True))

        if cmds.checkBoxGrp(cls.counter_vis_cbg, q=True, value1=True):
            radio_btn_index = cmds.radioButtonGrp(cls.counter_position,
                                                  q=True,
                                                  select=True)
            counter_position = 6
            if radio_btn_index == 1:
                counter_position = 1
            elif radio_btn_index == 2:
                counter_position = 3
            elif radio_btn_index == 3:
                counter_position = 4

            ZShotMask.set_counter_position(counter_position)
        else:
            ZShotMask.set_counter_position(0)

        ZShotMask.set_counter_padding(
            cmds.intField(cls.counter_padding, q=True, value=True))

        ZShotMask.refresh_mask()
Example #32
0
def setMeshLightAttrsAndShow(attribute):
    for item in cmds.textScrollList('MeshLightList',q=True,si=True):
        try:
            if attribute == 'translator':
                cmds.setAttr(item+'.aiTranslator',cmds.optionMenu('MeshLight_aiTranslator',q=True,v=True),type='string')
        except:
            pass
        try:
            if attribute == 'color':
                color = cmds.colorSliderGrp('MeshLight_aiColor',q=True,rgb=True)
                cmds.setAttr(item+'.color',color[0],color[1],color[2],type='double3')
        except:
            pass
        try:
            if attribute == 'intensity':
                cmds.setAttr(item+'.intensity',cmds.floatFieldGrp('MeshLight_aiIntensity',q=True,v1=True))
        except:
            pass
        try:
            if attribute == 'exposure':
                cmds.setAttr(item+'.aiExposure',cmds.floatSliderGrp('MeshLight_aiExposure',q=True,v=True))
        except:
            pass
        try:
            if attribute == 'useTemp':
                cmds.setAttr(item+'.aiUseColorTemperature',cmds.checkBox('MeshLight_aiUseTemp',q=True,v=True))
        except:
            pass
        try:
            if attribute == 'temp':
                cmds.setAttr(item+'.aiColorTemperature',cmds.floatSliderGrp('MeshLight_aiTemperature',q=True,v=True))
        except:
            pass
        try:
            if attribute == 'visible':
                cmds.setAttr(item+'.lightVisible',cmds.checkBox('MeshLight_aiVisible',q=True,v=True))
        except:
            pass
        try:
            if attribute == 'sample':
                cmds.setAttr(item+'.aiSamples',cmds.intFieldGrp('MeshLight_aiSample',q=True,v1=True))
        except:
            pass
        try:
            if attribute == 'normalize':
                cmds.setAttr(item+'.aiNormalize',cmds.checkBox('MeshLight_aiNormalize',q=True,v=True))
        except:
            pass
        try:
            if attribute == 'castShadows':
                cmds.setAttr(item+'.aiCastShadows',cmds.checkBox('MeshLight_aiCastShadows',q=True,v=True))
        except:
            pass
        try:
            if attribute == 'shadowDensity':
                cmds.setAttr(item+'.aiShadowDensity',cmds.floatSliderGrp('MeshLight_aiShadowDensity',q=True,v=True))
        except:
            pass
        try:
            if attribute == 'shadowColor':
                shadowColor = cmds.colorSliderGrp('MeshLight_aiShadowColor',q=True,rgb=True)
                cmds.setAttr(item+'.aiShadowColor',shadowColor[0],shadowColor[1],shadowColor[2],type='double3')
        except:
            pass
        try:
            if attribute == 'castVolumeShadow':
                cmds.setAttr(item+'.aiCastVolumetricShadows',cmds.checkBox('MeshLight_aiCastVolumeShadow',q=True,v=True))
        except:
            pass
        try:
            if attribute == 'volumeSample':
                cmds.setAttr(item+'.aiVolumeSamples',cmds.intFieldGrp('MeshLight_aiVolumeSample',q=True,v1=True))
        except:
            pass
        try:
            if attribute == 'aiAov':
                cmds.setAttr(item+'.aiAov',cmds.textFieldGrp('MeshLight_aiAov',q=True,tx=True),type='string')
        except:
            pass
Example #33
0
 def update_stored_values():
     ''' Updates Current Color '''
     
     gt_color_manager_settings["current_color"] = cmds.colorSliderGrp(color_slider, q=True, rgb=True) # for outliner?
     set_persistent_settings_color_manager('gt_color_manager_current_color', cmds.colorSliderGrp(color_slider, q=True, rgb=True))
Example #34
0
def roundedBlockWithHolesAngle():
    # set up block dimensions
    height = 3
    width = 1  #bump
    bendAngle = cmds.radioButtonGrp('roundedBlockWithHolesBendAngle',
                                    q=True,
                                    sl=True)
    if (bendAngle == 1):
        length = cmds.intSliderGrp('roundedBlockWithHolesAngleLength',
                                   q=True,
                                   v=True)
        bendLength = cmds.intSliderGrp('roundedBlockWithHolesAngleBendLength',
                                       q=True,
                                       v=True)
    if (bendAngle == 2):
        length = 4
        bendLength = 3
    rgb = cmds.colorSliderGrp('roundedBlockWithHolesAngleColour',
                              q=True,
                              rgbValue=True)

    # name
    nsTmp = "RoundedBlockWithHolesAngle" + str(rnd.randint(1000, 9999))

    cmds.select(clear=True)
    cmds.namespace(add=nsTmp)
    cmds.namespace(set=nsTmp)

    # define cubes size
    cubeSizeX = width * 0.8
    cubeSizeZ = length * 0.8
    cubeSizeY = height * 0.32
    bendSizeZ = bendLength * 0.8

    # create a cube
    cube = cmds.polyCube(h=cubeSizeY, w=cubeSizeX, d=cubeSizeZ)

    # move it up
    cmds.move((cubeSizeY / 2.0), moveY=True)

    # create holes
    for i in range(width):
        for j in range(length):
            # create cylinder in the place of a hole
            hole = cmds.polyCylinder(r=0.25, h=height / 2.0)

            # rotate and position it
            cmds.rotate(90, rotateX=True, a=True)
            cmds.rotate(90, rotateY=True, a=True)

            cmds.move((cubeSizeY / 2.0), moveY=True, a=True)
            cmds.move(((i * 0.8) - (cubeSizeX / 2.0) + 0.4),
                      moveX=True,
                      a=True)
            cmds.move(((j * 0.8) - (cubeSizeZ / 2.0)), moveZ=True, a=True)

            # remove it from the base block
            cube = cmds.polyCBoolOp(cube, hole, op=2, caching=False, ch=False)

    # add cylinders to round corners
    # right side
    rCylind = cmds.polyCylinder(r=cubeSizeY * 0.5, h=cubeSizeX)
    cmds.rotate(90, rotateX=True, a=True)
    cmds.rotate(90, rotateY=True, a=True)
    cmds.move((cubeSizeX / 2.0 + 0.079), moveY=True, a=True)
    cmds.move((-cubeSizeZ * 0.5), moveZ=True, a=True)
    # merge right cylinder with cube
    cube = cmds.polyCBoolOp(cube, rCylind, op=1, caching=False, ch=False)
    # add a hole
    rHole = cmds.polyCylinder(r=0.25, h=height / 2.0)
    cmds.rotate(90, rotateX=True, a=True)
    cmds.rotate(90, rotateY=True, a=True)
    cmds.move((cubeSizeY / 2.0), moveY=True, a=True)
    cmds.move(((0 * 0.8) - (cubeSizeX / 2.0) + 0.4), moveX=True, a=True)
    cmds.move(((0 * 0.8) - (cubeSizeZ / 2.0)), moveZ=True, a=True)
    cube = cmds.polyCBoolOp(cube, rHole, op=2, caching=False, ch=False)

    # left side
    lCylind = cmds.polyCylinder(r=cubeSizeY * 0.5, h=cubeSizeX)
    cmds.rotate(90, rotateX=True, a=True)
    cmds.rotate(90, rotateY=True, a=True)
    cmds.move((cubeSizeX / 2.0 + 0.079), moveY=True, a=True)
    cmds.move((cubeSizeZ * 0.5), moveZ=True, a=True)
    # merge left cylinder with cube
    cube = cmds.polyCBoolOp(cube, lCylind, op=1, caching=False, ch=False)
    # create a hole
    lHole = cmds.polyCylinder(r=0.25, h=height / 2.0)
    cmds.rotate(90, rotateX=True, a=True)
    cmds.rotate(90, rotateY=True, a=True)
    cmds.move((cubeSizeY / 2.0), moveY=True, a=True)
    cmds.move(((width * 0.8) - cubeSizeX), moveX=True, a=True)
    cmds.move(((length * 0.8) - (cubeSizeZ / 2.0)), moveZ=True, a=True)
    cube = cmds.polyCBoolOp(cube, lHole, op=2, caching=False, ch=False)

    # create a second cube for bend
    if (bendAngle == 1):  # at 90 degrees
        cubeBend = cmds.polyCube(h=cubeSizeY, w=cubeSizeX, d=bendSizeZ)
        cmds.rotate(90, rotateX=True, a=True)

        # move it up
        cmds.move((bendSizeZ / 2.0), moveY=True)

        # add cylinder to its end
        endCylind = cmds.polyCylinder(r=cubeSizeY * 0.5, h=cubeSizeX)
        cmds.rotate(90, rotateX=True, a=True)
        cmds.rotate(90, rotateY=True, a=True)
        cmds.move((bendSizeZ), moveY=True, a=True)

        # merge cube with cylinder
        cubeBend = cmds.polyCBoolOp(cubeBend,
                                    endCylind,
                                    op=1,
                                    caching=False,
                                    ch=False)

        # move bended cube to cube's end
        cmds.move((-cubeSizeZ / 2), moveZ=True, a=True)

        # move it up a bit
        cmds.move(0.5, moveY=True)

        # add holes to bended part
        # create holes
        for i in range(width):
            for j in range(bendLength):
                # create cylinder in the place of a hole
                bHole = cmds.polyCylinder(r=0.25, h=height / 2.0)
                # rotate and position it
                cmds.rotate(90, rotateX=True, a=True)
                cmds.rotate(90, rotateY=True, a=True)
                cmds.move((cubeSizeY / 2.0), moveY=True, a=True)
                cmds.move(((0 * 0.8) - (cubeSizeZ / 2.0)), moveZ=True, a=True)
                cmds.move(((0 * 0.8) - (cubeSizeX / 2.0) + 0.4),
                          moveX=True,
                          a=True)
                cmds.move(((j * 0.8) + (cubeSizeY / 2.0)), moveY=True, a=True)
                # remove it from the base block
                cubeBend = cmds.polyCBoolOp(cubeBend,
                                            bHole,
                                            op=2,
                                            caching=False,
                                            ch=False)

        # create the last hole
        endHole = cmds.polyCylinder(r=0.25, h=height / 2.0)
        # rotate and position it
        cmds.rotate(90, rotateX=True, a=True)
        cmds.rotate(90, rotateY=True, a=True)
        cmds.move((cubeSizeY / 2.0), moveY=True, a=True)
        cmds.move(((0 * 0.8) - (cubeSizeZ / 2.0)), moveZ=True, a=True)
        cmds.move((((bendLength) * 0.8) + (cubeSizeY / 2.0)),
                  moveY=True,
                  a=True)
        # remove it from end cylinder
        cubeBend = cmds.polyCBoolOp(cubeBend,
                                    endHole,
                                    op=2,
                                    caching=False,
                                    ch=False)

    if (bendAngle == 2):  # bend at 60 degrees
        # create a cube for bend
        cubeBend = cmds.polyCube(h=cubeSizeY, w=cubeSizeX, d=bendSizeZ)
        # move & rotate
        cmds.move((cubeSizeY), moveY=True)
        cmds.rotate(60, rotateX=True, a=True)
        cmds.move((0 - (cubeSizeZ / 2.0) + 1.04), moveZ=True, a=True)

        # add cylinder to its end
        endCylind = cmds.polyCylinder(r=cubeSizeY * 0.5 + 0.01, h=cubeSizeX)
        cmds.rotate(90, rotateX=True, a=True)
        cmds.rotate(90, rotateY=True, a=True)
        cmds.move((bendSizeZ - 0.4), moveY=True, a=True)
        cmds.move((-bendSizeZ / 2 + 0.04), moveZ=True, a=True)

        # merge cube with cylinder
        cubeBend = cmds.polyCBoolOp(cubeBend,
                                    endCylind,
                                    op=1,
                                    caching=False,
                                    ch=False)

        # move bended cube to cube's end
        cmds.move((-cubeSizeZ / 2), moveZ=True, a=True)

        # move it up a bit
        cmds.move(0.5, moveY=True)

        # add holes to bended part
        # create holes
        # HOLE ONE (from bottom)
        hole1 = cmds.polyCylinder(r=0.25, h=height / 2.0)
        # rotate and position it
        cmds.rotate(90, rotateX=True, a=True)
        cmds.rotate(90, rotateY=True, a=True)
        cmds.move(cubeSizeY / 2, moveY=True, a=True)
        cmds.move(-cubeSizeZ / 2.0, moveZ=True, a=True)
        cmds.move(((0 * 0.8) - (cubeSizeX * 0.5) + 0.4), moveX=True, a=True)
        # remove it from the base block
        cubeBend = cmds.polyCBoolOp(cubeBend,
                                    hole1,
                                    op=2,
                                    caching=False,
                                    ch=False)

        # HOLE TWO
        hole2 = cmds.polyCylinder(r=0.25, h=height / 2.0)
        # rotate and position it
        cmds.rotate(90, rotateX=True, a=True)
        cmds.rotate(90, rotateY=True, a=True)
        cmds.move(1.129, moveY=True, a=True)
        cmds.move(-1.994, moveZ=True, a=True)
        # remove it from the base block
        cubeBend = cmds.polyCBoolOp(cubeBend,
                                    hole2,
                                    op=2,
                                    caching=False,
                                    ch=False)

        # HOLE THREE
        hole3 = cmds.polyCylinder(r=0.25, h=height / 2.0)
        # rotate and position it
        cmds.rotate(90, rotateX=True, a=True)
        cmds.rotate(90, rotateY=True, a=True)
        cmds.move(1.834, moveY=True, a=True)
        cmds.move(-2.363, moveZ=True, a=True)
        # remove it from the base block
        cubeBend = cmds.polyCBoolOp(cubeBend,
                                    hole3,
                                    op=2,
                                    caching=False,
                                    ch=False)

        # HOLE FOUR
        endHole = cmds.polyCylinder(r=0.25, h=height / 2.0)
        # rotate and position it
        cmds.rotate(90, rotateX=True, a=True)
        cmds.rotate(90, rotateY=True, a=True)
        cmds.move(-2.741, moveZ=True, a=True)
        cmds.move(2.49, moveY=True, a=True)
        # remove it from end cylinder
        cubeBend = cmds.polyCBoolOp(cubeBend,
                                    endHole,
                                    op=2,
                                    caching=False,
                                    ch=False)

    # add material
    myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat")
    cmds.setAttr(nsTmp + ":blckMat.color",
                 rgb[0],
                 rgb[1],
                 rgb[2],
                 type='double3')

    cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False)
    cmds.delete(ch=True)

    cmds.hyperShade(assign=(nsTmp + ":blckMat"))
    cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
def globalModify_reference_ui():
	if cm.window('gmr_win',ex=True):
		cm.deleteUI('gmr_win')
	gmr_window=cm.window('gmr_win',t='GlobalModify v1.0',wh=(200,300))
	gmr_maincol=cm.columnLayout('g_main_col',cat=["both",3],adj=True)
	gmr_aw_f=cm.frameLayout('g_aw_frame',label='AO / WorldNormal',cll=True,borderStyle='etchedOut',\
		ec=lambda *args:resizeWindowH('gmr_win','g_zd_frame','g_id_frame',688,571,505,388),\
		cc=lambda *args:resizeWindowH('gmr_win','g_zd_frame','g_id_frame',362,245,179,62))
	gmr_faw_col=cm.columnLayout('g_faw_col',cat=["both",3],adj=True)
	gmr_samples=cm.intFieldGrp('g_samp', l='Samples', value1=45,cl2=['right','left'],cw2=[80,70])
	gmr_brig=cm.colorSliderGrp('g_brig',label='Bright', rgb=(1, 1, 1) ,cl3=['right','left','left'],cw3=[80,70,120])
	gmr_dark=cm.colorSliderGrp('g_dark',label='Dark', rgb=(0, 0, 0) ,cl3=['right','left','left'],cw3=[80,70,120])
	gmr_spread=cm.floatFieldGrp('g_spre', l='Spread', value1=0.8,cl2=['right','left'],cw2=[80,70])
	gmr_maxD=cm.floatFieldGrp('g_maxD', l='Max Distance', value1=25,cl2=['right','left'],cw2=[80,70])
	gmr_re_col=cm.columnLayout('g_re_col',cat=["both",83],adj=True)
	gmr_reflective=cm.checkBox('g_reflective',l='Reflective')
	cm.setParent('g_faw_col')
	gmr_outputM=cm.intSliderGrp('g_outputM',field=True, label='Output Mode', minValue=0, maxValue=3, fieldMinValue=0, fieldMaxValue=100, value=0 ,cl3=['right','left','left'],cw3=[80,70,120])
	gmr_oIA_col=cm.columnLayout('g_oIA_col',cat=["left",83],adj=True)
	gmr_OIA=cm.checkBox('g_OIA',l='Occlusion In Alpha')
	cm.setParent('g_faw_col')
	gmr_fallo=cm.floatFieldGrp('g_fallo', l='Falloff', value1=0.5,cl2=['right','left'],cw2=[80,70])
	gmr_idIncl=cm.intFieldGrp('g_idIncl', l='Id Inclexcl', value1=-1,cl2=['right','left'],cw2=[80,70])
	gmr_idNonself=cm.intFieldGrp('g_idNonself', l='Id Nonself', value1=1,cl2=['right','left'],cw2=[80,70])
	cm.separator('g_separ_up', height=10, style='in' )
	gmr_AO_col=cm.columnLayout('g_AO_col',cat=["left",83],adj=True)
	gmr_AO=cm.checkBox('g_AO',l='AO',v=True,onc=lambda *args:openCheckBox('g_WN',45,0.8,25,0,0.5,-1,1,1,0))
	gmr_WN=cm.checkBox('g_WN',l='World Normal',onc=lambda *args:openCheckBox('g_AO',0,0,0,3,1,1,1,1,0))
	cm.setParent('g_faw_col')
	cm.separator('g_separ_down', height=10, style='in' )
	gmr_mAWn=cm.button('g_mAWn',l='Modify AO /worldNormal...',h=30,bgc=[0.3,0.5,0.8],c=lambda *args:getAoAndWnM())
	cm.separator('g_separ_xiadown', height=10, style='in' )

	cm.setParent('g_main_col')
	gmr_zd_f=cm.frameLayout('g_zd_frame',label='Zdepth',cll=True,borderStyle='etchedOut',\
		ec=lambda *args:resizeWindowH('gmr_win','g_aw_frame','g_id_frame',688,362,505,179),\
		cc=lambda *args:resizeWindowH('gmr_win','g_aw_frame','g_id_frame',571,245,388,62))
	gmr_fzd_col=cm.columnLayout('g_fzd_col',cat=["both",3],adj=True)
	gmr_NCP=cm.floatFieldGrp('g_NCP', l='Near Clip Plane', value1=1,cl2=['right','left'],cw2=[120,70])
	gmr_FCP=cm.floatFieldGrp('g_FCP', l='Far Clip Plane', value1=20,cl2=['right','left'],cw2=[120,70])
	gmr_in_col=cm.columnLayout('g_in_col',cat=["left",123],adj=True)
	#gmr_invert=cm.checkBox('g_invert',l='Invert Result',v=True)
	cm.setParent('g_fzd_col')
	cm.separator('g_separ_zd_down', height=25, style='in' )
	gmr_zdepth=cm.button('g_zdepth',l='Modify Zdepth...',h=30,bgc=[0.3,0.5,0.8],c=lambda *args:getZdepthAndM())
	cm.separator('g_separ_zd_xiadown', height=10, style='in' )
	
	cm.setParent('g_main_col')
	gmr_id_f=cm.frameLayout('g_id_frame',label='ID',cll=True,borderStyle='etchedOut',\
		ec=lambda *args:resizeWindowH('gmr_win','g_aw_frame','g_zd_frame',688,360,571,245),\
		cc=lambda *args:resizeWindowH('gmr_win','g_aw_frame','g_zd_frame',505,179,388,62))
	gmr_fid_col=cm.columnLayout('g_fid_col',cat=["both",3],adj=True)
	gmr_asset=cm.colorSliderGrp('g_asset',label='Asset Object ID', rgb=(0, 0, 0) ,cl3=['right','left','left'],cw3=[80,70,120])
	gmr_mat=cm.colorSliderGrp('g_mat',label='Material ID', rgb=(0, 0, 0) ,cl3=['right','left','left'],cw3=[80,70,120])
	gmr_asset_col=cm.columnLayout('g_asset_col',cat=["left",123],adj=True)
	gmr_asset_c=cm.checkBox('g_asset_c',l='AssetID',v=1)
	gmr_mat_c=cm.checkBox('g_mat_c',l='MatID',v=1)
	cm.setParent('g_fid_col')
	cm.separator('g_separ_id_down', height=10, style='in' )
	gmr_id=cm.button('g_id',l='Modify ID...',h=30,bgc=[0.3,0.5,0.8],c=lambda *args:modifyID())
	cm.separator('g_g_separ_id_xiadown', height=10, style='in' )
	gmr_g_asset_col=cm.columnLayout('g_g_asset_col',cat=["left",10],adj=True)
	gmr_g_asset_c=cm.checkBox('g_g_asset_c',l='Reference Level (on: top && off: down)',v=1)
	cm.setParent('g_fid_col')
	gmr_r_id=cm.button('g_r_id',l='Random ID...',h=30,bgc=[0.3,0.5,0.8],c=lambda *args:modifyRandomID())
	cm.separator('g_separ_id_xiadown', height=10, style='in' )
	cm.window('gmr_win',e=True,wh=(320,688))
	cm.showWindow('gmr_win')
Example #36
0
def splinifyUI():

    # Create window
    if cmds.window('splinifyWin', exists=1):
        cmds.deleteUI('splinifyWin')
    window = cmds.window('splinifyWin', title='Splinify', sizeable=1)

    # Create form + UI elements
    form = cmds.formLayout(numberOfDivisions=100)
    scroll = cmds.scrollLayout(parent=form)
    scrollForm = cmds.formLayout(numberOfDivisions=100, parent=scroll)

    startJointText = cmds.textFieldGrp(label='Start Joint: ',
                                       adjustableColumn=2,
                                       editable=0)
    startJointBtn = cmds.button(label='Set Selected',
                                command=partial(checkSelectedJoint,
                                                startJointText))

    endJointText = cmds.textFieldGrp(label='End Joint: ',
                                     adjustableColumn=2,
                                     editable=0)
    endJointBtn = cmds.button(label='Set Selected',
                              command=partial(checkSelectedJoint,
                                              endJointText))

    boneIntSlider = cmds.intSliderGrp(label='Number of Bones: ',
                                      field=1,
                                      step=2,
                                      minValue=2,
                                      maxValue=100,
                                      value=10,
                                      adjustableColumn=3)
    jointChainOptions = cmds.optionMenuGrp(label='Joint Chain: ',
                                           changeCommand=partial(
                                               changeJointChain,
                                               boneIntSlider))
    cmds.menuItem(label='Create From Start/End Joints')
    cmds.menuItem(label='Use Existing Joint Chain')

    controlIntSlider = cmds.intSliderGrp(label='Number of Controls: ',
                                         field=1,
                                         step=2,
                                         minValue=2,
                                         maxValue=30,
                                         value=4,
                                         adjustableColumn=3)
    startColorSlider = cmds.colorSliderGrp(label='Start Control Color: ',
                                           rgb=(0, 0, 1))
    endColorSlider = cmds.colorSliderGrp(label='End Control Color: ',
                                         rgb=(0, 1, 0))

    volumePrsvCheckbox = cmds.checkBoxGrp(label='Preserve Volume: ', visible=0)

    splineTypeOptions = cmds.optionMenuGrp(
        label='Spline Type: ',
        changeCommand=partial(changeSplineType, controlIntSlider,
                              startColorSlider, endColorSlider,
                              volumePrsvCheckbox))
    cmds.menuItem(label='Cluster Controls')
    cmds.menuItem(label='Stretchy Spine')

    splinifyBtn = cmds.button(
        label='Splinify!',
        command=partial(executeSplinify, jointChainOptions, startJointText,
                        endJointText, boneIntSlider, splineTypeOptions,
                        controlIntSlider, startColorSlider, endColorSlider,
                        volumePrsvCheckbox),
        parent=form)
    applyBtn = cmds.button(label='Apply',
                           command=partial(applySplinify, jointChainOptions,
                                           startJointText, endJointText,
                                           boneIntSlider, splineTypeOptions,
                                           controlIntSlider, startColorSlider,
                                           endColorSlider, volumePrsvCheckbox),
                           parent=form)
    closeBtn = cmds.button(label='Close',
                           command="cmds.deleteUI('splinifyWin')",
                           parent=form)

    # Format UI elements
    cmds.formLayout(form,
                    edit=1,
                    attachForm=[(scroll, 'top', 5), (scroll, 'left', 5),
                                (scroll, 'right', 5), (splinifyBtn, 'left', 5),
                                (splinifyBtn, 'bottom', 5),
                                (applyBtn, 'bottom', 5),
                                (closeBtn, 'bottom', 5),
                                (closeBtn, 'right', 5)],
                    attachControl=[(scroll, 'bottom', 5, splinifyBtn),
                                   (splinifyBtn, 'right', 5, applyBtn),
                                   (closeBtn, 'left', 5, applyBtn)],
                    attachPosition=[
                        (applyBtn, 'left', 0, 34),
                        (applyBtn, 'right', 0, 66),
                    ])
    cmds.formLayout(scrollForm,
                    edit=1,
                    attachForm=[
                        (jointChainOptions, 'top', 25),
                        (jointChainOptions, 'left', 0),
                        (startJointText, 'left', 0),
                        (startJointBtn, 'right', 10),
                        (endJointText, 'left', 0),
                        (endJointText, 'right', 0),
                        (endJointBtn, 'right', 10),
                        (boneIntSlider, 'left', 0),
                        (boneIntSlider, 'right', 0),
                        (splineTypeOptions, 'left', 0),
                        (controlIntSlider, 'left', 0),
                        (controlIntSlider, 'right', 0),
                        (startColorSlider, 'left', 0),
                        (startColorSlider, 'right', 0),
                        (endColorSlider, 'left', 0),
                        (endColorSlider, 'right', 0),
                        (volumePrsvCheckbox, 'left', 0),
                        (volumePrsvCheckbox, 'right', 0),
                        (volumePrsvCheckbox, 'bottom', 5),
                    ],
                    attachControl=[
                        (jointChainOptions, 'bottom', 5, startJointText),
                        (startJointText, 'bottom', 5, endJointText),
                        (startJointText, 'right', 5, startJointBtn),
                        (startJointBtn, 'bottom', 5, endJointBtn),
                        (endJointText, 'right', 5, endJointBtn),
                        (endJointText, 'bottom', 5, boneIntSlider),
                        (endJointBtn, 'bottom', 5, boneIntSlider),
                        (boneIntSlider, 'bottom', 5, splineTypeOptions),
                        (splineTypeOptions, 'bottom', 5, controlIntSlider),
                        (controlIntSlider, 'bottom', 5, startColorSlider),
                        (startColorSlider, 'bottom', 5, endColorSlider),
                        (endColorSlider, 'bottom', 5, volumePrsvCheckbox),
                    ])
    cmds.showWindow(window)
Example #37
0
def getMeshLightAttrsAndShow():
    item = cmds.textScrollList('MeshLightList',q=True,si=True)[0]
    try:
        if cmds.getAttr(item+'.aiTranslator') == 'polyMesh':
            cmds.optionMenu('MeshLight_aiTranslator',e=True,sl=1)
        elif cmds.getAttr(item+'.aiTranslator') == 'mesh_light':
            cmds.optionMenu('MeshLight_aiTranslator',e=True,sl=2)
        elif cmds.getAttr(item+'.aiTranslator') == 'procedural':
            cmds.optionMenu('MeshLight_aiTranslator',e=True,sl=3)
        elif cmds.getAttr(item+'.aiTranslator') == 'quad':
            cmds.optionMenu('MeshLight_aiTranslator',e=True,sl=4)
        elif cmds.getAttr(item+'.aiTranslator') == 'cylinder':
            cmds.optionMenu('MeshLight_aiTranslator',e=True,sl=5)
        elif cmds.getAttr(item+'.aiTranslator') == 'disk':
            cmds.optionMenu('MeshLight_aiTranslator',e=True,sl=6)
    except:
        pass
    try:
        cmds.colorSliderGrp('MeshLight_aiColor',e=True,rgb=cmds.getAttr(item+'.color')[0])
    except:
        pass
    try:
        cmds.floatSliderGrp('MeshLight_aiIntensity',e=True,v=cmds.getAttr(item+'.intensity'))
    except:
        pass
    try:
        cmds.floatSliderGrp('MeshLight_aiExposure',e=True,v=cmds.getAttr(item+'.aiExposure'))
    except:
        pass
    try:
        cmds.checkBox('MeshLight_aiUseTemp',e=True,v=cmds.getAttr(item+'.aiUseColorTemperature'))
    except:
        pass
    try:
        cmds.floatSliderGrp('MeshLight_aiTemperature',e=True,v=cmds.getAttr(item+'.aiColorTemperature'))
    except:
        pass
    try:
        cmds.checkBox('MeshLight_aiVisible',e=True,v=cmds.getAttr(item+'.lightVisible'))
    except:
        pass
    try:
        cmds.intFieldGrp('MeshLight_aiSample',e=True,v1=cmds.getAttr(item+'.aiSamples'))
    except:
        pass
    try:
        cmds.checkBox('MeshLight_aiNormalize',e=True,v=cmds.getAttr(item+'.aiNormalize'))
    except:
        pass
    try:
        cmds.checkBox('MeshLight_aiCastShadows',e=True,v=cmds.getAttr(item+'.aiCastShadows'))
    except:
        pass
    try:
        cmds.floatSliderGrp('MeshLight_aiShadowDensity',e=True,v=cmds.getAttr(item+'.aiShadowDensity'))
    except:
        pass
    try:
        cmds.colorSliderGrp('MeshLight_aiShadowColor',e=True,rgb=cmds.getAttr(item+'.aiShadowColor')[0])
    except:
        pass
    try:
        cmds.checkBox('MeshLight_aiCastVolumeShadow',e=True,v=cmds.getAttr(item+'.aiCastVolumetricShadows'))
    except:
        pass
    try:
        cmds.intFieldGrp('MeshLight_aiVolumeSample',e=True,v1=cmds.getAttr(item+'.aiVolumeSamples'))
    except:
        pass
    try:
        cmds.textFieldGrp('MeshLight_aiAov',e=True,tx=cmds.getAttr(item+'.aiAov'))
    except:
        pass
    if cmds.radioButton('Single_Check',q=True,sl=True):
        cmds.select(item,r=True)
    elif cmds.radioButton('Double_Check',q=True,sl=True):
        pass
    refreshCounts()
Example #38
0
    def set_color(self, color):
        color = QtGui.QColor(color)

        cmds.colorSliderGrp(self._name, e=True, rgbValue=(color.redF(), color.greenF(), color.blueF()))
        self.on_color_changed()
Example #39
0
    def uiCreate(self):

        self.onCloseClicked()

        self.window = m.window(WIN_NAME,
                               title='Maya Window',
                               maximizeButton=False)

        uiLAY_mainForm = m.formLayout()

        self.uiLAY_mainScroll = m.scrollLayout(childResizable=True)

        mainColumn = m.columnLayout(
            adjustableColumn=True)  # main column layout with frames

        # --------
        self.uiLAY_frameCheckBoxes = self.uiCreateFrame(
            'uiLAY_frameCheckBoxes', 'Check Boxes (PMCheckBox)')

        m.columnLayout()

        m.separator(style='none', height=2)

        m.rowLayout(numberOfColumns=3)

        m.separator(width=140, style='none')
        self.uiCHK_test1 = m.checkBox('uiCHK_test1', label='test1')
        self.uiCHK_test2 = m.checkBox('uiCHK_test2', label='test2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameCheckBoxGroups = self.uiCreateFrame(
            'uiLAY_frameCheckBoxGroups', 'Check Box Groups (PMCheckBoxGrp#)')

        m.columnLayout()

        m.separator(style='none', height=2)
        self.uiCHKGRP_test1 = m.checkBoxGrp('uiCHKGRP_test1',
                                            numberOfCheckBoxes=1,
                                            label='PMCheckBoxGrp1',
                                            label1='test1')
        self.uiCHKGRP_test2 = m.checkBoxGrp('uiCHKGRP_test2',
                                            numberOfCheckBoxes=2,
                                            label='PMCheckBoxGrp2',
                                            labelArray2=('test1', 'test2'))
        self.uiCHKGRP_test3 = m.checkBoxGrp('uiCHKGRP_test3',
                                            numberOfCheckBoxes=3,
                                            label='PMCheckBoxGrp3',
                                            labelArray3=('test1', 'test2',
                                                         'test3'))
        self.uiCHKGRP_test4 = m.checkBoxGrp('uiCHKGRP_test4',
                                            numberOfCheckBoxes=4,
                                            label='PMCheckBoxGrp4',
                                            labelArray4=('test1', 'test2',
                                                         'test3', 'test4'))

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameColorSliders = self.uiCreateFrame(
            'uiLAY_frameColorSliders',
            'Color Slider Groups (PMColorSliderGrp)')

        m.columnLayout()

        m.separator(style='none', height=2)
        self.uiCLRGRP_test1 = m.colorSliderGrp('uiCLRGRP_test1', label='test1')
        self.uiCLRGRP_test2 = m.colorSliderGrp('uiCLRGRP_test2', label='test2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameFloatFields = self.uiCreateFrame(
            'uiLAY_frameFloatFields', 'Float Fields (PMFloatField)')

        m.columnLayout()

        m.separator(style='none', height=2)

        m.rowLayout(numberOfColumns=3)
        m.separator(width=140, style='none')
        self.uiFLF_test1 = m.floatField('uiFLF_test1')
        self.uiFLF_test2 = m.floatField('uiFLF_test2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameFloatFieldGroups = self.uiCreateFrame(
            'uiLAY_frameFloatFieldGroups',
            'Float Field Groups (PMFloatFieldGrp#)')

        m.columnLayout()

        m.separator(style='none', height=2)
        self.uiFLFGRP_test1 = m.floatFieldGrp('uiFLFGRP_test1',
                                              numberOfFields=1,
                                              label='PMFloatFieldGrp1')
        self.uiFLFGRP_test2 = m.floatFieldGrp('uiFLFGRP_test2',
                                              numberOfFields=2,
                                              label='PMFloatFieldGrp2')
        self.uiFLFGRP_test3 = m.floatFieldGrp('uiFLFGRP_test3',
                                              numberOfFields=3,
                                              label='PMFloatFieldGrp3')
        self.uiFLFGRP_test4 = m.floatFieldGrp('uiFLFGRP_test4',
                                              numberOfFields=4,
                                              label='PMFloatFieldGrp4')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameFloatScrollBars = self.uiCreateFrame(
            'uiLAY_frameFloatScrollBars',
            'Float Scroll Bars (PMFloatScrollBar)')

        m.columnLayout(adjustableColumn=True)

        m.separator(style='none', height=2)
        self.uiFLSCRL_test1 = m.floatScrollBar('uiFLSCRL_test1')
        self.uiFLSCRL_test2 = m.floatScrollBar('uiFLSCRL_test2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameFloatSliders = self.uiCreateFrame(
            'uiLAY_frameFloatSliders', 'Float Sliders (PMFloatSlider)')

        m.columnLayout(adjustableColumn=True)

        m.separator(style='none', height=2)
        self.uiFLTSLD_test1 = m.floatSlider('uiFLTSLD_test1')
        self.uiFLTSLD_test2 = m.floatSlider('uiFLTSLD_test2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameFloatSliderGroups = self.uiCreateFrame(
            'uiLAY_frameFloatSliderGroups',
            'Float Slider Groups (PMFloatSliderGrp)')
        m.columnLayout()
        m.separator(style='none', height=2)
        self.uiFLSGRP_test1 = m.floatSliderGrp('uiFLSGRP_test1',
                                               label='test1',
                                               field=True)
        self.uiFLSGRP_test2 = m.floatSliderGrp('uiFLSGRP_test2',
                                               label='test2',
                                               field=True)

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameIconTextCheckBoxes = self.uiCreateFrame(
            'uiLAY_frameIconTextCheckBoxes',
            'Icon Text Check Boxes (PMIconTextCheckBox)')

        m.columnLayout()

        m.rowLayout(numberOfColumns=3)

        m.separator(style='none', width=140)
        self.uiITCHK_test1 = m.iconTextCheckBox('uiITCHK_test1',
                                                style='iconAndTextHorizontal',
                                                label='cube',
                                                image1='cube')
        self.uiITCHK_test2 = m.iconTextCheckBox('uiITCHK_test2',
                                                style='iconAndTextHorizontal',
                                                label='cone',
                                                image1='cone')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameIconTextRadioButtons = self.uiCreateFrame(
            'uiLAY_frameIconTextRadioButtons',
            'Icon Text Radio Buttons (PMIconTextRadioButton)')

        m.columnLayout()

        m.rowLayout(numberOfColumns=4)

        m.separator(style='none', width=140)
        m.iconTextRadioCollection()
        self.uiITRAD_test1 = m.iconTextRadioButton(
            'uiITRAD_test1',
            style='iconAndTextHorizontal',
            label='cube',
            image1='cube')
        self.uiITRAD_test2 = m.iconTextRadioButton(
            'uiITRAD_test2',
            style='iconAndTextHorizontal',
            label='cone',
            image1='cone')
        self.uiITRAD_test3 = m.iconTextRadioButton(
            'uiITRAD_test3',
            style='iconAndTextHorizontal',
            label='torus',
            image1='torus')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameIconTextScrollLists = self.uiCreateFrame(
            'uiLAY_frameIconTextScrollLists',
            'Icon Text Scroll Lists (PMIconTextScrollList)')

        m.columnLayout()

        m.rowLayout(numberOfColumns=3)

        m.separator(style='none', width=140)
        self.uiITSLST_test1 = m.iconTextScrollList(
            'uiITSLST_test1',
            allowMultiSelection=True,
            append=('one', 'two', 'three', 'four', 'five', 'six', 'seven',
                    'eight', 'nine', 'ten'))
        self.uiITSLST_test2 = m.iconTextScrollList(
            'uiITSLST_test2',
            allowMultiSelection=True,
            append=('one', 'two', 'three', 'four', 'five', 'six', 'seven',
                    'eight', 'nine', 'ten'))

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameIntFields = self.uiCreateFrame(
            'uiLAY_frameIntFields', 'Int Fields (PMIntField)')

        m.columnLayout()

        m.separator(style='none', height=2)

        m.rowLayout(numberOfColumns=3)

        m.separator(width=140, style='none')
        self.uiINF_test1 = m.intField('uiINF_test1')
        self.uiINF_test2 = m.intField('uiINF_test2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameIntFieldGroups = self.uiCreateFrame(
            'uiLAY_frameIntFieldGroups', 'Int Field Groups (PMIntFieldGrp#)')

        m.columnLayout()

        m.separator(style='none', height=2)
        self.uiINFGRP_test1 = m.intFieldGrp('uiINFGRP_test1',
                                            numberOfFields=1,
                                            label='PMIntFieldGrp1')
        self.uiINFGRP_test2 = m.intFieldGrp('uiINFGRP_test2',
                                            numberOfFields=2,
                                            label='PMIntFieldGrp2')
        self.uiINFGRP_test3 = m.intFieldGrp('uiINFGRP_test3',
                                            numberOfFields=3,
                                            label='PMIntFieldGrp3')
        self.uiINFGRP_test4 = m.intFieldGrp('uiINFGRP_test4',
                                            numberOfFields=4,
                                            label='PMIntFieldGrp4')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameIntScrollBars = self.uiCreateFrame(
            'uiLAY_frameIntScrollBars', 'Int Scroll Bars (PMIntScrollBar)')

        m.columnLayout(adjustableColumn=True)

        m.separator(style='none', height=2)
        self.uiINSCRL_test1 = m.intScrollBar('uiINSCRL_test1')
        self.uiINSCRL_test2 = m.intScrollBar('uiINSCRL_test2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameIntSliders = self.uiCreateFrame(
            'uiLAY_frameIntSliders', 'Int Sliders (PMIntSlider)')

        m.columnLayout(adjustableColumn=True)

        m.separator(style='none', height=2)
        self.uiINTSLD_test1 = m.intSlider('uiINTSLD_test1')
        self.uiINTSLD_test2 = m.intSlider('uiINTSLD_test2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameIntSliderGroups = self.uiCreateFrame(
            'uiLAY_frameIntSliderGroups', 'Int Slider Groups (PMIntSliderGrp)')

        m.columnLayout()

        m.separator(style='none', height=2)
        self.uiINSGRP_test1 = m.intSliderGrp('uiINSGRP_test1',
                                             label='test1',
                                             field=True)
        self.uiINSGRP_test2 = m.intSliderGrp('uiINSGRP_test2',
                                             label='test2',
                                             field=True)

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameOptionMenus = self.uiCreateFrame(
            'uiLAY_frameOptionMenus', 'Option Menus (PMOptionMenu)')

        m.columnLayout()

        m.separator(style='none', height=2)

        m.rowLayout(numberOfColumns=3)

        m.separator(width=110, style='none')
        self.uiOPTMNU_test1 = m.optionMenu('uiOPTMNU_test1', label='test1')
        m.menuItem(label='one')
        m.menuItem(label='two')
        m.menuItem(label='three')
        self.uiOPTMNU_test2 = m.optionMenu('uiOPTMNU_test2', label='test2')
        m.menuItem(label='four')
        m.menuItem(label='five')
        m.menuItem(label='six')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameOptionMenuGroups = self.uiCreateFrame(
            'uiLAY_frameOptionMenuGroups',
            'Option Menus Groups (PMOptionMenuGrp)')

        m.columnLayout()

        m.separator(style='none', height=2)
        self.uiOPMGRP_test1 = m.optionMenuGrp('uiOPMGRP_test1',
                                              label='test1',
                                              extraLabel='extraLabel')
        m.menuItem(label='one')
        m.menuItem(label='two')
        m.menuItem(label='three')
        self.uiOPMGRP_test2 = m.optionMenuGrp('uiOPMGRP_test2',
                                              label='test2',
                                              extraLabel='extraLabel')
        m.menuItem(label='four')
        m.menuItem(label='five')
        m.menuItem(label='six')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameRadioButtons = self.uiCreateFrame(
            'uiLAY_frameRadioButtons', 'Radio Buttons (PMRadioButton)')

        m.columnLayout()

        m.rowLayout(numberOfColumns=4)

        m.separator(style='none', width=140)
        m.radioCollection()
        self.uiRAD_test1 = m.radioButton('uiRAD_test1', label='test1')
        self.uiRAD_test2 = m.radioButton('uiRAD_test2', label='test2')
        self.uiRAD_test3 = m.radioButton('uiRAD_test3', label='test3')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameRadioButtonGroups = self.uiCreateFrame(
            'uiLAY_frameRadioButtonGroups',
            'Radio Button Groups (PMRadioButtonGrp#)')

        m.columnLayout()
        m.separator(style='none', height=2)
        self.uiRADGRP_test1 = m.radioButtonGrp('uiRADGRP_test1',
                                               numberOfRadioButtons=1,
                                               label='PMRadioButtonGrp1',
                                               label1='test1')
        self.uiRADGRP_test2 = m.radioButtonGrp('uiRADGRP_test2',
                                               numberOfRadioButtons=2,
                                               label='PMRadioButtonGrp2',
                                               labelArray2=('test1', 'test2'))
        self.uiRADGRP_test3 = m.radioButtonGrp('uiRADGRP_test3',
                                               numberOfRadioButtons=3,
                                               label='PMRadioButtonGrp3',
                                               labelArray3=('test1', 'test2',
                                                            'test3'))
        self.uiRADGRP_test4 = m.radioButtonGrp('uiRADGRP_test4',
                                               numberOfRadioButtons=4,
                                               label='PMRadioButtonGrp4',
                                               labelArray4=('test1', 'test2',
                                                            'test3', 'test4'))

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameSymbolCheckBoxes = self.uiCreateFrame(
            'uiLAY_frameSymbolCheckBoxes',
            'Symbol Check Boxes (PMSymbolCheckBox)')

        m.columnLayout()

        m.rowLayout(numberOfColumns=3)

        m.separator(style='none', width=140)
        self.uiSYMCHK_test1 = m.symbolCheckBox('uiSYMCHK_test1',
                                               image='polyCube')
        self.uiSYMCHK_test2 = m.symbolCheckBox('uiSYMCHK_test2',
                                               image='polyCone')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameScriptTables = self.uiCreateFrame(
            'uiLAY_frameScriptTables', 'Script Tables (PMScriptTable)')

        m.columnLayout()

        m.rowLayout(numberOfColumns=3)

        m.separator(style='none', width=140)
        self.uiSCRTBL_test1 = m.scriptTable('uiSCRTBL_test1',
                                            selectionMode=3,
                                            rows=4,
                                            columns=2)
        self.uiSCRTBL_test2 = m.scriptTable('uiSCRTBL_test2',
                                            selectionMode=3,
                                            rows=4,
                                            columns=2)

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameScrollField = self.uiCreateFrame(
            'uiLAY_frameScrollField', 'Scroll Field (PMScrollField)')

        m.columnLayout()

        m.rowLayout(numberOfColumns=3)

        m.separator(style='none', width=140)
        self.uiSCRFLD_test1 = m.scrollField('uiSCRFLD_test1', wordWrap=True)
        self.uiSCRFLD_test2 = m.scrollField('uiSCRFLD_test2', wordWrap=True)

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameShelfTabLayout = self.uiCreateFrame(
            'uiLAY_frameShelfTabLayout', 'Shelf Tab Layout (PMShelfTabLayout)')

        m.columnLayout(adjustableColumn=True)

        self.uiSHLTAB_test1 = m.shelfTabLayout()

        m.shelfLayout('test1')
        m.setParent('..')
        m.shelfLayout('test2')
        m.setParent('..')
        m.shelfLayout('test3')
        m.setParent('..')

        m.setParent('..')

        self.uiSHLTAB_test2 = m.shelfTabLayout()

        m.shelfLayout('test4')
        m.setParent('..')
        m.shelfLayout('test5')
        m.setParent('..')
        m.shelfLayout('test6')
        m.setParent('..')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameTabLayout = self.uiCreateFrame(
            'uiLAY_frameTabLayout', 'Tab Layout (PMTabLayout)')

        m.columnLayout(adjustableColumn=True)

        self.uiTAB_test1 = m.tabLayout()

        uiLAY_tabRow1 = m.rowLayout(numberOfColumns=1)
        m.setParent('..')
        uiLAY_tabRow2 = m.rowLayout(numberOfColumns=1)
        m.setParent('..')
        uiLAY_tabRow3 = m.rowLayout(numberOfColumns=1)
        m.setParent('..')

        m.setParent('..')

        m.tabLayout(self.uiTAB_test1,
                    edit=True,
                    tabLabel=(
                        (uiLAY_tabRow1, 'test1'),
                        (uiLAY_tabRow2, 'test2'),
                        (uiLAY_tabRow3, 'test3'),
                    ))

        self.uiTAB_test2 = m.tabLayout()

        uiLAY_tabRow4 = m.rowLayout(numberOfColumns=1)
        m.setParent('..')
        uiLAY_tabRow5 = m.rowLayout(numberOfColumns=1)
        m.setParent('..')
        uiLAY_tabRow6 = m.rowLayout(numberOfColumns=1)
        m.setParent('..')

        m.setParent('..')

        m.tabLayout(self.uiTAB_test2,
                    edit=True,
                    tabLabel=(
                        (uiLAY_tabRow4, 'test4'),
                        (uiLAY_tabRow5, 'test5'),
                        (uiLAY_tabRow6, 'test6'),
                    ))

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameTextFields = self.uiCreateFrame(
            'uiLAY_frameTextFields', 'Text Fields (PMTextField)')

        m.columnLayout()

        m.separator(style='none', height=2)

        m.rowLayout(numberOfColumns=3)

        m.separator(width=140, style='none')
        self.uiTXT_test1 = m.textField('uiTXT_test1')
        self.uiTXT_test2 = m.textField('uiTXT_test2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameTextFieldButtonGroups = self.uiCreateFrame(
            'uiLAY_frameTextFieldButtonGroups',
            'Text Field Button Groups (PMTextFieldButtonGrp)')

        m.columnLayout()

        m.separator(style='none', height=2)
        self.uiTXBTGR_test1 = m.textFieldButtonGrp('uiTXBTGR_test1',
                                                   label='test1',
                                                   buttonLabel='button1')
        self.uiTXBTGR_test2 = m.textFieldButtonGrp('uiTXBTGR_test2',
                                                   label='test2',
                                                   buttonLabel='button2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameTextFieldGroups = self.uiCreateFrame(
            'uiLAY_frameTextFieldGroups', 'Text Field Groups (PMTextFieldGrp)')

        m.columnLayout()

        m.separator(style='none', height=2)
        self.uiTXTGRP_test1 = m.textFieldGrp('uiTXTGRP_test1', label='test1')
        self.uiTXTGRP_test2 = m.textFieldGrp('uiTXTGRP_test2', label='test2')

        m.setParent(mainColumn)

        # --------
        self.uiLAY_frameTextScrollLists = self.uiCreateFrame(
            'uiLAY_frameTextScrollLists',
            'Text Scroll Lists (PMTextScrollList)')

        m.columnLayout()

        m.rowLayout(numberOfColumns=3)

        m.separator(style='none', width=140)
        self.uiTXTLST_test1 = m.textScrollList(
            'uiTXTLST_test1',
            allowMultiSelection=True,
            append=('one', 'two', 'three', 'four', 'five', 'six', 'seven',
                    'eight', 'nine', 'ten'))
        self.uiTXTLST_test2 = m.textScrollList(
            'uiTXTLST_test2',
            allowMultiSelection=True,
            append=('one', 'two', 'three', 'four', 'five', 'six', 'seven',
                    'eight', 'nine', 'ten'))

        # --------
        m.setParent(uiLAY_mainForm)

        self.uiBTN_savePrefs = m.button(label='Save Prefs',
                                        height=MAIN_BUTTONS_HEIGHT,
                                        command=self.onSavePrefsClicked)

        self.uiBTN_loadPrefs = m.button(label='Load Prefs',
                                        height=MAIN_BUTTONS_HEIGHT,
                                        command=self.onLoadPrefsClicked)

        self.uiBTN_resetPrefs = m.button(label='Reset Prefs',
                                         height=MAIN_BUTTONS_HEIGHT,
                                         command=self.onResetPrefsClicked)

        m.setParent('..')  # -> window

        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachForm=[(self.uiLAY_mainScroll, 'top', 2)])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachForm=[(self.uiLAY_mainScroll, 'left', 2)])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachForm=[(self.uiLAY_mainScroll, 'right', 2)])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachControl=[(self.uiLAY_mainScroll, 'bottom', 2,
                                     self.uiBTN_savePrefs)])

        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachNone=[(self.uiBTN_savePrefs, 'top')])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachForm=[(self.uiBTN_savePrefs, 'left', 2)])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachPosition=[(self.uiBTN_savePrefs, 'right', 2, 33)])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachForm=[(self.uiBTN_savePrefs, 'bottom', 2)])

        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachNone=[(self.uiBTN_loadPrefs, 'top')])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachPosition=[(self.uiBTN_loadPrefs, 'left', 2, 33)])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachPosition=[(self.uiBTN_loadPrefs, 'right', 2, 66)])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachForm=[(self.uiBTN_loadPrefs, 'bottom', 2)])

        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachNone=[(self.uiBTN_resetPrefs, 'top')])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachPosition=[(self.uiBTN_resetPrefs, 'left', 2, 66)])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachForm=[(self.uiBTN_resetPrefs, 'right', 2)])
        m.formLayout(uiLAY_mainForm,
                     e=True,
                     attachForm=[(self.uiBTN_resetPrefs, 'bottom', 2)])

        m.showWindow(self.window)
Example #40
0
 def setWidth(self, width):
     """sets the size of the color widget, dpi scale handled, will scale with cmds as pyside has issues overriding
     *Not Tested should work"""
     self.colorWidth = width
     cmds.colorSliderGrp(e=True, columnWidth=[1, self.colorWidth])
Example #41
0
def roundedBlockWithHoles():
    # set up block dimensions
    height = 3
    width = 1  #bump
    length = cmds.intSliderGrp('roundedBlockWithHolesLength', q=True, v=True)
    rgb = cmds.colorSliderGrp('roundedBlockWithHolesColour',
                              q=True,
                              rgbValue=True)

    # name
    nsTmp = "RoundedBlockWithHoles" + str(rnd.randint(1000, 9999))

    cmds.select(clear=True)
    cmds.namespace(add=nsTmp)
    cmds.namespace(set=nsTmp)

    # define cube's size
    cubeSizeX = width * 0.8
    cubeSizeZ = length * 0.8
    cubeSizeY = height * 0.32

    # create a cube
    cube = cmds.polyCube(h=cubeSizeY, w=cubeSizeX, d=cubeSizeZ)

    # move it up
    cmds.move((cubeSizeY / 2.0), moveY=True)

    # create holes
    for i in range(width):
        for j in range(length):
            # create cylinder in the place of a hole
            hole = cmds.polyCylinder(r=0.25, h=height / 2.0)

            # rotate and position it
            cmds.rotate(90, rotateX=True, a=True)
            cmds.rotate(90, rotateY=True, a=True)

            cmds.move((cubeSizeY / 2.0), moveY=True, a=True)
            cmds.move(((i * 0.8) - (cubeSizeX / 2.0) + 0.4),
                      moveX=True,
                      a=True)
            cmds.move(((j * 0.8) - (cubeSizeZ / 2.0)), moveZ=True, a=True)

            # remove it from the base block
            cube = cmds.polyCBoolOp(cube, hole, op=2, caching=False, ch=False)

    # add cylinders to round corners
    # right side
    rCylind = cmds.polyCylinder(r=cubeSizeY * 0.5, h=cubeSizeX)
    cmds.rotate(90, rotateX=True, a=True)
    cmds.rotate(90, rotateY=True, a=True)
    cmds.move((cubeSizeX / 2.0 + 0.079), moveY=True, a=True)
    cmds.move((-cubeSizeZ * 0.5), moveZ=True, a=True)
    # create a hole in it
    rHole = cmds.polyCylinder(r=0.25, h=height / 2.0)
    cmds.rotate(90, rotateX=True, a=True)
    cmds.rotate(90, rotateY=True, a=True)
    cmds.move((cubeSizeY / 2.0), moveY=True, a=True)
    cmds.move(((0 * 0.8) - (cubeSizeX / 2.0) + 0.4), moveX=True, a=True)
    cmds.move(((0 * 0.8) - (cubeSizeZ / 2.0)), moveZ=True, a=True)
    rCylind = cmds.polyCBoolOp(rCylind, rHole, op=2, caching=False, ch=False)

    # left side
    lCylind = cmds.polyCylinder(r=cubeSizeY * 0.5, h=cubeSizeX)
    cmds.rotate(90, rotateX=True, a=True)
    cmds.rotate(90, rotateY=True, a=True)
    cmds.move((cubeSizeX / 2.0 + 0.079), moveY=True, a=True)
    cmds.move((cubeSizeZ * 0.5), moveZ=True, a=True)
    # create a hole in it
    lHole = cmds.polyCylinder(r=0.25, h=height / 2.0)
    cmds.rotate(90, rotateX=True, a=True)
    cmds.rotate(90, rotateY=True, a=True)
    cmds.move((cubeSizeY / 2.0), moveY=True, a=True)
    cmds.move(((width * 0.8) - cubeSizeX), moveX=True, a=True)
    cmds.move(((length * 0.8) - (cubeSizeZ / 2.0)), moveZ=True, a=True)
    lCylind = cmds.polyCBoolOp(lCylind, lHole, op=2, caching=False, ch=False)

    # subtract a cylinder from left side of the cube
    lCubeHole = cmds.polyCylinder(r=0.25, h=height / 2.0)
    cmds.rotate(90, rotateX=True, a=True)
    cmds.rotate(90, rotateY=True, a=True)
    cmds.move((cubeSizeY / 2.0), moveY=True, a=True)
    cmds.move(((width * 0.8) - cubeSizeX), moveX=True, a=True)
    cmds.move(((length * 0.8) - (cubeSizeZ / 2.0)), moveZ=True, a=True)
    cube = cmds.polyCBoolOp(cube, lCubeHole, op=2, caching=False, ch=False)

    # add material
    myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat")
    cmds.setAttr(nsTmp + ":blckMat.color",
                 rgb[0],
                 rgb[1],
                 rgb[2],
                 type='double3')

    cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False)
    cmds.delete(ch=True)

    cmds.hyperShade(assign=(nsTmp + ":blckMat"))
    cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
Example #42
0
def tableSetup():  #This will be called just one. At the startup.
    """
    Sets up the table board with three poles. Simple.

    Keyword arguments:
    NONE

    On Exit:  The geometry for the pegs and disks is created.
    """
    global pLeft, pMiddle, pRight, pLeftHigh, pMiddleHigh, pRightHigh, pegA, pegB, pegC

    # Defining the coordenates for each peg.
    positionList = [(-3.0, 0.0, 0.0), (0.0, 0.0, 0.0), (3.0, 0.0, 0.0),
                    (-3.0, 4.0, 0.0), (0.0, 4.0, 0.0), (3.0, 4.0, 0.0)]

    # pPos refers to an absolute position in the world space which is where the disks are stacked to.
    pLeft = positionList[0]
    pMiddle = positionList[1]
    pRight = positionList[2]

    # pPosHigh refers to an absoltue position in the world space that is on top of the peg.
    pLeftHigh = positionList[3]
    pMiddleHigh = positionList[4]
    pRightHigh = positionList[5]

    global colourArrayBoard, colourArrayPegs, colourArrayDisks
    colourArrayBoard = cmds.colorSliderGrp('rgb_board', q=True, rgb=True)
    colourArrayPegs = cmds.colorSliderGrp('rgb_pegs', q=True, rgb=True)
    colourArrayDisks = cmds.colorSliderGrp('rgb_disks', q=True, rgb=True)

    # Creating lists to put the disks into.
    pegA = []
    pegB = []
    pegC = []

    # Creating the table.
    global board
    board = cmds.polyCube(n='base', w=10, h=0.5, d=4)[0]
    cmds.move(0, 0.25, 0)
    # Adds the created geometry to the super list.
    global superList
    superList += [u'base']
    print 'board (' + board + ') has been added to superList. Now superList contains:', superList
    # Calls the method to apply the shader.
    import materials
    reload(materials)
    shadingObjs = materials.applyShaderBoard(board, colourArrayBoard)

    global superList
    superList += shadingObjs[0], shadingObjs[1]
    print shadingObjs[0], shadingObjs[
        1], "(314) have been added to superList. Now superList contains:", superList

    # Creating the pegs and placing them into the right place.
    poleNameList = ['A', 'B', 'C']
    colourArray = [1.0, 0.0, 0.0]
    for i in range(0, 3):
        pole = cmds.polyCylinder(n=poleNameList[i], radius=0.05, height=3.5)[0]
        # I distribute them alongside the table.
        cmds.move(-3 + 3 * i, 2, 0)

        global superList
        superList += pole
        print 'pole (' + pole + ') has been added to superList. Now superList contains:', superList
        import materials
        reload(materials)
        shadingObjs = materials.applyShaderPeg(pole, colourArrayPegs)

        global superList
        superList += shadingObjs[0], shadingObjs[1]
        print shadingObjs[0], shadingObjs[
            1], "(330) have been added to superList. Now superList contains:", superList
    def update_ui_elements(cls):
        if not cmds.window(cls.WINDOW_NAME, exists=True):
            return

        camera_name = ZShotMask.get_camera_name()
        if not camera_name:
            camera_name = cls.ALL_CAMERAS
        cmds.textFieldButtonGrp(cls.camera_name, e=True, text=camera_name)

        label_text = ZShotMask.get_label_text()
        for i in range(len(cls.label_text_ctrls)):
            cmds.textFieldGrp(cls.label_text_ctrls[i],
                              e=True,
                              text=label_text[i])

        color = ZShotMask.get_label_color()
        label_color = [color[0], color[1], color[2]]
        label_alpha = [color[3], color[3], color[3]]

        color = ZShotMask.get_border_color()
        border_color = [color[0], color[1], color[2]]
        border_alpha = [color[3], color[3], color[3]]

        cmds.textFieldButtonGrp(cls.label_font_tfg,
                                e=True,
                                text=ZShotMask.get_label_font())
        cmds.colorSliderGrp(cls.label_color_csg, e=True, rgbValue=label_color)
        cmds.colorSliderGrp(cls.label_trans_csg, e=True, rgbValue=label_alpha)
        cmds.floatField(cls.label_scale,
                        e=True,
                        value=ZShotMask.get_label_scale())

        border_visibility = ZShotMask.get_border_visible()
        cmds.checkBoxGrp(cls.border_vis_cbg,
                         e=True,
                         value1=border_visibility[0])
        cmds.checkBoxGrp(cls.border_vis_cbg,
                         e=True,
                         value2=border_visibility[1])
        cmds.colorSliderGrp(cls.border_color_csg,
                            e=True,
                            rgbValue=border_color)
        cmds.colorSliderGrp(cls.border_trans_csg,
                            e=True,
                            rgbValue=border_alpha)
        cmds.floatField(cls.border_scale,
                        e=True,
                        value=ZShotMask.get_border_scale())

        counter_position = ZShotMask.get_counter_position()
        counter_enabled = counter_position == 1 or counter_position == 3 or counter_position == 4 or counter_position == 6
        radio_btn_index = 0
        if counter_position == 1:
            radio_btn_index = 1
        elif counter_position == 3:
            radio_btn_index = 2
        elif counter_position == 4:
            radio_btn_index = 3
        elif counter_position == 6:
            radio_btn_index = 4

        cmds.checkBoxGrp(cls.counter_vis_cbg, e=True, value1=counter_enabled)
        cmds.radioButtonGrp(cls.counter_position,
                            e=True,
                            select=radio_btn_index)
        cmds.intField(cls.counter_padding,
                      e=True,
                      value=ZShotMask.get_counter_padding())
def createUI( windowname, pApplyCallback):
    '''Creates the user interface which will recieve various inputs from the user which will later be used to build the tree in the treegen function.
    The user can pick the treetype, the colour of the tree and leaves, the material, the length, the starting angle, the number of iterations, whether they want leaves and apples, 
    the type of leaf, the size of the leaf, and the thickness of the leaves.
    There are also 4 buttons,
    Apply will pass the control path names
    
       windowname	    : the name that will be displayed on the GUI
       pApplyCallback	: the function that the inputs will be passed to when the user clicks apply
    '''
    
    windowID = 'mainwindow'
    
    if cmds.window( windowID, exists=True):
        cmds.deleteUI(windowID)
    cmds.window( windowID, title= windowname , sizeable=False, resizeToFitChildren=True)
    
    cmds.columnLayout( adjustableColumn=True )
    
    #the user interface image that will appear at the top of the window
    submission_path = "/home/s5113911/PythonProgramming"
    cmds.image( w =10, h = 150, i= submission_path+"/Project/panarama4.jpg")
    cmds.separator(h =10, style = 'none')
       
    cmds.text( label ='Tree Type:',align='left')
    
    #controls to choose the treetype
    treetype =cmds.radioButtonGrp( label='', labelArray4=['Standard', 'Dispersed', 'Curved', 'Slant'], numberOfRadioButtons=4, select = 1 )
    treetype2 = cmds.radioButtonGrp( numberOfRadioButtons=2, shareCollection=treetype, label='', labelArray2=['Square', 'Curved2'] )
    
    cmds.separator(h =10, style = 'none')
    
    #control to choose the colour of the tree
    rgbs = cmds.colorSliderGrp( label='Tree Colour:',columnAlign=(1,'left'), rgb=(0.2, 0.08, 0.0) )
    
    cmds.separator(h =10, style = 'none')
    
    #control to choose the colour of the leaves
    rgbleaves = cmds.colorSliderGrp( label='Leaves Colour:',columnAlign=(1,'left'), rgb=(0.06, 0.2, 0.01) )
    
    cmds.separator(h =10, style = 'none')
    cmds.text( label ='Material:',align='left')
    
    #control to choose the material of the tree
    materiall =cmds.radioButtonGrp( label='', labelArray3=['Lambert', 'Blinn', 'Phong'], numberOfRadioButtons=3, select = 1 )
    
    cmds.separator(h =10, style = 'none')
    
    #slider controls to specify the length, angle and iterations of the tree, (iterations meaning th number of the types the chosen l-system will be iterated
    length = cmds.floatSliderGrp(label='Height:', minValue=0.05, maxValue=1.0, value=0.6, step=0.01, field=True, columnAlign=[1,'left'])
    angle = cmds.floatSliderGrp(label='Angle:', minValue=10, maxValue=60, value=25, step=0.01, field=True, columnAlign=[1,'left'])
    iterations = cmds.intSliderGrp( label='Iterations:', minValue=1, maxValue=5, value=4, step=1, field = True, columnAlign=[1,'left'] )
    
    cmds.separator(h =10, style = 'none')
    
    #control to enable or disable apples on the tree
    applecheck = cmds.checkBoxGrp( numberOfCheckBoxes=1, label='Fruit?:  ', columnAlign=[1,'left']  )
    
    cmds.separator(h =10, style = 'none')
    cmds.separator(h =10, style = 'none')
    
    cmds.text( label ='Leaf Type:',align='left')
    #control to enable or disable apples on the tree
    leaves =cmds.radioButtonGrp( label='', labelArray2=['Default', 'Maple'], numberOfRadioButtons=2, select = 1, enable = True )
    
    cmds.separator(h =10, style = 'none')
    cmds.separator(h =10, style = 'none')
    #control to enable or disable leaves on the tree
    leafcheck = cmds.checkBoxGrp( numberOfCheckBoxes=1, label='Leaves?:  ', columnAlign=[1,'left'], value1 =True, changeCommand1=functools.partial( toggleRadio, leaves )  )
    
    cmds.separator(h =10, style = 'none')
    cmds.separator(h =10, style = 'none')
    cmds.text( label ='Leaf Material:',align='left')
    #control to choose the material of the leaves
    materialleaves =cmds.radioButtonGrp( label='', labelArray3=['Lambert', 'Blinn', 'Phong'], numberOfRadioButtons=3, select = 1 )

    cmds.separator(h =10, style = 'none')
    cmds.separator(h =10, style = 'none')
    #control to specify a scaling factor for the leaves
    leafscale = cmds.floatSliderGrp( label='Leafscale:', minValue=0.1, maxValue=3, value=1.2, step=0.01, field = True, columnAlign=[1,'left'])
    
    cmds.separator(h =10, style = 'none')
    cmds.text( label ='Leaves Thickness:',align='left')
    
    #control to specify the 'thickness' of the leaves, e.g if thicker is selected the rule l = ll is added which on average will double the number of leaves created
    leavesamount =cmds.radioButtonGrp( label='', labelArray2=['Default', 'Thicker'], numberOfRadioButtons=2, select = 1)
     
    cmds.separator(h =10, style = 'none')
    cmds.separator(h =10, style = 'none')
    
    #creating and defining the flags of the progress bar, which will allow the user to track the programs progress for each tree generation
    progressControl = cmds.progressBar(maxValue=8000, width = 300, bgc =[0.23,0.16,0.0] )
    
    cmds.separator(h =10, style = 'none')
    
    #when the apply button is pressed, the path names of the various controls are passed to the pApplyCallback function( treegen function)
    cmds.button( label='Apply', backgroundColor=[0.9,0.9,0.9], command=functools.partial( pApplyCallback, length, iterations, treetype, materiall, rgbs, leafscale, leavesamount, rgbleaves, applecheck, leafcheck, angle, leaves, treetype2, progressControl, materialleaves) )
             
    cmds.separator(h =10, style = 'none')
    
    #the 'savemenu' fucntion is called
    cmds.button( label = 'Save', command=functools.partial(savemenu), backgroundColor=[0.101,0.338,0.017])
    cmds.separator(h =10, style = 'none') 
    
    #The 'previous' function is called
    cmds.button( label = 'Undo', command=functools.partial(previous), backgroundColor=[0.23,0.16,0.0])
    cmds.separator(h =10, style = 'none')
    
    cmds.separator(h =10, style = 'none')
    cmds.separator(h =10, style = 'none')
    cmds.separator(h =10, style = 'none')
   
    #the cancelCallback function is called
    cmds.button( label = 'Cancel', command=functools.partial( cancelCallback, windowID) )
    
    cmds.separator(h =10, style = 'none')
    
    cmds.showWindow()
    cmds.window(windowID, e=True, width=640)   
    def display(cls):
        cls.delete()

        main_window = cmds.window(cls.WINDOW_NAME,
                                  title="{0} (http://zurbrigg.com)".format(
                                      cls.APP_NAME),
                                  sizeable=True,
                                  menuBar=True)
        edit_menu = cmds.menu(label="Edit", parent=main_window)
        cmds.menuItem(label="Reset Settings",
                      command="ZShotMaskUi.reset_settings()",
                      parent=edit_menu)

        help_menu = cmds.menu(label="Help", parent=main_window)
        cmds.menuItem(label="About",
                      command="ZShotMaskUi.about()",
                      parent=help_menu)

        main_layout = cmds.columnLayout(adjustableColumn=True,
                                        parent=main_window)

        # Camera Section
        camera_layout = cmds.frameLayout(label="Camera", parent=main_layout)
        camera_form_layout = cmds.formLayout(parent=camera_layout)

        cls.camera_name = cmds.textFieldButtonGrp(
            label="Name  ",
            buttonLabel=" ... ",
            columnWidth=(1, 90),
            changeCommand="ZShotMaskUi.update_mask()",
            buttonCommand="ZShotMaskUi.display_camera_dialog()",
            parent=camera_form_layout)

        cmds.formLayout(camera_form_layout,
                        e=True,
                        af=(cls.camera_name, "top", 3))
        cmds.formLayout(camera_form_layout,
                        e=True,
                        af=(cls.camera_name, "left", 0))

        # Labels Section
        label_layout = cmds.frameLayout(label="Labels", parent=main_layout)
        label_form_layout = cmds.formLayout(parent=label_layout)

        cls.label_text_ctrls = []
        cls.label_settings_scale_ctrls = []
        cls.label_settings_offset_x_ctrls = []
        cls.label_settings_offset_y_ctrls = []

        label_text = ["", "", "", "", "", ""]

        for i in range(0, len(label_text)):
            cls.create_label_fields(i, label_form_layout)

        cls.label_font_tfg = cmds.textFieldButtonGrp(
            label="Font  ",
            buttonLabel=" ... ",
            columnWidth=(1, 90),
            editable=False,
            buttonCommand="ZShotMaskUi.display_font_dialog()",
            parent=label_form_layout)

        cls.label_color_csg = cmds.colorSliderGrp(
            label="Color  ",
            columnWidth=(1, 90),
            changeCommand="ZShotMaskUi.update_mask()",
            dragCommand="ZShotMaskUi.update_mask()",
            parent=label_form_layout)
        cls.label_trans_csg = cmds.colorSliderGrp(
            label="Transparency  ",
            columnWidth=(1, 90),
            changeCommand="ZShotMaskUi.update_mask()",
            dragCommand="ZShotMaskUi.update_mask()",
            parent=label_form_layout)

        font_scale_label = cmds.text("Scale  ",
                                     align="right",
                                     width=93,
                                     parent=label_form_layout)
        cls.label_scale = cmds.floatField(
            width=50,
            value=1.0,
            minValue=0.1,
            maxValue=2.0,
            step=0.01,
            precision=2,
            changeCommand="ZShotMaskUi.update_mask()",
            dragCommand="ZShotMaskUi.update_mask()",
            parent=label_form_layout)

        cmds.formLayout(label_form_layout,
                        e=True,
                        af=(cls.label_text_ctrls[0], "top", 3))
        cmds.formLayout(label_form_layout,
                        e=True,
                        af=(cls.label_text_ctrls[0], "left", 0))

        label_text_count = len(cls.label_text_ctrls)
        for i in range(1, label_text_count):
            cmds.formLayout(label_form_layout,
                            e=True,
                            ac=(cls.label_text_ctrls[i], "top", 0,
                                cls.label_text_ctrls[i - 1]))
            cmds.formLayout(label_form_layout,
                            e=True,
                            aoc=(cls.label_text_ctrls[i], "left", 0,
                                 cls.label_text_ctrls[i - 1]))

        cmds.formLayout(label_form_layout,
                        e=True,
                        ac=(cls.label_font_tfg, "top", 0,
                            cls.label_text_ctrls[label_text_count - 1]))
        cmds.formLayout(label_form_layout,
                        e=True,
                        aoc=(cls.label_font_tfg, "left", 0,
                             cls.label_text_ctrls[label_text_count - 1]))

        cmds.formLayout(label_form_layout,
                        e=True,
                        ac=(cls.label_color_csg, "top", 0, cls.label_font_tfg))
        cmds.formLayout(label_form_layout,
                        e=True,
                        aoc=(cls.label_color_csg, "left", 0,
                             cls.label_font_tfg))
        cmds.formLayout(label_form_layout,
                        e=True,
                        ac=(cls.label_trans_csg, "top", 0,
                            cls.label_color_csg))
        cmds.formLayout(label_form_layout,
                        e=True,
                        aoc=(cls.label_trans_csg, "left", 0,
                             cls.label_color_csg))
        cmds.formLayout(label_form_layout,
                        e=True,
                        ac=(font_scale_label, "top", 4, cls.label_trans_csg))
        cmds.formLayout(label_form_layout,
                        e=True,
                        ac=(cls.label_scale, "top", 0, cls.label_trans_csg))
        cmds.formLayout(label_form_layout,
                        e=True,
                        ac=(cls.label_scale, "left", 0, font_scale_label))
        cmds.formLayout(label_form_layout,
                        e=True,
                        af=(cls.label_scale, "bottom", 5))

        # Border Section
        border_layout = cmds.frameLayout(label="Border", parent=main_layout)

        border_form_layout = cmds.formLayout(parent=border_layout)
        cls.border_vis_cbg = cmds.checkBoxGrp(
            numberOfCheckBoxes=2,
            label="",
            labelArray2=("Top", "Bottom"),
            columnWidth3=(90, 60, 60),
            changeCommand="ZShotMaskUi.update_mask()",
            parent=border_form_layout)
        cls.border_color_csg = cmds.colorSliderGrp(
            label="Color  ",
            columnWidth=(1, 90),
            changeCommand="ZShotMaskUi.update_mask()",
            dragCommand="ZShotMaskUi.update_mask()",
            parent=border_form_layout)
        cls.border_trans_csg = cmds.colorSliderGrp(
            label="Transparency  ",
            columnWidth=(1, 90),
            changeCommand="ZShotMaskUi.update_mask()",
            dragCommand="ZShotMaskUi.update_mask()",
            parent=border_form_layout)
        border_scale_label = cmds.text("Scale  ",
                                       align="right",
                                       width=93,
                                       parent=border_form_layout)
        cls.border_scale = cmds.floatField(
            width=50,
            value=1.0,
            minValue=0.5,
            maxValue=2.0,
            step=0.01,
            precision=2,
            changeCommand="ZShotMaskUi.update_mask()",
            dragCommand="ZShotMaskUi.update_mask()",
            parent=border_form_layout)

        cmds.formLayout(border_form_layout,
                        e=True,
                        af=(cls.border_vis_cbg, "top", 3))
        cmds.formLayout(border_form_layout,
                        e=True,
                        af=(cls.border_vis_cbg, "left", 0))

        cmds.formLayout(border_form_layout,
                        e=True,
                        ac=(cls.border_color_csg, "top", 0,
                            cls.border_vis_cbg))
        cmds.formLayout(border_form_layout,
                        e=True,
                        ac=(cls.border_trans_csg, "top", 0,
                            cls.border_color_csg))
        cmds.formLayout(border_form_layout,
                        e=True,
                        ac=(border_scale_label, "top", 4,
                            cls.border_trans_csg))
        cmds.formLayout(border_form_layout,
                        e=True,
                        ac=(cls.border_scale, "top", 0, cls.border_trans_csg))
        cmds.formLayout(border_form_layout,
                        e=True,
                        ac=(cls.border_scale, "left", 0, border_scale_label))
        cmds.formLayout(border_form_layout,
                        e=True,
                        af=(cls.border_scale, "bottom", 5))

        # Counter Section
        counter_layout = cmds.frameLayout(label="Counter", parent=main_layout)
        counter_form_layout = cmds.formLayout(parent=counter_layout)

        cls.counter_vis_cbg = cmds.checkBoxGrp(
            numberOfCheckBoxes=1,
            label="",
            label1=("Enable"),
            columnWidth2=(90, 60),
            changeCommand="ZShotMaskUi.update_mask()",
            parent=counter_form_layout)
        cls.counter_position = cmds.radioButtonGrp(
            numberOfRadioButtons=4,
            label="",
            columnWidth5=(90, 86, 86, 86, 86),
            labelArray4=("Top-Left", "Top-Right", "Bottom-Left",
                         "Bottom-Right"),
            changeCommand="ZShotMaskUi.update_mask()",
            parent=counter_form_layout)
        counter_padding_label = cmds.text("Padding  ",
                                          align="right",
                                          width=93,
                                          parent=counter_form_layout)
        cls.counter_padding = cmds.intField(
            width=50,
            value=1,
            minValue=1,
            maxValue=6,
            step=1,
            changeCommand="ZShotMaskUi.update_mask()",
            parent=counter_form_layout)

        cmds.formLayout(counter_form_layout,
                        e=True,
                        af=(cls.counter_vis_cbg, "top", 3))
        cmds.formLayout(counter_form_layout,
                        e=True,
                        af=(cls.counter_vis_cbg, "left", 0))
        cmds.formLayout(counter_form_layout,
                        e=True,
                        ac=(cls.counter_position, "top", 0,
                            cls.counter_vis_cbg))
        cmds.formLayout(counter_form_layout,
                        e=True,
                        ac=(counter_padding_label, "top", 4,
                            cls.counter_position))
        cmds.formLayout(counter_form_layout,
                        e=True,
                        ac=(cls.counter_padding, "top", 0,
                            cls.counter_position))
        cmds.formLayout(counter_form_layout,
                        e=True,
                        ac=(cls.counter_padding, "left", 0,
                            counter_padding_label))

        # Buttons
        button_layout = cmds.formLayout(parent=main_layout)
        create_btn = cmds.button(label="Create",
                                 width=80,
                                 command="ZShotMask.create_mask()",
                                 parent=button_layout)
        delete_btn = cmds.button(label="Delete",
                                 width=80,
                                 command="ZShotMask.delete_mask()",
                                 parent=button_layout)
        cmds.formLayout(button_layout, e=True, af=(delete_btn, "right", 0))
        cmds.formLayout(button_layout,
                        e=True,
                        ac=(create_btn, "right", 2, delete_btn))

        cmds.window(main_window, e=True, w=100, h=100)
        cmds.window(main_window, e=True, sizeable=False)
        cmds.window(main_window, e=True, rtf=True)

        cls.update_ui_elements()

        cmds.showWindow(main_window)
Example #46
0
def createWindow():
    if cmds.window('MeshLightSetter',ex=True):
        cmds.deleteUI('MeshLightSetter')

    cmds.window('MeshLightSetter',t='MeshLight Setter',w=600,h=800)
    cmds.rowLayout(nc=2)
    cmds.frameLayout(l='aiTranslatorAttributes',w=380)
    cmds.formLayout('MeshLight_FormLayout')
    f1 = cmds.optionMenu('MeshLight_aiTranslator')
    cmds.menuItem(l='polymesh',p='MeshLight_aiTranslator')
    cmds.menuItem(l='mesh_light',p='MeshLight_aiTranslator')
    cmds.menuItem(l='procedural',p='MeshLight_aiTranslator')
    f2 = cmds.colorSliderGrp('MeshLight_aiColor',l='Color')
    f3 = cmds.floatFieldGrp('MeshLight_aiIntensity',l='Intensity')
    f4 = cmds.floatSliderGrp('MeshLight_aiExposure',l='Exposure',field=True)
    f5 = cmds.checkBox('MeshLight_aiUseTemp',l='Use Temperature')
    f6 = cmds.floatSliderGrp('MeshLight_aiTemperature',l='Temperature',minValue=0.0,maxValue=20000.0,field=True)
    f7 = cmds.checkBox('MeshLight_aiVisible',l='Light Visible')
    f8 = cmds.intFieldGrp('MeshLight_aiSample',l='Sample')
    f9 = cmds.checkBox('MeshLight_aiNormalize',l='Normalize')
    f10 = cmds.checkBox('MeshLight_aiCastShadows',l='Cast Shadows')
    f11 = cmds.floatSliderGrp('MeshLight_aiShadowDensity',l='ShadowDensity',minValue=0.0,maxValue=1.0,field=True)
    f12 = cmds.colorSliderGrp('MeshLight_aiShadowColor',l='Shadow Color')
    f13 = cmds.checkBox('MeshLight_aiCastVolumeShadow',l='Cast Volumeric Shadow')
    f14 = cmds.intFieldGrp('MeshLight_aiVolumeSample',l='Volume Sample')
    f15 = cmds.textFieldGrp('MeshLight_aiAov',l='AOV Group')
    f16 = cmds.rowLayout(nc=2)
    f17 = cmds.button(l='List LightGroup',c=lambda *args:refreshLightGroupMenu(),w=98)
    f18 = cmds.button(l='Set LightGroup',c=lambda *args:setLightGroupFromMenu(),w=98)
    cmds.setParent(u=True)
    f19 = cmds.textFieldGrp('AOVString',l='AOVs')
    f20 = cmds.textScrollList('MeshLight_LightGroupList',w=200,h=372)
    
    cmds.formLayout('MeshLight_FormLayout',e=True,af = [(f1,'top',0),(f1,'left',100),
                                                        (f2,'top',22),(f2,'left',-40),
                                                        (f3,'top',44),(f3,'left',-40),
                                                        (f4,'top',66),(f4,'left',-40),
                                                        (f5,'top',88),(f5,'left',90),
                                                        (f6,'top',110),(f6,'left',-40),
                                                        (f7,'top',132),(f7,'left',90),
                                                        (f8,'top',154),(f8,'left',-40),
                                                        (f9,'top',176),(f9,'left',90),
                                                        (f10,'top',198),(f10,'left',90),
                                                        (f11,'top',220),(f11,'left',-40),
                                                        (f12,'top',242),(f12,'left',-40),
                                                        (f13,'top',264),(f13,'left',90),
                                                        (f14,'top',286),(f14,'left',-40),
                                                        (f15,'top',308),(f15,'left',-40),
                                                        (f16,'top',333),(f16,'left',90),
                                                        (f19,'top',360),(f19,'left',-40),
                                                        (f20,'top',383),(f20,'left',90)
                                                        ])
    
    
    cmds.setParent(u=True)
    cmds.setParent(u=True)
    cmds.frameLayout(l='Mesh Light List',w=400)
    cmds.formLayout('MeshLightList_FormLayout')
    cmds.radioCollection()
    w1 = cmds.radioButton('AllLightCheck',l='List All Light',sl=True)
    w2 = cmds.radioButton('SelLightCheck',l='List Sel Light')
    #w1 = cmds.button(l='ALL MESH light',c=lambda *args:lightListRefresh(True),w=100)
    #w2 = cmds.button(l='Sel MESH Light',c=lambda *args:lightListRefresh(False),w=100)
    w3 = cmds.checkBox('List_NormalLight',l='Normal_Light')
    w4 = cmds.checkBox('List_MeshLight',l='Mesh_Light')
    w5 = cmds.textFieldGrp('MeshLight_Template',l='Template',w=400)
    w6 = cmds.button(l='Set Template',c=lambda *args:cmds.textFieldGrp('MeshLight_Template',e=True,tx=cmds.ls(sl=True,dag=True,ni=True)[0]),w=100)
    w7 = cmds.button(l='Convert!',c=lambda *args:convertMeshToMeshLight(),w=100)
    w8 = cmds.textScrollList('MeshLightList',w=400,h=700,ams=True)
    w9 = cmds.text('ListTotalNumber',l='0',w=50,nbg=True)
    w10 = cmds.text('ListSelectNumber',l='0',w=50,nbg=True)
    cmds.formLayout('MeshLightList_FormLayout',e=True,af = [(w1,'top',3),(w1,'left',0),
                                                            (w2,'top',3),(w2,'left',101),
                                                            (w3,'top',3),(w3,'left',205),
                                                            (w4,'top',3),(w4,'left',320),
                                                            (w5,'top',27),(w5,'left',-90),
                                                            (w6,'top',27),(w6,'left',297),
                                                            (w7,'top',52),(w7,'left',297),
                                                            (w8,'top',77),(w8,'left',0),
                                                            (w9,'top',55),(w9,'left',0),
                                                            (w10,'top',55),(w10,'left',50)
                                                            ])
    cmds.popupMenu('MeshLightListMenu',p='MeshLightList')
    cmds.menuItem(l='Select...',p='MeshLightListMenu',c=lambda *args:cmds.select([item for item in cmds.textScrollList('MeshLightList',q=True,si=True)]))

    cmds.showWindow('MeshLightSetter')

    cmds.textScrollList('MeshLightList',e=True,dcc=lambda *args:cmds.select(cmds.textScrollList('MeshLightList',q=True,si=True),r=True))
    cmds.textScrollList('MeshLightList',e=True,sc=lambda *args:getMeshLightAttrsAndShow())
    cmds.textScrollList('MeshLight_LightGroupList',e=True,ams=True,sc=lambda *args:genAovString(),dcc=lambda *args:selectLightByGroupName())
    cmds.optionMenu(f1,e=True,cc=lambda *args:setMeshLightAttrsAndShow('translator'))
    cmds.colorSliderGrp(f2,e=True,cc=lambda *args:setMeshLightAttrsAndShow('color'))
    cmds.floatFieldGrp(f3,e=True,cc=lambda *args:setMeshLightAttrsAndShow('intensity'))
    cmds.floatSliderGrp(f4,e=True,cc=lambda *args:setMeshLightAttrsAndShow('exposure'))
    cmds.checkBox(f5,e=True,cc=lambda *args:setMeshLightAttrsAndShow('useTemp'))
    cmds.floatSliderGrp(f6,e=True,cc=lambda *args:setMeshLightAttrsAndShow('temp'))
    cmds.checkBox(f7,e=True,cc=lambda *args:setMeshLightAttrsAndShow('visible'))
    cmds.intFieldGrp(f8,e=True,cc=lambda *args:setMeshLightAttrsAndShow('sample'))
    cmds.checkBox(f9,e=True,cc=lambda *args:setMeshLightAttrsAndShow('normalize'))
    cmds.checkBox(f10,e=True,cc=lambda *args:setMeshLightAttrsAndShow('castShadows'))
    cmds.floatSliderGrp(f11,e=True,cc=lambda *args:setMeshLightAttrsAndShow('shadowDensity'))
    cmds.colorSliderGrp(f12,e=True,cc=lambda *args:setMeshLightAttrsAndShow('shadowColor'))
    cmds.checkBox(f13,e=True,cc=lambda *args:setMeshLightAttrsAndShow('castVolumeShadow'))
    cmds.intFieldGrp(f14,e=True,cc=lambda *args:setMeshLightAttrsAndShow('volumeSample'))
    cmds.textFieldGrp(f15,e=True,cc=lambda *args:setMeshLightAttrsAndShow('aiAov'))
    cmds.radioButton('AllLightCheck',e=True,cc=lambda *args:lightListRefresh())
    cmds.radioButton('SelLightCheck',e=True,cc=lambda *args:lightListRefresh())
    cmds.checkBox('List_NormalLight',e=True,cc=lambda *args:lightListRefresh())
    cmds.checkBox('List_MeshLight',e=True,cc=lambda *args:lightListRefresh())
Example #47
0
def createUI():
    """
    Creates a user graphics interface.

    Keyword arguments:
    NONE

    On Exit:  All the functions will have been passed properly and the GUI will be initialised.
    """
    global windowID
    windowID = 'theWindow'

    # If the instance previously existed, delete it.
    if cmds.window(windowID, exists=True):
        cmds.deleteUI(windowID)

    # Main window setup.
    cmds.window(windowID,
                title="Towers Of Hanoi",
                sizeable=False,
                width=470,
                rtf=True)

    # Header image for the interface.
    import os
    pathVar = os.path.dirname(
        __file__)  # This stores the current working directory
    imagePath = pathVar + '/banner.png'
    cmds.columnLayout()
    cmds.image(image=imagePath)

    # We start a Tab Layout. We will parent a "Main" tab and a "Materials" tab.
    tabs = cmds.tabLayout()
    """A. MAIN SUPER-LAYOUT"""
    mainLayout = cmds.columnLayout(w=470)

    cmds.columnLayout()
    cmds.separator(h=10, style='none')

    def displayInstructions(*pArgs):
        """
        Shows in an independent window a list of instructions for the user to set things up quickly. It acts as a kind of
        user guide.

        Keyword arguments:
        NONE.

        On Exit:  Pops a window displaying some instructions for the user.
        """
        if cmds.window('instructions_window', exists=True):
            cmds.deleteUI('instructions_window')
        instructions_window = cmds.window('instructions_window',
                                          title="Instructions",
                                          s=False,
                                          mnb=False,
                                          mxb=False)
        instructionsLayout = cmds.frameLayout(l="Instructions",
                                              collapsable=False,
                                              cl=False,
                                              mw=10,
                                              mh=10)
        cmds.rowColumnLayout(nc=3,
                             cw=[(1, 20), (2, 480), (3, 20)],
                             cal=[(2, "left")],
                             parent=instructionsLayout)
        cmds.separator(st='none')
        cmds.text(
            l="- 1. Select the numbers of disks you want to play with.\n- 2. Click 'Place Disks' first. Then you "
            "will see that the disks has been brought to scene.\n- 3. Click 'Solve it!'. A lot of keyframes will appear on "
            "your timeline. Furthermore you will be able to\n       see each movement written down if you see the Script "
            "Editor window.\n- 4. If you want to change the number of disks FIRST CLEAR the scene by pressing 'Clear All'."
            "If\n       you skip this step you might crash the program.\n- 5. Once you are finished press the 'Exit' button"
            " and it will delete all the elements that\nhave been created for you"
        )
        cmds.separator(st='none')
        cmds.showWindow(instructions_window)

    """Layout 1: Instructions."""
    cmds.rowColumnLayout(nc=5,
                         cw=[(1, 20), (2, 245), (3, 10), (4, 175), (5, 20)],
                         cal=[(2, 'right')])
    cmds.separator(st='none')
    cmds.text(l="Click at the Instructions button for a quick guide -")
    cmds.separator(st='none')
    cmds.button(l="Instructions",
                c=displayInstructions,
                ann="Displays a quick guide for running this script properly.")
    cmds.separator(st='none')
    cmds.setParent(mainLayout)
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator(h=5, st='none')
    cmds.setParent(mainLayout)
    """Layout 2: Number of Disks integer slider."""
    cmds.columnLayout()
    global diskNumUIField
    diskNumUIField = cmds.intSliderGrp(
        l="Number of Disks: ",
        v=3,
        cw3=[115, 20, 305],
        min=1,
        max=10,
        fmx=20,
        f=True,
        ann="Number of disks you want to stack in the first peg")
    cmds.setParent(mainLayout)
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator(h=5, st='none')
    cmds.setParent(mainLayout)
    """Layout 3: First row of buttons, 'Place Disks' and 'Clear All'."""
    cmds.rowColumnLayout(nc=5,
                         cw=[(1, 20), (2, 212), (3, 6), (4, 212), (5, 20)])
    cmds.separator(st='none')
    # This global definition and declaration prevents the program from crashing because of non-defined variables. This
    # variable, later on, will contain the name of the board geometric object so that we can apply the shader easier.
    global board
    board = 0
    cmds.button(l="Place Disks",
                c=placeDisks,
                ann="Stacks a pile of disks into the source peg.")
    cmds.separator(st='none')
    cmds.button(l="Clear All", c=clearTowers, ann="Clears the disks.")
    cmds.separator(st='none')
    cmds.setParent(mainLayout)

    cmds.columnLayout()
    cmds.separator(h=3, st='none')
    cmds.setParent(mainLayout)
    """Layout 4: Second row of buttons, 'Solve it!' and 'Exit'."""
    cmds.rowColumnLayout(nc=5,
                         cw=[(1, 20), (2, 212), (3, 6), (4, 212), (5, 20)])
    cmds.separator(st='none')
    cmds.button(
        l="Solve it!",
        c=solvePuzzle,
        ann="Press to solve the puzzle once you have placed the disks.")
    cmds.separator(st='none')
    cmds.button(l="Exit", c=exitProcedure, ann="Quits the application")
    cmds.separator(st='none')
    cmds.setParent(mainLayout)
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator(h=10, st='none')
    cmds.setParent(mainLayout)
    """Layout 5: Warnings line."""
    cmds.rowColumnLayout(nc=4, cw=[(1, 20), (2, 70), (3, 360), (4, 20)])
    cmds.separator(st='none')
    cmds.text(l="Warnings")
    global warnings
    warnings = cmds.text(l="None.", en=False, ebg=True, bgc=[0, 0.66, 0.05])
    cmds.separator(st='none')
    cmds.setParent(mainLayout)
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator(st='none')
    cmds.setParent(mainLayout)
    """Layout 6: Help line."""
    cmds.rowColumnLayout(nc=3, cw=[(1, 20), (2, 430), (3, 20)])
    cmds.separator(st='none')
    cmds.helpLine(bgc=[0.0, 0.0, 0.0])
    cmds.separator(st='none')
    cmds.setParent(mainLayout)
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator(h=10, st='none')
    cmds.setParent(mainLayout)

    #Parents the whole thing (Layout 1, 2, 3, 4, 5 and 6 to a TAB in the tab layout.
    cmds.setParent(tabs)
    """B. MATERIALS SUPER-LAYOUT"""
    materialsLayout = cmds.columnLayout()
    """Layout 7: Colour pickers."""
    cmds.columnLayout()
    cmds.separator(h=35, st='none')
    cmds.colorSliderGrp('rgb_board',
                        l="Board: ",
                        rgb=(0.430, 0.230, 0.11),
                        cw3=[52, 30, 368],
                        ann="Board colour.")
    cmds.separator(st='none', h=10)
    cmds.colorSliderGrp('rgb_pegs',
                        l="Pegs: ",
                        rgb=(0.6, 0.6, 0.6),
                        cw3=[52, 30, 368],
                        ann="Pegs colour.")
    cmds.separator(st='none', h=10)
    cmds.colorSliderGrp('rgb_disks',
                        l="Disks: ",
                        rgb=(1.0, 0.0, 0.0),
                        cw3=[52, 30, 368],
                        ann="Disks colour.")
    cmds.setParent(materialsLayout)

    # Parents the Layout 7 under the 'Materials' TAB in the tab layout.
    cmds.setParent(tabs)

    # Naming the tabs.
    cmds.tabLayout(tabs,
                   e=True,
                   tabLabel=((mainLayout, "Main"), (materialsLayout,
                                                    "Materials")))
    cmds.showWindow()
Example #48
0
def getMeshLightAttrsAndShow():
    item = cmds.textScrollList('MeshLightList',q=True,si=True)[0]
    try:
        if cmds.getAttr(item+'.aiTranslator') == 'polyMesh':
            cmds.optionMenu('MeshLight_aiTranslator',e=True,sl=1)
        elif cmds.getAttr(item+'.aiTranslator') == 'mesh_light':
            cmds.optionMenu('MeshLight_aiTranslator',e=True,sl=2)
        else:
            cmds.optionMenu('MeshLight_aiTranslator',e=True,sl=3)
    except:
        pass
    try:
        cmds.colorSliderGrp('MeshLight_aiColor',e=True,rgb=cmds.getAttr(item+'.color')[0])
    except:
        pass
    try:
        cmds.floatFieldGrp('MeshLight_aiIntensity',e=True,v1=cmds.getAttr(item+'.intensity'))
    except:
        pass
    try:
        cmds.floatSliderGrp('MeshLight_aiExposure',e=True,v=cmds.getAttr(item+'.aiExposure'))
    except:
        pass
    try:
        cmds.checkBox('MeshLight_aiUseTemp',e=True,v=cmds.getAttr(item+'.aiUseColorTemperature'))
    except:
        pass
    try:
        cmds.floatSliderGrp('MeshLight_aiTemperature',e=True,v=cmds.getAttr(item+'.aiColorTemperature'))
    except:
        pass
    try:
        cmds.checkBox('MeshLight_aiVisible',e=True,v=cmds.getAttr(item+'.lightVisible'))
    except:
        pass
    try:
        cmds.intFieldGrp('MeshLight_aiSample',e=True,v1=cmds.getAttr(item+'.aiSamples'))
    except:
        pass
    try:
        cmds.checkBox('MeshLight_aiNormalize',e=True,v=cmds.getAttr(item+'.aiNormalize'))
    except:
        pass
    try:
        cmds.checkBox('MeshLight_aiCastShadows',e=True,v=cmds.getAttr(item+'.aiCastShadows'))
    except:
        pass
    try:
        cmds.floatSliderGrp('MeshLight_aiShadowDensity',e=True,v=cmds.getAttr(item+'.aiShadowDensity'))
    except:
        pass
    try:
        cmds.colorSliderGrp('MeshLight_aiShadowColor',e=True,rgb=cmds.getAttr(item+'.aiShadowColor')[0])
    except:
        pass
    try:
        cmds.checkBox('MeshLight_aiCastVolumeShadow',e=True,v=cmds.getAttr(item+'.aiCastVolumetricShadows'))
    except:
        pass
    try:
        cmds.intFieldGrp('MeshLight_aiVolumeSample',e=True,v1=cmds.getAttr(item+'.aiVolumeSamples'))
    except:
        pass
    try:
        cmds.textFieldGrp('MeshLight_aiAov',e=True,tx=cmds.getAttr(item+'.aiAov'))
    except:
        pass
    refreshCounts()
Example #49
0
def createWheel():
    # query UI choice
    createTire = cmds.radioButtonGrp('wheelTire', q=True, sl=True)
    createHub = cmds.radioButtonGrp('wheelHub', q=True, sl=True)

    # create a tire
    if (createTire == 1):
        # name
        nsTmp = "Tire" + str(rnd.randint(1000, 9999))
        cmds.select(clear=True)
        cmds.namespace(add=nsTmp)
        cmds.namespace(set=nsTmp)
        # query colour from UI
        rgb = cmds.colorSliderGrp('tireColour', q=True, rgbValue=True)
        # create cylinder for the base
        tire = cmds.polyCylinder(r=3.5, h=3.5, sx=36)
        # add a smaller sphere to round up the tire
        tmp = cmds.polySphere(r=3.35, sy=15, sx=36)
        cmds.scale(1.1, scaleY=True)
        # remove non intersecting parts
        tire = cmds.polyCBoolOp(tire, tmp, op=3, ch=False)
        # Add texture:
        # create cylinder as the base for texture at 1 side
        texture1 = cmds.polyCylinder(r=2.8, h=1.75, sx=36)
        # move it up
        cmds.move(1.75 / 2, moveY=True, a=True)
        # in range of subdivisions
        for i in range(35):
            #for all even numbers
            if (i % 2 == 0):
                cmds.select(texture1[0] + ".f[" + str(i) + "]")
                # local translate on Z and scale x
                cmds.polyExtrudeFacet(ltz=1, lsx=1.35)
        # duplicate texture 1 for the 2nd side
        texture2 = cmds.duplicate(texture1)
        cmds.select(texture2)
        cmds.move(-1.75 / 2, moveY=True, a=True)
        cmds.rotate(10, rotateY=True, a=True)
        # combine textures 1 and 2
        texture = cmds.polyCBoolOp(texture1, texture2, op=1, ch=False)
        # add a smaller sphere to round up the texture
        tmp = cmds.polySphere(r=3.7, sy=13, sx=36)
        # remove non intersecting parts
        texture = cmds.polyCBoolOp(texture, tmp, op=3, ch=False)
        cmds.polyMergeVertex(d=0.05, ch=False)
        # create another cylinder for the hole
        tmp = cmds.polyCylinder(r=2, h=3.5)
        # remove it
        tire = cmds.polyCBoolOp(tire, tmp, op=2, ch=False)
        tmp = cmds.polyCylinder(r=2, h=3.5)
        texture = cmds.polyCBoolOp(texture, tmp, op=2, ch=False)

        # add material
        myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat")
        cmds.setAttr(nsTmp + ":blckMat.color",
                     rgb[0],
                     rgb[1],
                     rgb[2],
                     type='double3')
        cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False)
        cmds.rotate(90, rotateX=True, a=True)
        cmds.rotate(90, rotateY=True, a=True)
        cmds.move(3.466, moveY=True, a=True)

        cmds.delete(ch=True)

        cmds.hyperShade(assign=(nsTmp + ":blckMat"))
        cmds.namespace(removeNamespace=":" + nsTmp,
                       mergeNamespaceWithParent=True)

    # create a hub
    if (createHub == 1):
        # name
        nsTmp = "Hub" + str(rnd.randint(1000, 9999))
        cmds.select(clear=True)
        cmds.namespace(add=nsTmp)
        cmds.namespace(set=nsTmp)
        # query colour from UI
        rgb = cmds.colorSliderGrp('hubColour', q=True, rgbValue=True)

        # base
        hub = cmds.polyCylinder(r=2.1, h=2.8)
        # outline
        tmp = cmds.polyCylinder(r=1.6, h=2.8)
        hub = cmds.polyCBoolOp(hub, tmp, op=2, ch=False)
        # inner part of the hub
        hubIn = cmds.polyCylinder(r=1.6, h=1.8)
        # center
        hubCenter = cmds.polyCylinder(r=0.3, h=2.4)
        hubIn = cmds.polyCBoolOp(hubIn, hubCenter, op=2, ch=False)

        # decor parts
        d1 = cmds.polyCylinder(r=0.4, h=2.8)
        cmds.move(-0.85, moveX=True, a=True)
        cmds.move(-0.03, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d1, op=1, ch=False)
        # subtract smaller cylinder inside
        d1c = cmds.polyCylinder(r=0.3, h=2.9)
        cmds.move(-0.85, moveX=True, a=True)
        cmds.move(-0.03, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d1c, op=2, ch=False)

        d3 = cmds.polyCylinder(r=0.4, h=2.8)
        cmds.move(-0.422, moveX=True, a=True)
        cmds.move(0.648, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d3, op=1, ch=False)
        # subtract smaller cylinder inside
        d3c = cmds.polyCylinder(r=0.3, h=2.9)
        cmds.move(-0.422, moveX=True, a=True)
        cmds.move(0.648, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d3c, op=2, ch=False)

        d4 = cmds.polyCylinder(r=0.4, h=2.8)
        cmds.move(0.416, moveX=True, a=True)
        cmds.move(0.627, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d4, op=1, ch=False)
        # subtract smaller cylinder inside
        d4c = cmds.polyCylinder(r=0.3, h=2.9)
        cmds.move(0.416, moveX=True, a=True)
        cmds.move(0.627, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d4c, op=2, ch=False)

        d5 = cmds.polyCylinder(r=0.4, h=2.8)
        cmds.move(0.835, moveX=True, a=True)
        cmds.move(-0.049, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d5, op=1, ch=False)
        # subtract smaller cylinder inside
        d5c = cmds.polyCylinder(r=0.3, h=2.9)
        cmds.move(0.835, moveX=True, a=True)
        cmds.move(-0.049, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d5c, op=2, ch=False)

        d6 = cmds.polyCylinder(r=0.4, h=2.8)
        cmds.move(0.431, moveX=True, a=True)
        cmds.move(-0.692, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d6, op=1, ch=False)
        # subtract smaller cylinder inside
        d6c = cmds.polyCylinder(r=0.3, h=2.9)
        cmds.move(0.431, moveX=True, a=True)
        cmds.move(-0.692, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d6c, op=2, ch=False)

        d7 = cmds.polyCylinder(r=0.4, h=2.8)
        cmds.move(-0.384, moveX=True, a=True)
        cmds.move(-0.734, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d7, op=1, ch=False)
        # subtract smaller cylinder inside
        d7c = cmds.polyCylinder(r=0.3, h=2.9)
        cmds.move(-0.384, moveX=True, a=True)
        cmds.move(-0.734, moveZ=True, a=True)
        hubIn = cmds.polyCBoolOp(hubIn, d7c, op=2, ch=False)

        # add material
        myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat")
        cmds.setAttr(nsTmp + ":blckMat.color",
                     rgb[0],
                     rgb[1],
                     rgb[2],
                     type='double3')

        cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False)
        cmds.rotate(90, rotateX=True, a=True)
        cmds.rotate(90, rotateY=True, a=True)
        cmds.move(3.466, moveY=True, a=True)
        cmds.delete(ch=True)

        cmds.hyperShade(assign=(nsTmp + ":blckMat"))
        cmds.namespace(removeNamespace=":" + nsTmp,
                       mergeNamespaceWithParent=True)
Example #50
0
    def randomizeColors(self, widget, *args):

        hsv = (random.uniform(0, 360), random.uniform(0.7, 1)**2,
               random.uniform(0.4, 1))
        mc.colorSliderGrp(widget, edit=True, hsv=hsv)
Example #51
0
 def updateColor(self, lightID, *args):
     newColor = cmds.colorSliderGrp(self.lightControls[lightID], query=True, rgb=True)
     cmds.setAttr(self.lights[lightID]+ '.color', newColor[0], newColor[1], newColor[2], type="double3")
Example #52
0
 def getHSV(self, swatch):
     hsv = mc.colorSliderGrp(swatch, query=True, hsv=True)
     return hsv[0] / 360.0, hsv[1], hsv[2]
def treegen( plength, piterations, ptreetype, pmaterialtype, prgbs, pleafscale, pleavesamount, prgbleaves, papplecheck, pleafcheck, pangle, pleaves, ptreetype2, progress, pleafmaterial, *pArgs):
	'''using the user inputs from createUI to set the variable that will define the characteristics of the tree
	
	  plength       : the path name of the length control which through querying will be used to set the length of the cyclinders that make up the entire tree structure
      piterations   : the path name of the iterations control which through querying will be used to set the number of iterations
      ptreetype     : the path name of the treetype control which through querying will be used to set the axiom and rules for the various treetypes (1-4)
      prgbs         : the path name of the rgbs control which through querying will be used to set the colour of the trunk and branches
      pleavesamount : the path name of the leavesamount control which through querying will be used to set the thickness of the leaves,
                      by specifying the leaf rule (l rule) in the dictionary, e.g l = ll
      prgbleaves    : the path name of the rgbleaves control which through querying will be used to set the rgb of the leaves
      papplecheck   : the path name of the applecheck control which through querying will be used to enable or disable fruit/apples in the tree
      pleafcheck    : the path name of the leafcheck control which through querying will be used to enable or disable leaves in the tree
      pangle        : the path name of the angle control which through querying will be used to set the starting angle in which brnaches in the tree will be created
      pleaves       : the path name of the leaves control which through querying will be used to set the type of leaves that will be generated (maple, standard)
      ptreetype2    : the path name of the treetype2 control which through querying will be used to set the axiom and rules for the 5th 6th and 7th treetypes (5-7)
      progress      : the path name of the progress control which through querying will be used to increment or set the specific value of the progress bar
	   
	'''
	
	cmds.progressBar(progress, pr = 0,  edit=True)
	
	#for the undo tool
	#saving previous scene before it gets deleted for the next tree generation
	cmds.file(rename="/home/s5113911/PythonProgramming/Project/previous")
	saved = cmds.file(save=True, type="mayaAscii")

	# clear up the scene
	cmds.select(all=True)
	cmds.delete()
	
	modelGroup = []
	
	actionString = ""	# the final action string to build the tree
	
	apple = False
	leaf = False
	lamount = 0

	axiom, ruleDictionary = treetype(cmds.radioButtonGrp(ptreetype, query=True, select=True), cmds.radioButtonGrp(ptreetype2, query=True, select=True))
	
	material = materialtype(cmds.radioButtonGrp(pmaterialtype, query=True, select=True))
	leafmaterial = materialtype(cmds.radioButtonGrp(pleafmaterial, query=True, select=True))
	
	leaftype = cmds.radioButtonGrp(pleaves, query=True, select=True)
	
	leavesamount = cmds.radioButtonGrp(pleavesamount, query=True, select=True)
	
	
	if(cmds.checkBoxGrp(papplecheck, query=True, value1=True)):
	    cmds.file("/home/s5113911/PythonProgramming/Project/apple.ma", i=True)
	    #cmds.file("\home\xyang\maya_scripts\submission\models\apple.ma", i = True)
	    apple = True
	    
	if(cmds.checkBoxGrp(pleafcheck, query=True, value1=True)):
	    if leaftype ==1:
	        #cmds.file("/home/s5113911/PythonProgramming/Project/leafy1.ma", i=True)
   	        cmds.file("/home/s5113911/PythonProgramming/Project/leafynomaterial.ma", i=True)
	       
	        #cmds.file("\home\xyang\maya_scripts\submission\models\leafy1.ma", i=True)
	    if leaftype ==2:
	        cmds.file("/home/s5113911/PythonProgramming/Project/mapleleaf2.ma", i=True)
	        #cmds.file("\home\xyang\maya_scripts\submission\models\mapleleaf2.ma", i = True)
	    leaf =True
	   
	iterations = cmds.intSliderGrp(piterations, query=True, value=True)
	stepLength = cmds.floatSliderGrp(plength, query=True, value=True)
	
	rgb = cmds.colorSliderGrp(prgbs, query=True, rgbValue=True)
	leavesrgb = cmds.colorSliderGrp(prgbleaves, query=True, rgbValue=True)
	leafscale = cmds.floatSliderGrp(pleafscale, query=True, value=True)
	angle = cmds.floatSliderGrp(pangle, query=True, value=True)
	
   
	if leavesamount==2:
	    addRule(ruleDictionary, "l", "ll")
	    lamount = 2
	
	# create the action string
	finalString=iterate(axiom, iterations, ruleDictionary)
	
	# create the 3D model
	modelGroup = createModel(finalString, stepLength, angle, leafscale, leaf, apple, progress)
	
	
	# set the color to green
	setMaterial(modelGroup[0], modelGroup[1], material, leafmaterial, rgb ,leavesrgb, progress)
Example #54
0
    def update_active_items():
        ''' Updates many of the stored gui values (Used by multiple elements) '''
        # Updates Visibility and Use gt_sel_manager
        gt_sel_manager["use_contains_string"] = cmds.checkBoxGrp(contains_string_or_not_checkbox, q=True, value1=True)
        gt_sel_manager["use_contains_no_string"] = cmds.checkBoxGrp(contains_string_or_not_checkbox, q=True, value2=True)
        gt_sel_manager["use_contains_type"] = cmds.checkBoxGrp(contains_type_or_not_checkbox, q=True, value1=True)
        gt_sel_manager["use_contains_no_type"] = cmds.checkBoxGrp(contains_type_or_not_checkbox, q=True, value2=True)
        gt_sel_manager["use_visibility_state"] = cmds.checkBox(use_visibility_state, q=True, value=True)
        gt_sel_manager["use_outliner_color"] = cmds.checkBox(use_outline_color, q=True, value=True)
        gt_sel_manager["use_no_outliner_color"] = cmds.checkBox(use_no_outline_color, q=True, value=True)
        
        
        # Updates Visibility
        if gt_sel_manager.get("use_contains_string"):
            cmds.textField(contains_name_text_field, e=True, en=True)
        else:
            cmds.textField(contains_name_text_field, e=True, en=False)
            
        if gt_sel_manager.get("use_contains_no_string"):
            cmds.textField(contains_no_name_text_field, e=True, en=True)
        else:
            cmds.textField(contains_no_name_text_field, e=True, en=False)
            
        if gt_sel_manager.get("use_contains_type"):
            cmds.textField(contains_type_text_field, e=True, en=True)
        else:
            cmds.textField(contains_type_text_field, e=True, en=False)
        
        if gt_sel_manager.get("use_contains_no_type"):
            cmds.textField(contains_no_type_text_field, e=True, en=True)
        else:
            cmds.textField(contains_no_type_text_field, e=True, en=False)
        
        if gt_sel_manager.get("use_visibility_state"):
            cmds.radioButton( visibility_rb1, e=True, en=True)
            cmds.radioButton( visibility_rb2, e=True, en=True)
        else:
            cmds.radioButton( visibility_rb1, e=True, en=False)
            cmds.radioButton( visibility_rb2, e=True, en=False)
        
        if gt_sel_manager.get("use_outliner_color"):
            cmds.colorSliderGrp(has_outliner_color_slider_one, e=True, en=True)
        else:
            cmds.colorSliderGrp(has_outliner_color_slider_one, e=True, en=False)
        
        if gt_sel_manager.get("use_no_outliner_color"):
            cmds.colorSliderGrp(has_no_outliner_color_slider_one, e=True, en=True)
        else:
            cmds.colorSliderGrp(has_no_outliner_color_slider_one, e=True, en=False)
        
        
        # Stores Values
        gt_sel_manager["stored_contains_string"] = parse_text_field(cmds.textField(contains_name_text_field, q=True, text=True))
        gt_sel_manager["stored_contains_no_string"] = parse_text_field(cmds.textField(contains_no_name_text_field, q=True, text=True))
        gt_sel_manager["stored_contains_type"] = parse_text_field(cmds.textField(contains_type_text_field, q=True, text=True))
        gt_sel_manager["stored_contains_no_type"] = parse_text_field(cmds.textField(contains_no_type_text_field, q=True, text=True))
        
        
        if gt_sel_manager.get('use_contains_type') or gt_sel_manager.get('use_contains_no_type'):
            cmds.optionMenu(shape_node_behavior_menu, e=True, en=True)
        else:
            cmds.optionMenu(shape_node_behavior_menu, e=True, en=False)
  
        gt_sel_manager["stored_shape_node_type"] = cmds.optionMenu(shape_node_behavior_menu, q=True, value=True)
     
        gt_sel_manager["stored_visibility_state"]  = cmds.radioButton(visibility_rb1, q=True, select=True )
        gt_sel_manager["stored_save_as_quick_selection"]  = cmds.radioButton(save_as_quick_selection_rb1, q=True, select=True )

        gt_sel_manager["stored_outliner_color"] = cmds.colorSliderGrp(has_outliner_color_slider_one, q=True, rgb=True)
        
        gt_sel_manager["stored_no_outliner_color"] = cmds.colorSliderGrp(has_no_outliner_color_slider_one, q=True, rgb=True)
def createUI():
    global win
    global colorField
    global temperatureField
    global intensityField
    global subdivsField
    global skp
    global sskp
    global noDecayBox
    global doubleSidedBox
    global radiusField
    global sphereSegmentsField
    global rayDistanceField
    
    win="multiLightWin"
    if cmds.window(win,exists=True):
        deleteWindow()
       
    myWindow=cmds.window(win,title="VRay Multiple Light v1.0",resizeToFitChildren=True,sizeable=True,maximizeButton=True,minimizeButton=True)    
    
    cmds.columnLayout(adjustableColumn=True,rowSpacing=2,columnAttach=("both",8))
     
    cmds.separator( height=15, style='in')
    
    cmds.frameLayout( label='Common Attributes',  bgc=(0.341,0.341,0.341), collapsable=True)
    
    cmds.columnLayout(adjustableColumn=True,rowSpacing=2,columnAttach=("both",8))
    
    cmds.checkBox(label="Enabled",onCommand=("enabled(True)"),offCommand=("enabled(False)"), value=True)
    
    cmds.separator( height=15, style='in')
    
    cmds.radioButtonGrp(label="Color Mode",numberOfRadioButtons=2, width=266, labelArray2=["color","temperature"], changeCommand1="setColorMode(False)",changeCommand2="setColorMode(True)",select=1,adjustableColumn=True,columnAlign=(1,"left"))
    
    cmds.separator( height=15, style='in')
    
    colorField=cmds.colorSliderGrp(label="Color",width=266,hsv=(360,0,0.700),changeCommand=setColor,dragCommand=setColor,adjustableColumn=True,columnAlign=(1,"left"))
    
    temperatureField=cmds.floatSliderGrp(label="Temperature",field=True,width=266, minValue=1000, maxValue=10000, fieldMinValue=1000, fieldMaxValue=30000,dragCommand=setTemperature,changeCommand=setTemperature,value=6500, precision=3, enable=False,adjustableColumn=True,columnAlign=(1,"left"))
        
    intensityField=cmds.floatSliderGrp(label="Intensity",field=True,width=266, minValue=0, maxValue=100, fieldMinValue=0, fieldMaxValue=1000000000,dragCommand=setIntensity,changeCommand=setIntensity,value=30, precision=3,adjustableColumn=True,columnAlign=(1,"left"))
    
    subdivsField=cmds.intSliderGrp(label="Subdivs",field=True,width=266, minValue=1, maxValue=32, fieldMinValue=1, fieldMaxValue=1000000000,dragCommand=setSubdivs,changeCommand=setSubdivs,value=8,adjustableColumn=True,columnAlign=(1,"left"))

    cmds.separator( height=15, style='in')
    
    noDecayBox=cmds.checkBox(label="No Decay",onCommand=("noDecay(True)"),offCommand=("noDecay(False)"))
    #doubleSidedBox=cmds.checkBox(label="Double Sided",onCommand=("doubleSided(True)"),offCommand=("doubleSided(False)"))
    cmds.checkBox(label="Invisible",onCommand=("invisible(True)"),offCommand=("invisible(False)"))
    #skp=cmds.checkBox(label="Skylight Portal",onCommand=("skylightPortal(True)"),offCommand=("skylightPortal(False)"))
    #sskp=cmds.checkBox(label="Simple Skylight Portal",onCommand=("simpleSkylightPortal(True)"),offCommand=("simpleSkylightPortal(False)"),enable=False) 
    cmds.checkBox(label="Store With Irradiance Map",onCommand=("storeWithIrradianceMap(True)"),offCommand=("storeWithIrradianceMap(False)")) 
    
    cmds.separator( height=12, style='in')
    
    cmds.checkBox(label="Affect Diffuse",onCommand=("affectDiffuse(True)"),offCommand=("affectDiffuse(False)"), value=True)
    cmds.checkBox(label="Affect Specular",onCommand=("affectSpecular(True)"),offCommand=("affectSpecular(False)"), value=True)
    cmds.checkBox(label="Affect Reflections",onCommand=("affectReflections(True)"),offCommand=("affectReflections(False)"), value=True)
    cmds.checkBox(label="Shadows",onCommand=("shadows(True)"),offCommand=("shadows(False)"), value=True)
    cmds.separator( height=15, style='in')
    
    cmds.setParent("..")
    cmds.setParent("..")
    cmds.setParent("..")
     
    cmds.frameLayout(label='Individual Attributes',backgroundColor=(0.341,0.341,0.341), collapsable=True,collapse=True)
    cmds.scrollLayout(height=200,childResizable=True)    
    cmds.columnLayout(adjustableColumn=True,rowSpacing=2,columnAttach=("both",8))
    
    cmds.frameLayout( label='VRayLightSphere',backgroundColor=(0.341,0.341,0.341), collapsable=True)
    cmds.columnLayout(adjustableColumn=True,rowSpacing=2,columnAttach=("both",8))
    
    radiusField=cmds.floatSliderGrp(label="Radius",field=True,width=266, minValue=0, maxValue=10, fieldMinValue=0, fieldMaxValue=1000000000,value=1, precision=3,dragCommand=setRadius,changeCommand=setRadius,adjustableColumn=True,columnAlign=(1,"left"))
    sphereSegmentsField=cmds.intSliderGrp(label="Sphere Segments",field=True,width=266, minValue=3, maxValue=64, fieldMinValue=1, fieldMaxValue=1000000000,value=20,dragCommand=setSphereSegments,changeCommand=setSphereSegments,adjustableColumn=True,columnAlign=(1,"left"))
        
    cmds.separator( height=15, style='in')
    
    cmds.setParent("..")
    cmds.setParent("..")
    
    cmds.frameLayout( label='VRayLightDome',backgroundColor=(0.341,0.341,0.341), collapsable=True)
    cmds.columnLayout(adjustableColumn=True,rowSpacing=2,columnAttach=("both",8))
    
    cmds.checkBox(label="Dome Spherical",onCommand=("domeSpherical(True)"),offCommand=("domeSpherical(False)"))
    cmds.checkBox(label="Use Ray Distance",onCommand=("useRayDistance(True)"),offCommand=("useRayDistance(False)"))
    rayDistanceField=cmds.floatSliderGrp(label="Ray Distance",field=True,width=266,enable=False, minValue=0, maxValue=100000, fieldMinValue=0, fieldMaxValue=1000000000,value=100000,dragCommand=setRayDistance,changeCommand=setRayDistance,precision=3,adjustableColumn=True,columnAlign=(1,"left"))
    
    cmds.separator( height=15, style='in')
    
    cmds.setParent("..")
    cmds.setParent("..")
    
    cmds.frameLayout( label='VRayLightRect',backgroundColor=(0.341,0.341,0.341), collapsable=True)
    cmds.columnLayout(adjustableColumn=True,rowSpacing=2,columnAttach=("both",8))
    
    doubleSidedBox=cmds.checkBox(label="Double Sided",onCommand=("doubleSided(True)"),offCommand=("doubleSided(False)"))
    skp=cmds.checkBox(label="Skylight Portal",onCommand=("skylightPortal(True)"),offCommand=("skylightPortal(False)"))
    sskp=cmds.checkBox(label="Simple Skylight Portal",onCommand=("simpleSkylightPortal(True)"),offCommand=("simpleSkylightPortal(False)"),enable=False)
    
    cmds.separator( height=15, style='in')
    
    cmds.setParent("..")
    cmds.setParent("..")
    
    cmds.frameLayout( label='VRayLightIES',backgroundColor=(0.341,0.341,0.341), collapsable=True)
    cmds.columnLayout(adjustableColumn=True,rowSpacing=2,columnAttach=("both",8))
    
    cmds.checkBox(label="Area Speculars",onCommand=("areaSpeculars(True)"),offCommand=("areaSpeculars(False)"), value=True)
    #skp=cmds.checkBox(label="Skylight Portal",onCommand=("skylightPortal(True)"),offCommand=("skylightPortal(False)"))
    #sskp=cmds.checkBox(label="Simple Skylight Portal",onCommand=("simpleSkylightPortal(True)"),offCommand=("simpleSkylightPortal(False)"),enable=False)
    
    #cmds.separator( height=15, style='in')
    
    cmds.setParent("..")
    cmds.setParent("..")
    
    cmds.setParent("..")
    cmds.setParent("..")
    
    cmds.setParent("..")
    
    cmds.separator( height=15, style='in')
    
    cmds.columnLayout(adjustableColumn=True,columnAttach=("both",80))    
    cmds.button(label="close",align="center", command=deleteWindow)
    cmds.setParent("..")
   
    cmds.separator( height=15, style='in')
    
    cmds.showWindow(myWindow)
Example #56
0
def build_gui_selection_manager():
    ''' Builds the main window for GT Selection Manager '''
    window_name = "build_gui_selection_manager"
    if cmds.window(window_name, exists =True):
        cmds.deleteUI(window_name)    

    # Main GUI Start Here =================================================================================

    build_gui_selection_manager = cmds.window(window_name, title=script_name + '  (v' + script_version + ')',\
                          titleBar=True, mnb=False, mxb=False, sizeable =True)
                          
    cmds.window(window_name, e=True, s=True, wh=[1,1])
    
    content_main = cmds.columnLayout(adj = True)
        
    # Title
    title_bgc_color = (.4, .4, .4)
    cmds.separator(h=10, style='none') # Empty Space
    cmds.rowColumnLayout(nc=1, cw=[(1, 270)], cs=[(1, 10)], p=content_main) # Window Size Adjustment
    cmds.rowColumnLayout(nc=3, cw=[(1, 10), (2, 200), (3, 50)], cs=[(1, 10), (2, 0), (3, 0)], p=content_main) # Title Column
    cmds.text(" ", bgc=title_bgc_color) # Tiny Empty Green Space
    cmds.text(script_name, bgc=title_bgc_color,  fn="boldLabelFont", align="left")
    cmds.button( l ="Help", bgc=title_bgc_color, c=lambda x:build_gui_help_selection_manager())
    cmds.separator(h=10, style='none', p=content_main) # Empty Space
    
    # Body ====================
    body_column = cmds.rowColumnLayout(nc=1, cw=[(1, 260)], cs=[(1,10)], p=content_main)
    
    cmds.separator(h=10)
    cmds.separator(h=5, style='none')  # Empty Space
    
    # Element Name
    cmds.text("Element Name")
    cmds.separator(h=10, style='none')  # Empty Space
    
    cmds.rowColumnLayout(nc=1, cw=[(1, 260)], cs=[(1,10)])
    contains_string_or_not_checkbox = cmds.checkBoxGrp(columnWidth2=[120, 1], numberOfCheckBoxes=2, \
                                label1 = ' Does Contain ', label2 = "  Doesn't Contain", v1 = gt_sel_manager.get("use_contains_string"), v2 = gt_sel_manager.get("use_contains_no_string"), \
                                cc1=lambda x:update_active_items(), cc2= lambda x:update_active_items())  
    
    # Element Name Textbox
    cmds.rowColumnLayout(nc=3, cw=[(1, 110),(2, 10),(3, 110)], cs=[(1,0),(2, 0),(2, 0)])
    contains_name_text_field = cmds.textField(text="_jnt", en=False, \
                                           enterCommand=lambda x:update_stored_values_and_run())
                                           
    cmds.separator(h=10, style='none')  # Empty Space
    
    contains_no_name_text_field = cmds.textField(text="endJnt, eye", en=False, \
                                           enterCommand=lambda x:update_stored_values_and_run())
                                           
    cmds.separator(h=10, style='none')  # Empty Space
    
    cmds.separator(h=10, p=body_column)
    
    # Element Type
    cmds.separator(h=5, style='none' , p=body_column)  # Empty Space
    cmds.text("Element Type", p=body_column)
    cmds.separator(h=5, style='none' , p=body_column)  # Empty Space
    
    cmds.rowColumnLayout(nc=1, cw=[(1, 260)], cs=[(1,10)], p=body_column)
    contains_type_or_not_checkbox = cmds.checkBoxGrp(columnWidth2=[120, 1], numberOfCheckBoxes=2, \
                                label1 = ' Does Contain ', label2 = "  Doesn't Contain", v1 = gt_sel_manager.get("use_contains_type"), v2 = gt_sel_manager.get("use_contains_no_type"), \
                                cc1=lambda x:update_active_items(), cc2= lambda x:update_active_items())  
    
    # Element Type Textbox
    cmds.rowColumnLayout(nc=3, cw=[(1, 110),(2, 10),(3, 110)], cs=[(1,0),(2, 0),(2, 0)])

    
    contains_type_text_field = cmds.textField(text="joint", en=False, \
                                           enterCommand=lambda x:update_stored_values_and_run()) 
    cmds.separator(h=10, style='none')  # Empty Space
    contains_no_type_text_field = cmds.textField(text="mesh", en=False, \
                                           enterCommand=lambda x:update_stored_values_and_run())

    
    # Element Type Shape Node Behaviour
    cmds.rowColumnLayout(nc=1, cw=[(1, 240)], cs=[(1,0)], p=body_column)
    cmds.separator(h=5, style='none')  # Empty Space
    shape_node_behavior_menu = cmds.optionMenu(en=False,label=' Behavior', cc=lambda x:update_active_items()) #######
    cmds.menuItem( label='Select Both Parent and Shape')
    cmds.menuItem( label='Select Shapes as Objects')
    cmds.menuItem( label='Select Parent Instead')
    cmds.menuItem( label='Ignore Shape Nodes')
    

    # Print Types Buttons
    cmds.separator(h=5, style='none')  # Empty Space
    cmds.rowColumnLayout(nc=2, cw=[(1, 130),(2, 130)], cs=[(1,0),(2, 0)], p=body_column)
    
    cmds.button(l ="Print Selection Types", c=lambda x:print_selection_types("selection"))                                                                    
    cmds.button(l ="Print All Scene Types", c=lambda x:print_selection_types("all")) 
    
    cmds.separator(h=5, style='none')  # Empty Space
    cmds.separator(h=10, p=body_column)
    
    # Visibility
    visibility_container = cmds.rowColumnLayout( p=body_column, numberOfRows=1)
    cmds.text("    ")
    use_visibility_state = cmds.checkBox(p=visibility_container, label=' Visibility State  --->  ', value=gt_sel_manager.get("use_visibility_state"),\
                         cc=lambda x:update_active_items())
    cmds.radioCollection()
    visibility_rb1 = cmds.radioButton( p=visibility_container, label=' On  ' , en=False)
    visibility_rb2 = cmds.radioButton( p=visibility_container,  label=' Off ', en=False, sl=True)
    cmds.separator(h=10, p=body_column)
    
    # Outline Color
    outline_color_container = cmds.rowColumnLayout( p=body_column, numberOfRows=1)
    cmds.text("    ")
    use_outline_color = cmds.checkBox(p=outline_color_container, label='', value=gt_sel_manager.get("use_outliner_color"),\
                         cc=lambda x:update_active_items())
                         
    has_outliner_color_slider_one = cmds.colorSliderGrp(en=False, label='Uses Outliner Color  --->  ', rgb=(gt_sel_manager.get("stored_outliner_color")[0], \
                                                                gt_sel_manager.get("stored_outliner_color")[1], gt_sel_manager.get("stored_outliner_color")[2]),\
                                                                columnWidth=((1,145),(2,30),(3,0)), cc=lambda x:update_active_items())
    cmds.button(l ="Get", bgc=(.2, .2, .2), w=30, c=lambda x:get_color_from_selection(has_outliner_color_slider_one), height=10, width=40)
    
    
    outline_no_color_container = cmds.rowColumnLayout( p=body_column, numberOfRows=1) 
    cmds.text("    ")                                              
    use_no_outline_color = cmds.checkBox(p=outline_no_color_container, label='', value=gt_sel_manager.get("use_no_outliner_color"),\
                         cc=lambda x:update_active_items())
                         
    has_no_outliner_color_slider_one = cmds.colorSliderGrp(en=False, label=' But Not Using This  --->   ', rgb=(gt_sel_manager.get("stored_no_outliner_color")[0], \
                                                                gt_sel_manager.get("stored_no_outliner_color")[1], gt_sel_manager.get("stored_no_outliner_color")[2]),\
                                                                columnWidth=((1,145),(2,30),(3,0)), cc=lambda x:update_active_items())
    cmds.button(l ="Get", bgc=(.2, .2, .2), w=30, c=lambda x:get_color_from_selection(has_no_outliner_color_slider_one), height=10, width=40)
                                                   
    cmds.separator(h=10, p=body_column)
    cmds.separator(h=5, style='none', p=body_column)  # Empty Space
                        
    # Store Selection One
    target_container = cmds.rowColumnLayout( p=body_column, numberOfRows=1)
    remove_from_sel_btn_one = cmds.button(p=target_container, l ="-", bgc=(.5, .3, .3), w=30, \
                            c=lambda x:selection_storage_manager('remove',1 ))
    store_sel_btn_one = cmds.button(p=target_container, l ="Store Selection", bgc=(.2, .2, .2), w=91, \
                            c=lambda x:selection_storage_manager('store',1))
    add_to_sel_btn_one = cmds.button(p=target_container, l ="+", bgc=(.3, .5, .3), w=30, \
                            c=lambda x:selection_storage_manager('add',1))
    reset_sel_btn_one = cmds.button(p=target_container, l ="Reset", w=55, \
                            c=lambda x:selection_storage_manager('reset',1))
    savesel_btn_one = cmds.button(p=target_container, l ="Save", w=55, \
                            c=lambda x:selection_storage_manager('save',1))
    
    # Store Selection Two
    target_container = cmds.rowColumnLayout( p=body_column, numberOfRows=1)
    remove_from_sel_btn_two = cmds.button(p=target_container, l ="-", bgc=(.5, .3, .3), w=30, \
                            c=lambda x:selection_storage_manager('remove',2))
    store_sel_btn_two = cmds.button(p=target_container, l ="Store Selection", bgc=(.2, .2, .2), w=91, \
                            c=lambda x:selection_storage_manager('store',2))
    add_to_sel_btn_two = cmds.button(p=target_container, l ="+", bgc=(.3, .5, .3), w=30, \
                            c=lambda x:selection_storage_manager('add',2))
    reset_sel_btn_two = cmds.button(p=target_container, l ="Reset", w=55, \
                            c=lambda x:selection_storage_manager('reset',2))
    save_sel_btn_two = cmds.button(p=target_container, l ="Save", w=55, \
                            c=lambda x:selection_storage_manager('save',2))
    cmds.separator(h=5, style='none', p=body_column)  # Empty Space

    save_as_container = cmds.rowColumnLayout( p=body_column, numberOfRows=1)                  
    cmds.radioCollection()
    
    save_as_quick_selection_rb1 = cmds.radioButton( p=save_as_container, sl=True, label=' Save as Quick Selection  ', cc=lambda x:update_active_items())
    cmds.radioButton( p=save_as_container,label=' Save as Text File ', cc=lambda x:update_active_items())

    cmds.separator(h=10, p=body_column)
    
    cmds.separator(h=10, style='none', p=body_column)  # Empty Space
    # Create New Selection (Main Function)
    cmds.button(p=body_column, l ="Create New Selection", c=lambda x:update_stored_values_and_run(True))
    
    cmds.separator(h=5, style='none', p=body_column)  # Empty Space
    # Update Selection (Main Function)
    cmds.button(p=body_column, l ="Update Current Selection", bgc=(.6, .6, .6), c=lambda x:update_stored_values_and_run(False))
    cmds.separator(h=10, style='none', p=body_column)  # Empty Space
    
    # End of Main Dialog =========================================================================================================
    
    def selection_storage_manager(operation, desired_container):
        '''
        Updates the storage section of the script
        
                Parameters:
                        operation (string): Which operation to execute. Save, load, store, reset, add, or remove.
                        desired_container (int): Which containg to update, 1 or 2.
        '''
        selection = cmds.ls(selection=True)
        error_detected = False
        
        if desired_container == 1:
            container = 'stored_selection_one'
            button = store_sel_btn_one
        else:
            container = 'stored_selection_two'
            button = store_sel_btn_two
        
        if len(selection) > 0:
            pass
        else:
            if operation != "save" and operation != "load" and operation != "add" and operation != "reset":
                cmds.warning('Nothing Selected')
            error_detected = True

            
        if operation == "remove" and error_detected == False:
            for obj in selection:
                if obj in gt_sel_manager.get(container):
                    try: 
                        gt_sel_manager.get(container).remove(obj)
                    except:
                        pass
        
        to_store_list = []
        if operation == "store" and error_detected == False:
            for obj in selection:
                to_store_list.append(obj)
            gt_sel_manager[container] = to_store_list
            
        to_add_list = []
        if operation == "add" and error_detected == False:
            for obj in selection:
                if obj not in gt_sel_manager.get(container):
                    to_add_list.append(obj)
                    
            for obj_add in to_add_list:
                gt_sel_manager.get(container).append(obj_add)
                     
        if operation == "reset":
            gt_sel_manager[container] = []
                
        if operation == "save":
            if gt_sel_manager.get('stored_save_as_quick_selection') != True:
                export_to_txt(gt_sel_manager.get(container)) ########
            else:
                new_set = cmds.sets(name="Set_StoredSelection_0" + str(desired_container))
                for obj in gt_sel_manager.get(container):
                    cmds.sets(obj, add=new_set)
                        
        if operation == "load":
            stored_list_manager(gt_sel_manager.get(container))

        # Updates Button
        if len(gt_sel_manager.get(container)) == 0:
            cmds.button(button, l ="Store Selection", e=True, bgc=(.2, .2, .2), c=lambda x:selection_storage_manager('store', desired_container))
        else:
            loaded_text = str(len(gt_sel_manager.get(container))) + " objects"
            if len(gt_sel_manager.get(container)) == 1:
                loaded_text = gt_sel_manager.get(container)[0]
            cmds.button(button, l =loaded_text,e=True, bgc=(.6, .8, .6), c=lambda x:selection_storage_manager('load',desired_container))
            
    
    def print_selection_types(selection_type):
        '''
        Prints the type of the selected objects.
                
                Parameters:
                        selection_type (string): Type of selection used when querying types. Selection = only selected objects. All = everything.
        '''
        selection = cmds.ls(selection=True)
        type_list = []
        if selection_type == "selection" and len(selection) > 0:
            for obj in selection:
                if cmds.objectType(obj) not in type_list:
                    type_list.append(cmds.objectType(obj))
                try: # Too handle elements without shapes
                    shape_node = cmds.listRelatives(obj, shapes=True, fullPath=True) or []
                except:
                    pass
                if shape_node != [] and cmds.objectType(shape_node[0]) not in type_list:
                    type_list.append(cmds.objectType(shape_node[0])+ " (Shape Node)") 

        if selection_type == "all":
            #type_list = cmds.ls(nodeTypes=True) # Too see every type available
            everything_in_scene = cmds.ls()
            for obj in everything_in_scene:
                if cmds.objectType(obj) not in type_list:
                    type_list.append(cmds.objectType(obj))
                try: # Too handle elements without shapes
                    shape_node = cmds.listRelatives(obj, shapes=True, fullPath=True) or []
                except:
                    pass
                if shape_node != [] and cmds.objectType(shape_node[0]) not in type_list:
                    type_list.append(cmds.objectType(shape_node[0]) + " (Shape Node)")

        if type_list != []:
            print("#" * 80)
            print(" " * 30 + " Types:")
            for type in type_list:
                print(type)
            print("#" * 80)
            #cmds.headsUpMessage( 'Open the Script Editor to see the list of types', verticalOffset=150 , time=5.0) 
            message = '<' + str(random.random()) + '>Open the <span style=\"color:#FF0000;\">Script Editor</span> to see the list of types.'
            cmds.inViewMessage(amg=message, pos='botLeft', fade=True, alpha=.9)
        else:
            cmds.warning("Nothing selected (or no types to be displayed)")

    def get_color_from_selection(color_slider):
        ''' 
        Updates many of the stored gui values (Used by multiple elements) 
        
                Parameters:
                        color_slider (colorSliderGrp): a color slider object to be updated.
        
        '''
        selection = cmds.ls(selection=True)
        if len(selection) > 0:
            obj_attr_list = cmds.listAttr(selection[0]) or []
            if len(obj_attr_list) > 0 and "outlinerColor" in obj_attr_list and "useOutlinerColor" in obj_attr_list:
                extracted_color = cmds.getAttr(selection[0] + ".outlinerColor")
                if cmds.getAttr(selection[0] + ".useOutlinerColor"):
                    cmds.colorSliderGrp(color_slider, e=True, rgb=extracted_color[0])
                else:
                    cmds.colorSliderGrp(color_slider, e=True, rgb=extracted_color[0])
                    cmds.warning("Color extracted, but it looks like the object selected is not using a custom outliner color")
            else:
                cmds.warning("Something went wrong. Try selecting another object.")
        else:
            cmds.warning("Nothing Selected. Please select an object containing the outliner color you want to extract and try again.")
        

    def update_active_items():
        ''' Updates many of the stored gui values (Used by multiple elements) '''
        # Updates Visibility and Use gt_sel_manager
        gt_sel_manager["use_contains_string"] = cmds.checkBoxGrp(contains_string_or_not_checkbox, q=True, value1=True)
        gt_sel_manager["use_contains_no_string"] = cmds.checkBoxGrp(contains_string_or_not_checkbox, q=True, value2=True)
        gt_sel_manager["use_contains_type"] = cmds.checkBoxGrp(contains_type_or_not_checkbox, q=True, value1=True)
        gt_sel_manager["use_contains_no_type"] = cmds.checkBoxGrp(contains_type_or_not_checkbox, q=True, value2=True)
        gt_sel_manager["use_visibility_state"] = cmds.checkBox(use_visibility_state, q=True, value=True)
        gt_sel_manager["use_outliner_color"] = cmds.checkBox(use_outline_color, q=True, value=True)
        gt_sel_manager["use_no_outliner_color"] = cmds.checkBox(use_no_outline_color, q=True, value=True)
        
        
        # Updates Visibility
        if gt_sel_manager.get("use_contains_string"):
            cmds.textField(contains_name_text_field, e=True, en=True)
        else:
            cmds.textField(contains_name_text_field, e=True, en=False)
            
        if gt_sel_manager.get("use_contains_no_string"):
            cmds.textField(contains_no_name_text_field, e=True, en=True)
        else:
            cmds.textField(contains_no_name_text_field, e=True, en=False)
            
        if gt_sel_manager.get("use_contains_type"):
            cmds.textField(contains_type_text_field, e=True, en=True)
        else:
            cmds.textField(contains_type_text_field, e=True, en=False)
        
        if gt_sel_manager.get("use_contains_no_type"):
            cmds.textField(contains_no_type_text_field, e=True, en=True)
        else:
            cmds.textField(contains_no_type_text_field, e=True, en=False)
        
        if gt_sel_manager.get("use_visibility_state"):
            cmds.radioButton( visibility_rb1, e=True, en=True)
            cmds.radioButton( visibility_rb2, e=True, en=True)
        else:
            cmds.radioButton( visibility_rb1, e=True, en=False)
            cmds.radioButton( visibility_rb2, e=True, en=False)
        
        if gt_sel_manager.get("use_outliner_color"):
            cmds.colorSliderGrp(has_outliner_color_slider_one, e=True, en=True)
        else:
            cmds.colorSliderGrp(has_outliner_color_slider_one, e=True, en=False)
        
        if gt_sel_manager.get("use_no_outliner_color"):
            cmds.colorSliderGrp(has_no_outliner_color_slider_one, e=True, en=True)
        else:
            cmds.colorSliderGrp(has_no_outliner_color_slider_one, e=True, en=False)
        
        
        # Stores Values
        gt_sel_manager["stored_contains_string"] = parse_text_field(cmds.textField(contains_name_text_field, q=True, text=True))
        gt_sel_manager["stored_contains_no_string"] = parse_text_field(cmds.textField(contains_no_name_text_field, q=True, text=True))
        gt_sel_manager["stored_contains_type"] = parse_text_field(cmds.textField(contains_type_text_field, q=True, text=True))
        gt_sel_manager["stored_contains_no_type"] = parse_text_field(cmds.textField(contains_no_type_text_field, q=True, text=True))
        
        
        if gt_sel_manager.get('use_contains_type') or gt_sel_manager.get('use_contains_no_type'):
            cmds.optionMenu(shape_node_behavior_menu, e=True, en=True)
        else:
            cmds.optionMenu(shape_node_behavior_menu, e=True, en=False)
  
        gt_sel_manager["stored_shape_node_type"] = cmds.optionMenu(shape_node_behavior_menu, q=True, value=True)
     
        gt_sel_manager["stored_visibility_state"]  = cmds.radioButton(visibility_rb1, q=True, select=True )
        gt_sel_manager["stored_save_as_quick_selection"]  = cmds.radioButton(save_as_quick_selection_rb1, q=True, select=True )

        gt_sel_manager["stored_outliner_color"] = cmds.colorSliderGrp(has_outliner_color_slider_one, q=True, rgb=True)
        
        gt_sel_manager["stored_no_outliner_color"] = cmds.colorSliderGrp(has_no_outliner_color_slider_one, q=True, rgb=True)

        
    def update_stored_values_and_run(is_new_selection): 
        ''' 
        Updates elements to reflect the use of the disconnect function. 
        Stored selection type.
        Then it runs the main function.
        
                Parameters:
                        is_new_selection (bool) : Is a new selection or existing one?
        
        '''
        update_active_items() # Updates Stored Values
        gt_sel_manager["stored_new_selection"] = is_new_selection
        manage_selection() # Runs main function

    # Show and Lock Window
    cmds.showWindow(build_gui_selection_manager)
    cmds.window(window_name, e=True, s=False)
    
    # Set Window Icon
    qw = omui.MQtUtil.findWindow(window_name)
    widget = wrapInstance(long(qw), QWidget)
    icon = QIcon(':/selectByHierarchy.png')
    widget.setWindowIcon(icon)
    def get_color(self):
        # color = cmds.colorSliderGrp(self._color_slider_widget.objectName(), q=True, rgbValue=True)
        color = cmds.colorSliderGrp(self._name, q=True, rgbValue=True)

        color = QtGui.QColor(color[0] * 255, color[1] * 255, color[2] * 255)
        return color
Example #58
0
cmds.menuItem(label="New Scene", command=('cmds.file(new=True, force=True)'))
cmds.menuItem(label="Delete Selected", command=('cmds.delete()'))

#          UI: adjust and create a Standard Block               #
#################################################################
cmds.frameLayout(collapsable=True,
                 label="Standard Block",
                 width=475,
                 height=140)

cmds.columnLayout()

cmds.intSliderGrp('height', l="Height", f=True, min=1, max=20, value=3)
cmds.intSliderGrp('blockWidth', l="Width", f=True, min=1, max=20, value=2)
cmds.intSliderGrp('blockLength', l="Length", f=True, min=1, max=20, value=8)
cmds.colorSliderGrp('blockColour', label="Colour", hsv=(120, 1, 1))

cmds.columnLayout()
cmds.button(label="Create Basic Block", command=('basicBlock()'))

# Level Up in Hierarchy
cmds.setParent('..')
cmds.setParent('..')
cmds.setParent('..')

#      UI: adjust and create a Standard Block With Holes        #
#################################################################
cmds.frameLayout(collapsable=True,
                 label="Standard Block with Holes",
                 width=475,
                 height=90)
def createUI():
    global win
    global colorField
    global temperatureField
    global intensityField
    global subdivsField
    global skp
    global sskp
    global noDecayBox
    global doubleSidedBox

    win = "multiLightWin"
    if cmds.window(win, exists=True):
        deleteWindow()

    myWindow = cmds.window(win,
                           title="VRay Multiple Light",
                           resizeToFitChildren=True,
                           sizeable=True,
                           maximizeButton=False,
                           minimizeButton=True)
    cmds.columnLayout(adjustableColumn=True,
                      rowSpacing=2,
                      columnAttach=("both", 8))

    cmds.separator(height=15, style='in')

    cmds.checkBox(label="Enabled",
                  onCommand=("enabled(True)"),
                  offCommand=("enabled(False)"),
                  value=True)

    cmds.separator(height=15, style='in')

    cmds.radioButtonGrp(numberOfRadioButtons=2,
                        labelArray2=["color", "temperature"],
                        changeCommand1="setColorMode(False)",
                        changeCommand2="setColorMode(True)",
                        select=1)

    cmds.separator(height=15, style='in')

    #cmds.rowLayout(numberOfColumns=2)

    cmds.columnLayout(adjustableColumn=True,
                      rowSpacing=2,
                      columnAttach=("both", 8))
    cmds.text(label="light Color", align="center", font="smallBoldLabelFont")
    colorField = cmds.colorSliderGrp(changeCommand=setColor,
                                     dragCommand=setColor)

    cmds.text(label="Temperature", align="center", font="smallBoldLabelFont")
    temperatureField = cmds.floatSliderGrp(field=True,
                                           minValue=0.00,
                                           maxValue=10000.00,
                                           fieldMinValue=0.00,
                                           fieldMaxValue=30000,
                                           dragCommand=setTemperature,
                                           changeCommand=setTemperature,
                                           value=6500,
                                           precision=3,
                                           enable=False)

    cmds.text(label="Intensity", align="center", font="smallBoldLabelFont")
    #cmds.separator( height=5)
    intensityField = cmds.floatSliderGrp(field=True,
                                         minValue=0.00,
                                         maxValue=100.00,
                                         fieldMinValue=0.00,
                                         fieldMaxValue=1000000000.00,
                                         dragCommand=setIntensity,
                                         changeCommand=setIntensity,
                                         value=30.00,
                                         precision=3)

    cmds.text(label="Subdivs", align="center", font="smallBoldLabelFont")
    subdivsField = cmds.intSliderGrp(field=True,
                                     minValue=1,
                                     maxValue=32,
                                     fieldMinValue=1,
                                     fieldMaxValue=1000000000,
                                     dragCommand=setSubdivs,
                                     changeCommand=setSubdivs,
                                     value=8)

    cmds.setParent("..")

    cmds.separator(height=15, style='in')

    noDecayBox = cmds.checkBox(label="No Decay",
                               onCommand=("noDecay(True)"),
                               offCommand=("noDecay(False)"))
    doubleSidedBox = cmds.checkBox(label="Double Sided",
                                   onCommand=("doubleSided(True)"),
                                   offCommand=("doubleSided(False)"))
    cmds.checkBox(label="invisible",
                  onCommand=("invisible(True)"),
                  offCommand=("invisible(False)"))
    skp = cmds.checkBox(label="Skylight Portal",
                        onCommand=("skylightPortal(True)"),
                        offCommand=("skylightPortal(False)"))
    sskp = cmds.checkBox(label="Simple Skylight Portal",
                         onCommand=("simpleSkylightPortal(True)"),
                         offCommand=("simpleSkylightPortal(False)"),
                         enable=False)
    cmds.checkBox(label="Store With Irradiance Map",
                  onCommand=("storeWithIrradianceMap(True)"),
                  offCommand=("storeWithIrradianceMap(False)"))

    cmds.separator(height=12, style='in')

    cmds.checkBox(label="Affect Diffuse",
                  onCommand=("affectDiffuse(True)"),
                  offCommand=("affectDiffuse(False)"),
                  value=True)
    cmds.checkBox(label="Affect Specular",
                  onCommand=("affectSpecular(True)"),
                  offCommand=("affectSpecular(False)"),
                  value=True)
    cmds.checkBox(label="Affect Reflections",
                  onCommand=("affectReflections(True)"),
                  offCommand=("affectReflections(False)"),
                  value=True)

    cmds.separator(height=15, style='in')

    cmds.columnLayout(adj=True, cat=("both", 70))
    cmds.button(label="close", align="center", command=deleteWindow)
    cmds.setParent("..")

    cmds.separator(height=15, style='in')
    cmds.showWindow(myWindow)
Example #60
0
def build_gui_color_manager():
    ''' Builds Main UI '''
    window_name = "build_gui_color_manager"
    if cmds.window(window_name, exists =True):
        cmds.deleteUI(window_name)    

    # Main GUI Start Here =================================================================================
    
    # Build UI
    build_gui_color_manager = cmds.window(window_name, title=script_name + '  (v' + script_version + ')',\
                          titleBar=True, mnb=False, mxb=False, sizeable =True)
                             
    cmds.window(window_name, e=True, s=True, wh=[1,1])
    
    content_main = cmds.columnLayout(adj = True)

    # Title Text
    title_bgc_color = (.4, .4, .4)
    cmds.separator(h=10, style='none') # Empty Space
    cmds.rowColumnLayout(nc=1, cw=[(1, 330)], cs=[(1, 10)], p=content_main) # Window Size Adjustment
    cmds.rowColumnLayout(nc=3, cw=[(1, 10), (2, 260), (3, 50)], cs=[(1, 10), (2, 0), (3, 0)], p=content_main) # Title Column
    cmds.text(" ", bgc=title_bgc_color) # Tiny Empty Green Space
    cmds.text(script_name, bgc=title_bgc_color,  fn="boldLabelFont", align="left")
    cmds.button( l ="Help", bgc=title_bgc_color, c=lambda x:build_gui_help_color_manager())
    cmds.separator(h=3, style='none', p=content_main) # Empty Space
    
    # Body ====================
    body_column = cmds.rowColumnLayout(nc=1, cw=[(1, 320)], cs=[(1,10)], p=content_main)

    cmds.rowColumnLayout(nc=1, cw=[(1, 300)], cs=[(1,10)])
        
    cmds.separator(h=20, p=body_column)
        
    mid_container = cmds.rowColumnLayout(p=body_column, h= 25,nc=2, cw=[(1, 160)], cs=[(1,5),(2,15)])
    mode_option = cmds.optionMenu(label='Mode', cc=lambda x:set_persistent_settings_color_manager('gt_color_manager_mode', cmds.optionMenu(mode_option, q=True, value=True)))
    cmds.menuItem( label='Drawing Override' )
    cmds.menuItem( label='Wireframe Color' )
    
    if gt_color_manager_settings.get('default_mode') == 'Drawing Override':
        cmds.optionMenu(mode_option, e=True, select=1) # 1-based selection
    else:
        cmds.optionMenu(mode_option, e=True, select=2) # 1-based selection
    
    target_option = cmds.optionMenu(label='Target', cc=lambda x:set_persistent_settings_color_manager('gt_color_manager_target', cmds.optionMenu(target_option, q=True, value=True)))
    cmds.menuItem( label='Transform' )
    cmds.menuItem( label='Shape' )
    
    if gt_color_manager_settings.get('default_target') == 'Transform':
        cmds.optionMenu(target_option, e=True, select=1) # 1-based selection
    else:
        cmds.optionMenu(target_option, e=True, select=2) # 1-based selection

    # Main Color Picker
    cmds.separator(h=10, style='none', p=body_column) # Empty Space
    color_container = cmds.rowColumnLayout(p=body_column, nc=1, h= 25, cw=[(1,310)], cs=[(1,5)])
    color_slider = cmds.colorSliderGrp(label='Current Color  ', rgb=(gt_color_manager_settings.get("current_color")[0], \
                                                                gt_color_manager_settings.get("current_color")[1],\
                                                                gt_color_manager_settings.get("current_color")[2]),\
                                                                cal=[1,'left'],
                                                                columnWidth=((1,80),(3,130)), cc=lambda x:update_stored_values())
    
    cmds.separator(h=7, style='none', p=body_column) # Empty Space
    
    c_btn_w = 30
    c_btn_s = 1
    cmds.rowColumnLayout(nc=10, cw=[(1,c_btn_w),(2,c_btn_w),(3,c_btn_w),(4,c_btn_w),(5,c_btn_w),(6,c_btn_w),(7,c_btn_w),(8,c_btn_w),(9,c_btn_w),(10,c_btn_w)],\
                         cs=[(1,5),(2,c_btn_s),(3,c_btn_s),(4,c_btn_s),(5,c_btn_s),(6,c_btn_s),(7,c_btn_s),(8,c_btn_s),(9,c_btn_s),(10,c_btn_s)], p=body_column)
    color_buttons_height = 20
    
    # Rainbow
    c_btn_01 = [1,.25,.25] # Red
    c_btn_02 = [1,.45,.15] # Orange
    c_btn_03 = [1,1,.35] # Yellow
    c_btn_04 = [.5,1,.20] # Green
    c_btn_05 = [.3,1,.8] # Cyan
    c_btn_06 = [.2,0.6,1] # Soft Blue
    c_btn_07 = [0,.2,1] # Blue
    c_btn_08 = [1,.45,.70] # Pink
    c_btn_09 = [.75,.35,.90] # Soft Purple
    c_btn_10 = [.45,0.2,0.9] # Purple
    

    cmds.button(l='', bgc=c_btn_01, h=color_buttons_height, c=lambda x:apply_preset(c_btn_01))
    cmds.button(l='', bgc=c_btn_02, h=color_buttons_height, c=lambda x:apply_preset(c_btn_02))
    cmds.button(l='', bgc=c_btn_03, h=color_buttons_height, c=lambda x:apply_preset(c_btn_03))
    cmds.button(l='', bgc=c_btn_04, h=color_buttons_height, c=lambda x:apply_preset(c_btn_04))
    cmds.button(l='', bgc=c_btn_05, h=color_buttons_height, c=lambda x:apply_preset(c_btn_05))
    cmds.button(l='', bgc=c_btn_06, h=color_buttons_height, c=lambda x:apply_preset(c_btn_06))
    cmds.button(l='', bgc=c_btn_07, h=color_buttons_height, c=lambda x:apply_preset(c_btn_07))
    cmds.button(l='', bgc=c_btn_08, h=color_buttons_height, c=lambda x:apply_preset(c_btn_08))
    cmds.button(l='', bgc=c_btn_09, h=color_buttons_height, c=lambda x:apply_preset(c_btn_09))
    cmds.button(l='', bgc=c_btn_10, h=color_buttons_height, c=lambda x:apply_preset(c_btn_10))
    
    cmds.separator(h=7, style='none', p=body_column) # Empty Space
    cmds.separator(h=15, p=body_column)
    bottom_container = cmds.rowColumnLayout(p=body_column,adj=True)
        
    checkbox_column = cmds.rowColumnLayout(p=bottom_container,nc=3, cw=[(1, 80),(2, 100),(3, 100)], cs=[(1,0),(2,60)],nbg=True)
    cmds.text('Set Color For')
    outliner_chk = cmds.checkBox(label='Outliner', p=checkbox_column, nbg=False, value=gt_color_manager_settings.get('default_set_outliner'),\
                                cc=lambda x:set_persistent_settings_color_manager('gt_color_manager_set_outliner',\
                                str(int(cmds.checkBox(outliner_chk, q=True, value=True)))))
    viewport_chk = cmds.checkBox(label='Viewport', p=checkbox_column, value=gt_color_manager_settings.get('default_set_viewport'),\
                                 cc=lambda x:set_persistent_settings_color_manager('gt_color_manager_set_viewport',\
                                 str(int(cmds.checkBox(viewport_chk, q=True, value=True)))))
    
    cmds.separator(h=10, style='none', p=bottom_container) # Empty Space
    cmds.button(l ="Reset", c=lambda x:set_color(reset=True), p=bottom_container) # Empty Space
    cmds.separator(h=5, style='none', p=bottom_container)
    cmds.button(l ="Apply", bgc=(.6, .6, .6), c=lambda x:set_color(), p=bottom_container) 
    cmds.separator(h=10, style='none', p=bottom_container) # Empty Space
                                                                                                                              
    def update_stored_values():
        ''' Updates Current Color '''
        
        gt_color_manager_settings["current_color"] = cmds.colorSliderGrp(color_slider, q=True, rgb=True) # for outliner?
        set_persistent_settings_color_manager('gt_color_manager_current_color', cmds.colorSliderGrp(color_slider, q=True, rgb=True))


    def apply_preset(rgb_color):
        '''
        Updates current color with the provided input then runs main function.
        
                Parameters:
                    rgb_color (list): a list of three floats describing an RGB Color (e.g. [1,0,0] for Red)
        
        '''
        managed_r = math.pow((rgb_color[0] + 0.055) / 1.055, 2.4)
        managed_g = math.pow((rgb_color[1] + 0.055) / 1.055, 2.4)
        managed_b = math.pow((rgb_color[2] + 0.055) / 1.055, 2.4)
        
        cmds.colorSliderGrp(color_slider, e=True, rgb= (managed_r,managed_g,managed_b))
        update_stored_values()
        set_color()

    def set_color(reset=False):
        '''' 
        Uses the provided settings to manage colors (Main function of this script) 
        
                Parameter:
                    reset (bool): Type of operation. Reset active will restore default colors.
        
        '''
        errors = ''
        try:
            function_name = 'GT Color Manager - Set Color'
            cmds.undoInfo(openChunk=True, chunkName=function_name)
            valid_selection = True
            objects_to_color = []
            colored_total = 0
            
            # Grab Necessary Values
            mode = cmds.optionMenu(mode_option, q=True, value=True)
            target = cmds.optionMenu(target_option, q=True, value=True)
            color = gt_color_manager_settings.get('current_color')
            set_outliner = cmds.checkBox(outliner_chk, q=True, value=True)
            set_viewport = cmds.checkBox(viewport_chk, q=True, value=True)
            
            # Functions
            def set_color_drawing_override(obj_to_set):
                ''' 
                Uses drawing override settings to set the color of an object 

                        Parameters:
                            obj_to_set (str): Name (path) of the object to affect.
                
                '''
                using_wireframe = cmds.getAttr(obj_to_set + '.useObjectColor')
                if using_wireframe != 0:
                    cmds.color( obj_to_set )
                cmds.setAttr(obj_to_set + '.overrideEnabled', 1)
                cmds.setAttr(obj_to_set + '.overrideRGBColors', 1)
                cmds.setAttr(obj_to_set + '.overrideColorR', color[0])
                cmds.setAttr(obj_to_set + '.overrideColorG', color[1])
                cmds.setAttr(obj_to_set + '.overrideColorB', color[2])
                return 1

            def set_color_wireframe_tool(obj_to_set):
                ''' 
                Uses wireframe color to set the color of an object 
                
                        Parameters:
                            obj_to_set (str): Name (path) of the object to affect.
                
                '''
                using_override = cmds.getAttr(obj_to_set + '.overrideEnabled')
                if using_override: 
                    cmds.setAttr(obj_to_set + '.overrideEnabled', 0)
                    cmds.setAttr(obj_to_set + '.overrideColorR', 0)
                    cmds.setAttr(obj_to_set + '.overrideColorG', 0)
                    cmds.setAttr(obj_to_set + '.overrideColorB', 0)
                cmds.color( obj_to_set, rgb=(color[0], color[1], color[2]) )
                return 1

            def set_color_outliner(obj_to_set):
                ''' 
                Sets the outliner color for the selected object 
                
                        Parameters:
                            obj_to_set (str): Name (path) of the object to affect.
                
                '''
                extrated_r = math.pow(color[0], 0.454)
                extrated_g = math.pow(color[1], 0.454)
                extrated_b = math.pow(color[2], 0.454)
                
                cmds.setAttr(obj_to_set + '.useOutlinerColor', 1)
                cmds.setAttr(obj_to_set + '.outlinerColorR', extrated_r)
                cmds.setAttr(obj_to_set + '.outlinerColorG', extrated_g)
                cmds.setAttr(obj_to_set + '.outlinerColorB', extrated_b)
                return 1
   
            def set_color_reset(obj_to_set, reset_overrides=False, reset_wireframe=False, reset_outliner=False):
                ''' Resets the color of the selected objects
                
                        Parameters:
                            obj_to_set (str): Name (path) of the object to affect.
                            reset_overrides (bool) : Reseting Overrides
                            reset_wireframe (bool) : Reseting Wireframe
                            reset_outliner (bool) : Reseting Outliner
                
                '''
                if reset_overrides:
                    using_override = cmds.getAttr(obj_to_set + '.overrideEnabled')
                    if using_override: 
                        cmds.setAttr(obj_to_set + '.overrideEnabled', 0)
                        cmds.setAttr(obj_to_set + '.overrideColorR', 0)
                        cmds.setAttr(obj_to_set + '.overrideColorG', 0)
                        cmds.setAttr(obj_to_set + '.overrideColorB', 0)
                
                if reset_wireframe:
                    using_wireframe = cmds.getAttr(obj_to_set + '.useObjectColor')
                    if using_wireframe != 0:
                        cmds.color( obj_to_set )
                
                if reset_outliner:
                    try:
                        cmds.setAttr(obj_to_set + '.useOutlinerColor', 0)
                    except:
                        pass
                return 1
          
            selection = cmds.ls(selection=True)
 
            if len(selection) < 1:
                valid_selection = False
                cmds.warning('You need to select at least one object.')
                
            if valid_selection:
            # Determine what to color
                if target == 'Transform':
                    objects_to_color = selection
                else:
                    for sel in selection:
                        shapes = cmds.listRelatives(sel, shapes=True, fullPath=True) or []
                        for shape in shapes:
                            objects_to_color.append(shape)
                
                # Determine total of objects to be colored
                if len(objects_to_color) < 1:
                    valid_selection = False
                    cmds.warning('No shapes were found. Make sure you\'re using the correct "Target" option.')
  
                
            # Set Color
            if valid_selection and reset == False:
                for obj in objects_to_color:
                    if set_viewport:
                        try:
                            if mode == 'Drawing Override':
                                colored_total += set_color_drawing_override(obj)
                            else:
                                colored_total += set_color_wireframe_tool(obj)
                        except Exception as e:
                            errors += str(e) + '\n'
                    if set_outliner:
                        try:
                            if set_viewport:
                                set_color_outliner(obj)
                            else:
                                colored_total += set_color_outliner(obj)
                        except Exception as e:
                            errors += str(e) + '\n'
                            
            if valid_selection and reset == True:
                for obj in objects_to_color:
                    if set_viewport:
                        try:
                           colored_total += set_color_reset(obj, reset_overrides=True, reset_wireframe=True)
                        except Exception as e:
                            errors += str(e) + '\n'
                    if set_outliner:
                        try:
                            if set_viewport:
                                set_color_reset(obj, reset_outliner=True)
                            else:
                                colored_total += set_color_reset(obj, reset_outliner=True)
                        except Exception as e:
                            errors += str(e) + '\n'
            
            # Create message 
            message = '<' + str(random.random()) + '><span style=\"color:#FF0000;text-decoration:underline;\">' +  str(colored_total) + ' </span>'
            is_plural = 'objects were'
            if colored_total == 1:
                is_plural = 'object was'
            if reset:
                message += is_plural + '  reset to the default color.'
            else:
                message += is_plural + '  colored.'
            
            cmds.inViewMessage(amg=message, pos='botLeft', fade=True, alpha=.9)
                
        except Exception as e:
            errors += str(e) + '\n'
        finally:
            cmds.undoInfo(closeChunk=True, chunkName=function_name)
        if errors != '':
            cmds.warning('An error occured. Open the script editor for more information.')
            print('######## Errors: ########')
            print(errors)
    
    # Show and Lock Window
    cmds.showWindow(build_gui_color_manager)
    cmds.window(window_name, e=True, s=False)
    
    # Set Window Icon
    qw = omui.MQtUtil.findWindow(window_name)
    widget = wrapInstance(long(qw), QWidget)
    icon = QIcon(':/render_swColorPerVertex.png')
    widget.setWindowIcon(icon)