Exemple #1
0
 def setValue(self, value):
     if(self.rootUI is not None):
         cmds.radioButtonGrp(self.axisRadio, edit=True, select=value.axis + 1)
         cmds.checkBox(self.negativeCheck, edit=True, value=value.negative)
         
     self.value = value
     self.callChangeFunc()
	def projListWindow(self, *args):

		global projRoot
		global pathTypeId
		global projRootList
		window = 'ProjectLoader'
		cmds.deleteUI(window) if cmds.window(window, ex= 1) else None
		cmds.window(window, t= window, s= 0)

		cmds.columnLayout(adj= 1)
		rdBtnLabel = ['Z :/', '//' + os.getenv('computername').lower() + '/', 'D :/']
		cmds.radioButtonGrp('pathTypeRidBtn', l= 'Path Type : ', la3= rdBtnLabel, an1 = rdBtnLabel[0], an2= rdBtnLabel[1], an3 = rdBtnLabel[2], nrb= 3,cw4= [70, 40, 65, 50], sl= pathTypeId, cc= self.changePathType)
		cmds.radioButtonGrp('workTypeRidBtn', l= 'Work Type : ', la2= ['1-scenes', '1-shots'], nrb= 2,cw3= [70, 70, 50], sl= workTypeId, cc= self.changeWorkType)
		cmds.frameLayout('projListFrame', l= 'List', li= 106, w= 244)
		cmds.columnLayout('projListColumn', adj= 1)
		cmds.button('openPrjBtn', l= projRoot, w= 240, h= 25, bgc= [0.1, 0.5, 0.7], c= self.openProjFolder)
		cmds.button('justForGapBtn1', l= '', h= 2, bgc= [.25,.25,.25], en= 0)
		for i, p in reversed(list(enumerate(projRootList))):
			if cmds.file(p, q= 1, ex= 1):
				projRoot = p
				pathTypeId = i + 1
				mel.eval('radioButtonGrp -e -en' + str(i + 1) + ' 1 -sl ' + str(pathTypeId) + ' "pathTypeRidBtn";')
			else:
				mel.eval('radioButtonGrp -e -en' + str(i + 1) + ' 0 -sl ' + str(pathTypeId) + ' "pathTypeRidBtn";')
		if projRoot:
			self.refreshProjList()
		else:
			sorryStr = 'All project root path off-line.\n' + '\n'.join(projRootList)
			cmds.confirmDialog( title='Sorry', message=sorryStr, button=['Confirm'], defaultButton='Confirm', icon= 'information')
		cmds.window(window, e= 1, w= 10, h= 10)
		cmds.showWindow(window)
def enableCurve(*args):
    """when hierarchy is selected, this enables the option for curves only """
    val = cmds.radioButtonGrp(widgets["hierarchyRBG"], q=True, sl=True)
    if val==2:
        cmds.radioButtonGrp(widgets["curvesRBG"], e=True, en=True)
    else:
        cmds.radioButtonGrp(widgets["curvesRBG"], e=True, en=False)
	def __init__(self): 
		### Initialize, definitions		
	    	if(mc.window("ms_orientJoint",exists=True)):
            	    mc.deleteUI("ms_orientJoint",window=True)
	    	mc.window("ms_orientJoint",title="Orient Joint v1.0",rtf=True)
	    	mc.columnLayout()
	    	
	    	mc.rowLayout(nc=2)
	    	mc.text(" ")
	    	mc.text("Orient joint A to joint B")
	    	mc.setParent("..")
	    	
	    	mc.separator(w=500)

		self.aimAxisField = mc.radioButtonGrp(label="Aim Axis",labelArray3=['x','y','z'],nrb=3,sl = 1)
		self.aimAxisPolField = mc.radioButtonGrp(label="Aim Axis Polarity",labelArray2=['+','-'],nrb=2,sl = 1)
		self.upAxisField = mc.radioButtonGrp(label="Up Axis",labelArray3=['x','y','z'],nrb=3,sl  = 2)
		self.upPolarityField = mc.radioButtonGrp(label="Up Axis Polarity",labelArray2=['+','-'],nrb=2,sl=1)
		
		mc.separator(w=500)
		
		mc.rowLayout(nc=3)
		mc.text(" ")
		mc.button(label="-=Orient=-",c=self.orient)
		mc.button(label="-=None Orient=-",c=self.noneOrient)
		
		mc.setParent("..")

	    	mc.showWindow("ms_orientJoint")
Exemple #5
0
    def mainModule(self):
        cmds.rowColumnLayout(nc=2,cw =[(1,130),(2,285)]) #etchedOut rowlumnLayout.str#
        cmds.frameLayout(label=self.moduleLabel,mw =1 ,mh =3,bs="etchedOut",cl= 0,cll=0 ,h=self.hgt)
        cmds.symbolButton(h= 80,image= 'sphere.png' )
        #cmds.rowColumnLayout( numberOfRows=1 ) #Side rowlumnLayout.str#

        #cmds.setParent('..')   #Side rowlumnLayout.end#
        cmds.setParent('..')   #etchedOut rowlumnLayout.end#

        cmds.frameLayout(label='options:',mw =1 ,mh =3,bs="etchedOut",cl= 0,cll=0 ,h= self.hgt)
        #optionsForm = cmds.formLayout()
        cmds.rowColumnLayout(nc=5,cw =[(1,50),(2,50),(3,50),(4,50),(5,50)])
        cmds.text(l='joint:')
        cmds.text(l='fingers:')
        cmds.text(l='no:')
        cmds.text(l='segment:')
        cmds.text(l='symmetry:')
        cmds.textField()
        cmds.checkBox(l ="" )
        cmds.textField()
        cmds.textField()
        cmds.checkBox(l ="" )
        #cmds.formLayout(optionsForm ,e=1,)
        cmds.setParent('..')

        cmds.rowColumnLayout( numberOfRows=1 )#Side: .str
        cmds.text(l=' Side: ')
        cmds.radioButtonGrp(nrb=2 ,la2=["L","R"] ,cw2=[30 ,30],sl =1)
        cmds.scrollField(wordWrap =1,text ="creates arm skeleton template setup. ideal use: any arm Humans, Insects.." ,editable= 0,h=80,w=180)
        cmds.setParent('..')##Side: .end

        cmds.setParent('..')
        cmds.setParent('..')
        cmds.separator(height =3 ,style= "none" )
Exemple #6
0
def makeGUI():

    if cmds.window('CameraProject', ex=1, q=1): 
        cmds.deleteUI('CameraProject')
    camProjWindow = cmds.window('CameraProject')
    form = cmds.formLayout(numberOfDivisions=125)
    b1 = cmds.radioButtonGrp('ButtonOne', label='Frame Type', labelArray2=['Animated', 'Specific Frame(s)'], numberOfRadioButtons=2)
    b2 = cmds.radioButtonGrp('ButtonTwo', label='Material Type', labelArray2=['VRayLight', 'VRayMtl'], numberOfRadioButtons=2)
    tf3 = cmds.textField('textField', width=200)
    sepText = cmds.text(label = 'Separate frames by comma (limit 9)')
    b3 = cmds.button(label='GO', width=100, command='cameraProject.actOnPress()')
    
    ########## Checks for ShotCam #############
    
    if not cmds.objExists('*shotcam*'):
        shotcamWarn = cmds.text(label = 'Could not find shotcam. Please import and re-run tool.', bgc = [1,0,0])
    else:
        shotcamWarn = cmds.text(label = 'Found shotcam', bgc = [0,1,0])
        
    ######## Checks for HDR #################
        
    hdrExists = cmds.ls(type='VRayLightDomeShape')
    if len(hdrExists) == 0:
        hdrWarn = cmds.text(label = 'Could not find HDR. Please import and re-run tool', bgc = [1,0,0])
    else:
        hdrWarn = cmds.text('Found HDR', bgc = [0,1,0])
        
    ####### Loads VRay ##########################
    
    if cmds.pluginInfo('vrayformaya', q=True, loaded=True) == False:
        cmds.loadPlugin('vrayformaya', qt=True)
    
    cmds.formLayout(form, edit=True, attachControl=[(b1, 'bottom', 5, b2), (tf3, 'left', 25, b1), (b2, 'bottom', 25, b3), (tf3, 'bottom', 5, sepText), (b3, 'bottom', 50, shotcamWarn), (shotcamWarn, 'bottom', 75, hdrWarn)], attachForm = [(b3, 'left', 500), (sepText, 'left', 410), (shotcamWarn, 'left', 25), (hdrWarn, 'left', 25)])
    cmds.showWindow(camProjWindow)
Exemple #7
0
def jointOrientRefreshUI_aimAxis():
	'''
	Refresh Aim Axis list based on Primary Axis selection.
	'''
	labelIndex = mc.radioButtonGrp('jointOrientPrimAxisRBG',q=True,sl=True)
	labelArray = [('Y','Z'),('X','Z'),('X','Y')]
	mc.radioButtonGrp('jointOrientAimAxisRBG',e=True,la2=labelArray[labelIndex-1])
Exemple #8
0
	def uiSetFlags(self):
		'''
		Gets the channel state data from the UI and then sets the flags.
		'''
		# Get channel state flag values
		channelState = []
		for attr in self.channel:
			channelState.append(mc.radioButtonGrp('rbg'+attr.upper(),q=1,sl=1)-2)
		
		# Get list of objects to set flags for
		objType = mc.radioButtonGrp('rbgObjType',q=1,sl=1)
		objectList = []
		
		if objType == 1: objectList = mc.ls(sl=1)
		elif objType == 2:
			doit = mc.confirmDialog(title='Confirm Set Flags on ALL Transforms', 
						m='Are you sure you want to mass edit all the channel state attributes?',
						button=('Yes','No'),
						defaultButton='No',
						cancelButton='No',
						dismissString='NO')
			if doit == 'No': return
			objectList = mc.ls('*.channelState',o=True)
		elif objType == 3:
			selType = mc.textField('tfType',q=1,text=1)
			objectList = mc.ls(type=selType)
		
		# Set Flags
		self.setFlags(channelState,objectList)
 def __init__(self,*args):
     if(cmds.window("rbbnChainBuilder",exists=True)):
         cmds.deleteUI("rbbnChainBuilder",window=True)
 	
     cmds.window("rbbnChainBuilder",title="Build Ribbon Rig v1.0", rtf=True)
     cmds.columnLayout()
     
 	self.prefixFld = cmds.textFieldGrp(label='Prefix',text='L_upLegRbbn_')	        
     self.ribbonFld = cmds.textFieldButtonGrp( label="Ribbon:", buttonLabel="Load", bc = self.loadRibbon)#,text='main_plane'  )
     self.startFld = cmds.textFieldButtonGrp( label="Start Control:", buttonLabel="Load", bc = self.loadStart,text='cnt_1'  )
     self.endFld = cmds.textFieldButtonGrp( label="End Control:", buttonLabel="Load", bc = self.loadEnd,text='cnt_2' )
     self.numFld = cmds.intFieldGrp(label='Controls:',nf=1,v1=5)
     self.skinFld = cmds.intFieldGrp(label='Skin Joints:',nf=1,v1=5)
     self.buildFld = cmds.radioButtonGrp(nrb=2,labelArray2=('U','V'),label='Build along:',sl=1)
     
     
     cmds.frameLayout(label='Control Options: ',fn='boldLabelFont',cll=False)
     cmds.columnLayout()
     self.crvCreateFld = cmds.radioButtonGrp(nrb=2,labelArray2=('Yes','No'),label='Create bend-bo controls?',sl=1)
     self.radFld = cmds.floatFieldGrp(label='Radius:',nf=1,v1=0.2)
     self.crvNrFld = cmds.radioButtonGrp(nrb=3,labelArray3=('X','Y','Z'),label='Controller normal Axis:',sl=2)
     cmds.setParent("..")
     cmds.setParent("..")
     
     cmds.rowLayout(nc=2,cw2=(200,100))
     cmds.text(' ')
     cmds.button(label = "          Create", c = self.buildRig,w=100 )
 	cmds.setParent('..')
 		
     cmds.showWindow("rbbnChainBuilder")
Exemple #10
0
 def readUI(self):
     '''
     This reads the UI elements and turns them into arguments saved in a kwargs style member variable
     '''
     
     if self.uiArgDict:
         #this is some fanciness to read the values of UI elements and generate or run the resulting command
         #keys represent the argument names, the values are UI elements
         
         for k in self.uiArgDict.keys():
             
             uiType = mc.objectTypeUI(self.uiArgDict[k])
             value = None
             if uiType == 'rowGroupLayout':
                 controls = mc.layout(self.uiArgDict[k], query=True, childArray=True)
                 if 'check1' in controls:
                     value = mc.checkBoxGrp(self.uiArgDict[k], query=True, value1=True)
                 elif 'radio1' in controls:
                     buttonNumber = mc.radioButtonGrp(self.uiArgDict[k], query=True, select=True)
                     #there should be a control for the label and each the buttons..I hope
                     labels = mc.radioButtonGrp(self.uiArgDict[k], query=True, **{'labelArray'+str(len(controls)-1):True})
                     value = labels[buttonNumber-1]
             else:
                 OpenMaya.MGlobal.displayWarning('Cannot read '+uiType+' UI element: '+self.uiArgDict[k])
                 continue
             
             self.kwargs[k] = value
def doOptions(input_width, input_divisionsType, input_divisions, input_divisionsPerUnit, input_taper, input_frontTwist, input_lengthTwist, input_upVector, input_uvScale, input_uvScaleType, input_uvPinLocation):
	"""This is the function called when the apply or create button is clicked"""
	try:
		utils.dg.validateSelection(type='transform', min=1)
		curves = utils.dg.getFilteredRelatives(cmds.ls(sl=True), 'nurbsCurve', False)
		if len(curves) is 0: raise Exception('None of the objects you have selected are NURBS curves.')
				
		# call the command
		if cmds.radioButtonGrp(input_divisionsType, q=True, select=True) == 1:
			cmds.am_ribbon(
				width = cmds.floatSliderGrp(input_width, q=True, v=True),
				divisions = cmds.floatSliderGrp(input_divisions, q=True, v=True),
				taper = cmds.floatSliderGrp(input_taper, q=True, v=True),
				twistBase = cmds.floatSliderGrp(input_frontTwist, q=True, v=True),
				twistLength = cmds.floatSliderGrp(input_lengthTwist, q=True, v=True),
				upVector = cmds.floatFieldGrp(input_upVector, q=True, v=True),
				uvScale = cmds.floatSliderGrp(input_uvScale, q=True, v=True),
				uvGroupScale = cmds.radioButtonGrp(input_uvScaleType, q=True, select=True) - 1,
				uvPin = cmds.radioButtonGrp(input_uvPinLocation, q=True, select=True) - 1)
		else:
			cmds.am_ribbon(
				width = cmds.floatSliderGrp(input_width, q=True, v=True),
				divisionsPerUnit = cmds.floatSliderGrp(input_divisionsPerUnit, q=True, v=True),
				taper = cmds.floatSliderGrp(input_taper, q=True, v=True),
				twistBase = cmds.floatSliderGrp(input_frontTwist, q=True, v=True),
				twistLength = cmds.floatSliderGrp(input_lengthTwist, q=True, v=True),
				upVector = cmds.floatFieldGrp(input_upVector, q=True, v=True),
				uvScale = cmds.floatSliderGrp(input_uvScale, q=True, v=True),
				uvGroupScale = cmds.radioButtonGrp(input_uvScaleType, q=True, select=True) - 1,
				uvPin = cmds.radioButtonGrp(input_uvPinLocation, q=True, select=True) - 1)
	except: raise
def makeGUI():
    if cmds.window('VRayAtrributeAssigner', ex=1, q=1):
        cmds.deleteUI('VRayAttributeAssigner')      
    
    vrayAttrAssignWindow = cmds.window('VRayAttributeAssigner')
    form = cmds.formLayout()
    
    RB1 = cmds.radioButtonGrp('ButtonOne', label='Assign to objects  ', labelArray2=['By Selection', 'By Keyword'], numberOfRadioButtons=2, of2 = 'cmds.textField("keyIn", enable=0, edit=True)', on2 = 'cmds.textField("keyIn", enable=1, edit=True)',  cw3 = [150, 100, 50])
    getButtonState = cmds.radioButtonGrp('ButtonOne', q=True, sl=True)
    keyText = cmds.text(label = 'Keyword')
    keyInput = cmds.textField('keyIn', width = 200, enable=0)
    
    debugButton = cmds.button(label='DEBUG', width=50, command='debugButton()')
    
    IDcheckBox = cmds.checkBox('IDCheck', label = 'Object ID', ofc = 'cmds.textField("IDIn", enable=0, edit=True)\ncmds.checkBox("IDRemove", value=0, enable=0, edit=True)',  onc = 'cmds.textField("IDIn", enable=1, edit=True)\ncmds.checkBox("IDRemove", enable=1, edit=True)' )
    
    IDRemoveBox = cmds.checkBox('IDRemove', label = 'Remove', en=False, onc = 'cmds.textField("IDIn", enable=0, edit=True)',  ofc = 'cmds.textField("IDIn", enable=1, edit=True)')
    
    IDText = cmds.text(label = 'Object ID #')
    IDInput = cmds.textField('IDIn', tx = '0', width = 50, enable=0)
    
    UAcheckBox = cmds.checkBox('UACheck', label = 'User Attributes', ofc = 'cmds.textField("UAIn", enable=0, edit=True)\ncmds.checkBox("UARemove", value = 0, enable=0, edit=True)',  onc = 'cmds.textField("UAIn", enable=1, edit=True)\ncmds.checkBox("UARemove", enable=1, edit=True)')
    
    UARemoveBox = cmds.checkBox('UARemove', label = 'Remove', en=False, onc = 'cmds.textField("UAIn", enable=0, edit=True)',  ofc = 'cmds.textField("UAIn", enable=1, edit=True)')
    
    UAText = cmds.text(label = 'UserAttributes')
    UAInput = cmds.textField('UAIn', width = 500, enable=0)
    
    DOIT = cmds.button(label='DO IT!', width=100, command='actOnPress()')
    
    cmds.formLayout(form, edit=True, attachForm = [(RB1, 'left', 0), (RB1, 'top', 10), (keyText, 'top', 35), (keyText, 'left', 100), (keyInput, 'top', 30), (keyInput, 'left', 150), (debugButton, 'top', 30), (debugButton, 'left', 360), (IDcheckBox, 'top', 75), (IDcheckBox, 'left', 25), (IDRemoveBox, 'top', 75), (IDRemoveBox, 'left', 100), (IDText, 'left', 15), (IDText, 'top', 100), (IDInput, 'left', 80), (IDInput, 'top', 95), (UAcheckBox, 'top', 135), (UAcheckBox, 'left', 25), (UARemoveBox, 'top', 135), (UARemoveBox, 'left', 125), (UAText, 'left', 15), (UAText, 'top', 165), (UAInput, 'left', 100), (UAInput, 'top', 160), (DOIT, 'left', 500), (DOIT, 'top', 200)])
  
     
    cmds.showWindow(vrayAttrAssignWindow)
def tanUI(*args):
    """the UI for the clean/tangent functions"""
    if cmds.window("tanWin", exists=True):
        cmds.deleteUI("tanWin")

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

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

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

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

    cmds.showWindow(widgets["win"])
    cmds.window(widgets["win"], e=True, w=300, h=160)
Exemple #14
0
 def setEnabled(self, enabled):
     if(self.rootUI is not None):        
         if(enabled):
             cmds.radioButtonGrp(self.axisRadio, edit=True, enable=True)
             cmds.checkBox(self.negativeCheck, edit=True, enable=True)
         else:
             cmds.radioButtonGrp(self.axisRadio, edit=True, enable=False)
             cmds.checkBox(self.negativeCheck, edit=True, enable=False)
 def cmdAimRig(self, *args):
     ar = web.mod('animRig_lib')
     axs = [None, [1, 0, 0], [0, 1, 0], [0, 0, 1]]
     inverseA = cmds.checkBox(self.actionColumn.c15, q=True, v=True)
     aimGp = cmds.radioButtonGrp(self.actionColumn.aimGrp, q=True, select=True)
     inverseU = cmds.checkBox(self.actionColumn.c16, q=True, v=True)
     upGp = cmds.radioButtonGrp(self.actionColumn.upGrp, q=True, select=True)
     ar.aimRig(target=None, obj=None, aim=axs[aimGp], u=axs[upGp], tipOffset=1.0, mo=False, bake=True, inverseA=inverseA, inverseU=inverseU)
Exemple #16
0
 def mirrorChange(self, *args):
     #get state of the mirror checkbox
     on = cmds.checkBox(self.widgets["mirrorCB"], q=True, v=True)
     #if it's on, turn on the other options
     if on:
         cmds.radioButtonGrp(self.widgets["axisRBG"], e=True, en=True)
     #if not, turn off the other options
     else:
         cmds.radioButtonGrp(self.widgets["axisRBG"], e=True, en=False)
def brickHeightToggle():
    flatBrick = cmds.checkBox('flatBrickCheck', query = True, value = True)
    
    if( flatBrick == True ):
        cmds.intSliderGrp( 'brickHeight', edit = True, value = 1, enable = False)
        cmds.radioButtonGrp( 'brickHoleOptions', edit = True, select = 3, enable = False)
    elif( flatBrick == False ):
        cmds.intSliderGrp( 'brickHeight', edit = True, enable = True )
        cmds.radioButtonGrp( 'brickHoleOptions', edit = True, enable = True)
def enableSelect(*args):
    """when hierarchy is selected, this enables the option for curves only """
    val = cmds.radioButtonGrp(widgets["tanHierRBG"], q=True, sl=True)
    if val==2:
        cmds.radioButtonGrp(widgets["tanCurvesRBG"], e=True, en=True)
        cmds.button(widgets["selectBut"], e=True, en=True)
    else:
        cmds.radioButtonGrp(widgets["tanCurvesRBG"], e=True, en=False)
        cmds.button(widgets["selectBut"], e=True, en=False)
def selectHier(*args):
    """this selects the objects based on the filters in the tangents tab"""

    #get selected objects
    hier = cmds.radioButtonGrp(widgets["hierarchyRBG"], q=True, sl=True)
    curves = cmds.radioButtonGrp(widgets["curvesRBG"], q=True, sl=True)

    selection = cmds.ls(sl=True, type="transform")
    #this is the selection list to operate on
    sel = []
    if selection:
        if hier==2:
            #if hierarchy is selected, we then (and only then) have the option to choose the types we'll get
            if curves == 1:
                #filter the selection down to the new selection
                curveList = []
                for obj in selection:
                    relsSh = cmds.listRelatives(obj, ad=True, f=True, type=["nurbsCurve", "renderBox", "renderSphere", "renderCone"])
                    if relsSh:
                        for shape in relsSh:
                            curve = cmds.listRelatives(shape, p=True, f=True, type="transform")[0]
                            curveList.append(curve)
                if curveList:
                    for curve in curveList:
                        sel.append(curve)

                for obj in selection:
                    sel.append(obj)

            elif curves == 2:
                #get transforms without filtering for curves
                dagList = []
                for obj in selection:
                    transform = cmds.listRelatives(obj, ad=True, f=True, type="transform")
                    if transform:
                        for this in transform:
                            dagList.append(this)
                    #add in the object itself
                    dagList.append(obj)

                for this in dagList:
                    sel.append(this)

                for obj in selection:
                    sel.append(obj)

        elif hier==1:
            for obj in selection:
                sel.append(obj)

        #now select
        cmds.select(cl=True)
        cmds.select(sel)

    else:
        cmds.warning("You don't have any transforms selected!")
Exemple #20
0
	def uiSetAll(self,select):
		'''
		Function used by ChannelState.ui().
		Sets all channel state radio buttons to a specified value
		@param select: The value to set the radio buttons to
		@type select: int
		'''
		for attr in self.channel:
			# Set RadioButton Selection
			mc.radioButtonGrp('rbg'+attr.upper(),e=1,sl=select)
Exemple #21
0
def jointOrientRefreshUI_aimAxis():
    """
    Refresh Aim Axis list based on Primary Axis selection.
    """
    # Get Orient Axis Label Index
    labelIndex = cmds.radioButtonGrp("jointOrientPrimAxisRBG", q=True, sl=True)
    if not labelIndex:
        labelIndex = cmds.radioButtonGrp("jointOrientPrimAxisNegRBG", q=True, sl=True) + 3
    labelArray = [("Y", "Z"), ("X", "Z"), ("X", "Y")] * 2
    cmds.radioButtonGrp("jointOrientAimAxisRBG", e=True, la2=labelArray[labelIndex - 1])
def tf_buttonCmd():
    
    #set the selection type for the selectedJoint array to joint only...
    selectedJoint = cmds.ls(selection=True, type='joint')
    #if we've selected any joints
    if len(selectedJoint) > 0:
        #do all of this stuff...
        colorIndex = cmds.colorIndexSliderGrp( colorSlider, query = True, value = True)
        
        dummySizeW = cmds.intSliderGrp(sizeSliderW, query = True, value = True)
        dummySizeD = cmds.intSliderGrp(sizeSliderD, query = True, value = True)
        
        subdivs = cmds.radioButtonGrp(dummyRadio, query= True, sl= True)
        
        
        #check if we have the prefix enabled
        if cmds.checkBox(lockPrefixText, query= True, value = True) == 1 :
            prefix = cmds.textField(dummyPrefix, query = True, tx= True)
        else:
            prefix = ""
        #check if we have the suffix text enabled
        if cmds.checkBox(lockSuffixText, query= True, value = True) == 1 :
            suffix = cmds.textField(dummySuffix, query = True, tx= True)
        else:
            suffix = ""
        
        
        allDisplayLayers = cmds.ls(type = 'displayLayer')
        dummyLayer = 'DummyLayer'
        #check if we have the DummyLayer
        doLayer = tf_findDupeLayer(dummyLayer,allDisplayLayers)
        #if not... make it
        if doLayer == 0:
            tf_createLayer(dummyLayer, colorIndex)
            
        #if they want joint and all children
        if cmds.radioButtonGrp( jointRadio, query=True, sl=True ) == 1 :
            
            allDescendants_SA = tf_listChain( selectedJoint )
            #do the dummy on the root joint
            tf_doTheDummy( selectedJoint[0], colorIndex, dummySizeW, dummySizeD, subdivs, prefix, suffix)
            #now iterate through the whole joint chain
            for eachJoint in allDescendants_SA:
                
                tf_doTheDummy( eachJoint, colorIndex, dummySizeW, dummySizeD, subdivs, prefix, suffix)
                
                
        #if they want selected joint   
        if cmds.radioButtonGrp( jointRadio, query=True, sl=True ) == 2:
    
            tf_doTheDummy( selectedJoint[0], colorIndex, dummySizeW, dummySizeD, subdivs, prefix, suffix)
            
    #if we don't have any selected joints... return warning to console
    else:
        cmds.warning("Select joint(s) then press 'Create'")
Exemple #23
0
def addItemUI():
    """ create the ui that asks for the name, command and source type of the custom item """
    deleteWindow(WINDOWNAME)
    cmds.window(WINDOWNAME, t='add custom item', s=False)
    cmds.formLayout()
    cmds.columnLayout(adj=True)
    cmds.textFieldGrp('create_customname', label='name', text='')
    cmds.textFieldGrp('create_customCommand', label='command', text='')
    cmds.radioButtonGrp('create_customSourceRadioButton',label='source:', nrb=2, l1='python', l2='mel', select=1)
    cmds.separator('create_customSeparator', style='in')
    cmds.button(l='add', command=createItem)
    # displays the window
    cmds.showWindow(WINDOWNAME)
 def cmdAimPivotRig(self, *args):
     ar = web.mod('animRig_lib')
     axs = [None, [1, 0, 0], [0, 1, 0], [0, 0, 1]]
     inverseA = cmds.checkBox(self.actionColumn.c18, q=True, v=True)
     aimGp = cmds.radioButtonGrp(self.actionColumn.aimPivotGrp, q=True, select=True)
     inverseU = cmds.checkBox(self.actionColumn.c19, q=True, v=True)
     upGp = cmds.radioButtonGrp(self.actionColumn.upPivotGrp, q=True, select=True)
     master = cmds.checkBox(self.actionColumn.c21, q=True, v=True)
     masterPos = cmds.radioButtonGrp(self.actionColumn.masterGrp, q=True, select=True) - 1
     distance = cmds.floatSliderGrp(self.actionColumn.sl1, q=True, v=True)
     autoDs = cmds.checkBox(self.actionColumn.c22, q=True, v=True)
     # ar.aimPivotRig(target=None, obj=None, size=0.3, aim=axs[aimGp], u=axs[upGp], tipOffset=1.0, mo=False, bake=True, inverseA=inverseA, inverseU=inverseU)
     ar.aimPivotRig(aim=axs[aimGp], u=axs[upGp], offset=distance, masterControl=master, masterPosition=masterPos, inverseA=inverseA, inverseU=inverseU, autoDistance=autoDs)
Exemple #25
0
 def createBtnCmd(self, *args):
     # Creates a function for the radio button group.
     self.objIndAsCmd = {1:mc.polyCube, 2:mc.polyCone, 3:mc.polyCylinder, 4:mc.polySphere}
     # Creates the object variable for the create function.
     objIndex = mc.radioButtonGrp(self.objType, query = True, select = True)
     # Creates a variable for the new object to be created based on the above array and objIndex variable.
     newObject = self.objIndAsCmd[objIndex]()
    
     # Following section creates necessary variables for the expression.
     # Creates a variable to select the previously created object.
     sel = mc.ls(sl=True)
     # Creates the attribute variable using the user input from the GUI.
     att = mc.textField(self.attribute, query = True, text = True)
     # Creates the minimum value variable using the user input from the GUI.
     minimum = mc.floatField(self.min, query = True, value = True)
     # Creates the maximum value variable using the user input from the GUI.
     maximum = mc.floatField(self.max, query = True, value = True)
     # Creates the time period variable using the user input from the GUI.
     period = mc.floatField(self.time, query = True, value = True)
     # Creates the variable for the type of oscillation radio group.
     oscType = mc.radioButtonGrp(self.oscillate, query = True, select = True)
     # Creates the speed variable for which the created object will travel at.
     speed = 6.28/period
     # Creates the random variable.  It is created as 'ran' because random is a pre-defined function in python.
     ran = (maximum - minimum)/2.0
     # Creates the start variable.
     start = minimum + ran
     
    
     # Creates the expression that will drive the script.
     # objectName.attributeName = sin(time*speed) * range + start.
     # Creates the expression for the cos oscillation.
     expressionTextCos = (sel[0] + "." + str(att)
                       + " = cos(time * " + str(speed)
                       + " ) * " + str(ran) + " + "
                       + str(start) + ";")
     
     # Creates the expression for sin
     expressionTextSin = (sel[0] + "." + str(att)
                       + " = sin(time * " + str(speed)
                       + " ) * " + str(ran) + " + "
                       + str(start) + ";")
     # Calls the expression.
     if oscType == 1:
         mc.expression(string=expressionTextSin)
         print "ExpressionSin has sucessfully run."
     elif oscType == 2:
         mc.expression(string=expressionTextCos)
         print "ExpressionCos has successfully run."
     else:
         print "Expression didn't properly execute."
def antiAliasNoiseQual():
	global aanqSeparator
	aanqGroup1=cmds.radioButtonGrp( "aanqRadButGrp1", numberOfRadioButtons=3, label='Anitalias/Noise Qual (15%)', labelArray3=['A+ -A', 'B+ -B', 'C+ -C'], onCommand=antiAliasButton1)
	aanqGroup2=cmds.radioButtonGrp( "aanqRadButGrp2", numberOfRadioButtons=2, shareCollection=aanqGroup1, label='', labelArray2=['D', 'F'], onCommand=antiAliasButton2)
	cmds.formLayout( gradeFrm, edit=1, attachForm=[aanqGroup1, "left", 5], attachControl=[aanqGroup1, "top", 5, cflSeparator])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[aanqGroup2, "left", 5, ], attachControl=[aanqGroup2, "top", 5, aanqGroup1])
	aanqShapeField=cmds.intFieldGrp( "aanqIntField", numberOfFields=1, label='Grade', changeCommand=updateGradeTotal)
	aanqTextScrollList=cmds.scrollField("aanqTSList", w=200, h=150, wordWrap=1)
	aanqCommentsLabel=cmds.text( label='Comments' )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[aanqShapeField, "top", 5], attachControl=[aanqShapeField, "top", 10, aanqGroup2])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[aanqTextScrollList, "left", 140], attachControl=[aanqTextScrollList, "top", 10, aanqShapeField])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[aanqCommentsLabel, "left", 60], attachControl=[aanqCommentsLabel, "top", 10, aanqShapeField])
	aanqSeparator=cmds.separator( height=15, width=460, style='in' )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[aanqSeparator, "left", 5], attachControl=[aanqSeparator, "top", 5, aanqTextScrollList])
def rayTracing():
	global rayTraceSeparator
	rayTraceGroup1 = cmds.radioButtonGrp( "rayTraceButGrp1", numberOfRadioButtons=3, label='Raytracing (40&)', labelArray3=['A+ -A', 'B+ -B', 'C+ -C'], onCommand=rayTraceButton1 )
	rayTraceGroup2 = cmds.radioButtonGrp( "rayTraceButGrp2", numberOfRadioButtons=2, shareCollection=rayTraceGroup1, label='', labelArray2=['D', 'F'], onCommand=rayTraceButton2  )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[rayTraceGroup1, "left", 5], attachControl=[rayTraceGroup1, "top", 5, mateTextSeparator])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[rayTraceGroup2, "left", 5, ], attachControl=[rayTraceGroup2, "top", 5, rayTraceGroup1])
	rayTraceShapeField=cmds.intFieldGrp( "rayTraceIntField", numberOfFields=1, label='Grade', changeCommand=updateGradeTotal)
	rayTraceTextScrollList=cmds.scrollField("rayTraceTSList", w=200, h=150, wordWrap=1)
	rayTraceCommentsLabel=cmds.text( label='Comments' )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[rayTraceShapeField, "top", 5], attachControl=[rayTraceShapeField, "top", 10, rayTraceGroup2])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[rayTraceTextScrollList, "left", 140], attachControl=[rayTraceTextScrollList, "top", 10, rayTraceShapeField])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[rayTraceCommentsLabel, "left", 60], attachControl=[rayTraceCommentsLabel, "top", 10, rayTraceShapeField])
	rayTraceSeparator=cmds.separator( height=15, width=460, style='in' )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[rayTraceSeparator, "left", 5], attachControl=[rayTraceSeparator, "top", 5, rayTraceTextScrollList])
def lightingFunction():
	global lightSeparator
	lightGroup1 = cmds.radioButtonGrp( "lightButGrp1", numberOfRadioButtons=3, label='Lighting (60%)', labelArray3=['A+ -A', 'B+ -B', 'C+ -C'], onCommand=lightingButton1 )
	lightGroup2 = cmds.radioButtonGrp( "lightButGrp2", numberOfRadioButtons=2, shareCollection=lightGroup1, label='', labelArray2=['D', 'F'], onCommand=lightingButton2  )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[[lightGroup1, "top", 5], [lightGroup1, "left", 5]])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[lightGroup2, "left", 5, ], attachControl=[lightGroup2, "top", 5, lightGroup1])
	lightShapeField=cmds.intFieldGrp( "lightIntField", numberOfFields=1, label='Grade', changeCommand=updateGradeTotal)
	lightTextScrollList=cmds.scrollField("lightTSList", w=200, h=150, wordWrap=1)
	lightCommentsLabel=cmds.text( label='Comments' )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[lightShapeField, "top", 5], attachControl=[lightShapeField, "top", 10, lightGroup2])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[lightTextScrollList, "left", 140], attachControl=[lightTextScrollList, "top", 10, lightShapeField])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[lightCommentsLabel, "left", 60], attachControl=[lightCommentsLabel, "top", 10, lightShapeField])
	lightSeparator=cmds.separator( height=15, width=460, style='in' )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[lightSeparator, "left", 5], attachControl=[lightSeparator, "top", 5, lightTextScrollList])
def compFocalLength():
	global cflSeparator
	cflGroup1 = cmds.radioButtonGrp( "cflButGrp1", numberOfRadioButtons=3, label='Comp/Focal Length (15%)', labelArray3=['A+ -A', 'B+ -B', 'C+ -C'], onCommand=compFocalButton1 )
	cflGroup2 = cmds.radioButtonGrp( "cflButGrp2", numberOfRadioButtons=2, shareCollection=cflGroup1, label='', labelArray2=['D', 'F'], onCommand=compFocalButton2  )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[cflGroup1, "left", 5], attachControl=[cflGroup1, "top", 5, lightSeparator])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[cflGroup2, "left", 5, ], attachControl=[cflGroup2, "top", 5, cflGroup1])
	cflShapeField=cmds.intFieldGrp( "cflIntField", numberOfFields=1, label='Grade', changeCommand=updateGradeTotal)
	cflTextScrollList=cmds.scrollField("cflTSList", w=200, h=150, wordWrap=1)
	cflCommentsLabel=cmds.text( label='Comments' )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[cflShapeField, "top", 5], attachControl=[cflShapeField, "top", 10, cflGroup2])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[cflTextScrollList, "left", 140], attachControl=[cflTextScrollList, "top", 10, cflShapeField])
	cmds.formLayout( gradeFrm, edit=1, attachForm=[cflCommentsLabel, "left", 60], attachControl=[cflCommentsLabel, "top", 10, cflShapeField])
	cflSeparator=cmds.separator( height=15, width=460, style='in' )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[cflSeparator, "left", 5], attachControl=[cflSeparator, "top", 5, cflTextScrollList])
    def secondWindow(self,*args):
        if(mc.window('fkAttsToControlWin',exists=True)):
            mc.deleteUI('fkAttsToControlWin',window=True)

        numFlds = mc.intField(self.numChains,query=True,value=True)

        if(mc.window('fkInitialWin',exists=True)):
            mc.deleteUI('fkInitialWin',window=True)

        mc.window('fkAttsToControlWin',title='FK Atts To Control v1.1',rtf=True)
        mc.columnLayout()

        self.labelField = mc.textFieldGrp(label='Main Label:',text='L_Hand')
        self.cntField = mc.textFieldButtonGrp(label='Control:',bl='Load',bc=self.loadCnt) 


        self.attNameFlds = []
        self.startFlds = []
        self.endFlds = []

        x = 0
        while x < numFlds:
            x = x + 1

            mc.frameLayout( label='Limb %i'%x,cll=True,cl=False )
            mc.columnLayout()
            self.attNameFlds.append( mc.textFieldGrp(label='Attribute name:') )
            self.startFlds.append( mc.textFieldButtonGrp(label='Start Joint:',bl='load' )  )
            self.endFlds.append( mc.textFieldButtonGrp(label='End Joint:',bl='load')  )
            mc.setParent("..")
            mc.setParent("..")	


            startFldCmd = 'sel = mc.ls(sl=True,fl=True)\nmc.textFieldButtonGrp("%s", edit=True, text=sel[0])' % self.startFlds[x-1]
            mc.textFieldButtonGrp( self.startFlds[x-1], edit=True,bc = startFldCmd)
            endFldCmd = 'sel = mc.ls(sl=True,fl=True)\nmc.textFieldButtonGrp("%s", edit=True, text=sel[0])' % self.endFlds[x-1]
            mc.textFieldButtonGrp( self.endFlds[x-1], edit=True,bc = endFldCmd)

        mc.text('  Axis: ',font='boldLabelFont')
        self.aimField = mc.radioButtonGrp(label='Curl Rotate Axis:',nrb=3,labelArray3=('x','y','z'),sl=3)
        self.twistField = mc.radioButtonGrp(label='Twist Rotate Axis:',nrb=3,labelArray3=('x','y','z'),sl=1)
        self.upField = mc.radioButtonGrp(label='Spread Rotate Axis:',nrb=3,labelArray3=('x','y','z'),sl=2)

        mc.rowLayout(nc=2,cw2=(200,100))
        mc.text(" ")
        mc.button(label='    -=Create=-',w=80,c=self.createHand)
        mc.setParent("..")

        mc.showWindow('fkAttsToControlWin')
Exemple #31
0
def createUI(uiID,scriptName):    
           
    if cmds.window(uiID, exists = True):    
            cmds.deleteUI(uiID)
            
    objectList = cmds.ls(selection = True)
    alignTarget = objectList.pop(-1)  
    targetRotScl = cmds.xform(alignTarget, query = True, rotation = True, worldSpace = True) + cmds.xform(alignTarget, query = True, scale = True, relative = True, worldSpace = True) #zmienna przechowująca rotacje i skale docelowego obiektu

    objectListInitial = [] #trzyma początkowe transofrmacje obiwktów z objectList
    
    for x in objectList:
        transform = [cmds.getAttr(x + '.translateX'), 
                     cmds.getAttr(x + '.translateY'),
                     cmds.getAttr(x + '.translateZ'),
                     cmds.getAttr(x + '.rotateX'),
                     cmds.getAttr(x + '.rotateY'),
                     cmds.getAttr(x + '.rotateZ'),
                     cmds.getAttr(x + '.scaleX'),
                     cmds.getAttr(x + '.scaleY'),
                     cmds.getAttr(x + '.scaleZ')]
        objectListInitial.append(transform)

    def cancelCallback(*pArgs):
        if cmds.window(uiID, exists = True):
            cmds.deleteUI(uiID)
            
        for obj in objectList: #pętla przywracające wstępne transformacje w razie cancel
            x = objectList.index(obj)
            cmds.setAttr(obj + '.translate',objectListInitial[x][0],objectListInitial[x][1],objectListInitial[x][2])
            cmds.setAttr(obj + '.rotate',objectListInitial[x][3],objectListInitial[x][4],objectListInitial[x][5])
            cmds.setAttr(obj + '.scale',objectListInitial[x][6],objectListInitial[x][7],objectListInitial[x][8])
        
    def okCallback(*pArgs):
        if cmds.window(uiID, exists = True):
            cmds.deleteUI(uiID)
                           
    def changePos(*pArgs):
        turboAlignUiKemot[0] = cmds.checkBox(posX, query = True, value = True)
        turboAlignUiKemot[1] = cmds.checkBox(posY, query = True, value = True)
        turboAlignUiKemot[2] = cmds.checkBox(posZ, query = True, value = True) 
        turboAlignUiKemot[3] = cmds.radioButtonGrp(currentObj, query = True, select = True)   
        turboAlignUiKemot[4] = cmds.radioButtonGrp(targetObj, query = True, select = True)
        posValuList = turboAlignUiKemot[:3] #lista trzymająca checkboxy x y z pozycji
        #alignTargetTransforms = [] --------przetrzymuje dane o pozycji targetu       

        #==========sekcja kodu do wyznaczania pozycji odniesienia docelowego obiektu TARGET
        if turboAlignUiKemot[4] == 1:
            targetPosition = cmds.xform(alignTarget, query = True, boundingBox = True)[:3]
            
        elif turboAlignUiKemot[4] == 2:
            targetPosition = cmds.objectCenter(alignTarget)
            
        elif turboAlignUiKemot[4] == 3:
            targetPosition = cmds.xform(alignTarget, query = True, rp = True, ws = True)
            
        elif turboAlignUiKemot[4] == 4:
            targetPosition = cmds.xform(alignTarget, query = True, boundingBox = True)[3:]
            
        #==========sekcja kodu do wyznaczania pozycji odniesienia zaznaczonych obiektów CURRENT
        if turboAlignUiKemot[3] == 1:
            for obj in objectList:
                objMinimum = cmds.xform(obj, query = True, boundingBox = True)[:3]
                objCenter = cmds.objectCenter(obj)
                positionMinimum = [targetPosition[0] + (objCenter[0] - objMinimum[0]), targetPosition[1] + (objCenter[1] - objMinimum[1]), targetPosition[2] + (objCenter[2] - objMinimum[2])]
                transform = combineLists(positionMinimum, objectListInitial[objectList.index(obj)],posValuList)
                cmds.setAttr(obj + '.translate', transform[0], transform[1], transform[2])
            
        elif turboAlignUiKemot[3] == 2:
            for obj in objectList:
                transform = combineLists(targetPosition, objectListInitial[objectList.index(obj)],posValuList)
                cmds.setAttr(obj + '.translate', transform[0], transform[1], transform[2]) 
                
            
        elif turboAlignUiKemot[3] == 3:
            for obj in objectList:
                objPivot = cmds.xform(obj, query = True, rp = True)
                positionPivot = [targetPosition[0] - objPivot[0], targetPosition[1] - objPivot[1], targetPosition[2] - objPivot[2]]
                transform = combineLists(positionPivot, objectListInitial[objectList.index(obj)],posValuList)
                cmds.setAttr(obj + '.translate', transform[0], transform[1], transform[2]) 
            
        elif turboAlignUiKemot[3] == 4:
            for obj in objectList:
                objMaximum = cmds.xform(obj, query = True, boundingBox = True)[3:]
                objCenter = cmds.objectCenter(obj)
                positionMaximum = [targetPosition[0] + (objCenter[0] - objMaximum[0]), targetPosition[1] + (objCenter[1] - objMaximum[1]), targetPosition[2] + (objCenter[2] - objMaximum[2])]
                transform = combineLists(positionMaximum, objectListInitial[objectList.index(obj)],posValuList)
                cmds.setAttr(obj + '.translate', transform[0], transform[1], transform[2])
                
    def changeRot(*pArgs):
        turboAlignUiKemot[5] = cmds.checkBox(orientX, query = True, value = True)
        turboAlignUiKemot[6] = cmds.checkBox(orientY, query = True, value = True)
        turboAlignUiKemot[7] = cmds.checkBox(orientZ, query = True, value = True)
        for obj in objectList:
            transform = combineLists(targetRotScl[:3],objectListInitial[objectList.index(obj)][3:6],turboAlignUiKemot[5:8])
            cmds.setAttr(obj + '.rotate', transform[0], transform[1], transform[2])
        
    def changeScl(*pArgs):
        turboAlignUiKemot[8] = cmds.checkBox(scaleX, query = True, value = True)
        turboAlignUiKemot[9] = cmds.checkBox(scaleY, query = True, value = True)
        turboAlignUiKemot[10] = cmds.checkBox(scaleZ, query = True, value = True)
        for obj in objectList:
            transform = combineLists(targetRotScl[3:],objectListInitial[objectList.index(obj)][6:],turboAlignUiKemot[8:])
            cmds.setAttr(obj + '.scale', transform[0], transform[1], transform[2])
        
    cmds.window(uiID, title = scriptName, sizeable = False, width = 300) #komenda ropzpoczynająca tworzenie struktury okna  
    cmds.columnLayout(columnAttach = ('both', 5), columnWidth = 300)
    cmds.separator(height = 25, style = 'singleDash')
    cmds.text(label = 'Align position', align = 'center')
    cmds.separator(height = 25, style = 'singleDash')
    cmds.setParent('..')
    
    cmds.rowLayout(numberOfColumns = 3, columnWidth = [(1,100),(2,100),(3,100)])
    posX = cmds.checkBox(label = 'X Position', value = turboAlignUiKemot[0], changeCommand = changePos)
    posY = cmds.checkBox(label = 'Y Position', value = turboAlignUiKemot[1], changeCommand = changePos)
    posZ = cmds.checkBox(label = 'Z Position', value = turboAlignUiKemot[2], changeCommand = changePos)
    cmds.setParent('..') #przestaje szukać childów dla rowLayout
    cmds.separator(height = 20, style = 'none')
    
    cmds.rowLayout(columnAttach = [(1, 'both', 0),(2, 'left', 5)], numberOfColumns = 2, columnWidth = [(1,150),(2,150)])
    cmds.text(label = 'Current object:', align = 'center')
    cmds.text(label = 'Target object:', align = 'center')
    cmds.setParent('..')
    cmds.separator(height = 5, style = 'none')
            
    cmds.rowLayout(columnAttach = [(1, 'both', 25),(2, 'left', 5)], numberOfColumns = 2, columnWidth = [(1,150),(2,150)])
    currentObj = cmds.radioButtonGrp(numberOfRadioButtons = 4, vertical = True, labelArray4 = ('Minimum','Center','Pivot point','Maximum'), select = turboAlignUiKemot[3], onCommand = changePos)
    targetObj = cmds.radioButtonGrp(numberOfRadioButtons = 4, vertical = True, labelArray4 = ('Minimum','Center','Pivot point','Maximum'), select = turboAlignUiKemot[4], onCommand = changePos)
    cmds.setParent('..')
    cmds.separator(height = 25, style = 'singleDash')
    
    cmds.text(label = 'Align orientation (local)', align = 'center')
    cmds.separator(height = 15, style = 'none')
    cmds.rowLayout(numberOfColumns = 3, columnWidth = [(1,100),(2,100),(3,100)])
    orientX = cmds.checkBox(label = 'X Axis', value = turboAlignUiKemot[5], changeCommand = changeRot)
    orientY = cmds.checkBox(label = 'Y Axis', value = turboAlignUiKemot[6], changeCommand = changeRot)
    orientZ = cmds.checkBox(label = 'Z Axis', value = turboAlignUiKemot[7], changeCommand = changeRot)
    cmds.setParent('..')
    cmds.separator(height = 25, style = 'singleDash')
    
    cmds.text(label = 'Align scale', align = 'center')
    cmds.separator(height = 15, style = 'none')
    cmds.rowLayout(numberOfColumns = 3, columnWidth = [(1,100),(2,100),(3,100)])
    scaleX = cmds.checkBox(label = 'X Axis', value = turboAlignUiKemot[8], changeCommand = changeScl)
    scaleY = cmds.checkBox(label = 'Y Axis', value = turboAlignUiKemot[9], changeCommand = changeScl)
    scaleZ = cmds.checkBox(label = 'Z Axis', value = turboAlignUiKemot[10], changeCommand = changeScl)
    cmds.setParent('..')
    cmds.separator(height = 25, style = 'singleDash')
    
    cmds.rowLayout(columnAttach = [(1, 'both', 15),(2, 'both',0)], numberOfColumns = 2)
    cmds.button(label = 'OK', width = 120, height = 30, command = okCallback)
    cmds.button(label = 'Cancel', width = 120, height = 30, command = cancelCallback)
   
    changePos()
    changeRot()
    changeScl()
    print 'done'
          
    cmds.showWindow() #komenda pokazująca okno
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 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)
Exemple #34
0
def OCT_RenderSet_zwz_UI():
    if mc.windowPref('RenderSet_zwz', exists=True):
        mc.windowPref('RenderSet_zwz', remove=True)
    if mc.window('RenderSet_zwz', exists=True):
        mc.deleteUI('RenderSet_zwz', window=True)
    allCameras = mc.listCameras(p=True)
    myStartFrameV = mc.getAttr("defaultRenderGlobals.startFrame")
    myEndFrameV = mc.getAttr("defaultRenderGlobals.endFrame")
    myRenderwidth = mc.getAttr("defaultResolution.width")
    myRenderheight = mc.getAttr("defaultResolution.height")

    mc.window("RenderSet_zwz",
              title=u"OCT_RenderSet_zwz",
              menuBar=True,
              widthHeight=(350, 340),
              resizeToFitChildren=True,
              sizeable=True)
    mc.formLayout('formLyt', numberOfDivisions=100)

    one = mc.columnLayout('First_Set', parent='formLyt')
    mc.rowLayout('projectRow',
                 numberOfColumns=3,
                 columnAttach3=['left', 'left', 'left'],
                 columnWidth3=[5, 260, 35],
                 columnOffset3=[2, 2, 2],
                 adjustableColumn3=True,
                 parent='First_Set')
    mc.text(label=u'工程地址:', w=68, parent='projectRow')
    mc.textField('ProjectAddress',
                 text='',
                 width=250,
                 alwaysInvokeEnterCommandOnReturn=True,
                 parent='projectRow')
    mc.button(label=u'设置',
              width=35,
              command='OCT_generel.OCT_RenderSet_zwz.SetProjectAddress_zwz()',
              backgroundColor=(0.9, 0.5, 0),
              annotation=u"请输入工程层名",
              parent='projectRow')

    mc.rowLayout('oneRow',
                 numberOfColumns=3,
                 columnAttach3=['left', 'left', 'left'],
                 columnWidth3=[5, 260, 35],
                 columnOffset3=[2, 2, 2],
                 adjustableColumn3=True,
                 parent='First_Set')
    mc.text(label=u'一般渲染名:', w=68, parent='oneRow')
    mc.textField(
        'RederAddress',
        text=
        '<Scene>/<RenderLayer>/<Camera>/<RenderPass>/<Camera>.<RenderPass>',
        width=250,
        alwaysInvokeEnterCommandOnReturn=True,
        parent='oneRow')
    mc.button(label=u'设置',
              width=35,
              command='OCT_generel.OCT_RenderSet_zwz.SetRenderAddress_zwz()',
              backgroundColor=(0.9, 0.5, 0),
              annotation=u"请输入渲染层名",
              parent='oneRow')

    mc.rowLayout('twoRow',
                 numberOfColumns=3,
                 columnAttach3=['left', 'left', 'left'],
                 columnWidth3=[5, 260, 35],
                 columnOffset3=[2, 2, 2],
                 adjustableColumn3=True,
                 parent='First_Set')
    mc.text(label=u'Vray渲染名:', w=68, parent='twoRow')
    mc.textField('VrayRederAddress',
                 text='<Scene>/<Layer>/<Camera>/<Camera>',
                 width=250,
                 alwaysInvokeEnterCommandOnReturn=True,
                 parent='twoRow')
    mc.button(
        label=u'设置',
        width=35,
        command='OCT_generel.OCT_RenderSet_zwz.SetVrayRenderAddress_zwz()',
        backgroundColor=(0.9, 0.5, 0),
        annotation=u"请输入渲染层名",
        parent='twoRow')

    mc.rowLayout('threeRow',
                 numberOfColumns=2,
                 columnAttach2=['left', 'left'],
                 columnWidth2=[260, 35],
                 columnOffset2=[2, 1],
                 columnAlign=[1, 'left'],
                 cw2=[334, 35],
                 parent='First_Set')
    mc.radioButtonGrp(
        'FormatSet',
        label=u'渲染格式设置:',
        labelArray2=['Software/Mental Ray (iff)', 'Arnold (Tiff)'],
        numberOfRadioButtons=2,
        columnAlign=[1, 'left'],
        columnAlign2=['left', 'left'],
        cw3=[85, 160, 90],
        sl=1,
        parent='threeRow')
    mc.button(label=u'设置',
              width=35,
              command='OCT_generel.OCT_RenderSet_zwz.SetRenderFormat_zwz()',
              backgroundColor=(0.9, 0.5, 0),
              annotation=u"请输入需要选择物体的名字",
              parent='threeRow')

    mc.rowLayout('fourRow',
                 numberOfColumns=5,
                 columnAttach5=['left', 'left', 'left', 'left', 'left'],
                 columnWidth5=[5, 68, 70, 88, 80],
                 columnOffset5=[2, 2, 10, 15, 24],
                 adjustableColumn5=True,
                 parent='First_Set')
    mc.text(label=u'开始帧:', w=68, parent='fourRow')
    mc.textField('startFrame',
                 text=myStartFrameV,
                 width=60,
                 alwaysInvokeEnterCommandOnReturn=True,
                 parent='fourRow')
    mc.text(label=u'结束帧:', w=68, parent='fourRow')
    mc.textField('endFrame',
                 text=myEndFrameV,
                 width=60,
                 alwaysInvokeEnterCommandOnReturn=True,
                 parent='fourRow')
    mc.button(label=u'设置',
              width=35,
              command='OCT_generel.OCT_RenderSet_zwz.SetRenderStarFram_zwz()',
              backgroundColor=(0.9, 0.5, 0),
              annotation=u"请输入帧数范围",
              parent='fourRow')

    mc.rowLayout('fiveRow',
                 numberOfColumns=5,
                 columnAttach5=['left', 'left', 'left', 'left', 'left'],
                 columnWidth5=[5, 68, 70, 88, 80],
                 columnOffset5=[2, 2, 10, 15, 24],
                 adjustableColumn5=True,
                 parent='First_Set')
    mc.text(label=u'宽:', w=68, parent='fiveRow')
    mc.textField('RenderWidth',
                 text=myRenderwidth,
                 width=60,
                 alwaysInvokeEnterCommandOnReturn=True,
                 parent='fiveRow')
    mc.text(label=u'高:', w=68, parent='fiveRow')
    mc.textField('RenderHeight',
                 text=myRenderheight,
                 width=60,
                 alwaysInvokeEnterCommandOnReturn=True,
                 parent='fiveRow')
    mc.button(label=u'设置',
              width=35,
              command='OCT_generel.OCT_RenderSet_zwz.SetRenderWH_zwz()',
              backgroundColor=(0.9, 0.5, 0),
              annotation=u"请输入渲染尺寸",
              parent='fiveRow')

    two = mc.frameLayout('Cameras_Set',
                         label=u'设置渲染摄像机(面板可拉伸)',
                         labelAlign='top',
                         borderStyle='etchedOut',
                         w=300,
                         h=100,
                         parent='formLyt')
    mc.textScrollList('selectCameras',
                      append=allCameras,
                      allowMultiSelection=True,
                      h=100,
                      parent='Cameras_Set')

    three = mc.columnLayout('Second_Set', parent='formLyt')
    mc.rowLayout('CamerasButton',
                 numberOfColumns=2,
                 columnWidth2=(190, 190),
                 columnAlign2=('center', 'center'),
                 height=30,
                 parent='Second_Set')
    mc.button('loadCameras',
              label=u'设置摄像机',
              width=170,
              command='OCT_generel.OCT_RenderSet_zwz.SetAllmyCameras_zwz()',
              backgroundColor=(0.9, 0.5, 0),
              parent='CamerasButton')
    mc.button('clearCameras',
              label=u'清除所有摄像机',
              width=170,
              command='OCT_generel.OCT_RenderSet_zwz.CleanAllCameras_zwz()',
              backgroundColor=(0.9, 0.3, 0.3),
              parent='CamerasButton')
    mc.button(
        'SetAll',
        label=u'设置以上所有选项',
        width=362,
        h=25,
        command='OCT_generel.OCT_RenderSet_zwz.SetAllmyRenderSetting_zwz()',
        backgroundColor=(0.2, 0.8, 0.3),
        parent='Second_Set')

    four = mc.frameLayout('clipPlane_Set',
                          label=u'设置所有摄像机距离值',
                          labelAlign='top',
                          w=362,
                          bv=0,
                          cll=True,
                          cl=True,
                          parent='formLyt')
    mc.columnLayout(parent=four)
    mc.checkBox('cheackClip', label='Auto Render Clip Plane', w=135)
    mc.textFieldGrp('nearClip',
                    label='Near Clip Plane',
                    text='0.100',
                    cw2=[85, 100],
                    cal=[1, 'left'])
    mc.textFieldGrp('farClip',
                    label='Far Clip Plane',
                    text='10000000.000',
                    cw2=[85, 100],
                    cal=[1, 'left'])
    mc.button(
        label=u'设置所有摄像机距离值',
        width=365,
        command='OCT_generel.OCT_RenderSet_zwz.setAllmyCmaerasClip_zwz()',
        backgroundColor=(0.9, 0.5, 0))

    mc.formLayout('formLyt',
                  e=True,
                  attachForm=[(one, 'top', 5), (one, 'left', 5),
                              (two, 'right', 5), (two, 'top', 155),
                              (two, 'left', 5), (three, 'left', 5),
                              (four, 'left', 5), (four, 'bottom', 5)],
                  attachControl=[(two, 'bottom', 1, three),
                                 (three, 'bottom', 1, four)],
                  attachNone=[(three, 'top')],
                  attachPosition=[(one, 'left', 0, 0), (one, 'top', 0, 0)])
    mayaversions = mc.about(v=True)
    if mayaversions.find('2009') >= 0:
        mc.radioButtonGrp('FormatSet', e=True, enable2=False)
    mc.showWindow('RenderSet_zwz')
 def displayOptions(self):
     self.col = mc.columnLayout(adjustableColumn = True)
     self.radios = mc.radioButtonGrp(label="TYPe of Function", labelArray2=["Parent","MotionPath"], numberOfRadioButtons=2)
     self.strnfin = mc.intFieldGrp(numberOfFields = 2, label = "Start & Finish Frames", value1 = 0, value2 = 120)
Exemple #36
0
def optionsWindow():
    """This function creates an options window for making ribbons along selected hair curves."""
    # create the main interface
    if cmds.window(kMakeRibbonsOptionsWindow, q=True, ex=True):
        cmds.deleteUI(kMakeRibbonsOptionsWindow)
    mainWindow = cmds.window(kMakeRibbonsOptionsWindow,
                             title='%s Options' % kToolName,
                             menuBar=True,
                             wh=(545, 465))

    # build the menu bar
    cmds.menu(label='Help')
    amui.helpMenuItem(kToolName, __file__)
    amui.aboutMenuItem(kToolName, kVersionNumber, kVersionDate)

    mainForm = cmds.formLayout(nd=100)

    # build the section to get information about the new ribbons
    if_width = cmds.floatSliderGrp(v=3.0,
                                   min=0.0,
                                   max=100,
                                   fmn=0.0,
                                   fmx=100,
                                   label='Width:',
                                   field=True)
    if_divisionsType = cmds.radioButtonGrp(
        label='Compute Divisions:',
        labelArray2=['Statically', 'Dynamically'],
        numberOfRadioButtons=2,
        select=2)
    if_divisions = cmds.intSliderGrp(v=1,
                                     min=1,
                                     max=100,
                                     fmn=0,
                                     fmx=100,
                                     label='Divisions:',
                                     field=True,
                                     en=False)
    if_divisionsPerUnit = cmds.floatSliderGrp(v=0.5,
                                              min=0.0,
                                              max=10.0,
                                              fmn=0.0,
                                              fmx=100,
                                              label='Divisions per Unit:',
                                              field=True)
    cmds.radioButtonGrp(
        if_divisionsType,
        e=True,
        cc=('amTools.modeling.makeRibbons.doRadioDivisions("%s", "%s", "%s")' %
            (if_divisionsType, if_divisions, if_divisionsPerUnit)))
    if_taper = cmds.floatSliderGrp(v=1.0,
                                   min=0.0,
                                   max=15.0,
                                   fmn=0.0,
                                   fmx=15.0,
                                   label='Taper:',
                                   field=True)
    if_frontTwist = cmds.floatSliderGrp(v=0.0,
                                        min=-180.0,
                                        max=180.0,
                                        fmn=-360.0,
                                        fmx=360.0,
                                        label='Front Twist:',
                                        field=True)
    if_lengthTwist = cmds.floatSliderGrp(v=0.0,
                                         min=-180.0,
                                         max=180.0,
                                         fmn=-180.0,
                                         fmx=180.0,
                                         label='Length Twist:',
                                         field=True)
    if_upVector = cmds.floatFieldGrp(v1=0,
                                     v2=1,
                                     v3=0,
                                     nf=3,
                                     pre=4,
                                     label='Base Up Vector:')

    # position the input fields for the new parents
    cmds.formLayout(mainForm,
                    edit=True,
                    attachForm=[(if_width, 'left', 30), (if_width, 'top', 5)],
                    attachNone=[(if_width, 'right'), (if_width, 'bottom')])
    cmds.formLayout(mainForm,
                    edit=True,
                    attachForm=[(if_divisionsType, 'left', 30)],
                    attachNone=[(if_divisionsType, 'right'),
                                (if_divisionsType, 'bottom')],
                    attachControl=[(if_divisionsType, 'top', 5, if_width)])
    cmds.formLayout(mainForm,
                    edit=True,
                    attachForm=[(if_divisions, 'left', 30)],
                    attachNone=[(if_divisions, 'right'),
                                (if_divisions, 'bottom')],
                    attachControl=[(if_divisions, 'top', 5, if_divisionsType)])
    cmds.formLayout(mainForm,
                    edit=True,
                    attachForm=[(if_divisionsPerUnit, 'left', 30)],
                    attachNone=[(if_divisionsPerUnit, 'right'),
                                (if_divisionsPerUnit, 'bottom')],
                    attachControl=[(if_divisionsPerUnit, 'top', 5,
                                    if_divisions)])
    cmds.formLayout(mainForm,
                    edit=True,
                    attachForm=[(if_taper, 'left', 30)],
                    attachNone=[(if_taper, 'right'), (if_taper, 'bottom')],
                    attachControl=[(if_taper, 'top', 5, if_divisionsPerUnit)])
    cmds.formLayout(mainForm,
                    edit=True,
                    attachForm=[(if_frontTwist, 'left', 30)],
                    attachNone=[(if_frontTwist, 'right'),
                                (if_frontTwist, 'bottom')],
                    attachControl=[(if_frontTwist, 'top', 5, if_taper)])
    cmds.formLayout(mainForm,
                    edit=True,
                    attachForm=[(if_lengthTwist, 'left', 30)],
                    attachNone=[(if_lengthTwist, 'right'),
                                (if_lengthTwist, 'bottom')],
                    attachControl=[(if_lengthTwist, 'top', 5, if_frontTwist)])
    cmds.formLayout(mainForm,
                    edit=True,
                    attachForm=[(if_upVector, 'left', 30)],
                    attachNone=[(if_upVector, 'right'),
                                (if_upVector, 'bottom')],
                    attachControl=[(if_upVector, 'top', 5, if_lengthTwist)])

    # build the section to get information for the uv generation options
    uvFrame = eval(
        'cmds.frameLayout(collapsable=True, label="UV Generation Options:" %s)'
        % amui.__frameAlignCenter__)
    uvForm = cmds.formLayout(nd=100)

    if_uvScale = cmds.floatSliderGrp(v=1.0,
                                     min=0.0,
                                     max=1.0,
                                     fmn=-1.0,
                                     fmx=1.0,
                                     label='UV Scale:',
                                     field=True,
                                     en=False)
    if_uvScaleType = cmds.radioButtonGrp(
        label='UV Normalization:',
        labelArray3=['None', 'Longest', 'Shortest'],
        numberOfRadioButtons=3,
        select=2)
    cmds.radioButtonGrp(
        if_uvScaleType,
        e=True,
        cc=('amTools.modeling.makeRibbons.doRadioUVs("%s", "%s")' %
            (if_uvScaleType, if_uvScale)))
    if_uvPinLocation = cmds.radioButtonGrp(label='Pin UVs:',
                                           labelArray2=['Top', 'Bottom'],
                                           numberOfRadioButtons=2,
                                           select=2)

    # position the input fields for the uv generation options
    cmds.formLayout(uvForm,
                    edit=True,
                    attachForm=[(if_uvScale, 'left', 30),
                                (if_uvScale, 'top', 5)],
                    attachNone=[(if_uvScale, 'right'), (if_uvScale, 'bottom')])
    cmds.formLayout(uvForm,
                    edit=True,
                    attachForm=[(if_uvScaleType, 'left', 30)],
                    attachNone=[(if_uvScaleType, 'right'),
                                (if_uvScaleType, 'bottom')],
                    attachControl=[(if_uvScaleType, 'top', 5, if_uvScale)])
    cmds.formLayout(uvForm,
                    edit=True,
                    attachForm=[(if_uvPinLocation, 'left', 30)],
                    attachNone=[(if_uvPinLocation, 'right'),
                                (if_uvPinLocation, 'bottom')],
                    attachControl=[(if_uvPinLocation, 'top', 5, if_uvScaleType)
                                   ])

    cmds.setParent('..')  # Go up to uvForm
    cmds.setParent('..')  # Go up to mainForm

    # position the frame for the uv generation options
    cmds.formLayout(mainForm,
                    edit=True,
                    attachPosition=[(uvFrame, 'left', -1, 0),
                                    (uvFrame, 'right', -1, 100)],
                    attachControl=[(uvFrame, 'top', 5, if_upVector)],
                    attachNone=[(uvFrame, 'bottom')])

    # create the buttons to execute the script
    cmd_create = 'amTools.modeling.makeRibbons.doOptions ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")' % (
        if_width, if_divisionsType, if_divisions, if_divisionsPerUnit,
        if_taper, if_frontTwist, if_lengthTwist, if_upVector, if_uvScale,
        if_uvScaleType, if_uvPinLocation)
    amui.threeButtonLayout(mainForm, mainWindow, cmd_create)

    cmds.showWindow(mainWindow)
Exemple #37
0
def changeTan(*args):
    """this changes the tangent types of the objects based on settings in the tangent tab"""
    #get selected objects
    hier = cmds.radioButtonGrp(widgets["tanHierRBG"], q=True, sl=True)
    curves = cmds.radioButtonGrp(widgets["tanCurvesRBG"], q=True, sl=True)

    selection = cmds.ls(sl=True, type="transform")
    #this is the selection list to operate on
    sel = []
    if selection:
        if hier==2:
            #if hierarchy is selected, we then (and only then) have the option to choose the types we'll get
            if curves == 1:
                #filter the selection down to the new selection
                curveList = []
                for obj in selection:
                    relsSh = cmds.listRelatives(obj, ad=True, f=True, type=["nurbsCurve", "renderBox", "renderSphere", "renderCone"])
                    if relsSh:
                        for shape in relsSh:
                            curve = cmds.listRelatives(shape, p=True, f=True, type="transform")[0]
                            curveList.append(curve)
                if curveList:
                    for curve in curveList:
                        sel.append(curve)
                for obj in selection:
                    sel.append(obj)

            elif curves == 2:
                #get transforms without filtering for curves
                dagList = []
                for obj in selection:
                    transform = cmds.listRelatives(obj, ad=True, f=True, type="transform")
                    if transform:
                        for this in transform:
                            dagList.append(this)
                    #add in the object itself
                    dagList.append(obj)

                for this in dagList:
                    sel.append(this)

                for obj in selection:
                    sel.append(obj)

        elif hier==1:
            for obj in selection:
                sel.append(obj)

    else:
        cmds.warning("You haven't selected any transform nodes!")
    #get framerange
    rangeRaw = cmds.radioButtonGrp(widgets["tanTimeRBG"], q=True, sl=True)
    if rangeRaw==1:
        startF = cmds.playbackOptions(query=True, min=True)
        endF = cmds.playbackOptions(query=True, max=True)
    if rangeRaw==3:
        startF = cmds.intFieldGrp(widgets["tanFrameRangeIFG"], q=True, v1=True)
        endF = cmds.intFieldGrp(widgets["tanFrameRangeIFG"], q=True, v2=True)
    #get tangent type
    tanNum = cmds.radioButtonGrp(widgets["tangentType"], q=True, sl=True)
    if tanNum==1:
        tanType = "step"
    elif tanNum==2:
        tanType = "linear"
    elif tanNum==3:
        tanType = "spline"
    elif tanNum==4:
        tanType = "auto"

    #for keys in range, change tangent type (don't use frame range if rangeRaw==2
    for obj in sel:
        if rangeRaw==2:
            if tanNum==1:
                cmds.keyTangent(obj, ott="step")
            else:
                cmds.keyTangent(obj, ott=tanType, itt=tanType)
        else:
            if tanNum==1:
                cmds.keyTangent(obj, ott="step", t=(startF,endF))
            else:
                cmds.keyTangent(obj, ott=tanType, itt=tanType, t=(startF,endF))
Exemple #38
0
def doRadioDivisions(input_radio, input_divisions, input_divisionsPerUnit):
    inputState = (cmds.radioButtonGrp(input_radio, q=True, select=True) == 1)
    cmds.intSliderGrp(input_divisions, e=True, en=inputState)
    cmds.floatSliderGrp(input_divisionsPerUnit, e=True, en=(not inputState))
Exemple #39
0
def jointOrientUI():
    '''
	UI for jointOrient()
	'''
    # Window
    window = 'jointOrientUI'
    if mc.window(window, q=True, ex=1): mc.deleteUI(window)
    window = mc.window(window, t='Joint Orient Tool')

    # UI Elements
    #---
    width = 272
    height = 459
    cw1 = 90
    cw2 = 60
    cw3 = 60
    cw4 = 50

    # Layout
    CL = mc.columnLayout(w=width, adj=True)

    # Aim Method
    aimRBG = mc.radioButtonGrp(
        'jointOrientAimRBG',
        nrb=3,
        l='Aim Method',
        la3=['Axis', 'Object', 'Cross'],
        sl=1,
        cc='glTools.ui.joint.jointOrientRefreshUI_aimMethod()',
        cw=[(1, cw1), (2, cw2), (3, cw3)])

    # Aim Axis Direction Layout
    axisFL = mc.frameLayout('jointOrientAxisFL',
                            l='Orientation Axis',
                            w=(width - 8),
                            h=70,
                            cll=0)
    axisCL = mc.columnLayout(adj=True)

    primAxisRBG = mc.radioButtonGrp(
        'jointOrientPrimAxisRBG',
        nrb=3,
        l='Primary Axis',
        la3=['X', 'Y', 'Z'],
        sl=1,
        cc='glTools.ui.joint.jointOrientRefreshUI_aimAxis()',
        cw=[(1, cw1), (2, cw2), (3, cw3), (4, cw4)])
    aimAxisRBG = mc.radioButtonGrp('jointOrientAimAxisRBG',
                                   nrb=2,
                                   l='Aim Axis',
                                   la2=['Y', 'Z'],
                                   sl=1,
                                   cw=[(1, cw1), (2, cw2)])

    mc.setParent('..')
    mc.setParent('..')

    # Aim Axis Direction Layout
    aimAxisFL = mc.frameLayout('jointOrientAimAxisFL',
                               l='Orientation Aim Axis',
                               w=(width - 8),
                               h=70,
                               cll=0)
    aimAxisCL = mc.columnLayout(adj=True)

    oriAxisPosRBG = mc.radioButtonGrp('jointOrientOriAxisPosRBG',
                                      nrb=3,
                                      l='Aim Direction',
                                      la3=['+X', '+Y', '+Z'],
                                      sl=1,
                                      cw=[(1, cw1), (2, cw2), (3, cw3),
                                          (4, cw4)])
    oriAxisNegRBG = mc.radioButtonGrp('jointOrientOriAxisNegRBG',
                                      nrb=3,
                                      scl=oriAxisPosRBG,
                                      l='',
                                      la3=['-X', '-Y', '-Z'],
                                      cw=[(1, cw1), (2, cw2), (3, cw3),
                                          (4, cw4)])

    mc.setParent('..')
    mc.setParent('..')

    # Aim Object Layout
    aimObjFL = mc.frameLayout('jointOrientAimObjFL',
                              l='Aim Object',
                              w=(width - 8),
                              h=55,
                              cll=0)
    aimObjCL = mc.columnLayout(adj=True)
    aimObjCreateB = mc.button(l='Create Aim Object',
                              w=(width - 12),
                              c='glTools.ui.joint.jointOrientCreateControl()')

    mc.setParent('..')
    mc.setParent('..')

    # Cross Product Layout
    crossProdFL = mc.frameLayout('jointOrientCrossProdFL',
                                 l='Cross Product',
                                 w=(width - 8),
                                 h=70,
                                 cll=0)
    crossProdCL = mc.columnLayout(adj=True)
    crossProdCBG = mc.checkBoxGrp('jointOrientCrossProdCBG',
                                  l='Invert Result',
                                  ncb=1,
                                  cw=[(1, cw1), (2, cw2)])
    crossProdRBG = mc.radioButtonGrp('jointOrientCrossProdRBG',
                                     l='Joint As',
                                     nrb=3,
                                     la3=['Base', 'Apex', 'Tip'],
                                     sl=2,
                                     cw=[(1, cw1), (2, cw2), (3, cw3),
                                         (4, cw4)])

    mc.setParent('..')
    mc.setParent('..')

    # Rotate Joint Orientation
    #rotJointOriFL = mc.frameLayout('jointOrientRotOriFL',l='Rotate Joint Orientation',w=(width-8),h=55,cll=0)
    rotJointOriFL = mc.frameLayout('jointOrientRotOriFL',
                                   l='Rotate Joint Orientation',
                                   cll=0)
    rotJointOriRCL = mc.rowColumnLayout(nr=3)
    mc.text(l=' X - ')
    mc.text(l=' Y - ')
    mc.text(l=' Z - ')
    mc.button(w=80,
              l='-90',
              c='glTools.ui.joint.jointOrientRotateOrient(-90,0,0)')
    mc.button(w=80,
              l='-90',
              c='glTools.ui.joint.jointOrientRotateOrient(0,-90,0)')
    mc.button(w=80,
              l='-90',
              c='glTools.ui.joint.jointOrientRotateOrient(0,0,-90)')
    mc.button(w=80,
              l='180',
              c='glTools.ui.joint.jointOrientRotateOrient(180,0,0)')
    mc.button(w=80,
              l='180',
              c='glTools.ui.joint.jointOrientRotateOrient(0,180,0)')
    mc.button(w=80,
              l='180',
              c='glTools.ui.joint.jointOrientRotateOrient(0,0,180)')
    mc.button(w=80,
              l='+90',
              c='glTools.ui.joint.jointOrientRotateOrient(90,0,0)')
    mc.button(w=80,
              l='+90',
              c='glTools.ui.joint.jointOrientRotateOrient(0,90,0)')
    mc.button(w=80,
              l='+90',
              c='glTools.ui.joint.jointOrientRotateOrient(0,0,90)')

    mc.setParent('..')
    mc.setParent('..')

    # Toggle Axis View
    mc.button(l='Toggle Local Axis Display',
              w=(width - 8),
              c='mc.toggle(localAxis=True)')
    # Orient Joint
    mc.button(l='Orient Joint',
              w=(width - 8),
              c='glTools.ui.joint.jointOrientFromUI()')
    # Close UI
    mc.button(l='Close', c='mc.deleteUI("' + window + '")')

    # Prepare Window
    mc.window(window, e=True, w=width, h=height)
    mc.frameLayout(aimObjFL, e=True, en=False)
    mc.frameLayout(crossProdFL, e=True, en=False)

    # Show Window
    mc.showWindow(window)
Exemple #40
0
def jointOrientCreateControl():
    '''
	Create joint orient control for each selected joint
	'''
    # Check Window
    window = 'jointOrientUI'
    upAxis = (0, 1, 0)
    if mc.window(window, q=True, ex=1):

        # Build UpAxis List
        upAxisList = [((0, 1, 0), (0, 0, 1)), ((1, 0, 0), (0, 0, 1)),
                      ((1, 0, 0), (0, 1, 0))]
        # Get Axis Selection
        aimAx = mc.radioButtonGrp('jointOrientPrimAxisRBG', q=True, sl=True)
        upAx = mc.radioButtonGrp('jointOrientAimAxisRBG', q=True, sl=True)
        # Build Axis Values
        upAxis = upAxisList[aimAx - 1][upAx - 1]

    # Create control
    jntList = mc.ls(sl=True, type='joint')
    ctrlList = []
    for jnt in jntList:

        # Get child joint
        cJnt = mc.listRelatives(jnt, c=True, pa=True)
        if not cJnt: continue

        # Generate control prefix
        prefix = glTools.utils.stringUtils.stripSuffix(jnt)

        # Check for existing orien control
        if mc.objExists(prefix + '_ori01_orientGrp'):
            print('Orient control already exists for joint "' + jnt + '"!!')
            continue

        # Create orient control
        circle = mc.circle(c=(0, 0, 0),
                           nr=(0, 1, 0),
                           sw=360,
                           r=1,
                           d=3,
                           ut=0,
                           tol=0.01,
                           s=8,
                           ch=1,
                           n=prefix + '_ori01_orientControl')
        for ch in ['tx', 'ty', 'tz', 'rx', 'rz', 'sx', 'sy', 'sz']:
            mc.setAttr(circle[0] + '.' + ch, l=True, k=False)

        # Create orient UP locator
        upLoc = mc.spaceLocator(n=prefix + '_up01_orientLoc')
        mc.parent(upLoc[0], circle[0])
        mc.setAttr(upLoc[0] + '.tz', 1.0)
        mc.connectAttr(upLoc[0] + '.tz', circle[1] + '.radius', f=True)
        for ch in ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']:
            mc.setAttr(upLoc[0] + '.' + ch, l=True, k=False)

        # Create orient control group
        ctrlGrp = mc.group(em=True, n=prefix + '_ori01_orientGrp')
        mc.parent(circle[0], ctrlGrp)

        # Position control group
        mc.delete(mc.pointConstraint(jnt, ctrlGrp))
        mc.delete(
            mc.aimConstraint(cJnt[0],
                             ctrlGrp,
                             aimVector=(0, 1, 0),
                             upVector=(0, 0, 1),
                             wu=upAxis,
                             wuo=jnt,
                             wut='objectrotation'))

        # Scale control elements
        dist = glTools.utils.mathUtils.distanceBetween(
            mc.xform(jnt, q=True, ws=True, rp=True),
            mc.xform(cJnt[0], q=True, ws=True, rp=True))
        mc.setAttr(upLoc[0] + '.tz', dist * 0.5)

        # Lock orient control group
        mc.parent(ctrlGrp, jnt)
        for ch in ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']:
            mc.setAttr(ctrlGrp + '.' + ch, l=True, k=False)

        # Add message connection form joint to orient control
        mc.addAttr(circle[0], ln='joint', at='message')
        mc.connectAttr(jnt + '.message', circle[0] + '.joint', f=True)

        # Append control list
        ctrlList.append(circle[0])

    # Select controls
    mc.select(ctrlList)
Exemple #41
0
def jointOrientFromUI(close=False):
    '''
	Execute jointOrient() from UI
	'''
    # Window
    window = 'jointOrientUI'
    if not mc.window(window, q=True, ex=1):
        raise UIError('JointOrient UI does not exist!!')

    # Build Axis List
    axisList = ['x', 'y', 'z', '-x', '-y', '-z']
    #axisList = [(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)]

    # Build UpAxis List
    upAxisList = [('y', 'z'), ('x', 'z'), ('x', 'y')]
    #upAxisList = [((0,1,0),(0,0,1)),((1,0,0),(0,0,1)),((1,0,0),(0,1,0))]

    # Build Axis Dictionary
    axisDict = {
        'x': (1, 0, 0),
        'y': (0, 1, 0),
        'z': (0, 0, 1),
        '-x': (-1, 0, 0),
        '-y': (0, -1, 0),
        '-z': (0, 0, -1)
    }

    # Get joint selection
    jntList = mc.ls(sl=True, type='joint')
    if not jntList: return

    # Aim Method
    aimMethod = mc.radioButtonGrp('jointOrientAimRBG', q=True, sl=True)

    # Get Axis Selection
    aimAx = mc.radioButtonGrp('jointOrientPrimAxisRBG', q=True, sl=True)
    upAx = mc.radioButtonGrp('jointOrientAimAxisRBG', q=True, sl=True)
    # Build Axis Values
    aimAxis = axisList[aimAx - 1]
    upAxis = upAxisList[aimAx - 1][upAx - 1]

    # Axis
    upVector = (0, 1, 0)
    if aimMethod == 1:

        # Check joint selection
        if not jntList: raise UserInputError('Invalid joint selection!!')
        # Get UpVector Selection
        upVec = mc.radioButtonGrp('jointOrientOriAxisPosRBG', q=True, sl=True)
        if not upVec:
            upVec = mc.radioButtonGrp(
                'jointOrientOriAxisNegRBG', q=True, sl=True) + 3
        # Build UpAxis Value
        upVector = axisDict[axisList[upVec - 1]]

        # Execute Command
        for jnt in jntList:
            glTools.utils.joint.orient(jnt,
                                       aimAxis=aimAxis,
                                       upAxis=upAxis,
                                       upVec=upVector)

    # Object
    elif aimMethod == 2:

        # Check for orient control selection
        cccList = mc.ls('*_ori01_orientControl', sl=True)
        for ccc in cccList:
            if mc.objExists(ccc + '.joint'):
                cJnt = mc.listConnections(ccc + '.joint',
                                          s=True,
                                          d=False,
                                          type='joint')
                if not cJnt: continue
                if not jntList.count(cJnt[0]): jntList.append(cJnt[0])

        # Determine orient control
        for jnt in jntList:
            prefix = glTools.utils.stringUtils.stripSuffix(jnt)
            ctrlGrp = prefix + '_ori01_orientGrp'
            oriCtrl = prefix + '_ori01_orientControl'
            upLoc = prefix + '_up01_orientLoc'
            if (not mc.objExists(ctrlGrp)) or (not mc.objExists(oriCtrl)) or (
                    not mc.objExists(upLoc)):
                print('Joint "' + jnt +
                      '" has no orient control!! Unable to orient joint!!')
                continue
            # Extract upVector from orient control
            jPos = mc.xform(jnt, q=True, ws=True, rp=True)
            upPos = mc.xform(upLoc, q=True, ws=True, rp=True)
            upVector = glTools.utils.mathUtils.offsetVector(upPos, jPos)

            # Execute Command
            glTools.utils.joint.orient(jnt,
                                       aimAxis=aimAxis,
                                       upAxis=upAxis,
                                       upVec=upVector)

            # Delete orient control
            mc.delete(ctrlGrp)

    # Cross
    elif aimMethod == 3:

        # Invert
        invert = mc.checkBoxGrp('jointOrientCrossProdCBG', q=True, v1=True)
        # Joint As
        jointAs = mc.radioButtonGrp('jointOrientCrossProdRBG', q=True, sl=True)

        # Get Cross vector
        for jnt in jntList:

            # Check for child joint
            if not mc.listRelatives(jnt, c=True):
                glTools.utils.joint.orient(jnt)
                continue
            if jointAs == 1:  # BASE
                bJnt = jnt
                aJnt = mc.listRelatives(jnt, c=True, pa=True, type='joint')
                if not aJnt:
                    raise UserInputError(
                        'Insufficient joint connectivity to determine apex from base "'
                        + jnt + '"!!')
                aJnt = aJnt[0]
                tJnt = mc.listRelatives(aJnt, c=True, pa=True, type='joint')
                if not tJnt:
                    raise UserInputError(
                        'Insufficient joint connectivity to determine tip from apex "'
                        + aJnt + '"!!')
                tJnt = tJnt[0]
            elif jointAs == 2:  # APEX
                bJnt = mc.listRelatives(jnt, c=True, pa=True, type='joint')
                if not bJnt:
                    raise UserInputError(
                        'Insufficient joint connectivity to determine base from base "'
                        + jnt + '"!!')
                bJnt = bJnt[0]
                aJnt = jnt
                tJnt = mc.listRelatives(jnt, p=True, pa=True, type='joint')
                if not tJnt:
                    raise UserInputError(
                        'Insufficient joint connectivity to determine tip from apex "'
                        + jnt + '"!!')
                tJnt = tJnt[0]
            elif jointAs == 3:  # TIP
                tJnt = jnt
                aJnt = mc.listRelatives(jnt, p=True, pa=True, type='joint')
                if not tJnt:
                    raise UserInputError(
                        'Insufficient joint connectivity to determine apex from tip "'
                        + jnt + '"!!')
                aJnt = aJnt[0]
                bJnt = mc.listRelatives(aJnt, p=True, pa=True, type='joint')
                if not bJnt:
                    raise UserInputError(
                        'Insufficient joint connectivity to determine base from apex "'
                        + aJnt + '"!!')
                bJnt = bJnt[0]

            # Get joint positions
            bPos = mc.xform(bJnt, q=True, ws=True, rp=True)
            aPos = mc.xform(aJnt, q=True, ws=True, rp=True)
            tPos = mc.xform(tJnt, q=True, ws=True, rp=True)
            # Calculate cross product
            vec1 = glTools.utils.mathUtils.offsetVector(aPos, bPos)
            vec2 = glTools.utils.mathUtils.offsetVector(tPos, aPos)
            cross = glTools.utils.mathUtils.crossProduct(vec1, vec2)
            # Invert
            if invert: cross = (-cross[0], -cross[1], -cross[2])

            # Execute Command
            glTools.utils.joint.orient(jnt,
                                       aimAxis=aimAxis,
                                       upAxis=upAxis,
                                       upVec=cross)

    # Select Joint Children
    mc.select(mc.listRelatives(jntList, c=True, type='joint'))

    # Cleanup
    if close: mc.deleteUI(window)
def setPivotToManip_apply():
    # get trans
    transX = cmds.checkBox('nwSAK_modWorldSpaceAniTransXCB', q=True, v=True)
    transY = cmds.checkBox('nwSAK_modWorldSpaceAniTransYCB', q=True, v=True)
    transZ = cmds.checkBox('nwSAK_modWorldSpaceAniTransZCB', q=True, v=True)
    # get rotate
    rotateX = cmds.checkBox('nwSAK_modWorldSpaceAniRotateXCB', q=True, v=True)
    rotateY = cmds.checkBox('nwSAK_modWorldSpaceAniRotateYCB', q=True, v=True)
    rotateZ = cmds.checkBox('nwSAK_modWorldSpaceAniRotateZCB', q=True, v=True)
    # get scale
    scaleX = cmds.checkBox('nwSAK_modWorldSpaceAniScaleXCB', q=True, v=True)
    scaleY = cmds.checkBox('nwSAK_modWorldSpaceAniScaleYCB', q=True, v=True)
    scaleZ = cmds.checkBox('nwSAK_modWorldSpaceAniScaleZCB', q=True, v=True)
    # get selected
    sel = cmds.ls(sl=True, type='transform')
    manipPos = cmds.floatFieldGrp('nwSAK_manipPivotAni', q=True, v=True)
    targetTrans = cmds.floatFieldGrp('nwSAK_transPivotsAni', q=True, v=True)
    targetRot = cmds.floatFieldGrp('nwSAK_rotPivotsAni', q=True, v=True)
    targetScale = cmds.floatFieldGrp('nwSAK_scalePivotsAni', q=True, v=True)
    types = cmds.radioButtonGrp('nwSAK_animovTypeSelect', q=True, sl=True)
    if sel:
        if manipPos:
            if (types == 1):
                # cycle
                for stuff in sel:
                    # get select trans
                    selTrans = cmds.xform(stuff, q=True, ws=True, t=True)
                    selRot = cmds.xform(stuff, q=True, ws=True, ro=True)
                    selScale = cmds.xform(stuff, q=True, r=True, s=True)
                    # set/reset array
                    trans = []
                    rotate = []
                    scale = []
                    ### check for trans
                    if (transX == 1):
                        trans.append(targetTrans[0])
                    else:
                        trans.append(selTrans[0])
                    if (transY == 1):
                        trans.append(targetTrans[1])
                    else:
                        trans.append(selTrans[1])
                    if (transZ == 1):
                        trans.append(targetTrans[2])
                    else:
                        trans.append(selTrans[2])
                    ### check for rot
                    if (rotateX == 1):
                        rotate.append(targetRot[0])
                    else:
                        rotate.append(selRot[0])
                    if (rotateY == 1):
                        rotate.append(targetRot[1])
                    else:
                        rotate.append(selRot[1])
                    if (rotateZ == 1):
                        rotate.append(targetRot[2])
                    else:
                        rotate.append(selRot[2])
                    ### check for scl
                    if (scaleX == 1):
                        scale.append(targetScale[0])
                    else:
                        scale.append(selScale[0])
                    if (scaleY == 1):
                        scale.append(targetScale[1])
                    else:
                        scale.append(selScale[1])
                    if (scaleZ == 1):
                        scale.append(targetScale[2])
                    else:
                        scale.append(selScale[2])
                    cmds.xform(stuff, ws=True, t=trans, ro=rotate)
                    cmds.xform(stuff, r=True, s=scale)
                nmGUI_func.nmGUI_runCheck(
                    'complete', 'Selected transforms set to captured')
            else:
                # do pivot
                for obj in sel:
                    cmds.xform(worldSpace=True, pivots=manipPos)
                # line
                nmGUI_func.nmGUI_runCheck(
                    'complete', 'Pivot(s) set to captured pivot position')
        # line
        else:
            nmGUI_func.nmGUI_runCheck('error',
                                      'No captured target transforms/pivot')
    # line
    else:
        nmGUI_func.nmGUI_runCheck('error',
                                  'Select a target to set transforms/pivot')
Exemple #43
0
    def setupUi(self):
        mc.window(self.win_name, t='ld_mirrorMe', s=0)
        mc.columnLayout(adj=True)
        mc.frameLayout(label='MirrorMe', cll=0)
        mc.radioButtonGrp(
            'ld_mirrorMode_rBGrp',
            label=' Mode:',
            la3=['Curve', 'Mesh', 'Deformer'],
            nrb=3,
            cw4=[50, 60, 60, 60],
            cal=[1, 'left'],
            sl=1,
            cc=lambda *_: self.switchMode(),
        )
        mc.radioButtonGrp(
            'ld_mirrorAxis_rBGrp',
            label=' Axis:',
            la3=['X', 'Y', 'Z'],
            nrb=3,
            cw4=[50, 60, 60, 60],
            cal=[1, 'left'],
            sl=1,
        )
        mc.rowColumnLayout(nc=2, cw=[1, 50])
        mc.text(label=' Search:')
        mc.textField('ld_mm_search_tField', tx='L_')
        mc.text(label=' Replace:')
        mc.textField('ld_mm_replace_tField', tx='R_')
        mc.setParent('..')

        # Curve Layout
        mc.frameLayout(
            'ld_mMode1_fLayout',
            l='Curve',
            cll=0,
        )
        mc.radioButtonGrp(
            'ld_mCurve_position_rBGrp',
            label=' Position:',
            la3=['World 0', 'Original', 'Mirrored'],
            nrb=3,
            cw4=[50, 60, 60, 60],
            cal=[1, 'left'],
            sl=1,
        )
        mc.rowLayout(nc=2, adj=1)
        mc.colorIndexSliderGrp(
            'ld_mCurve_colour_cISGrp',
            label=' Colour:',
            cal=[1, 'center'],
            h=20,
            cw3=[35, 30, 90],
            min=1,
            max=32,
            v=7,
        )
        mc.checkBox(
            'ld_mCurve_colour_cBox',
            label='',
            w=15,
            value=True,
            onc=lambda *_: mc.colorIndexSliderGrp(
                'ld_mCurve_colour_cISGrp', e=True, en=True),
            ofc=lambda *_: mc.colorIndexSliderGrp(
                'ld_mCurve_colour_cISGrp', e=True, en=False),
        )
        mc.setParent('..')
        mc.rowColumnLayout(nc=2, cw=[1, 70])
        mc.button(
            label='Curve(s)',
            c=lambda *_: self.addToField('ld_mCurve_original_tField', True),
        )
        mc.textField('ld_mCurve_original_tField')
        mc.setParent('..')
        mc.setParent('..')

        # Mesh Layout
        mc.frameLayout('ld_mMode2_fLayout', label='Mesh', cll=0, m=0)
        mc.radioButtonGrp(
            'ld_mMesh_position_rBGrp',
            label=' Position:',
            la2=['Target', 'Original'],
            nrb=2,
            cw3=[50, 90, 90],
            cal=[1, 'left'],
            sl=1,
        )
        mc.rowColumnLayout(nc=2, cw=[1, 70])
        mc.button(
            label='Original',
            c=lambda *_: self.addToField('ld_mMesh_original_tField', False),
        )
        mc.textField('ld_mMesh_original_tField')
        mc.button(
            label='Target(s)',
            c=lambda *_: self.addToField('ld_mMesh_target_tField', True),
        )
        mc.textField('ld_mMesh_target_tField')
        mc.setParent('..')
        mc.setParent('..')

        # Deformer Layout
        mc.frameLayout(
            'ld_mMode3_fLayout',
            label='Deformer',
            cll=0,
            m=0,
        )
        mc.text(label='This version only supports Clusters')
        mc.rowColumnLayout(nc=2, cw=[1, 70])
        mc.button(
            label='Object',
            c=lambda *_: self.addToField('ld_mDeformer_object_tField', False),
        )
        mc.textField('ld_mDeformer_object_tField')
        mc.button(
            label='Deformer(s)',
            c=lambda *_: self.addToField('ld_mDeformer_deformer_tField', True),
        )
        mc.textField('ld_mDeformer_deformer_tField')
        mc.setParent('..')
        mc.setParent('..')
        mc.button(
            label='Mirror!',
            h=35,
            c=lambda *_: self.applyMirror(),
        )
        mc.setParent('..')
Exemple #44
0
 def switchMode(self):
     self.switchLayouts(
         mc.radioButtonGrp('ld_mirrorMode_rBGrp', q=True, sl=True))
 def LoadAutoRig(self):
     import AutoRig
     reload(AutoRig)
     selected = cmds.radioButtonGrp(self.childParentRG, q = True, select = True)
     AutoRig.RunAutoRig(selected)
Exemple #46
0
    def runProc(self):
        if cmds.columnLayout('singleSelectCL', q=1, vis=1):
            sDriver = cmds.textFieldButtonGrp('sourceDriverTextB', q=1, tx=1)
            sDriven = cmds.textFieldButtonGrp('sourceDrivenTextB', q=1, tx=1)
            tDriver = cmds.textFieldButtonGrp('targeDriverTextB', q=1, tx=1)
            tDriven = cmds.textFieldButtonGrp('targeDrivenTextB', q=1, tx=1)
        else:
            sDriver = cmds.textFieldGrp('sourceDriverText', q=1, tx=1)
            sDriven = cmds.textFieldGrp('sourceDrivenText', q=1, tx=1)
            tDriver = cmds.textFieldGrp('targeDriverText', q=1, tx=1)
            tDriven = cmds.textFieldGrp('targeDrivenText', q=1, tx=1)
        if not sDriver or not sDriven or not tDriver or not tDriven:
            return
        tDriverMirror = 1 if cmds.radioButtonGrp(
            'tDriverMirrorRadioB', q=1, sl=1) == 1 else -1
        rDriverMirror = 1 if cmds.radioButtonGrp(
            'rDriverMirrorRadioB', q=1, sl=1) == 1 else -1
        tDrivenMirror = 1 if cmds.radioButtonGrp(
            'tDrivenMirrorRadioB', q=1, sl=1) == 1 else -1
        rDrivenMirror = 1 if cmds.radioButtonGrp(
            'rDrivenMirrorRadioB', q=1, sl=1) == 1 else -1

        drivenAttr = cmds.setDrivenKeyframe(sDriven, q=1, dn=1)  #全部受驱动属性
        for i in drivenAttr:
            driverAttr = cmds.setDrivenKeyframe(i, q=1, cd=1)
            time = cmds.keyframe(i, q=1, fc=1)
            value = cmds.keyframe(i, q=1, vc=1)
            if driverAttr and time:
                splitDriver = driverAttr[0].split('.', 1)
                if splitDriver[0] == sDriver:
                    splitDriven = i.split('.', 1)

                    mirrorT = mirrorV = 1
                    if 'translate' in splitDriver[1]:  #驱动者镜像
                        mirrorT = tDriverMirror
                    elif 'rotate' in splitDriver[1]:
                        mirrorT = rDriverMirror

                    if 'translate' in splitDriven[1]:  #被驱动者镜像
                        mirrorV = tDrivenMirror
                    elif 'rotate' in splitDriven[1]:
                        mirrorV = rDrivenMirror

                    newtDriver = '%s.%s' % (tDriver, splitDriver[1])
                    newtDriven = '%s.%s' % (tDriven, splitDriven[1])
                    for i in range(len(time)):
                        cmds.setDrivenKeyframe(newtDriven,
                                               cd=newtDriver,
                                               dv=time[i] * mirrorT,
                                               v=value[i] * mirrorV)
        """
        acUL = cmds.listConnections(sDriven, t='animCurveUL')
        if acUL:
            for i in range(len(acUL)):
                topNode = cmds.listConnections('%s.input' %acUL[i], c=1)
                if topNode and cmds.nodeType(topNode[1]) == 'unitConversion':
                    topNode = cmds.listConnections('%s.input' %topNode[0], c=1)
        acUA = cmds.listConnections(sDriven, t='animCurveUA')
        cmds.listConnections('locator1_rotateY', c=1, t='animCurveUA')
        """


#MirrorDriverKey().Ui()
	def changeWorkType(self, *args):

		global workTypeId
		workTypeId = cmds.radioButtonGrp('workTypeRidBtn', q= 1, sl= 1)
Exemple #48
0
 def toggleDuplicateICControls(self, option):
     mc.radioButtonGrp("geoType", edit=True, enable=option)
     mc.checkBox("duplicateInputGraph", edit=True, enable=option)
Exemple #49
0
    def optionsPanelUI(self, name, parent, collapse=False):
        """Create options panel UI controls"""

        popupHelp = "For more options, duplicate your objects first using Edit>Duplicate Special, then use the Scatter Selected Objects option."

        mc.frameLayout(width=400,
                       collapsable=True,
                       cl=collapse,
                       borderStyle="etchedIn",
                       label="Options")
        mc.columnLayout(name)
        mc.separator(height=4, style="none")
        mc.rowLayout(numberOfColumns=1,
                     columnAttach1="left",
                     columnAlign1="both",
                     columnOffset1=142)
        mc.columnLayout()
        mc.radioCollection("mode")
        mc.radioButton("scatterSelected",
                       label="Scatter Selected Objects",
                       select=True)
        mc.radioButton("duplicateScatter",
                       label="Duplicate and Scatter",
                       onCommand=lambda *args: self.toggleControls(True),
                       offCommand=lambda *args: self.toggleControls(False))
        mc.setParent(name)
        mc.separator(width=396, height=12, style="in")
        mc.intSliderGrp("nCopies",
                        label="Number of copies: ",
                        value=50,
                        field=True,
                        minValue=1,
                        maxValue=100,
                        fieldMinValue=0,
                        fieldMaxValue=1000)
        mc.radioButtonGrp(
            "geoType",
            label="Geometry type: ",
            labelArray2=['Copy', 'Instance'],
            numberOfRadioButtons=2,
            columnWidth3=[140, 78, 156],
            select=1,
            annotation=popupHelp,
            onCommand1=lambda *args: self.toggleDuplicateControls(True),
            onCommand2=lambda *args: self.toggleDuplicateControls(False))
        mc.rowLayout(numberOfColumns=1,
                     columnAttach1="left",
                     columnAlign1="both",
                     columnOffset1=142)
        mc.columnLayout()
        mc.checkBox(
            "duplicateInputGraph",
            label="Duplicate input graph",
            value=0,
            annotation=popupHelp,
            onCommand=lambda *args: self.toggleDuplicateIGControls(False),
            offCommand=lambda *args: self.toggleDuplicateIGControls(True))
        mc.checkBox(
            "duplicateInputConnections",
            label="Duplicate input connections",
            value=0,
            annotation=popupHelp,
            onCommand=lambda *args: self.toggleDuplicateICControls(False),
            offCommand=lambda *args: self.toggleDuplicateICControls(True))
        mc.separator(height=4, style="none")
        mc.checkBox("newGroup",
                    label="Parent objects under new group",
                    value=1)
        mc.checkBox("keepOrig", label="Keep original object(s)", value=1)
        mc.setParent(name)
        mc.separator(height=8, style="none")
        mc.setParent(parent)

        # If single object is selected, automatically enter duplicate mode
        if len(mc.ls(selection=True)) == 1:
            mc.radioCollection("mode", edit=True, select="duplicateScatter")
            self.toggleControls(True)
        else:
            mc.radioCollection("mode", edit=True, select="scatterSelected")
            self.toggleControls(False)
    def exportSelection(self, *args):

        fileName = ""

        # Get Selection
        selection = cmds.ls(sl=True)

        # Get Framerange
        frameIn = cmds.playbackOptions(q=True, ast=True)
        frameOut = cmds.playbackOptions(q=True, aet=True)

        # Get Destination Path
        dest_path = cmds.textFieldButtonGrp("tfbPath", q=True, tx=True) + "/"

        # Set Flags for Export
        flag1 = "-frameRange " + str(frameIn) + " " + str(frameOut) + " "
        flag2 = " -step 1 -attr visibility -noNormals -stripNamespaces -uvWrite -worldSpace -writeVisibility" + " -file %s"

        # Export every char
        for item in selection:

            # Set filename
            if (cmds.radioButtonGrp("rbFileName", q=True, sl=True) == 2):
                fileName = "char_" + item.lower()
            elif (cmds.radioButtonGrp("rbFileName", q=True, sl=True) == 3):
                fileName = "prop_" + item.lower()
            else:
                fileName = item.lower()

            shot = cmds.textFieldGrp("tfShot", q=True, text=True)
            if len(shot) > 0:
                fileName = shot + "_" + fileName

            fileName = fileName.split(":")[0]
            if fileName[len(fileName) - 1] == "_":
                fileName = fileName[:len(fileName) - 2]

            # Exception for MIDDLEGROUND, FOREGROUND and BACKGROUND
            if item == "MIDDLEGROUND" or item == "FOREGROUND" or item == "BACKGROUND":
                flags = flag1 + "-root " + item + " " + flag2 % (
                    dest_path + fileName + ".abc")
                pm.AbcExport(j=flags)
                continue

            cmds.select(item, hi=True)
            shapes = cmds.ls(sl=True, type='mesh', fl=True)
            deformer = cmds.ls(sl=True, type="deformBend", fl=True)

            meshes = ""

            for mesh in shapes:

                transformNode = cmds.listRelatives(mesh, parent=True,
                                                   f=True)[0]

                # Kick hidden meshes
                parentNode = cmds.listRelatives(transformNode,
                                                parent=True,
                                                f=True)
                if cmds.getAttr(transformNode + ".visibility") == False or (
                        parentNode == None and
                        cmds.getAttr(parentNode[0] + ".visibility") == False):
                    continue

                # Kick other unwanted meshes
                if "body_scale" in transformNode or "blendShape_master" in transformNode:
                    continue

                meshes += "-root " + transformNode + " "

            print meshes
            meshes = meshes[0:(len(meshes) - 1)]

            flags = flag1 + meshes + flag2 % (dest_path + fileName + ".abc")
            pm.AbcExport(j=flags)
Exemple #51
0
def doOptions(input_width, input_divisionsType, input_divisions,
              input_divisionsPerUnit, input_taper, input_frontTwist,
              input_lengthTwist, input_upVector, input_uvScale,
              input_uvScaleType, input_uvPinLocation):
    """This is the function called when the apply or create button is clicked"""
    try:
        utils.dg.validateSelection(type='transform', min=1)
        curves = utils.dg.getFilteredRelatives(cmds.ls(sl=True), 'nurbsCurve',
                                               False)
        if len(curves) is 0:
            raise Exception(
                'None of the objects you have selected are NURBS curves.')

        # call the command
        if cmds.radioButtonGrp(input_divisionsType, q=True, select=True) == 1:
            cmds.am_ribbon(width=cmds.floatSliderGrp(input_width,
                                                     q=True,
                                                     v=True),
                           divisions=cmds.floatSliderGrp(input_divisions,
                                                         q=True,
                                                         v=True),
                           taper=cmds.floatSliderGrp(input_taper,
                                                     q=True,
                                                     v=True),
                           twistBase=cmds.floatSliderGrp(input_frontTwist,
                                                         q=True,
                                                         v=True),
                           twistLength=cmds.floatSliderGrp(input_lengthTwist,
                                                           q=True,
                                                           v=True),
                           upVector=cmds.floatFieldGrp(input_upVector,
                                                       q=True,
                                                       v=True),
                           uvScale=cmds.floatSliderGrp(input_uvScale,
                                                       q=True,
                                                       v=True),
                           uvGroupScale=cmds.radioButtonGrp(
                               input_uvScaleType, q=True, select=True) - 1,
                           uvPin=cmds.radioButtonGrp(
                               input_uvPinLocation, q=True, select=True) - 1)
        else:
            cmds.am_ribbon(width=cmds.floatSliderGrp(input_width,
                                                     q=True,
                                                     v=True),
                           divisionsPerUnit=cmds.floatSliderGrp(
                               input_divisionsPerUnit, q=True, v=True),
                           taper=cmds.floatSliderGrp(input_taper,
                                                     q=True,
                                                     v=True),
                           twistBase=cmds.floatSliderGrp(input_frontTwist,
                                                         q=True,
                                                         v=True),
                           twistLength=cmds.floatSliderGrp(input_lengthTwist,
                                                           q=True,
                                                           v=True),
                           upVector=cmds.floatFieldGrp(input_upVector,
                                                       q=True,
                                                       v=True),
                           uvScale=cmds.floatSliderGrp(input_uvScale,
                                                       q=True,
                                                       v=True),
                           uvGroupScale=cmds.radioButtonGrp(
                               input_uvScaleType, q=True, select=True) - 1,
                           uvPin=cmds.radioButtonGrp(
                               input_uvPinLocation, q=True, select=True) - 1)
    except:
        raise
Exemple #52
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)
    def createMainForm(self):
        self.radioMode = cmds.radioButtonGrp(label = 'Copy Options : ',
                                             labelArray2 = ['Normal',
                                                            'Instance'],
                                             numberOfRadioButtons = 2,
                                             select = 1,
                                             onCommand1 = self.onCmdNormal,
                                             onCommand2 = self.onCmdInstance,
                                             )

        self.number = cmds.intFieldGrp(label = 'Number of copies', value = [5, 1, 1, 1])
        cmds.formLayout(self.optionsForm,
                        e = True,
                        attachControl = ([self.number, 'top', 10, self.radioMode])
                        )

        self.xTrans = cmds.floatFieldGrp(label = 'Translate X [min, max]',
                                         numberOfFields = 2
                                         )
        cmds.formLayout(self.optionsForm,
                        e = True,
                        attachControl = ([self.xTrans, 'top', 10, self.number])
                        )
        self.yTrans = cmds.floatFieldGrp(label = 'Translate Y [min, max]',
                                         numberOfFields = 2
                                         )
        cmds.formLayout(self.optionsForm,
                        e = True,
                        attachControl = ([self.yTrans, 'top', 2, self.xTrans]),
                        )
        self.zTrans = cmds.floatFieldGrp(label = 'Translate Z [min, max]',
                                         numberOfFields = 2
                                         )
        cmds.formLayout(self.optionsForm,
                        e = True,
                        attachControl = ([self.zTrans, 'top', 2, self.yTrans])
                        )

        self.xRotate = cmds.floatFieldGrp(label = 'Rotate X [min, max]',
                                         numberOfFields = 2
                                         )
        cmds.formLayout(self.optionsForm,
                        e = True,
                        attachControl = ([self.xRotate, 'top', 10, self.zTrans])
                        )
        self.yRotate = cmds.floatFieldGrp(label = 'Rotate Y [min, max]',
                                         numberOfFields = 2
                                         )
        cmds.formLayout(self.optionsForm,
                        e = True,
                        attachControl = ([self.yRotate, 'top', 2, self.xRotate])
                        )
        self.zRotate = cmds.floatFieldGrp(label = 'Rotate Z [min, max]',
                                         numberOfFields = 2
                                         )
        cmds.formLayout(self.optionsForm,
                        e = True,
                        attachControl = ([self.zRotate, 'top', 2, self.yRotate])
                        )

        self.xScale = cmds.floatFieldGrp(label = 'Slace X [min, max]',
                                         numberOfFields = 2,
                                         value = [1.0, 1.0, 1.0, 1.0]
                                         )
        cmds.formLayout(self.optionsForm,
                        e = True,
                        attachControl = ([self.xScale, 'top', 10, self.zRotate])
                        )
        self.yScale = cmds.floatFieldGrp(label = 'Scale Y [min, max]',
                                         numberOfFields = 2,
                                         value = [1.0, 1.0, 1.0, 1.0]
                                         )
        cmds.formLayout(self.optionsForm,
                        e = True,
                        attachControl = ([self.yScale, 'top', 2, self.xScale])
                        )
        self.zScale = cmds.floatFieldGrp(label = 'Scale Z [min, max]',
                                         numberOfFields = 2,
                                         value = [1.0, 1.0, 1.0, 1.0]
                                         )
        cmds.formLayout(self.optionsForm,
                        e = True,
                        attachControl = ([self.zScale, 'top', 2, self.yScale])
                        )
Exemple #54
0
def crvToolsUI():
    if cmds.window("crvToolWin", exists=True):
        cmds.deleteUI("crvToolWin")

    width, height = 300, 220
    widgets["win"] = cmds.window("crvToolWin",
                                 t="zbw_curveTools",
                                 w=width,
                                 h=height)
    widgets["CLO"] = cmds.columnLayout()

    # common functions
    widgets["funcsFrLO"] = cmds.frameLayout("Common Curve Functions",
                                            w=width,
                                            cll=False,
                                            bgc=(0, 0, 0))
    widgets["funcsFLO"] = cmds.formLayout(w=width, h=250, bgc=(.3, .3, .3))

    widgets["cvDisplBut"] = cmds.button(
        l="Toggle CV display on selected crvs!",
        width=280,
        h=35,
        bgc=(.5, .5, .4),
        c=toggleDispl)
    widgets["reverseBut"] = cmds.button(l="Reverse Selected Curves!",
                                        width=280,
                                        h=35,
                                        bgc=(.4, .5, .4),
                                        c=reverseCurve)
    widgets["alignAttachBut"] = cmds.button(
        l="Quick align/attach! (2 selected, move 2nd->1st)",
        w=280,
        h=35,
        bgc=(.5, .5, .4),
        c=alignAttach)
    widgets["clusterBut"] = cmds.button(l="Cluster Selected Curves!",
                                        width=280,
                                        h=35,
                                        bgc=(.4, .5, .4),
                                        c=clusterCurves)
    widgets["reparaBut"] = cmds.button(
        l="Reparameterize Selected Crvs to 0-1!",
        width=280,
        h=35,
        bgc=(.5, .5, .4),
        c=reparameter)
    widgets["pivStartBut"] = cmds.button(l="Move Pivot to Start!",
                                         width=135,
                                         h=35,
                                         bgc=(.5, .4, .4),
                                         c=partial(movePivot, 0))
    widgets["pivEndBut"] = cmds.button(l="Move Pivot to End!",
                                       width=135,
                                       h=35,
                                       bgc=(.5, .4, .4),
                                       c=partial(movePivot, 1))

    cmds.formLayout(widgets["funcsFLO"],
                    e=True,
                    af=[
                        (widgets["cvDisplBut"], "left", 10),
                        (widgets["cvDisplBut"], "top", 5),
                        (widgets["reverseBut"], "left", 10),
                        (widgets["reverseBut"], "top", 45),
                        (widgets["alignAttachBut"], "left", 10),
                        (widgets["alignAttachBut"], "top", 85),
                        (widgets["clusterBut"], "left", 10),
                        (widgets["clusterBut"], "top", 125),
                        (widgets["reparaBut"], "left", 10),
                        (widgets["reparaBut"], "top", 165),
                        (widgets["pivStartBut"], "left", 10),
                        (widgets["pivStartBut"], "top", 205),
                        (widgets["pivEndBut"], "left", 155),
                        (widgets["pivEndBut"], "top", 205),
                    ])

    cmds.setParent(widgets["CLO"])
    widgets["rebuildFrLO"] = cmds.frameLayout("Rebuild Curves",
                                              w=width,
                                              cll=True,
                                              cl=False,
                                              bgc=(0, 0, 0))
    widgets["rebuildFLO"] = cmds.formLayout(w=width, h=155, bgc=(.3, .3, .3))
    widgets["ptText"] = cmds.text(l="How to calculate rebuild pt count?")
    widgets["methodRBG"] = cmds.radioButtonGrp(nrb=2,
                                               l1="pts/unit",
                                               l2="total count",
                                               sl=1,
                                               cc=toggleMethod)
    widgets["recoIFBG"] = cmds.intFieldGrp(l="Points/Unit:",
                                           nf=1,
                                           cal=[(1, "left"), (2, "left")],
                                           v1=30,
                                           en=True,
                                           cw=[(1, 70), (2, 50)])
    widgets["totalIFBG"] = cmds.intFieldGrp(l="Total Count:",
                                            nf=1,
                                            cal=[(1, "left"), (2, "left")],
                                            v1=1000,
                                            en=False,
                                            cw=[(1, 70), (2, 50)])
    widgets["rebuildBut"] = cmds.button(l="Rebuild Curves!",
                                        w=280,
                                        h=35,
                                        bgc=(.5, .4, .4),
                                        c=rebuildCurves)

    cmds.formLayout(widgets["rebuildFLO"],
                    e=True,
                    af=[
                        (widgets["ptText"], "left", 10),
                        (widgets["ptText"], "top", 5),
                        (widgets["methodRBG"], "left", 10),
                        (widgets["methodRBG"], "top", 25),
                        (widgets["recoIFBG"], "left", 10),
                        (widgets["recoIFBG"], "top", 55),
                        (widgets["totalIFBG"], "left", 10),
                        (widgets["totalIFBG"], "top", 80),
                        (widgets["rebuildBut"], "left", 10),
                        (widgets["rebuildBut"], "top", 110),
                    ])

    # hammer points
    cmds.setParent(widgets["CLO"])
    widgets["hammerFrLO"] = cmds.frameLayout("Hammer/Smooth Points",
                                             w=width,
                                             cll=True,
                                             cl=False,
                                             bgc=(0, 0, 0))
    widgets["hammerFLO"] = cmds.formLayout(w=width, h=90, bgc=(.3, .3, .3))
    widgets["hammerText"] = cmds.text(
        l="Move selected points towards surrounding pts", al="left")
    widgets["hammerNumIFG"] = cmds.intFieldGrp(
        nf=1,
        l="# of sample pts on either side",
        cal=[(1, "left"), (2, "left")],
        cw=[(1, 170), (2, 50)],
        v1=1)
    widgets["hammerBut"] = cmds.button(l="Hammer/Smooth Points!",
                                       w=280,
                                       h=35,
                                       bgc=(.3, .4, .5),
                                       c=doHammer)
    # create avg cvs functions - find center of cvs and lerp towards them (0-1)

    cmds.formLayout(widgets["hammerFLO"],
                    e=True,
                    af=[
                        (widgets["hammerText"], "left", 10),
                        (widgets["hammerText"], "top", 5),
                        (widgets["hammerNumIFG"], "left", 10),
                        (widgets["hammerNumIFG"], "top", 25),
                        (widgets["hammerBut"], "left", 10),
                        (widgets["hammerBut"], "top", 50),
                    ])

    # create line
    cmds.setParent(widgets["CLO"])
    widgets["lineFrLO"] = cmds.frameLayout("Create Line",
                                           w=width,
                                           cll=True,
                                           cl=False,
                                           bgc=(0, 0, 0))
    widgets["lineFLO"] = cmds.formLayout(w=width, h=90, bgc=(.3, .3, .3))
    widgets["lineText"] = cmds.text(l="Create a nurbs line along an axis",
                                    al="left")
    widgets["lineLenFFG"] = cmds.floatFieldGrp(nf=1,
                                               l="Length",
                                               cal=[(1, "left"), (2, "left")],
                                               cw=[(1, 40), (2, 35)],
                                               v1=10.0)
    widgets["lineDenFFG"] = cmds.floatFieldGrp(nf=1,
                                               l="Pts/Unit",
                                               cal=[(1, "left"), (2, "left")],
                                               cw=[(1, 40), (2, 35)],
                                               v1=.5,
                                               pre=3)
    widgets["lineAxisRBG"] = cmds.radioButtonGrp(nrb=3,
                                                 l1="x",
                                                 l2="y",
                                                 l3="z",
                                                 cw=[(1, 35), (2, 35),
                                                     (3, 35)],
                                                 sl=1)
    widgets["lineBut"] = cmds.button(l="Create Line!",
                                     w=280,
                                     h=35,
                                     bgc=(.5, .5, .4),
                                     c=createLine)

    cmds.formLayout(widgets["lineFLO"],
                    e=True,
                    af=[
                        (widgets["lineText"], "left", 10),
                        (widgets["lineText"], "top", 5),
                        (widgets["lineLenFFG"], "left", 10),
                        (widgets["lineLenFFG"], "top", 25),
                        (widgets["lineDenFFG"], "left", 90),
                        (widgets["lineDenFFG"], "top", 25),
                        (widgets["lineAxisRBG"], "left", 170),
                        (widgets["lineAxisRBG"], "top", 25),
                        (widgets["lineBut"], "left", 10),
                        (widgets["lineBut"], "top", 50),
                    ])

    # smooth points
    # cmds.setParent(widgets["CLO"])
    # widgets["smoothFrLO"] = cmds.frameLayout("Smooth Points", w=width, cll=False, cl=True, bgc = (0, 0, 0))
    # widgets["smoothCLO"] = cmds.columnLayout()
    # cmds.separator(h=5)
    # widgets["smthText"] = cmds.text(l="Conform pts position around an extreme pt", al="left")
    # cmds.separator(h=5)
    # widgets["smthNumIFG"] = cmds.intFieldGrp(nf = 1, l = "# of pts on either side", cal=[(1, "left"), (2, "left")], cw = [(1, 170), (2, 50)], v1=5)
    # widgets["smthPushFFG"] = cmds.floatFieldGrp(nf = 1, l = "tangent push amount (+/-0.05ish?)", cal=[(1, "left"), (2, "left")], cw = [(1, 170), (2, 50)], v1=0.05, precision = 3)
    # widgets["smoothBut"] = cmds.button(l="Smooth Points!", w = 300, h=35, bgc = (.5, .5, .4), c = doSmooth)

    cmds.window(widgets["win"],
                e=True,
                w=300,
                resizeToFitChildren=True,
                sizeable=True)
    cmds.showWindow(widgets["win"])
Exemple #55
0
def snapIt(*args):
    """does the snapping by xform. Should work with any rotation order, etc"""
    mode = cmds.radioButtonGrp(widgets["avgRBG"], q=True, sl=True)

    translate = cmds.checkBoxGrp(widgets["cbg"], q=True, v1=True)
    rotate = cmds.checkBoxGrp(widgets["cbg"], q=True, v2=True)
    pivot = cmds.checkBox(widgets["rpCB"], q=True, v=True)

    sel = cmds.ls(sl=True)

    if mode==1:

        target = sel[0]
        objects = sel[1:]

        for obj in objects:
            if translate:
                if pivot:
                    targetPos = cmds.xform(target, ws=True, q=True, rp=True)
                else:
                    targetPos = cmds.xform(target, ws=True, q=True, t=True)

                cmds.xform(obj, ws=True, t=targetPos)

            if rotate:
                #get rot order of obj
                tarRot = cmds.xform(target, ws=True, q=True, ro=True)
                objRO = cmds.xform(obj, q=True, roo=True)
                tarRO = cmds.xform(target, q=True, roo=True)
                cmds.xform(obj, roo=tarRO)
                cmds.xform(obj, ws=True, ro=tarRot)
                cmds.xform(obj, roo=objRO, p=True)

        cmds.select(objects)
    else:
        if (len(sel)>=2):
            targets = sel[0:-1]
            object = sel[-1:][0]

            objRO = cmds.xform(object, q=True, roo=True)

            # tarPosList = []
            # tarRotList = []
            txList = []
            tyList = []
            tzList = []
            rxList = []
            ryList = []
            rzList = []
            TX, TY, TZ, RX, RY, RZ = 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
            for tar in targets:
                if pivot:
                    tarPos = cmds.xform(tar, q=True, ws=True, rp=True)
                else:
                    tarPos = cmds.xform(tar, q=True, ws=True, t=True)
                txList.append(tarPos[0])
                tyList.append(tarPos[1])
                tzList.append(tarPos[2])

                #convert it to the rot order of the object
                tarRO = cmds.xform(tar, q=True, roo=True)
                cmds.xform(tar, p=True, roo=objRO)
                #get the rotation
                tarRot = cmds.xform(tar, q=True, ws=True, ro=True)
                rxList.append(tarRot[0])
                ryList.append(tarRot[1])
                rzList.append(tarRot[2])
                #convert it back
                cmds.xform(tar, p=True, roo=tarRO)

            #now average them all
            for tx in txList:
                TX += tx
            for ty in tyList:
                TY += ty
            for tz in tzList:
                TZ += tz
            for rx in rxList:
                RX += rx
            for ry in ryList:
                RY += ry
            for rz in rzList:
                RZ += rz

            avgTx = TX/len(txList)
            avgTy = TY/len(tyList)
            avgTz = TZ/len(tzList)
            avgRx = RX/len(rxList)
            avgRy = RY/len(ryList)
            avgRz = RZ/len(rzList)

            if translate:
                cmds.xform(object, ws=True, t=(avgTx, avgTy,avgTz))
            if rotate:
                cmds.xform(object, ws=True, ro=(avgRx, avgRy, avgRz))

        else:
            cmds.warning("You need to select two objects or more!")
Exemple #56
0
    def Create(self):
        
        #main layout with tabs
        self.form = cmds.formLayout()
        self.tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
        cmds.formLayout( self.form, edit=True, attachForm=((self.tabs, 'top', 0), (self.tabs, 'left', 0), (self.tabs, 'bottom', 0), (self.tabs, 'right', 0)) )
        
        #modelling tab
        self.child1 = cmds.rowColumnLayout(parent = self.tabs, numberOfColumns=1)
        
        #duplicate and scatter
        self.dupScatFrame = cmds.frameLayout(parent = self.child1, label = "Duplicate and Scatter", collapsable = True, collapse = True)
        self.dupScatRC = cmds.rowColumnLayout(parent = self.dupScatFrame, numberOfColumns = 3)

        cmds.text(parent = self.dupScatRC, label = "X range")
        self.xMinField = cmds.floatField(parent = self.dupScatRC, value = -10)
        self.xMaxField = cmds.floatField(parent = self.dupScatRC, value = 10)
        cmds.text(parent = self.dupScatRC, label = "Y range")
        self.yMinField = cmds.floatField(parent = self.dupScatRC, value = -10)
        self.yMaxField = cmds.floatField(parent = self.dupScatRC, value = 10)
        cmds.text(parent = self.dupScatRC, label = "Z range")
        self.zMinField = cmds.floatField(parent = self.dupScatRC, value = -10)
        self.zMaxField = cmds.floatField(parent = self.dupScatRC, value = 10)
        cmds.text(parent = self.dupScatRC, label = "Number of Duplicates")
        self.dupNumField = cmds.intField(parent = self.dupScatRC, value = 10)

        self.dupScatCol = cmds.columnLayout(parent = self.dupScatFrame)
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.dupScatFrame, label = "Duplicate", command = lambda : self.DupAndScatter(cmds.intField(self.dupNumField, q = 1, v = 1), cmds.floatField(self.xMinField , q = 1, v = 1), cmds.floatField(self.xMaxField , q = 1, v = 1), cmds.floatField(self.yMinField , q = 1, v = 1), cmds.floatField(self.yMaxField , q = 1, v = 1), cmds.floatField(self.zMinField , q = 1, v = 1), cmds.floatField(self.zMaxField , q = 1, v = 1)))
        
        #rigging tab
        self.child2 = cmds.rowColumnLayout(parent = self.tabs, numberOfColumns=1)
        
        #locator creator
        self.createLocatorFrame = cmds.frameLayout(parent = self.child2, label = "Create Locators", collapsable = True, collapse = True)
        self.createLocatorRC = cmds.rowColumnLayout(parent = self.createLocatorFrame, numberOfColumns = 2)
        cmds.text(parent = self.createLocatorRC, label = "Type")
        self.createLocatorMenu = cmds.optionMenu(parent = self.createLocatorRC)
        cmds.menuItem(parent = self.createLocatorMenu, label = "Center of Objects")
        cmds.menuItem(parent = self.createLocatorMenu, label = "Center of Components")
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.createLocatorFrame, label = "Create Locator", command = lambda : self.CreateLocator(cmds.optionMenu(self.createLocatorMenu, q = True, v = True)))

        cmds.separator(parent = self.child2, style = "double")

        #joint creator
        self.createJointFrame = cmds.frameLayout(parent = self.child2, label = "Create Joints", collapsable = True, collapse = True)
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.createJointFrame, label = "Create Joints", command = lambda : self.CreateJoints())

        cmds.separator(parent = self.child2, style = "double")
        
        #joint orient
        self.jointOrientFrame = cmds.frameLayout(parent = self.child2, label = "Orient Joints", collapsable = True, collapse = True)
        
        self.primaryAxisRC = cmds.radioButtonGrp(parent = self.jointOrientFrame, label = "Primary Axis:", ad3 = 1, cw3 = [20, 20, 20], labelArray3 = ["X", "Y", "Z"], numberOfRadioButtons = 3, select = 1)

        self.secondaryAxisRC = cmds.radioButtonGrp(parent = self.jointOrientFrame,  label = "Secondary Axis:", ad3 = 1, cw3 = [20, 20, 20], labelArray3 = ["X", "Y", "Z"], numberOfRadioButtons = 3, select = 3)

        self.SAORC = cmds.radioButtonGrp(parent = self.jointOrientFrame, label = "Secondary Axis World Orientation", ad3 = 1, cw3 = [20, 20, 20], labelArray3 = ["X", "Y", "Z"], numberOfRadioButtons = 3, select = 1)
        
        self.upOrDown = cmds.optionMenu(parent = self.jointOrientFrame)
        cmds.menuItem(parent = self.upOrDown, label = "+")
        cmds.menuItem(parent = self.upOrDown, label = "-")
        
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.jointOrientFrame, label = "Orient Joints", command = lambda : self.OrientJoints(self.QueryRadioButtonGrp(self.primaryAxisRC), self.QueryRadioButtonGrp(self.secondaryAxisRC), self.QueryRadioButtonGrp(self.SAORC), cmds.optionMenu(self.upOrDown, q = 1, value = 1), True, True, True))
        
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.jointOrientFrame, label = "Freeze Rotations", command = lambda : self.FreezeRotation())
        
        cmds.separator(parent = self.child2, style = "double")
        
        #ik solvers
        self.ikSolversFrame = cmds.frameLayout(parent = self.child2, label = "IK Solvers", collapsable = True, collapse = True)
        cmds.text(parent = self.ikSolversFrame, label = "Spline IK")
        self.splineSelectHierarchyCB = cmds.checkBox(parent = self.ikSolversFrame, label = "Select Hierarchy")
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.ikSolversFrame, label = "Create Spline IK", command = lambda : self.SplineIK(cmds.checkBox(self.splineSelectHierarchyCB, query = 1, value = 1)))
        
        cmds.separator(parent = self.child2, style = "double")

        #control creator
        self.createControlFrame = cmds.frameLayout(parent = self.child2, label = "Create Controls", collapsable = True, collapse = True)
        self.createControlRC = cmds.rowColumnLayout(parent = self.createControlFrame, numberOfColumns=2)
        self.createControlGrid = cmds.gridLayout(parent = self.createControlFrame, numberOfColumns = 8)
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0, 0, 0), command = lambda x: self.SetColor(1) )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.75, 0.75, 0.75), command = lambda x: self.SetColor(2) )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.5, 0.5, 0.5), command = lambda x: self.SetColor(3) )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (.8, 0, 0.2), command = lambda x: self.SetColor(4)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0, 0, .4), command = lambda x: self.SetColor(5)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0, 0, 1), command = lambda x: self.SetColor(6)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0, .3, 0), command = lambda x: self.SetColor(7)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.2, 0, 0.3), command = lambda x: self.SetColor(8)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (.8, 0, .8), command = lambda x: self.SetColor(9)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.6, 0.3, 0.2), command = lambda x: self.SetColor(10)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.25, 0.13, 0.13), command = lambda x: self.SetColor(11)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.7, .2, 0), command = lambda x: self.SetColor(12)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (1, 0, 0), command = lambda x: self.SetColor(13)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0, 1, 0), command = lambda x: self.SetColor(14)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0, 0.3, 0.6), command = lambda x: self.SetColor(15)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (1, 1, 1), command = lambda x: self.SetColor(16)  )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (1, 1, 0), command = lambda x: self.SetColor(17)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0, 1, 1), command = lambda x: self.SetColor(18)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0, 1, .8), command = lambda x: self.SetColor(19)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (1, .7, .7), command = lambda x: self.SetColor(20)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.9, .7, .5), command = lambda x: self.SetColor(21)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (1, 1, 0.4), command = lambda x: self.SetColor(22)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0, 0.7, .4), command = lambda x: self.SetColor(23)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (.6, .4, .2), command = lambda x: self.SetColor(24)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (.63, .63, .17), command = lambda x: self.SetColor(25)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.4, 0.6, 0.2), command = lambda x: self.SetColor(26)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.2, 0.63, 0.35), command = lambda x: self.SetColor(27)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.18, 0.63, 0.63), command = lambda x: self.SetColor(28)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.18, 0.4, 0.63), command = lambda x: self.SetColor(29)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.43, 0.18, 0.63), command = lambda x: self.SetColor(30)   )
        cmds.button( label = "", parent = self.createControlGrid, backgroundColor = (0.63, 0.18, 0.4), command = lambda x: self.SetColor(31)   )
        cmds.text(parent = self.createControlRC, label = "Control Type")
        self.createControlOptnMenu = cmds.optionMenu(parent = self.createControlRC)
        cmds.menuItem(parent = self.createControlOptnMenu, label = "")
        cmds.menuItem(parent = self.createControlOptnMenu, label = "Circle")
        cmds.menuItem(parent = self.createControlOptnMenu, label = "Square")
        cmds.menuItem(parent = self.createControlOptnMenu, label = "Flower")
        cmds.text(parent = self.createControlRC, label = "Constrain to Joint")
        self.createControlCheckbox = cmds.checkBox(parent = self.createControlRC, value = False, label = "")
        cmds.text(parent = self.createControlRC, label = "Color Joints")
        self.colorJointsCheckbox = cmds.checkBox(parent = self.createControlRC, value = False, label = "")
        cmds.text(parent = self.createControlRC, label = "Rotate 90 Y")
        self.rotateYCheckbox = cmds.checkBox(parent = self.createControlRC, value = False, label = "")
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.createControlFrame, label = "Create Controls", command = lambda : self.CreateControl(cmds.optionMenu(self.createControlOptnMenu, q = True, v = True), self.colorIndex, cmds.checkBox(self.createControlCheckbox, q= True, v = True), cmds.checkBox(self.colorJointsCheckbox, q= True, v = True), cmds.checkBox(self.rotateYCheckbox, q= True, v = True)))
        cmds.text(parent = self.createControlRC, label = "Control Color:")
        
        cmds.separator(parent = self.child2, style = "double")

        # constraints
        self.constraintsFrame = cmds.frameLayout(parent = self.child2, label = "Constraints", collapsable = True, collapse = True)

        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.constraintsFrame, label = "Parent-Scale Constraint", command = lambda : self.ParentScaleConstraint())
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.constraintsFrame, label = "Split Parent Constrain", command = lambda : self.SplitParentConstrain())
        
        cmds.separator(parent = self.child2, style = "double")

        #RK system tools
        self.rkFrame = cmds.frameLayout(parent = self.child2, label = "IKFK System", collapsable = True, collapse = True)
        
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.rkFrame, label = "Create IK FK Chains", command = lambda : self.CreateIKFKJoints())
        
        self.scrollList = cmds.textScrollList(parent = self.rkFrame)
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.rkFrame, label = "Add", command = lambda : self.AddToTextScrollList(self.scrollList))
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.rkFrame, label = "Create Transform Control Attributes", command = lambda : self.CreateIKFKAttributes(self.QueryTextScrollList(self.scrollList)), ann = "Select your Transform control to run this command. Will create an IKFK attribute for two arms and two legs")

        self.rkRC1 = cmds.rowColumnLayout(parent = self.rkFrame, numberOfColumns=2)
        cmds.text(parent = self.rkRC1, label = "Attribute Number", ann = "Check the order of the user-created attributes on Transform control to get this number")
        self.rkAttrNum1 = cmds.intField(parent = self.rkRC1, value = 1)
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.rkFrame, label = "Key IKFK Switch", command = lambda : self.RKConstraintSetDrivenKey(self.QueryTextScrollList(self.scrollList), cmds.intField(self.rkAttrNum1, q = 1, v = 1)), ann  = "Select your Transform control first, then select the parent constraints on your RK joint chain for one joint system (ie for the left arm)")

        self.rkRC2 = cmds.rowColumnLayout(parent = self.rkFrame, numberOfColumns=2)
        cmds.text(parent = self.rkRC2, label = "Attribute Number", ann = "Check the order of the user-created attributes on Transform control to get this number")
        self.rkAttrNum2 = cmds.intField(parent = self.rkRC2, value = 1)
        cmds.text(parent = self.rkRC2, label = "Control Type")
        self.rkOptnMenu = cmds.optionMenu(parent = self.rkRC2)
        cmds.menuItem(parent = self.rkOptnMenu, label = "FK")
        cmds.menuItem(parent = self.rkOptnMenu, label = "IK")
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.rkFrame, label = "Key Control Visibility", command = lambda : self.RKCtrlSetDrivenKey(self.QueryTextScrollList(self.scrollList), cmds.intField(self.rkAttrNum2, q = 1, v = 1), cmds.optionMenu(self.rkOptnMenu, q = 1, v = 1)) , ann = "Select Transform control first, then select the controls for one joint system (ie the left arm IK controls)")
        
        cmds.separator(parent = self.child2, style = "double")

        #skinning animator
        self.skinAnimFrame = cmds.frameLayout(parent = self.child2, label = "Skinning Auto Animator", collapsable = True, collapse = True)
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.skinAnimFrame, label = "Animate", command = lambda : self.SkinningAnim())
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.skinAnimFrame, label = "Clear Keys", command = lambda : cmds.cutKey())

        
        
        #utility tab
        self.child3 = cmds.rowColumnLayout(parent = self.tabs, numberOfColumns=1)

        #renamer
        self.renamerFrame = cmds.frameLayout(parent = self.child3, label = "Renamer", collapsable = True, collapse = True)
        self.renamerRC = cmds.rowColumnLayout(parent = self.renamerFrame, numberOfColumns = 2)

        cmds.text(parent = self.renamerRC, label = "Name")
        self.nameField = cmds.textField(parent = self.renamerRC, text = "name")
        cmds.text(parent = self.renamerRC, label = "Number Padding")
        self.numPadField = cmds.textField(parent = self.renamerRC, text = "00")
        cmds.text(parent = self.renamerRC, label = "Number")
        self.numField = cmds.intField(parent = self.renamerRC, value = 1)
        cmds.text(parent = self.renamerRC, label = "Suffix")
        self.suffixField = cmds.textField(parent = self.renamerRC, text = "suffix")

        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.renamerFrame, label = "Rename and Number", command = lambda : self.RenameAndNumber(cmds.textField(self.nameField, q = 1, text = 1), cmds.textField(self.numPadField, q = 1, text = 1), cmds.intField(self.numField, q = 1, v = 1), cmds.textField(self.suffixField, q = 1, text = 1)))

        #filter selection
        self.filselFrame = cmds.frameLayout(parent = self.child3, label = "Filter Selection", collapsable = True, collapse = True)
        self.filselRC = cmds.rowColumnLayout(parent = self.filselFrame, numberOfColumns = 2)
        cmds.text(parent = self.filselRC, label = "Select Hierarchy")
        self.filselCheckbox = cmds.checkBox(parent = self.filselRC, value = True, label = "")
        cmds.text(parent = self.filselRC, label = "Node Type")
        self.filselText = cmds.textField(parent = self.filselRC)
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.filselFrame, label = "Filter Selection", command = lambda : self.FilterSelection(cmds.checkBox(self.filselCheckbox, q = 1, v = 1), cmds.textField(self.filselText, q = 1, text = 1)))

        #randomize selection
        self.randSelFrame = cmds.frameLayout(parent = self.child3, label = "Randomize Selection", collapsable = True, collapse = True)
        self.randSelRC = cmds.rowColumnLayout(parent = self.randSelFrame, numberOfColumns = 2)

        cmds.text(parent = self.randSelRC, label = "Percent of Selection")
        self.percentSelField = cmds.floatField(parent = self.randSelRC, value = 50)
        cmds.iconTextButton(style = "textOnly", rpt = 1, parent = self.randSelFrame, label = "Randomize", command = lambda : self.RandomizeSelection(cmds.floatField(self.percentSelField, q = 1, v = 1)))
        
        #set up tab layout
        cmds.tabLayout( self.tabs, edit=True, tabLabel=((self.child1, 'Modelling'), (self.child2, 'Rigging'), (self.child3, 'Utility')) )
Exemple #57
0
def doRadioUVs(input_radio, input_uvScaleSlider):
    inputState = (cmds.radioButtonGrp(input_radio, q=True, select=True) == 1)
    cmds.floatSliderGrp(input_uvScaleSlider, e=True, en=inputState)
Exemple #58
0
 def QueryRadioButtonGrp(self, radioGrp):
     return cmds.radioButtonGrp(radioGrp, query = 1, select = 1)
Exemple #59
0
    def create(self,*args):
        #Define/Store variables
        label = mc.textFieldGrp(self.labelField,query=True,text=True)
        control = mc.textFieldButtonGrp(self.cntField,query=True,text=True)
        fkControl = mc.textFieldButtonGrp(self.fkCntField,query=True,text=True)

        aimVal = mc.radioButtonGrp(self.aimField,query=True,select=True)
        twistVal = mc.radioButtonGrp(self.twistField,query=True,select=True)
        upVal = mc.radioButtonGrp(self.upField,query=True,select=True)

        #Set aim, twist, up
        aim = ' '
        twist = ' '
        up = ' '

        if aimVal == 1:
            aim = 'X'
        if aimVal == 2:
            aim = 'Y'
        if aimVal == 3:
            aim = 'Z'

        if twistVal == 1:
            twist = 'X'
        if twistVal == 2:
            twist = 'Y'
        if twistVal == 3:
            twist = 'Z'

        if upVal == 1:
            up = 'X'
        if upVal == 2:
            up = 'Y'
        if upVal == 3:
            up = 'Z'

            #Create main attributes on control
        mc.select(control,r=True)
        attList = mc.attributeInfo(control,all=True)

        if(label not in attList):
            try:
                mc.addAttr(longName=label,k=True)
                mc.setAttr(control + '.' + label, lock=True)
            except:
                pass #Attribute already exists

        #Per limb specified by user
        for (nameFld,startJntFld,endJntFld) in zip(self.attNameFlds,self.startFlds,self.endFlds):
            #Get data for current limb
            name = mc.textFieldGrp(nameFld,query=True,text=True)
            startJnt = mc.textFieldButtonGrp(startJntFld,query=True,text=True)
            endJnt = mc.textFieldButtonGrp(endJntFld,query=True,text=True)

            #Get full chain
            chain = []

            #Get the hierarchy of startJnt, then store it until endJnt is found
            try:
                mc.select(startJnt,r=True,hi=True)
                sel = mc.ls(sl=True,fl=True,type='joint')
                tempChain = sel

                for each in tempChain:
                    if each == endJnt:
                        chain.append(each)
                        break
                    else:
                        chain.append(each)
            except:
                pass

            #Store parent of chain
            parent = mc.listRelatives(chain[0],parent=True)

            #Unparent joints
            for each in chain:
                try:
                    mc.parent(each,w=True)
                except:
                    pass

            #Create duplicate joints above orig joints, then store duplicate joint names
            dupJoints = []
            for joint in chain:
                offName = joint + '_off'
                jnt = mc.duplicate(joint,rr=True,po=True,n=offName)
                dupJoints.append(jnt)

            #Rebuild heirarchy
            x = 0
            while x < len(chain):
                mc.parent(chain[x],dupJoints[x])
                if x != 0:
                    mc.parent(dupJoints[x],chain[x-1])
                x = x + 1

            #Adding Curl atts on controller
            x= 0 
            while x < len(chain):
                mc.addAttr(control, longName=name + '_curl_' + str(x+1),k=True)
                x = x + 1

            #Adding spread atts on controller
            x= 0 
            while x < len(chain):
                mc.addAttr(control, longName=name + '_spread_' + str(x+1),k=True)
                x = x + 1

            #Twist
            mc.addAttr(control, longName=name + '_Twist',k=True)

            #Connect attributes to dupJoints rotate's ( aim = curl, up = spread )
            x = 0
            #try:
            mc.connectAttr( control + '.' + name + '_Twist' , str(dupJoints[x][0]) + '.rotate' + twist ) 
            while x < len(chain):
                mc.connectAttr( control + '.' + name + '_curl_' + str(x+1) , str(dupJoints[x][0]) + '.rotate' + aim )
                mc.connectAttr( control + '.' + name + '_spread_' + str(x+1), str(dupJoints[x][0]) + '.rotate' + up )
                x = x + 1
            #except:
            #	pass

            #Create fk controllers on joints
            #Duplicate FK control, parent it to chain joints, delete left over transform node
            for each in chain:
                #Duplicate control
                tempCnt = mc.duplicate(fkControl)
                #Select the shape
                tempShp = mc.pickWalk(tempCnt,direction='down')
                mc.parent(tempShp,each,r=True,s=True)
                mc.delete(tempCnt)

            #reparent chain to parent
            mc.parent(dupJoints[0],parent)
def runUI():

    # Make a new window
    mddExporterWindow = 'mddExporter_window'
    if cmds.window(mddExporterWindow, exists=1):
        cmds.deleteUI(mddExporterWindow, window=True)
    if cmds.windowPref(mddExporterWindow, exists=1):
        cmds.windowPref(mddExporterWindow, remove=True)
    mddExporterWindow = cmds.window(
        mddExporterWindow,
        menuBar=True,
        title="Maya OBJ/MDD/Particle Sequence Exporter to Houdini",
        iconName='Short Name',
        s=0,
        widthHeight=(400, 310))
    cmds.menu(label='Help', helpMenu=True)
    cmds.menuItem(label='Short Help', command=helpWindow)

    startFrame = cmds.playbackOptions(q=1, minTime=1)
    endFrame = cmds.playbackOptions(q=1, maxTime=1)
    cmds.columnLayout(adjustableColumn=True)
    cmds.text(label='*** Select Objects in the Viewport First *** ',
              align='center')
    cmds.separator()
    rangeSlider = cmds.intFieldGrp('em_rangeSlider',
                                   numberOfFields=3,
                                   columnAlign=[1, 'left'],
                                   label='Frame Range',
                                   columnWidth5=(82, 62, 62, 40, 40),
                                   extraLabel='inc',
                                   value1=startFrame,
                                   value2=endFrame,
                                   value3=1)
    cmds.separator()
    mddFpsOptionMenu = cmds.floatFieldGrp('em_frate',
                                          numberOfFields=1,
                                          label='Frame Rate',
                                          extraLabel='fps',
                                          value1=getMayaFrameRate(),
                                          columnWidth3=(82, 40, 40))
    cmds.separator()
    radioButtons = cmds.radioButtonGrp(
        'em_modeRadio',
        label='Export To :  ',
        labelArray3=['OBJ', 'MDD', 'Particle Geo'],
        select=2,
        adjustableColumn=1,
        columnAlign=[1, 'left'],
        numberOfRadioButtons=3,
        changeCommand='fx_mdd_obj_exporter.onRadioBtnChanged()')
    cmds.separator()
    cmds.textFieldButtonGrp('em_fileName',
                            label='FileName',
                            text='c:/temp/foo.mdd',
                            columnWidth3=(82, 265, 40),
                            columnAlign=[1, 'left'],
                            buttonLabel='Open',
                            buttonCommand=getExportFilePathUI)
    cmds.separator()
    cmds.button(label='EXPORT', command=launchExport)

    cmds.frameLayout(label='Particles Custom Variable to Export',
                     borderStyle='etchedOut',
                     collapsable=1,
                     collapse=1)
    cmds.columnLayout()
    cmds.rowColumnLayout(numberOfColumns=2,
                         columnAttach=(1, 'right', 0),
                         columnWidth=[(1, 100), (2, 250)])
    cmds.text(label='UserVector 1')
    cmds.textField('userVector1')
    cmds.text(label='UserVector 2')
    cmds.textField('userVector2')
    cmds.setParent('..')

    cmds.rowColumnLayout(numberOfColumns=2,
                         columnAttach=(1, 'right', 0),
                         columnWidth=[(1, 100), (2, 250)])
    cmds.text(label='UserFloat 1')
    cmds.textField('userFloat1')
    cmds.text(label='UserFloat 2')
    cmds.textField('userFloat2')
    cmds.setParent('..')

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

    cmds.separator()

    cmds.setParent('..')
    cmds.showWindow(mddExporterWindow)