def zbw_offsetAnim(*args):
    """creates offset from first obj sel to last based on the entered offset value"""
    def zbw_runOffsetAnim(*args):
        #get frame range!!!!!!
        #get selection, check that they are tranforms
        sel = cmds.ls(sl=True,type="transform")
        selSize = int(len(sel))
        #for each selection mult the index by the offset value
        for i in range(0,selSize):
            obj = sel[i]
            offsetRaw = cmds.intFieldGrp('zbw_offsetValue', q=True, v=True)
            offset = offsetRaw[0]
            multFactor = i * offset
            #shift the entire anim curve by the offset mult value
            cmds.keyframe(obj, edit=True,relative=True,timeChange=multFactor,time=(1,24))

    #create UI, get offset value, frame range or all anim
    if (cmds.window('zbw_offsetAnimUI', exists=True)):
        cmds.deleteUI('zbw_offsetAnimUI', window=True)
        cmds.windowPref('zbw_offsetAnimUI', remove=True)
    window=cmds.window('zbw_offsetAnimUI', widthHeight=(350,200), title='zbw_offsetAnim')
    cmds.columnLayout(cal='center')
    cmds.intFieldGrp('zbw_offsetValue', cal=(1,'left'), label='frequency(frames)', value1=5)
    #CREATE FRAME RANGE AREA (WHICH FRAMES ARE WE DOING?)
    #WHEN THAT HAPPENS, WHAT DO WE DO WITH THE FRAMES AFTER THAT? (PROBABLY NOTHING. . . LET USER WORRY ABOUT IT)
    #checkbox for random freq (to give a random amount to offset each object)
    #cmds.checkBoxGrp('zbw_animNoiseRandom', cal=(1,'left'), cw=(1, 175),label='random frequency on', value1=0, cc=zbw_animNoiseRandom)
    cmds.button('zbw_offsetAnimGo', label='offset!', width=75, command=zbw_runOffsetAnim)

    cmds.showWindow(window)
Example #2
0
    def updateStartAndEndFrame(self, startFrameField, endFrameField ):

        minTime = cmds.playbackOptions( q=1, minTime=1 )
        maxTime = cmds.playbackOptions( q=1, maxTime=1 )

        cmds.intFieldGrp( startFrameField, e=1, v1= -5, v2=minTime )
        cmds.intFieldGrp( endFrameField  , e=1, v1= maxTime, v2=5 )
Example #3
0
def exportGeoFromUI():
	'''
	writeGeoCache from UI 
	'''
	# Get UI info
	path = mc.textFieldButtonGrp('meshCache_pathTBG',q=True,text=True)
	start = mc.intFieldGrp('meshCache_rangeIFG',q=True,v1=True)
	end = mc.intFieldGrp('meshCache_rangeIFG',q=True,v2=True)
	pad = mc.intFieldGrp('meshCache_paddingIFG',q=True,v1=True)
	uvSet = mc.textFieldGrp('meshCache_uvSetTFG',q=True,text=True)
	worldSpace = bool(mc.radioButtonGrp('meshCache_spaceRBG',q=True,sl=True)-1)
	gz = mc.checkBoxGrp('meshCache_gzipCBG',q=True,v1=True)
	
	# Check UV Set
	if uvSet == 'default': uvSet = ''
	
	# Get selection
	sel = [i for i in mc.ls(sl=True,fl=True,o=True) if glTools.utils.mesh.isMesh(i)]
	if not sel:
		print 'No valid mesh objects selected for export!!'
		return
	
	# Export each mesh
	for mesh in sel:
		
		# Generate file name
		mesh_name = mesh.replace(':','_')
		
		# Export
		glTools.tools.meshCache.writeGeoCache(path,mesh_name,mesh,start,end,pad,uvSet,worldSpace,gz)
Example #4
0
    def doExport(self):
        outFolder = cmds.textFieldButtonGrp('outputFolder', q=True, tx=True)

        if (outFolder == ''):
            cmds.confirmDialog( title='Render To Texture', message='An Output folder must be selected', button=['Ok'], defaultButton='Ok', cancelButton='Ok', dismissString='Ok' )
            return False


        resolution = cmds.intFieldGrp('resolution', q=True, v1=True)
        aa_sampling = cmds.intFieldGrp('aa_samples', q=True, v1=True)
        
        filter_type = cmds.optionMenuGrp('filter', q=True, v=True)
        filter_width = cmds.floatFieldGrp('filterWidth', q=True, v1=True)
        shader = cmds.textFieldGrp('shader', q=True, tx=True)

        selList = cmds.ls(sl=1)

        if (len(selList) == 0):
            cmds.confirmDialog( title='Render To Texture', message='No Geometry Selected', button=['Ok'], defaultButton='Ok', cancelButton='Ok', dismissString='Ok' )
            return False

        cmds.arnoldRenderToTexture(folder=outFolder, shader=shader, resolution=resolution, aa_samples=aa_sampling, filter=filter_type, filter_width=filter_width )

        cmds.deleteUI(self.window)
        return True
Example #5
0
def intAttribute(mainSetting, setting):
    cmds.intFieldGrp(str(setting.keys()[0])+'_attribute',
                    numberOfFields=1,
                    label=str(setting.keys()[0]).replace('_', ' '),
                    value1=setting.values()[0],
                    cc="import dmptools.setup.settingsWindow as settingsWindow;settingsWindow.updateIntAttr('"+mainSetting+"')"
                    )
Example #6
0
def initializeBakeRange():
    """
    Initialize bake anim range based on playback timeline min/max.
    """
    start = cmds.playbackOptions(q=True, min=True)
    end = cmds.playbackOptions(q=True, max=True)
    cmds.intFieldGrp('xferMocap_startEndCBG', e=True, v1=start, v2=end)
Example #7
0
def toggleBakeRange():
    """
    Toggle bake anim range input.
    """
    enable = cmds.checkBoxGrp('xferMocap_bakeRangeCBG', q=True, value1=True)
    cmds.intFieldGrp('xferMocap_startEndCBG', e=True, en=enable)
    if not enable: initializeBakeRange()
def extendUI(*args):
    """UI for the script"""
    #UI
    if cmds.window("curbWin", exists=True):
        cmds.deleteUI("curbWin")

    cmds.window("curbWin", t="zbw_polyExtender", w=200, h=200)
    cmds.columnLayout("colLO")
    cmds.frameLayout("topFrame", l="Covert Edge", cll=True, bgc=(.2,.2,.2))
    cmds.text("Select poly edge to convert")
    cmds.button("convertBut", l="Convert!", w=200, h=30, bgc=(.8, .8,.6), c=convertEdge)
    cmds.separator(h=5)

    cmds.setParent("colLO")

    cmds.frameLayout("midFrame", l="Create Poly", cll=True, bgc=(.2,.2,.2))
    cmds.text("Select curve")
    cmds.separator(h=5)
    cmds.textFieldGrp("name", l="Name", w=200, cw=[(1,30), (2,170)], tx="newPoly")
    cmds.checkBox("curbCB", l="Positive Direction", v=True)
    # cmds.checkBox("bumpCB", l="Add vertical hump?", v=True)
    cmds.floatFieldGrp("curbFFG", l="Curb Width", cal=((1, "left"),(2,"left")), cw=([1,75],[2,50]), v1=10)
    cmds.intFieldGrp("UDivIFG", l="Width Subdivisions", cal=((1, "left"),(2,"left")), cw=([1,75],[2,50]), v1=1)
    cmds.intFieldGrp("VDivIFG", l="Length Subdivisions", cal=((1, "left"),(2,"left")), cw=([1,75],[2,50]), v1=1)
    cmds.checkBox("polyHistory", l="Keep history on final poly?", v=False)
    cmds.checkBox("history", l="Keep history objects?", v=True, cc=enableHistory)

    cmds.separator(h=5)
    cmds.button("curbBut", l="Create Curb", h=40, w=200, bgc=(.6, .8, .6), c=extendPoly)

    cmds.showWindow("curbWin")
    cmds.window("curbWin", e=True, h=150, w=200)
Example #9
0
def exportGeoCombinedFromUI():
	'''
	writeGeoCombineCache from UI
	'''
	# Get UI info
	path = mc.textFieldButtonGrp('meshCache_pathTBG',q=True,text=True)
	name = mc.textFieldGrp('meshCache_nameTFG',q=True,text=True)
	start = mc.intFieldGrp('meshCache_rangeIFG',q=True,v1=True)
	end = mc.intFieldGrp('meshCache_rangeIFG',q=True,v2=True)
	pad = mc.intFieldGrp('meshCache_paddingIFG',q=True,v1=True)
	uvSet = mc.textFieldGrp('meshCache_uvSetTFG',q=True,text=True)
	worldSpace = bool(mc.radioButtonGrp('meshCache_spaceRBG',q=True,sl=True)-1)
	gz = mc.checkBoxGrp('meshCache_gzipCBG',q=True,v1=True)
	
	# Check Name
	if not name:
		print 'Provide valid cache name and try again!'
		return
	
	# Check UV Set
	if uvSet == 'default': uvSet = ''
	
	# Get selection
	sel = [i for i in mc.ls(sl=True,fl=True,o=True) if glTools.utils.mesh.isMesh(i)]
	if not sel:
		print 'No valid mesh objects selected for export!!'
		return
	
	# Write Combine Cache
	glTools.tools.meshCache.writeGeoCombineCache(path,name,sel,start,end,pad,uvSet,worldSpace,gz)
Example #10
0
def get_ui_values():
    global engine_path, folder, file_name, export_batch, resolution_x, resolution_y, exposure, gamma, \
        ray_number, time, seed, export_animation, start_frame, end_frame, export_normals, invert_normals, check_Z, materials
        
    engine_path = cmds.textFieldButtonGrp(engine_field, query=True, text=True)
    folder = cmds.textFieldButtonGrp(directory_field, query=True, text=True)
    file_name = cmds.textFieldGrp(file_field, query=True, text=True)
    
    export_batch = cmds.checkBoxGrp(batch_field, query=True, value1=True)
    
    resolution_x = cmds.intFieldGrp(resolution_field, query=True, value1=True)
    resolution_y = cmds.intFieldGrp(resolution_field, query=True, value2=True)
    exposure = cmds.floatSliderGrp(exposure_field, query=True, value=True)
    gamma = cmds.floatSliderGrp(gamma_field, query=True, value = True)
    ray_number = cmds.intSliderGrp(rays_field, query=True, value=True)
    seed = cmds.intSliderGrp(seed_field, query=True, value=True)
    time = cmds.intSliderGrp(time_field, query=True, value=True)
    export_animation = cmds.checkBoxGrp(animation_field, query=True, value1=True)
    start_frame =  cmds.intFieldGrp(frame_range_field, query=True, value1=True)
    end_frame =  cmds.intFieldGrp(frame_range_field, query=True, value2=True)
    export_normals = cmds.checkBoxGrp(normals_export_field, query=True, value1=True)
    invert_normals = cmds.checkBoxGrp(normals_invert_field, query=True, value1=True)
    check_Z = cmds.checkBoxGrp(check_Z_field, query = True, value1=True)
    
    materials = []
    for mat in range(5):
        materials.append(cmds.floatFieldGrp(eval('material_%i_field' % (mat)), query=True, value=True))
Example #11
0
def initializeBakeRange():
	'''
	Initialize bake anim range based on playback timeline min/max.
	'''
	start = mc.playbackOptions(q=True,min=True)
	end = mc.playbackOptions(q=True,max=True)
	mc.intFieldGrp('xferMocap_startEndCBG',e=True,v1=start,v2=end)
Example #12
0
    def __init__(self) :
        # now we create a window ready to populate the components
        self.m_window = cmds.window( title='Flock The System', )
        # create a layout
        form = cmds.formLayout()
        tabs = cmds.tabLayout(innerMarginWidth=10, innerMarginHeight=10)
        cmds.formLayout( form, edit=True, attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'right', 0)) )
        
        child1 = cmds.rowColumnLayout(numberOfColumns=1)
        #cmds.image( image='/home/i7867155/Desktop/Screenshot.png' )
        cmds.intFieldGrp( numberOfFields=2, label='Start Frame',  extraLabel='End Frame', value1=3, value2=3,  )
        #cmds.button( label='Update Flock', bgc=(1,0,0)  )
        #cmds.iconTextButton( style='iconOnly', image1='/home/i7867155/Desktop/Screenshot.png', command='click()' )
        
        

        exportButton = cmds.button( label='Export/Update Curves', command='exportCurves()' )


        cmds.setParent( tabs )

        child2 = cmds.rowColumnLayout(numberOfColumns=2)
        cmds.button(width=50)
        cmds.button()
        cmds.button()
        cmds.setParent( tabs )

        cmds.tabLayout( tabs, edit=True, tabLabel=((child1, 'Pre-flock'), (child2, 'Post-flock')) )
        
        # finally show the window
        cmds.showWindow( self.m_window )
Example #13
0
 def accept(self, *args):        
     numAnts = int(cmds.intFieldGrp("numAnts",query=True,value=True)[0])                    
     startFrame = int(cmds.intFieldGrp("startFrame",query=True,value=True)[0])                    
     endFrame = int(cmds.intFieldGrp("endFrame",query=True,value=True)[0])                    
     
     curves = cmds.textScrollList("curves",q=True,ai=True)
     if curves == None:
         curves = ["curve1"]
     isFlat = cmds.checkBox("isFlat", query = True, value = True)        
     vel = cmds.floatSliderGrp("Velocity", query=True, value=True)        
     load = cmds.floatSliderGrp("load", query=True, value=True)
     
     ground = cmds.textFieldButtonGrp("groundObj",q=True,text=True)
     if ground == None:
         ground = "nurbsPlane1"
         
     
     numCurves = len(curves)
     
     if (numAnts > 1) and (numAnts != numCurves):
         cmds.warning("the number of ants and curves must be the same")
         return 0
     else:
         if (numAnts > 1):
             self.duplicateAnts(numAnts-1)
         for ind in range(numAnts):                
             arcLen = cmds.arclen(curves[ind])
             # rebuiltCurve = cmds.rebuildCurve(curves[ind], kr=1)[0]            
             ct.walking(ind+1, startFrame, endFrame, curves[ind], ground, vel, load, isFlat)
 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")
Example #15
0
def toggleBakeRange():
	'''
	Toggle bake anim range input.
	'''
	enable = mc.checkBoxGrp('xferMocap_bakeRangeCBG',q=True,value1=True)
	mc.intFieldGrp('xferMocap_startEndCBG',e=True,en=enable)
	if not enable: initializeBakeRange()
def gradeTotalsFrame():	
	cmds.frameLayout( label='Grade Totals', cll=True, labelAlign='center', borderStyle='etchedIn', w=480 )
	cmds.columnLayout()
	gradeFrm = cmds.formLayout()
	global gradeTotal
	global cflDeductGradeTotal
	global aanDeductGradeTotal
	global proDeductGradeTotal
	global lateGradeTotal
	global totalGradeTotal
	# Create the Output Grades and Comments to Text File button
	textOutputButton=cmds.button( label='Output Grades and Comments to Text File', align='center', command=textOutputButtonFunction )
	cmds.formLayout( gradeFrm, edit=1, attachForm=[[textOutputButton, "left", 5], [textOutputButton, "top", 5]])
	# Create the Art Grade Total label and intField
	gradeGradeField=cmds.intFieldGrp( "gradeIntField", numberOfFields=1, label='Grade Total', changeCommand=updateGradeTotal)
	cmds.formLayout( gradeFrm, edit=1, attachOppositeControl=[[gradeGradeField, "top", 35, textOutputButton], [gradeGradeField, "left", 0, textOutputButton]])
	# Create the Antialias/Noise Deductions Grade Total label and intField
	aanDeductGradeField=cmds.intFieldGrp( "aanDeductGradeIntField", numberOfFields=1, label='Alias/Noise Deductions', changeCommand=updateGradeTotal)
	cmds.formLayout( gradeFrm, edit=1, attachOppositeControl=[[aanDeductGradeField, "top", 35, gradeGradeField], [aanDeductGradeField, "left", 0, gradeGradeField]])
	# Create the Professionalism Deductions Grade Total label and intField
	proDeductGradeField=cmds.intFieldGrp( "proDeductGradeIntField", numberOfFields=1, label='Prof Deductions', changeCommand=updateGradeTotal)
	cmds.formLayout( gradeFrm, edit=1, attachOppositeControl=[[proDeductGradeField, "top", 35, aanDeductGradeField], [proDeductGradeField, "left", 0, aanDeductGradeField]])
	# Create the Late Deductions Grade Total label and intField
	lateGradeField=cmds.intFieldGrp( "lateGradeIntField", numberOfFields=1, label='Late Deductions', changeCommand=updateGradeTotal)
	cmds.formLayout( gradeFrm, edit=1, attachOppositeControl=[[lateGradeField, "top", 35, proDeductGradeField], [lateGradeField, "left", 0, proDeductGradeField]])
	# Create the Overall Grade Total label and intField
	totalGradeField=cmds.intFieldGrp( "totalGradeIntField", numberOfFields=1, label='Final Grade Total')
	cmds.formLayout( gradeFrm, edit=1, attachOppositeControl=[[totalGradeField, "top", 35, lateGradeField], [totalGradeField, "left", 0, lateGradeField]])
	cmds.setParent('..')
	cmds.setParent('..')
	cmds.setParent('..')
def continueOutputFunction():
	gradeOutputTotal=cmds.intFieldGrp( "gradeIntField", q=1, value1=1)
	lateGradeOutputTotal=cmds.intFieldGrp( "lateGradeIntField", q=1, value1=1)
	totalGradeOutputTotal=cmds.intFieldGrp( "totalGradeIntField", q=1, value1=1)
# Queries the Grade comments for output
	aanqTSListOutput=cmds.scrollField("aanqTSList", q=1, tx=1)
	cflTSListOutput=cmds.scrollField("cflTSList", q=1, tx=1)
	lightTSTSListOutput=cmds.scrollField("lightTSList", q=1, tx=1)
	proTSListOutput=cmds.scrollField("proTSList", q=1, tx=1)
# Formats the comments for output	
	sceneFileOutput=open(selectedFileName+".txt", 'w')
	sceneFileOutput.write("Grading for: "+sceneFileName+"\r\n")
	sceneFileOutput.write("-----------------------------------\r\n")
	sceneFileOutput.write("Lighting Comments: "+lightTSTSListOutput+"\r\n")
	sceneFileOutput.write("Lighting Grade: "+str(lightGradeTotal)+"\r\n")
	sceneFileOutput.write("\r\n")
	sceneFileOutput.write("Grade Total: "+str(gradeOutputTotal)+"\r\n")
	sceneFileOutput.write("-----------------------------------\r\n")
	sceneFileOutput.write("Deduction Comments:\r\n")
	sceneFileOutput.write("Composition & Focal Length Comments: "+cflTSListOutput+"\r\n")
	sceneFileOutput.write("Antialiasing & Noise Quality Comments: "+aanqTSListOutput+"\r\n")
	sceneFileOutput.write("Professionalism Comments: "+proTSListOutput+"\r\n")
	sceneFileOutput.write("-----------------------------------\r\n")
	sceneFileOutput.write("Comp/Focal Len Deductions (15%): -"+str(cflDisplayGradeTotal)+"\r\n")
	sceneFileOutput.write("Alias/Noise Deductions (15%): -"+str(aanqDisplayGradeTotal)+"\r\n")
	sceneFileOutput.write("Prof Deductions (10%): -"+str(proDisplayGradeTotal)+"\r\n")
	sceneFileOutput.write("Late Deductions: -"+str(lateGradeOutputTotal)+"\r\n")
	sceneFileOutput.write("-----------------------------------\r\n")
	sceneFileOutput.write("Overall Grade Total: "+str(totalGradeOutputTotal)+"\r\n")
	sceneFileOutput.close()
Example #18
0
def bakeDynamicCmd(*args):
    '''
    Bake the dynamic simulation as key frames on the joints rotations for the specified frame range
    '''
    # display warning message
    result = cmds.confirmDialog(messageAlign="left", title="Bake Simulation", message="Baking simulation will replace the dynamics\nfor keyframe animation. Action is undoable. Do you wish to continue?", button=["Yes", "No"])
     
    if result == "Yes":
        # get selected object
        selected = cmds.ls(sl=True)
         
        if selected:
            # manage the dynamic node
            dNode = lpDynamicChain(node=selected[0])
            startJoint = dNode.startJoint[0]
            endJoint = dNode.endJoint[0]
             
            # get frame range
            startFrame = cmds.intFieldGrp("frameRangeIFG", q=True, v1=True)
            endFrame = cmds.intFieldGrp("frameRangeIFG", q=True, v2=True)
             
            if cmds.checkBoxGrp("useTimeSliderCBG", q=True, v1=True):
                startFrame = cmds.playbackOptions(q=True, minTime=True)
                endFrame = cmds.playbackOptions(q=True, maxTime=True)
             
            # get the joints
            joints = [startJoint]
            joints.extend( findAllJointsFromTo(startJoint, endJoint) )
             
        # bake the simulation for the frame range - this action is undoable
        cmds.bakeResults(joints, t=(startFrame, endFrame), dic=False, preserveOutsideKeys=True, simulation=True)
Example #19
0
	def enable_distributed(self, arg) :
		"""enable_distributed

		:param arg: Missing documentation about arg argument
		:return:
		"""
		ar_distr_frame = self.winMain + '|f0|t0|tc2|fr2'
		ar_distr = ar_distr_frame + '|fc2|'
		setDefaultIntValue(
			self_prefix,
			'ar_distributed',
			self.ar_param,
			arg
		)
		cmds.checkBoxGrp(
			ar_distr + 'ar_nomaster',
			edit=True,
			enable=arg
		)

		# cmds.intFieldGrp(
		#     ar_distr + 'ar_port',
		#     edit=True,
		#     enable=arg
		# )

		cmds.intFieldGrp(
			ar_distr + 'ar_hosts_min',
			edit=True,
			enable=arg
		)

		cmds.intFieldGrp(
			ar_distr + 'ar_hosts_max',
			edit=True,
			enable=arg
		)

		# cmds.intFieldGrp(
		#     ar_distr + 'ar_threads_limit',
		#     edit=True,
		#     enable=arg
		# )

		cmds.textFieldGrp(
			ar_distr + 'ar_hosts',
			edit=True,
			enable=arg
		)

		bg_color = self.save_frame_bgc
		if arg:
			bg_color = self.def_frame_bgc

		cmds.frameLayout(
			ar_distr_frame,
			edit=True,
			bgc=bg_color
		)  # , enableBackground=False
Example #20
0
 def spreadOn(self, *args):
     #get value of spread joints cb
     on = cmds.checkBoxGrp(self.widgets["jointOptionsCBG"], q=True, v1=True)
     #if spread joints in on
     if on:
         cmds.intFieldGrp(self.widgets["numSpreadIFG"], e=True, en=True)
     else:
         cmds.intFieldGrp(self.widgets["numSpreadIFG"], e=True, en=False)
def getRange(*args):
    sl = cmds.radioButtonGrp(widgets["rangeRBG"], q=True, sl=True)
    if sl==1:
        startF = cmds.playbackOptions (query=True, minTime=True)
        endF = cmds.playbackOptions (query=True, maxTime=True)
    else:
        startF = cmds.intFieldGrp(widgets["frameRangeIFG"], q=True, v1=True)
        endF = cmds.intFieldGrp(widgets["frameRangeIFG"], q=True, v2=True)
    return(int(startF), int(endF))
Example #22
0
def createUI():

	preUI()

	mc.window( 'gitMayaWin', title="Git Tools", iconName='', widthHeight=(200, 55) )
	mc.menuBarLayout()
	mc.menu( label='File' )
	mc.menuItem( label='Create Repo', c=lambda *args: createRepo() )
	mc.setParent( '..' )
	mc.columnLayout( adjustableColumn=True )
	mc.rowLayout( numberOfColumns=3, columnWidth3=(80, 80, 80))
	mc.button( label='Create Repo', w=80, h=80)
	mc.button( label='Clone Repo', w=80, h=80)
	mc.setParent( '..' )
	mc.separator(h=10, style='none')
	mc.textFieldButtonGrp( 'repoPath', label='Repo Path', text='', buttonLabel='Browse', bc=lambda *args: getFolder() )
	mc.button( label='Refresh', c=lambda *args: initRepo() )
	mc.separator(h=10, style='none')
	mc.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
	mc.columnLayout( 'Files', adjustableColumn=True )
	mc.rowColumnLayout(nc=5)
	mc.separator(h=20, style='none')
	mc.text(l='Working Copy Changes')
	mc.separator(h=20, style='none')
	mc.separator(h=20, style='none')
	mc.text(l='Staged Changes')
	mc.columnLayout( 'workingChangesColor', adjustableColumn=True)
	mc.setParent( '..' )
	mc.textScrollList( 'workingChanges', numberOfRows=16, allowMultiSelection=True)
	mc.columnLayout( adjustableColumn=True )
	mc.button( label='>>', c=lambda *args: addChanged())
	mc.button( label='>' )
	mc.separator(h=30, style='none')
	mc.button( label='<', c=lambda *args: remSelected())
	mc.button( label='<<' )
	mc.setParent( '..' )
	mc.columnLayout( 'stagedChangesColor', adjustableColumn=True )
	mc.setParent( '..' )
	mc.textScrollList( 'stagedChanges', numberOfRows=16, allowMultiSelection=True)
	mc.setParent( '..' )
	mc.textFieldButtonGrp( 'commitMessage', label='Message', text='', buttonLabel='Commit', bc=lambda *args: doCommit() )
	mc.separator(h=20)
	mc.setParent( '..' )

	mc.columnLayout( 'History', adjustableColumn=True )
	mc.intFieldGrp( 'commitCount', numberOfFields=1, label='Number of Commits', value1=10, cc=lambda *args: getCommits())
	mc.scrollLayout(h=250, horizontalScrollBarThickness=16, verticalScrollBarThickness=16)
	mc.rowColumnLayout( 'commitsGrid', numberOfColumns=2, cw=([1,450],[2,150]) )
	mc.setParent( '..' )
	mc.setParent( '..' )
	mc.text(l='Commited Changes')
	mc.textScrollList( 'commitChanges', numberOfRows=16, allowMultiSelection=True)
	mc.showWindow( 'gitMayaWin' )

	postUI()
Example #23
0
        def sceneBake( *args ):
            import sgFunctionSceneBake2
            
            bakeTargets = cmds.textField( self.ui.bakeTargetField, q=1, tx=1 ).split( ' ' )
            cachePath   = cmds.textField( self.ui.cachePathField, q=1, tx=1 )
            
            startOffset, startFrame = cmds.intFieldGrp( self.ui.uiFrames.startFrame, q=1, v=1 )
            endFrame   , endOffset  = cmds.intFieldGrp( self.ui.uiFrames.endFrame, q=1, v=1 )

            print "export target", bakeTargets, cachePath, startFrame, endFrame, startOffset, endOffset
            sgFunctionSceneBake2.exportBakedData(bakeTargets, cachePath, startFrame, endFrame, startOffset, endOffset)
Example #24
0
def exportPointDataUI():
    """
    Main UI for the exportPointData module
    """
    # Get current frame range
    startFrame = cmds.playbackOptions(q=True, min=True)
    endFrame = cmds.playbackOptions(q=True, max=True)

    # Window
    window = 'exportPointDataUI'
    if cmds.window(window, q=True, ex=True): cmds.deleteUI(window)
    window = cmds.window(window, t='Export Point Data', s=False)

    # Layout
    CL = cmds.columnLayout(adj=True)

    # UI Elements
    pathTBG = cmds.textFieldButtonGrp('exportPoint_pathTBG', label='Path', buttonLabel='...')
    camTBG = cmds.textFieldButtonGrp('exportPoint_camTBG', label='Camera (2D only)', buttonLabel='Select')
    rangeIFG = cmds.intFieldGrp('exportPoint_rangeIFG', nf=2, label='Frame Range', v1=startFrame, v2=endFrame)
    resIFG = cmds.intFieldGrp('exportPoint_resIFG', nf=2, label='Resolution', v1=2348, v2=1152)
    refIFG = cmds.intFieldGrp('exportPoint_refIFG', nf=1, label='Offset Base Frame', v1=startFrame)
    resOMG = cmds.optionMenuGrp('exportPoint_resOMG', label='Resolution Preset')
    export2DB = cmds.button('exportPoint_export2DB', label='Export 2D Point Data',
                          c='glTools.ui.exportPointData.export2DFromUI()')
    export2DOffsetB = cmds.button('exportPoint_export2DOffsetB', label='Export 2D Offset Data',
                                c='glTools.ui.exportPointData.export2DOffsetFromUI()')
    export3DB = cmds.button('exportPoint_export3DB', label='Export 3D Point Data',
                          c='glTools.ui.exportPointData.export3DFromUI()')
    export3DRotB = cmds.button('exportPoint_export3DRotB', label='Export 3D Rotate Data',
                             c='glTools.ui.exportPointData.export3DRotationFromUI()')
    closeB = cmds.button('exportPoint_closeB', label='Close', c='cmds.deleteUI("' + window + '")')

    # Resolution presets
    cmds.setParent(resOMG)
    cmds.menuItem(label='WIDE(full)')
    cmds.menuItem(label='WIDE(half)')
    cmds.menuItem(label='WIDE(quarter)')

    # UI Callbacks
    cmds.textFieldButtonGrp(pathTBG, e=True, bc='glTools.ui.utils.exportFolderBrowser("' + pathTBG + '")')
    cmds.textFieldButtonGrp(camTBG, e=True, bc='glTools.ui.utils.loadTypeSel("' + camTBG + '",selType="transform")')
    cmds.optionMenuGrp(resOMG, e=True, cc='glTools.tools.exportPointData.setResolution()')

    # Popup menu
    cmds.popupMenu(parent=camTBG)
    for cam in cmds.ls(type='camera'):
        if cmds.camera(cam, q=True, orthographic=True): continue
        camXform = cmds.listRelatives(cam, p=True, pa=True)[0]
        cmds.menuItem(l=camXform, c='cmds.textFieldButtonGrp("exportPoint_camTBG",e=True,text="' + camXform + '")')

    # Show Window
    cmds.window(window, e=True, w=435, h=275)
    cmds.showWindow(window)
def extendPoly(*args):
    """does the polyextension by grabbing the curve, offsetting it and then lofting. Then converts the nurbs surface to polys"""

    #make sure a curve is selected
    selection = cmds.ls(sl=True)
    if selection:
        sel = selection[0]
        shape = cmds.listRelatives(sel, s=True)[0]
        type = cmds.objectType(shape)
        name = cmds.textFieldGrp("name", q=True, tx=True)
        hisGrp = cmds.checkBox("history", q=True, v=True)
        hisPoly = cmds.checkBox("polyHistory", q=True, v=True)

        if type== "nurbsCurve":
            #offset the curb
            distance = cmds.floatFieldGrp("curbFFG", q=True, v1=True)
            # bump = cmds.checkBox("bumpCB", q=True, v=True)
            pos = cmds.checkBox("curbCB", q=True, v=True)
            if pos == 0:
                dist = distance * -1
            else:
                dist = distance
            U = cmds.intFieldGrp("UDivIFG", q=True, v1=True)
            V = cmds.intFieldGrp("VDivIFG", q=True, v1=True)

            origCrv = cmds.rename(sel, "%s_inner_CRV"%name)
            outCurve = cmds.offsetCurve(origCrv, d=dist, n="%s_outer_CRV"%name)
            midCurve = cmds.offsetCurve(origCrv, d=dist/2, n="%s_mid_CRV"%name)
            # if bump:
            #     cmds.xform(midCurve, ws=True, r=True, t=(0,5,0))

            cmds.select(cl=True)

            lofted = cmds.loft(origCrv, midCurve, outCurve)[0]
            loft = cmds.rename(lofted, "%s_lofted"%name)

            polygon = cmds.nurbsToPoly(loft, pt=1, ch=hisPoly, f=2, un=U, vn=V)[0]
            poly = cmds.rename(polygon, "%s_poly"%name)

            curbGrp = cmds.group(empty=True)
            grp = cmds.rename(curbGrp, "%s_History_GRP"%name)

            # cmds.rename(poly, "polyCurb")

            cmds.parent(loft, outCurve, midCurve, origCrv, grp)

            cmds.setAttr("%s.v"%grp, 0)
            if not hisGrp:
                cmds.delete(grp)

        else:
            cmds.warning("That's not a curve! You need to select a curve!")
    else:
        cmds.warning("You haven't selected anything!")
Example #26
0
	def enable_range ( self, arg ) :
		"""enable_range

		:param arg: Missing documentation of arg argument
		:return:
		"""
		setDefaultIntValue(self_prefix, 'job_animation', self.job_param, arg)
		cmds.intFieldGrp(
			'%s|f0|t0|tc0|fr1|fc1|job_range' % self.winMain,
			edit=True,
			enable=arg
		)
Example #27
0
def deleteAttribute(scrollListName):
    objects = cmds.textScrollList(scrollListName, q=True, si=True)
    print objects
    for object in objects:
        attrName = object+'.'+scrollListName
        # Unlock attribute, so it can be deleted
        cmds.setAttr(attrName, edit=True, lock=False)
        cmds.deleteAttr(object, at=scrollListName)
        # Remove reference from UI fields, this will affect
        cmds.textFieldGrp('animNameField', edit=True, text='None')
        cmds.intFieldGrp('animFrameField', edit=True, value1=0, value2=0)
    updateTextFields(scrollListName, mode='RefreshAll')
Example #28
0
def export2DOffsetFromUI():
    """
    export2DOffsetData from UI
    """
    # Get selection
    sel = cmds.ls(sl=True, fl=True)
    if not sel:
        print 'No points selected for export!!'
        return

    # Get UI data
    path = cmds.textFieldButtonGrp('exportPoint_pathTBG', q=True, text=True)
    cam = cmds.textFieldButtonGrp('exportPoint_camTBG', q=True, text=True)
    start = cmds.intFieldGrp('exportPoint_rangeIFG', q=True, v1=True)
    end = cmds.intFieldGrp('exportPoint_rangeIFG', q=True, v2=True)
    ref = cmds.intFieldGrp('exportPoint_refIFG', q=True, v1=True)
    xRes = cmds.intFieldGrp('exportPoint_resIFG', q=True, v1=True)
    yRes = cmds.intFieldGrp('exportPoint_resIFG', q=True, v2=True)

    # Check UI data
    if not cam or not cmds.objExists(cam):
        print('No valid camera specified!')
        return
    if start > end:
        print('Invalid range specified!')
        return
    if not path.endswith('/'): path += '/'

    # For each point
    for pt in sel:

        # Generate export file path
        sel_name = pt.split(':')[-1].replace('.', '_').replace('[', '_').replace(']', '')
        filepath = path + sel_name + '_2DOffset.txt'

        # Check path
        if os.path.isfile(filepath):
            chk = cmds.confirmDialog(t='Warning: File exists',
                                   message='File "' + filepath + '" already exist! Overwrite?', button=['Yes', 'No'],
                                   defaultButton='Yes', cancelButton='No', dismissString='No')
            if chk == 'No': continue

        # Isolate Select - ON
        setIsolateSelect(pt, 1)

        # Export data
        glTools.tools.exportPointData.export2DOffsetData(filepath, pt, cam, start, end, xRes, yRes, ref)

        # Isolate Select - OFF
        setIsolateSelect(pt, 0)
def lightingButton2(*args):
	lightingD="Renders show below average understanding of soft lighting.  The lighting does not direct the viewer's eye to the subject. No lighting style based on cinema reference."
	lightingF="Renders show unsatisfactory understanding of soft lighting.  A strong lack of appeal of lighting direction and complete lack of style based on cinema reference."
	lightingRow2=cmds.radioButtonGrp( "lightButGrp2", q=1, sl=1)
	if (lightingRow2 ==1):
		cmds.intFieldGrp( "lightIntField", e=1, value1=72)
		cmds.scrollField("lightTSList", e=1, cl=1)
		cmds.scrollField("lightTSList", e=1, insertText=lightingD)
		updateGradeTotal()
	else:
		cmds.intFieldGrp( "lightIntField", e=1, value1=69)
		cmds.scrollField("lightTSList", e=1, cl=1)
		cmds.scrollField("lightTSList", e=1, insertText=lightingF)
		updateGradeTotal()
def proButton2(*args):
	proD="Student did not name their files correctly, image is incorrect resolution. Student often had trouble problem solving without instructors help."
	proF="Student did not name their files correctly, image is incorrect resolution. Student had poor trouble shooting skills."
	proRow2=cmds.radioButtonGrp( "proButGrp2", q=1, sl=1)
	if (proRow2 ==1):
		cmds.intFieldGrp( "proIntField", e=1, value1=75)
		cmds.scrollField("proTSList", e=1, cl=1)
		cmds.scrollField("proTSList", e=1, insertText=proD)
		updateGradeTotal()
	else:
		cmds.intFieldGrp( "proIntField", e=1, value1=100)
		cmds.scrollField("proTSList", e=1, cl=1)
		cmds.scrollField("proTSList", e=1, insertText=proF)
		updateGradeTotal()
Example #31
0
def animRetargetPanel():
    maya.window(windowID, widthHeight=(
        430, 610), title='animRetargetPanel', s=True)
    layout = maya.columnLayout(w=430, h=610, rs=5)
    maya.columnLayout(h=5)
    maya.setParent('..')
    maya.text(l='animRetarget Tool', al='center',
              w=430, h=10, fn='boldLabelFont')
    srcDtnForm = maya.formLayout()
    # define UI for source
    srcLayout = maya.columnLayout(w=200, h=280, rs=5)
    maya.text(l='Source', al='center', w=200, h=20, fn='boldLabelFont')
    global srcBox
    srcBox = maya.textScrollList(w=200, h=200, sc=selection)
    maya.button(l='Add Source', w=200, h=20, c=partial(addItem, srcBox))
    maya.button(l='Remove Source', w=200, h=20, c=partial(removeItem, srcBox))
    maya.setParent('..')
    # define UI for destination
    dtnLayout = maya.columnLayout(w=200, h=280, rs=5)
    maya.text(l='Destination', al='center', w=200, h=20, fn='boldLabelFont')
    global dtnBox
    dtnBox = maya.textScrollList(w=200, h=200, ams=True, sc=selection)
    maya.button(l='Add Destination', w=200, h=20, c=partial(addItem, dtnBox))
    maya.button(
        l='Remove Destination', w=200, h=20, c=partial(removeItem, dtnBox))
    maya.setParent('..')
    maya.formLayout(srcDtnForm, e=True, ac=[dtnLayout, 'left', 10, srcLayout], af=[
                    (srcLayout, 'left', 10), (dtnLayout, 'right', 10)])
    maya.setParent('..')
    # Copy Options
    maya.separator(w=430, st='in')
    maya.columnLayout(rs=2)
    maya.text(l='Copy Keys Options', w=430, h=20, fn='boldLabelFont')
    global copyKeyOptions
    copyKeyOptions = maya.radioButtonGrp(numberOfRadioButtons=2, label='Time range:', labelArray2=[
                                         'All', 'Start/End'], sl=1, cc=onCkChanged)
    global timeStart
    timeStart = maya.floatFieldGrp(
        numberOfFields=1, label='Start time:', value1=0.000, en=False)
    global timeEnd
    timeEnd = maya.floatFieldGrp(
        numberOfFields=1, label='End time:', value1=10.000, en=False)
    maya.setParent('..')
    maya.separator(w=430, st='in')
    maya.columnLayout(rs=2)
    maya.text(l='Paste Keys Options', w=430, h=20, fn='boldLabelFont')
    maya.columnLayout(cat=['left',20])

    global timeRange
    timeRange=maya.radioButtonGrp(numberOfRadioButtons=2, label='Time range:', labelArray2=[
                                         'Current', 'Start/End'], sl=1, cc=onPkChanged)
    global pasteKeyOptions
    pasteKeyOptions = maya.radioButtonGrp(w=430,numberOfRadioButtons=4, l='Paste method:',labelArray4=[
                                         'merge','replace','scaleMerge','scaleReplace'], cw5=[75,65,65,100,100],sl=2)
    global pastetimeStart
    pastetimeStart = maya.floatFieldGrp(
        numberOfFields=1, label='Start time:', value1=0.000, en=False)
    global pastetimeEnd
    pastetimeEnd = maya.floatFieldGrp(
        numberOfFields=1, label='End time:', value1=10.000, en=False)

    global timeOffsetOptions
    timeOffsetOptions=maya.radioButtonGrp(numberOfRadioButtons=2, label='Offset type:', labelArray2=[
                                         'Same', 'Recursively'], sl=1)
    global timeOffsetMehod
    timeOffsetMehod=maya.radioButtonGrp(numberOfRadioButtons=2, label='Offset method:', labelArray2=[
                                         'Fixed', 'Random'], sl=1, cc=onOffsetMethodChanged)
    maya.setParent('..')
    maya.columnLayout(cat=['left', 80])
    global fixedtimeOffset
    fixedtimeOffset = maya.intFieldGrp(
        numberOfFields=1, label='Fixed Offset Amount:', value1=0.00)
    global RandomtimeOffset
    RandomtimeOffset = maya.intFieldGrp(
        numberOfFields=2, label='Random Offset Range:', value1=0.00,value2=0.00,en=False)
    maya.setParent('..')
    maya.separator(w=430,st='in')
    maya.columnLayout(h=5)
    maya.setParent('..')
    maya.columnLayout(cat=['left', 150],rs=5)
    maya.button(
        l='Remove Animation', al='center', w=130, h=30, c=btnRemove)

    maya.button(
        l='Retarget Animation', al='center', w=130, h=30, c=btnRetarget)

    maya.showWindow(windowID)
Example #32
0
def extendUI(*args):
    """UI for the script"""
    #UI
    if cmds.window("curbWin", exists=True):
        cmds.deleteUI("curbWin")

    cmds.window("curbWin", t="zbw_polyExtender", w=200, h=200)
    cmds.columnLayout("colLO")
    cmds.frameLayout("topFrame", l="Covert Edge", cll=True, bgc=(.2, .2, .2))
    cmds.text("Select poly edge to convert")
    cmds.button("convertBut",
                l="Convert!",
                w=200,
                h=30,
                bgc=(.8, .8, .6),
                c=convertEdge)
    cmds.separator(h=5)

    cmds.setParent("colLO")

    cmds.frameLayout("midFrame", l="Create Poly", cll=True, bgc=(.2, .2, .2))
    cmds.text("Select curve")
    cmds.separator(h=5)
    cmds.textFieldGrp("name",
                      l="Name",
                      w=200,
                      cw=[(1, 30), (2, 170)],
                      tx="newPoly")
    cmds.checkBox("curbCB", l="Positive Direction", v=True)
    # cmds.checkBox("bumpCB", l="Add vertical hump?", v=True)
    cmds.floatFieldGrp("curbFFG",
                       l="Curb Width",
                       cal=((1, "left"), (2, "left")),
                       cw=([1, 75], [2, 50]),
                       v1=10)
    cmds.intFieldGrp("UDivIFG",
                     l="Width Subdivisions",
                     cal=((1, "left"), (2, "left")),
                     cw=([1, 75], [2, 50]),
                     v1=1)
    cmds.intFieldGrp("VDivIFG",
                     l="Length Subdivisions",
                     cal=((1, "left"), (2, "left")),
                     cw=([1, 75], [2, 50]),
                     v1=1)
    cmds.checkBox("polyHistory", l="Keep history on final poly?", v=False)
    cmds.checkBox("history",
                  l="Keep history objects?",
                  v=True,
                  cc=enableHistory)

    cmds.separator(h=5)
    cmds.button("curbBut",
                l="Create Curb",
                h=40,
                w=200,
                bgc=(.6, .8, .6),
                c=extendPoly)

    cmds.showWindow("curbWin")
    cmds.window("curbWin", e=True, h=150, w=200)
Example #33
0
 def customUI(self):
     self.widgets["ribbonNameTFG"] = cmds.textFieldGrp(l="Ribbon Rig Name",
                                                       cal=[(1, "left"),
                                                            (2, "left")],
                                                       cw=[(1, 100),
                                                           (2, 200)],
                                                       tx="ribbon")
     cmds.separator(h=10, style="single")
     self.widgets["jointsIFG"] = cmds.intFieldGrp(
         l="Number of Jnts (3 min)",
         cal=([1, "left"]),
         cw=([1, 125], [2, 100]),
         v1=5)
     self.widgets["axis"] = cmds.radioButtonGrp(l="Ribbon Ctrl Axis",
                                                nrb=3,
                                                l1="x",
                                                l2="y",
                                                l3="z",
                                                cal=([1, "left"]),
                                                cw=([1, 125], [2,
                                                               50], [3,
                                                                     50]),
                                                sl=2,
                                                en=True)
     self.widgets["fkSetupCB"] = cmds.checkBox(l="Setup FK Controls", v=1)
     self.widgets["heightFFG"] = cmds.floatFieldGrp(l="Ribbon Height",
                                                    cal=[(1, "left"),
                                                         (2, "left")],
                                                    cw=[(1, 125), (2, 100)],
                                                    v1=10.0)
     self.widgets["ratioFFG"] = cmds.floatFieldGrp(l="Heigth/width Ratio",
                                                   cal=[(1, "left"),
                                                        (2, "left")],
                                                   cw=[(1, 125), (2, 100)],
                                                   v1=5)
     #create a slider for where we want the middle piece of the ribbon
     self.widgets["centerPosFSG"] = cmds.floatSliderGrp(
         l="Center Ctrl Position",
         f=True,
         cal=[(1, "left"), (2, "left"), (3, "left")],
         cw=[(1, 125), (2, 50), (3, 200)],
         min=0,
         max=1,
         fmn=0,
         fmx=1,
         v=0.5,
         pre=3)
     #option for making (or not) control structure
     #-------option to use my own surface?
     self.widgets["existingGeoCB"] = cmds.checkBox(
         l="Use existing nurbs curve", v=0, cc=self.geoEnable)
     #this will reveal text field grp w button
     #checking and unchecking will activate options (and deactivate)
     self.widgets["geoTFBG"] = cmds.textFieldButtonGrp(l="Select Geometry",
                                                       bl="<<<",
                                                       en=False,
                                                       cal=[(1, "left"),
                                                            (2, "left"),
                                                            (3, "left")],
                                                       cw=[(1, 100),
                                                           (2, 250),
                                                           (3, 50)],
                                                       bc=self.getGeo)
     self.widgets["directionRBG"] = cmds.radioButtonGrp(l="Along U or V?",
                                                        nrb=2,
                                                        l1="u",
                                                        l2="v",
                                                        cal=[(1, "left"),
                                                             (2, "left")],
                                                        cw=[(1, 100),
                                                            (2, 50),
                                                            (3, 50)],
                                                        sl=2,
                                                        en=False)
Example #34
0
def GetIntGrpValue(intGrpName):
    ''' Returns the value of an int group '''
    value = cmds.intFieldGrp(intGrpName, q=True, v=True)
    return value
Example #35
0
    def apply_call_back(self, pPolyNumberField,
                        pTreeDepthField,
                        pTreeSegmentLength,
                        pLengthDecrease,
                        pRadius,
                        pRadDecrease,
                        pBranches,
                        pBranches_a,
                        pFoliageSze,
                        pFoliageRes,
                        pSeed,
                        pFoliageC,
                        pTreeC,
                        pFoliageN,
                        pFoliageSpread,
                        pFirstSegmentL,
                        pTreeType,
                        pBranchChance,
                        pAngleChance,
                        pTurnChance,
                        pTurnAmount,
                        pAngleAmount,
                        *pArgs
                        ):
        polycount = cmds.intSliderGrp(pPolyNumberField, query=True, value=True)
        tree_depth = cmds.intSliderGrp(pTreeDepthField, query=True, value=True)
        segment_length = cmds.floatSliderGrp(pTreeSegmentLength, query=True, value=True)
        length_dec = cmds.floatSliderGrp(pLengthDecrease, query=True, value=True)
        radius = cmds.floatSliderGrp(pRadius, query=True, value=True)
        radius_d = cmds.floatSliderGrp(pRadDecrease, query=True, value=True)
        branches = cmds.intSliderGrp(pBranches, query=True, value=True)
        branches_a = cmds.floatSliderGrp(pBranches_a, query=True, value=True)
        foliage_s = cmds.floatSliderGrp(pFoliageSze, query=True, value=True)
        foliage_r = cmds.intSliderGrp(pFoliageRes, query=True, value=True)
        p_seed = cmds.intFieldGrp(pSeed, query=True, value=True)
        treeCor = cmds.colorSliderGrp(pTreeC, query=True, rgbValue=True)
        foliageCor = cmds.colorSliderGrp(pFoliageC, query=True, rgbValue=True)
        foliage_n = cmds.intSliderGrp(pFoliageN, query=True, value=True)
        foliage_spread = cmds.floatSliderGrp(pFoliageSpread, query=True, value=True)
        first_segment_l = cmds.floatSliderGrp(pFirstSegmentL, query=True, value=True)
        tree_type = cmds.radioButtonGrp(pTreeType, query=True, select=True)
        branch_chance = cmds.floatSliderGrp(pBranchChance, query=True, value=True)
        angle_chance = cmds.floatSliderGrp(pAngleChance, query=True, value=True)
        turn_chance = cmds.floatSliderGrp(pTurnChance, query=True, value=True)
        turn_amount = cmds.floatSliderGrp(pTurnAmount, query=True, value=True)
        angle_amount = cmds.floatSliderGrp(pAngleAmount, query=True, value=True)

        cmds.setAttr(treeTrunkShader + '.color', treeCor[0], treeCor[1], treeCor[2], type='double3')
        # cmds.connectAttr( treeTrunkShader+'.outColor', treeTrunkShaderSG+'.surfaceShader', f=1)
        cmds.setAttr(foliageShader + '.color', foliageCor[0], foliageCor[1], foliageCor[2], type='double3')
        # cmds.connectAttr( foliageShader+'.outColor', foliageShaderSG+'.surfaceShader', force=True)

        random.seed(p_seed[0])
        self.delete_previous()
        if tree_type == 1:
            self.create(tree_depth,
                        segment_length, length_dec, radius, radius_d,
                        [0.0, 1.0, 0.0],
                        [0.0, 0.0, 0.0],
                        0.0, 0.0,
                        polycount, branches, branches_a,
                        foliage_s, foliage_r, 0.0, True, foliage_n, foliage_spread, first_segment_l,
                        branch_chance, angle_chance, turn_chance, turn_amount, angle_amount
                        )
        if tree_type == 2:
            self.createPine(tree_depth,
                            segment_length, length_dec, radius, radius_d,
                            [0.0, 1.0, 0.0],
                            [0.0, 0.0, 0.0],
                            0.0, 0.0,
                            polycount, branches, branches_a,
                            foliage_s, foliage_r, 0.0, True, foliage_n, foliage_spread, first_segment_l, 1,
                            branch_chance,
                            angle_chance, turn_chance, turn_amount, angle_amount
                            )

        self.merge_tree()
Example #36
0
    y = 0
    z = 0
    cubeEdge = round(N**(1. / 3))
    if cubeEdge < 1: cubeEdge = 1
    for i in clonedItems:
        cmds.scale(1, 1, 1, i)
        cmds.move(0, 0, 0, i)

    for i in clonedItems:
        cmds.move(0 + x, 0 + y, 0 + z, i)
        r = random.random()
        cmds.scale(r, r, r, i)

        x = x + 1
        if x > cubeEdge - 1:
            x = 0
            y = y + 1
            if y > cubeEdge - 1:
                y = 0
                z = z + 1


window = cmds.window("UI7", s=False)
cmds.columnLayout()
Number = cmds.intFieldGrp(numberOfFields=1,
                          label='Number of clones',
                          extraLabel='N',
                          value1=0)

ScriptButton = cmds.button(label='Go !', c=execute)
cmds.showWindow(window)
Example #37
0
import maya.cmds as mc
if mc.window("MyWindow", q=True, ex=True):
    mc.deleteUI("MyWindow")
mc.window("MyWindow", t="Example Window", width=598, height=555)
mc.columnLayout()
mc.text(l="Text element")
mc.intFieldGrp(l="intField")
mc.button(l="Button")
mc.text(l="etc.")
mc.showWindow("MyWindow")
'''
if ( `window -exists MyWindow` ) {
 deleteUI MyWindow;
}
window -t "Example Window" -w 598 -h 555 MyWindow;
 
columnLayout;
text -l "Text element";
intFieldGrp -l "intField";
button -l "Button";
text -l "etc";
 
showWindow MyWindow;
'''
Example #38
0
    def loadInfo():

        if not os.path.exists(Win_Global.infoPath): return None
        f = open(Win_Global.infoPath, 'r')
        data = json.load(f)
        f.close()

        if type(data) != list: return None
        if len(data) != 8: return None

        cmds.floatFieldGrp(Win_Global.controllerSize, e=1, v1=data[0])
        cmds.intFieldGrp(Win_Global.numBodyJoints, e=1, v1=data[1])
        cmds.intFieldGrp(Win_Global.numArmUpperJnts, e=1, v1=data[2])
        cmds.intFieldGrp(Win_Global.numArmLowerJnts, e=1, v1=data[3])
        cmds.intFieldGrp(Win_Global.numLegUpperJnts, e=1, v1=data[4])
        cmds.intFieldGrp(Win_Global.numLegLowerJnts, e=1, v1=data[5])
        cmds.intFieldGrp(Win_Global.headType, e=1, v1=data[6])
        cmds.intFieldGrp(Win_Global.bodyType, e=1, v1=data[7])
Example #39
0
def exportPointDataUI():
    '''
	Main UI for the exportPointData module
	'''
    # Get current frame range
    startFrame = mc.playbackOptions(q=True, min=True)
    endFrame = mc.playbackOptions(q=True, max=True)

    # Window
    window = 'exportPointDataUI'
    if mc.window(window, q=True, ex=True): mc.deleteUI(window)
    window = mc.window(window, t='Export Point Data', s=False)

    # Layout
    CL = mc.columnLayout(adj=True)

    # UI Elements
    pathTBG = mc.textFieldButtonGrp('exportPoint_pathTBG',
                                    label='Path',
                                    buttonLabel='...')
    camTBG = mc.textFieldButtonGrp('exportPoint_camTBG',
                                   label='Camera (2D only)',
                                   buttonLabel='Select')
    rangeIFG = mc.intFieldGrp('exportPoint_rangeIFG',
                              nf=2,
                              label='Frame Range',
                              v1=startFrame,
                              v2=endFrame)
    resIFG = mc.intFieldGrp('exportPoint_resIFG',
                            nf=2,
                            label='Resolution',
                            v1=2348,
                            v2=1152)
    refIFG = mc.intFieldGrp('exportPoint_refIFG',
                            nf=1,
                            label='Offset Base Frame',
                            v1=startFrame)
    resOMG = mc.optionMenuGrp('exportPoint_resOMG', label='Resolution Preset')
    export2DB = mc.button('exportPoint_export2DB',
                          label='Export 2D Point Data',
                          c='glTools.ui.exportPointData.export2DFromUI()')
    export2DOffsetB = mc.button(
        'exportPoint_export2DOffsetB',
        label='Export 2D Offset Data',
        c='glTools.ui.exportPointData.export2DOffsetFromUI()')
    export3DB = mc.button('exportPoint_export3DB',
                          label='Export 3D Point Data',
                          c='glTools.ui.exportPointData.export3DFromUI()')
    export3DRotB = mc.button(
        'exportPoint_export3DRotB',
        label='Export 3D Rotate Data',
        c='glTools.ui.exportPointData.export3DRotationFromUI()')
    closeB = mc.button('exportPoint_closeB',
                       label='Close',
                       c='mc.deleteUI("' + window + '")')

    # Resolution presets
    mc.setParent(resOMG)
    mc.menuItem(label='WIDE(full)')
    mc.menuItem(label='WIDE(half)')
    mc.menuItem(label='WIDE(quarter)')

    # UI Callbacks
    mc.textFieldButtonGrp(pathTBG,
                          e=True,
                          bc='glTools.ui.utils.exportFolderBrowser("' +
                          pathTBG + '")')
    mc.textFieldButtonGrp(camTBG,
                          e=True,
                          bc='glTools.ui.utils.loadTypeSel("' + camTBG +
                          '",selType="transform")')
    mc.optionMenuGrp(resOMG,
                     e=True,
                     cc='glTools.tools.exportPointData.setResolution()')

    # Popup menu
    mc.popupMenu(parent=camTBG)
    for cam in mc.ls(type='camera'):
        if mc.camera(cam, q=True, orthographic=True): continue
        camXform = mc.listRelatives(cam, p=True, pa=True)[0]
        mc.menuItem(
            l=camXform,
            c='mc.textFieldButtonGrp("exportPoint_camTBG",e=True,text="' +
            camXform + '")')

    # Show Window
    mc.window(window, e=True, w=435, h=275)
    mc.showWindow(window)
Example #40
0
def snowFactoryWindow():
    #windowsName = "snowFactoryUI"
    if mc.window('snowFactoryUI', exists=True):
        mc.deleteUI('snowFactoryUI')
    window = mc.window('snowFactoryUI',
                       title='Snow Factory',
                       widthHeight=(400, 600),
                       sizeable=0,
                       minimizeButton=0,
                       maximizeButton=0)
    form = mc.formLayout()
    #imagePath = (mc.internalVar(upd=True) + "icons/SnowFactoryLogo.jpg")
    mc.image('logo',
             width=400,
             height=155,
             image=path + "/script/model/snowFactory/SnowFactoryLogo.jpg")
    mc.text('particleSetupText', label='Snow Setup:', font='boldLabelFont')
    mc.button('particlesSetupButton',
              label='Set',
              width=80,
              height=30,
              command=snowFactory)
    mc.text('meshSettingsText', label='Mesh Settings:', font='boldLabelFont')
    mc.floatSliderGrp('thresholdSlider',
                      label='Threshold',
                      field=True,
                      columnWidth3=(120, 40, 150),
                      minValue=0,
                      maxValue=2,
                      fieldMinValue=0,
                      fieldMaxValue=10,
                      value=0.1,
                      dragCommand=threshold,
                      changeCommand=threshold)
    mc.floatSliderGrp('blobbyRadiusScaleSlider',
                      label='Blobby Radius',
                      field=True,
                      columnWidth3=(120, 40, 150),
                      minValue=0,
                      maxValue=10,
                      fieldMinValue=0,
                      fieldMaxValue=10,
                      value=1.8,
                      dragCommand=blobbyRadiusScale,
                      changeCommand=blobbyRadiusScale)
    mc.floatSliderGrp('MotionStreakSlider',
                      label='Motion Streak',
                      field=True,
                      columnWidth3=(120, 40, 150),
                      minValue=0,
                      maxValue=10,
                      fieldMinValue=0,
                      fieldMaxValue=10,
                      value=0,
                      dragCommand=MotionStreak,
                      changeCommand=MotionStreak)
    mc.floatSliderGrp('MeshTriangleSizeSlider',
                      label='Triangle Size',
                      field=True,
                      columnWidth3=(120, 40, 150),
                      minValue=0,
                      maxValue=10,
                      fieldMinValue=0,
                      fieldMaxValue=10,
                      value=0.2,
                      dragCommand=MeshTriangleSize,
                      changeCommand=MeshTriangleSize)
    mc.intFieldGrp('maxTriangleResolutionField',
                   numberOfFields=1,
                   label='Triangle Resolution',
                   columnWidth2=(120, 40),
                   value1=100,
                   changeCommand=MaxTriangleResolution)
    methods = mc.optionMenuGrp('meshMethodMenu',
                               label='Method',
                               columnWidth2=(40, 10),
                               changeCommand=MeshMethod)
    mc.menuItem(label='Triangle Mesh')
    mc.menuItem(label='Tetrahedra')
    mc.menuItem(label='Acute Tetrahedra')
    mc.menuItem(label='Quad Mesh')
    mc.optionMenuGrp('meshMethodMenu', e=True, sl=4)
    mc.floatSliderGrp('meshSmoothingItrSlider',
                      label='Smoothing Iterations',
                      field=True,
                      columnWidth3=(120, 40, 150),
                      minValue=0,
                      maxValue=10,
                      fieldMinValue=0,
                      fieldMaxValue=10,
                      value=10,
                      dragCommand=MeshSmoothingItr,
                      changeCommand=MeshSmoothingItr)
    mc.text('cleanupText', label='Cleanup Setup:', font='boldLabelFont')
    mc.button('extractButton',
              label='Extract',
              width=80,
              height=30,
              command=snowExtract)
    mc.text('ruchitText',
            label='By:- Ruchit Bhatt(www.vimeo.com/ruchitbhatt)',
            font='boldLabelFont')
    mc.formLayout(
        form,
        edit=True,
        attachPosition=[('logo', 'top', 0, 0), ('logo', 'left', 0, 0),
                        ('particleSetupText', 'left', 10, 0),
                        ('particlesSetupButton', 'left', 160, 0),
                        ('meshSettingsText', 'left', 10, 0),
                        ('thresholdSlider', 'left', 45, 0),
                        ('blobbyRadiusScaleSlider', 'left', 45, 0),
                        ('MotionStreakSlider', 'left', 45, 0),
                        ('MeshTriangleSizeSlider', 'left', 45, 0),
                        ('maxTriangleResolutionField', 'left', 45, 0),
                        ('meshMethodMenu', 'left', 125, 0),
                        ('meshSmoothingItrSlider', 'left', 45, 0),
                        ('cleanupText', 'left', 10, 0),
                        ('extractButton', 'left', 160, 0),
                        ('ruchitText', 'left', 10, 0)],
        attachControl=[
            ('particleSetupText', 'top', 10, 'logo'),
            ('particlesSetupButton', 'top', 10, 'particleSetupText'),
            ('particlesSetupButton', 'top', 10, 'particleSetupText'),
            ('meshSettingsText', 'top', 15, 'particlesSetupButton'),
            ('thresholdSlider', 'top', 10, 'meshSettingsText'),
            ('blobbyRadiusScaleSlider', 'top', 10, 'thresholdSlider'),
            ('MotionStreakSlider', 'top', 10, 'blobbyRadiusScaleSlider'),
            ('MeshTriangleSizeSlider', 'top', 10, 'MotionStreakSlider'),
            ('maxTriangleResolutionField', 'top', 10,
             'MeshTriangleSizeSlider'),
            ('meshMethodMenu', 'top', 10, 'maxTriangleResolutionField'),
            ('meshSmoothingItrSlider', 'top', 10, 'meshMethodMenu'),
            ('cleanupText', 'top', 15, 'meshSmoothingItrSlider'),
            ('extractButton', 'top', 10, 'cleanupText'),
            ('ruchitText', 'top', 25, 'extractButton')
        ])
    mc.showWindow('snowFactoryUI')
Example #41
0
def cleanUI(*args):
    """the UI for the clean/tangent functions"""

    if cmds.window("cleanWin", exists=True):
        cmds.deleteUI("cleanWin")

    widgets["win"] = cmds.window("cleanWin", t="zbw_cleanKeys", w=300, h=220)
    widgets["mainCLO"] = cmds.columnLayout()
    # widgets["tabLO"] = cmds.tabLayout()

    widgets["cleanCLO"] = cmds.columnLayout("Clean Keys")
    # some explanation
    cmds.text("Options for which keys to clean/delete:")
    cmds.separator(h=10)
    # radio button group for all selected or for hierarchy under selected
    widgets["hierarchyRBG"] = cmds.radioButtonGrp(
        nrb=2,
        l1="Selected Objs Only",
        l2="Hierarchy Under Selected",
        sl=2,
        cw=[(1, 120), (2, 75), (3, 75)],
        cc=enableCurve)
    # radioButtons for time (timeslider, all anim, range)
    widgets["timeRBG"] = cmds.radioButtonGrp(nrb=3,
                                             l1="Timeslider",
                                             l2="All Anim",
                                             l3="Frame Range",
                                             sl=2,
                                             cw=[(1, 100), (2, 75), (3, 75)],
                                             cc=partial(
                                                 enableFR, "timeRBG",
                                                 "frameRangeIFG", "keepCBG"))
    # int field group for frame range
    widgets["frameRangeIFG"] = 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)])

    # radio button group for nurbs curves only or for all transforms
    widgets["curvesRBG"] = cmds.radioButtonGrp(
        nrb=2,
        l1="Curves/Volume Primatives Only",
        l2="All DAG",
        sl=1,
        cw=[(1, 190), (2, 110)])

    cmds.separator(h=10, style="single")

    # area to create/keep buffer curves
    widgets["bufCBG"] = cmds.checkBoxGrp(ncb=2,
                                         l1="Buffer Original Curve",
                                         l2="Overwrite Existing Buffer",
                                         v1=1,
                                         v2=0,
                                         cw=([1, 140], [2, 50], [3,
                                                                 100], [4,
                                                                        50]),
                                         cal=([1, "left"], [2, "left"],
                                              [3, "left"], [4, "left"]))

    cmds.separator(h=10, style="single")
    # check box for singlets and couplets
    cmds.text("Singletons have only one key. Couplets have only 2 keys")
    widgets["keepCBG"] = cmds.checkBoxGrp(ncb=2,
                                          l1="Keep Singletons",
                                          l2="Keep Identical Couplets",
                                          v1=0,
                                          v2=0)

    cmds.separator(h=10)
    widgets["buttonRCLO"] = cmds.rowColumnLayout(w=300,
                                                 nc=2,
                                                 cw=[(1, 200), (2, 100)])
    widgets["cleanBut"] = cmds.button(l="Clean Animation Curves!",
                                      w=200,
                                      h=40,
                                      bgc=(.6, .8, .6),
                                      c=clean)
    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=220)
Example #42
0
def clean(*args):
    """this cleans the keyframes based on the settings in clean tab"""

    # get info from options in UI
    hier = cmds.radioButtonGrp(widgets["hierarchyRBG"], q=True, sl=True)
    timeOption = cmds.radioButtonGrp(widgets["timeRBG"], q=True, sl=True)
    singles = cmds.checkBoxGrp(widgets["keepCBG"], q=True, v1=True)
    couplets = cmds.checkBoxGrp(widgets["keepCBG"], q=True, v2=True)
    curves = cmds.radioButtonGrp(widgets["curvesRBG"], q=True, sl=True)
    startF = 0
    endF = 0
    tolerance = 0.0001
    # checking buffer settings
    buffer = cmds.checkBoxGrp(widgets["bufCBG"], q=True, v1=True)
    bufOverwrite = cmds.checkBoxGrp(widgets["bufCBG"], q=True, v2=True)

    # get the selection based on the criteria above
    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)

                    dagList.append(obj)

                for this in dagList:
                    sel.append(this)

        elif hier == 1:
            for obj in selection:
                sel.append(obj)
                # print "%s is selected"%obj

    else:
        cmds.warning("You haven't selected any transform nodes!")

    if timeOption == 1:
        # get timeslider range start
        startF = cmds.playbackOptions(query=True, min=True)
        endF = cmds.playbackOptions(query=True, max=True)
    elif timeOption == 3:
        # get frame range from int field
        startF = cmds.intFieldGrp(widgets["frameRangeIFG"], q=True, v1=True)
        endF = cmds.intFieldGrp(widgets["frameRangeIFG"], q=True, v2=True)

    # print "The frame range is %s to %s"%(startF, endF)

    # print "this will clean keys for: %s"%sel
    # loop through objects
    for object in sel:
        # create buffer curve
        if buffer:
            cmds.bufferCurve(object, ov=bufOverwrite)

        keyedAttr = []
        # find which attr have keys on them
        keyedAttrRaw = cmds.keyframe(object, q=True, name=True)
        # now fix the "object_" part to "object."
        if keyedAttrRaw:
            for oldAttr in keyedAttrRaw:
                # strip full path to object down to just obj, then use that to parse the attr name
                onlyObject = object.rpartition("|")[2]
                newAttr = oldAttr.partition("%s_" % onlyObject)[2]
                # print "stripped attr = %s, the object I'm stripping is %s"%(newAttr, onlyObject)
                keyedAttr.append(newAttr)
                # print "object: %s    attr:%s"%(object, newAttr)
            # loop through attrs with keys
            for attr in keyedAttr:
                for a in range(2):
                    keyList = []
                    # time range stuff, if using all anim, don't use frame range. Otherwise use startF, endF
                    if timeOption == 2:
                        keyList = cmds.keyframe(object, query=True, at=attr)
                    else:
                        keyList = cmds.keyframe(object,
                                                query=True,
                                                at=attr,
                                                time=(startF, endF))
                    # if there are keys, start the looping to check to delete them
                    if (keyList):
                        keySize = len(keyList)

                        if keySize < 3:
                            if keySize < 2:
                                # currentVal = cmds.getAttr((object+"."+attr), time=keyList[0])
                                if not singles:
                                    if (timeOption != 3):
                                        # get the value
                                        val = cmds.getAttr("%s.%s" %
                                                           (object, attr))
                                        # cut the key
                                        if timeOption == 1:
                                            cmds.cutKey(object,
                                                        at=attr,
                                                        cl=True,
                                                        t=(startF, endF))
                                            # set the values (to make sure it doens't drop it to zero)
                                            cmds.setAttr(
                                                "%s.%s" % (object, attr), val)
                                        else:
                                            cmds.cutKey(object,
                                                        at=attr,
                                                        cl=True)
                                            # set the values (to make sure it doens't drop it to zero)
                                            cmds.setAttr(
                                                "%s.%s" % (object, attr), val)
                            else:
                                # check for keep start end options
                                if not couplets:
                                    if (timeOption != 3):
                                        firstKey = keyList[0]
                                        secondKey = keyList[1]
                                        firstVal = cmds.keyframe(
                                            object,
                                            at=attr,
                                            query=True,
                                            time=(firstKey, firstKey),
                                            eval=True)
                                        secondVal = cmds.keyframe(
                                            object,
                                            at=attr,
                                            query=True,
                                            time=(secondKey, secondKey),
                                            eval=True)
                                        # add a check in here for keep first keep last
                                        if (abs(firstVal[0] - secondVal[0]) <
                                                tolerance):
                                            if timeOption == 1:
                                                cmds.cutKey(object,
                                                            at=attr,
                                                            cl=True,
                                                            t=(startF, endF))
                                                cmds.setAttr(
                                                    "%s.%s" % (object, attr),
                                                    firstVal[0])
                                            else:
                                                cmds.cutKey(object,
                                                            at=attr,
                                                            cl=True)
                                                cmds.setAttr(
                                                    "%s.%s" % (object, attr),
                                                    firstVal[0])
                        else:
                            # start with second key and compare until second to last
                            # USE DIFFERENCE VALUE
                            for i in range(1, keySize - 1):

                                thisKey = keyList[i]
                                prevKey = keyList[i - 1]
                                nextKey = keyList[i + 1]
                                thisVal = cmds.keyframe(object,
                                                        at=attr,
                                                        query=True,
                                                        time=(thisKey,
                                                              thisKey),
                                                        eval=True)
                                prevVal = cmds.keyframe(object,
                                                        at=attr,
                                                        query=True,
                                                        time=(prevKey,
                                                              prevKey),
                                                        eval=True)
                                nextVal = cmds.keyframe(object,
                                                        at=attr,
                                                        query=True,
                                                        time=(nextKey,
                                                              nextKey),
                                                        eval=True)
                                # accounting for floating point errors
                                prevDiff = abs(thisVal[0] - prevVal[0])
                                nextDiff = abs(thisVal[0] - nextVal[0])
                                if (prevDiff < tolerance) and (nextDiff <
                                                               tolerance):
                                    cmds.cutKey(object,
                                                at=attr,
                                                time=(thisKey, thisKey),
                                                cl=True)
                    else:
                        # print "%s had no keys on %s"%(object, attr)
                        pass
Example #43
0
    def __init__(self):

        filePath = cmds.file('voxelize.png', q=True, loc=True)

        self.mainWindow = cmds.window(title='Mesh Voxelizer',
                                      width=300,
                                      height=430,
                                      sizeable=False,
                                      menuBar=True)
        self.windowForm = cmds.formLayout(numberOfDivisions=100)
        self.helpMenu = cmds.menu(l='Help', helpMenu=True, p=self.mainWindow)
        self.helpMenuItem = cmds.menuItem(l='Voxelizer Help', c=self.printHelp)
        self.aboutMenuItem = cmds.menuItem(l='About Voxelizer',
                                           c=self.printAbout)
        self.windowImg = cmds.image(h=125,
                                    w=280,
                                    i=filePath,
                                    p=self.windowForm)
        self.meshInputTxt = cmds.text(l='Mesh to Voxelize: ',
                                      width=100,
                                      height=25,
                                      p=self.windowForm)
        self.meshInput = cmds.textField(w=95, h=25, p=self.windowForm)
        self.meshInputButton = cmds.button(label='Load',
                                           width=40,
                                           height=25,
                                           command=self.loadSelected,
                                           p=self.windowForm)
        self.voxelResTxt = cmds.text(l='Voxel Resolution: ',
                                     width=100,
                                     height=25,
                                     p=self.windowForm)
        self.voxelResSlider = cmds.intSliderGrp(field=True,
                                                minValue=10,
                                                maxValue=50,
                                                value=10,
                                                p=self.windowForm)
        self.animatedTxt = cmds.text(l='Animated: ',
                                     width=70,
                                     height=25,
                                     p=self.windowForm)
        self.animatedCheck = cmds.checkBox(l='On', width=50, height=25)
        self.meshVoxelButton = cmds.button(label='Voxelize',
                                           width=100,
                                           height=25,
                                           command=self.toVoxel,
                                           p=self.windowForm)
        self.renderText = cmds.text(l='Render Options:',
                                    width=100,
                                    height=25,
                                    p=self.windowForm)
        self.framesText = cmds.text(l='Frames: ',
                                    width=60,
                                    height=25,
                                    p=self.windowForm)
        self.renderFrames = cmds.intFieldGrp(nf=2,
                                             w=200,
                                             h=25,
                                             p=self.windowForm)
        self.renderButton = cmds.button(label='Render',
                                        width=100,
                                        height=25,
                                        command=self.renderScene,
                                        p=self.windowForm)
        self.cameraInputTxt = cmds.text(l='Camera: ',
                                        width=100,
                                        height=25,
                                        p=self.windowForm)
        self.cameraInput = cmds.textField(w=70,
                                          h=25,
                                          tx='persp',
                                          p=self.windowForm)
        self.cameraInputButton1 = cmds.button(label='Load',
                                              width=40,
                                              height=25,
                                              command=self.loadCamera,
                                              p=self.windowForm)
        self.cameraInputButton2 = cmds.button(label='Default',
                                              width=50,
                                              height=25,
                                              command=self.defaultCamera,
                                              p=self.windowForm)

        cmds.formLayout(self.windowForm,
                        edit=True,
                        attachForm=[(self.windowImg, 'top', 5),
                                    (self.windowImg, 'left', 10),
                                    (self.meshInputTxt, 'top', 150),
                                    (self.meshInputTxt, 'left', 25),
                                    (self.meshInput, 'top', 150),
                                    (self.meshInput, 'left', 140),
                                    (self.meshInputButton, 'top', 150),
                                    (self.meshInputButton, 'left', 235),
                                    (self.voxelResTxt, 'top', 180),
                                    (self.voxelResTxt, 'left', 25),
                                    (self.voxelResSlider, 'top', 200),
                                    (self.voxelResSlider, 'left', 30),
                                    (self.animatedTxt, 'top', 230),
                                    (self.animatedTxt, 'left', 25),
                                    (self.animatedCheck, 'top', 230),
                                    (self.animatedCheck, 'left', 180),
                                    (self.renderText, 'top', 260),
                                    (self.renderText, 'left', 25),
                                    (self.framesText, 'top', 290),
                                    (self.framesText, 'left', 25),
                                    (self.renderFrames, 'top', 290),
                                    (self.renderFrames, 'left', 110),
                                    (self.cameraInputTxt, 'top', 320),
                                    (self.cameraInputTxt, 'left', 5),
                                    (self.cameraInput, 'top', 320),
                                    (self.cameraInput, 'left', 110),
                                    (self.cameraInputButton1, 'top', 320),
                                    (self.cameraInputButton1, 'left', 185),
                                    (self.cameraInputButton2, 'top', 320),
                                    (self.cameraInputButton2, 'left', 225),
                                    (self.meshVoxelButton, 'top', 370),
                                    (self.meshVoxelButton, 'left', 30),
                                    (self.renderButton, 'top', 370),
                                    (self.renderButton, 'left', 175)])
        cmds.showWindow(self.mainWindow)
Example #44
0
     pmc='if cmds.optionMenuGrp("objToI_omG0",q=1,sl=1) ==1:cmds.menuItem("objToI_mi0",e=1,l="Load Selected Curve")\nelse:cmds.menuItem("objToI_mi0",e=1,l="Load Selected Object")') 
def loadSelect():return cmds.ls(sl=1,tr=1)[0]
cmds.menuItem("objToI_mi0", l='Load Selected Object', c='if cmds.optionMenuGrp("objToI_omG0",q=1,sl=1)==1:cmds.textField("objToI_tf0",e=1,tx=txQ())\nelse:cmds.textField("objToI_tf0",e=1,tx=loadSelect())')
cmds.optionMenuGrp("objToI_omG1", label=' World Up Type : ', cw=[(1, 90),(2,50)], cal=(1,'right'),
     cc='if cmds.optionMenuGrp("objToI_omG1",q=1,sl=1) != 1:cmds.textField("objToI_tf1",e=1,en=1)\nelse:cmds.textField("objToI_tf1",e=1,en=0)')
cmds.menuItem( label='Vector' )
cmds.menuItem( label='Object Up', c='cmds.textField("objToI_tf0", e=1,en=1)')
cmds.menuItem( label='Object Rotation Up' )
cmds.textField("objToI_tf1",tx="World Up Object", h=23,en=0)  
cmds.popupMenu( button=3 , #---------pop up
     pmc='cmds.menuItem("objToI_mi1",e=1,l="Load Selected Object")') 
cmds.menuItem("objToI_mi1", l='Load Selected Object', c='cmds.textField("objToI_tf1",e=1,tx=loadSelect())' )
cmds.setParent("objToI_fl")

cmds.rowColumnLayout("objToI_rcl1", nc =1, cw = (1,340))
cmds.intFieldGrp("objToI_ifG0", nf=3, l='Aim : ', v1 = 1,v2 = 0, v3 = 0,cal=[(1,'right')],cw=[(1,70)])
cmds.intFieldGrp("objToI_ifG1", nf=3, l='Up : ', v1 = 0,v2 = 1, v3 = 0,cal=[(1,'right')],cw=[(1,70)])
cmds.intFieldGrp("objToI_ifG2", nf=3, l='World Up : ', v1 = 0,v2 = 1, v3 = 0,cal=[(1,'right')],cw=[(1,70)])
cmds.setParent("objToI_fl")

cmds.rowColumnLayout(nc =2, cw = [(1,20),(2,200)])
cmds.text(l='')
cmds.checkBox("objToI_cb2", l='Keep Original Orientation')
cmds.text( l ='', h=5)
cmds.setParent("objToI_top")                                         # 컨스트레인 텝 설정 끝
cmds.text( l ='', h=5)#--------------------------------------------------------------------------------------------------------------

cmds.rowColumnLayout( nc =3, cw = [(1,20),(2,150),(3,150)] )#------------------------------------------------------------------------
cmds.text( l ='')
cmds.checkBox("objToI_cb0", l='Keep Original Tanslation')                                               #기타 옵션들 텝 설정
cmds.checkBox("objToI_cb1", l='Delete Constraint')
Example #45
0
def w01_TerminalSelection():
    '''{'path':'General/w01_TerminalSelection()',
'icon2':'menuIconWindow.png',
'icon':':/selectByObject.png',
'html':'',
'usage':'w01_TerminalSelection()',
}
'''
    if cmds.window('w01', exists=True):
        cmds.deleteUI('w01')
    cmds.window('w01',title='w01_Terminal Selection ', tbm=False, w=650,sizeable=False)
    #form = cmds.formLayout('form', p=QSWindow, w=550, numberOfDivisions=100)
    cmds.formLayout('w01_formL', p='w01', w=500, numberOfDivisions=100)
    
    cmds.rowColumnLayout( 'w01_rcL', p='w01_formL', numberOfColumns=3)
    cmds.radioButtonGrp( 'w01_01',  p='w01_rcL', label='first', numberOfRadioButtons=3, cw=([1,20],[2,20],[3,20]),select=1, rat=([1,'top', 25], [2,'both', 10]),  vertical=True, changeCommand='w01_01_cc()\nw01_changeUI_command(w01_objectsData)' )
    cmds.radioButtonGrp( 'w01_02',  p='w01_rcL', label='sec', numberOfRadioButtons=3, cw=([1,20],[2,20],[3,20]), select=2,  rat=([1,'top', 25], [2,'both', 10]),  vertical=True, changeCommand='w01_02_cc()\nw01_changeUI_command(w01_objectsData)' )
    cmds.radioButtonGrp( 'w01_03',  p='w01_rcL', label='third', numberOfRadioButtons=3, cw=([1,25],[2,25],[3,25]), select=3,rat=([1,'top', 25], [2,'both', 10]),  vertical=True, changeCommand='w01_03_cc()\nw01_changeUI_command(w01_objectsData)')
    
    
    
    cmds.rowColumnLayout( 'w01_rcL02', p='w01_formL', numberOfColumns=4, width=600, columnWidth=[(1, 300), (2, 40), (3, 40), (4,130)], cs=[1,10] )
    
    #row 1b
    cmds.button('w01_rcL02_01', p='w01_rcL02', label='Get Objects From Selected', command='w01_objectsData = w01_rcL02_01_c()\nw01_changeUI_command(w01_objectsData)')
    cmds.text(                  p='w01_rcL02', enable=False,visible=False)
    cmds.text(                  p='w01_rcL02', enable=False,visible=False)
    #cmds.text(                  p='w01_rcL02', enable=False,visible=False)
    cmds.intFieldGrp( 'w01_disCount', label='count', w=80, cl2=['right','center'], cw2=[60,50], value1=0, bgc=[.8,.5,0], en=False)
    
    
    
    #row 2
    cmds.floatSliderGrp( 'w01_rcL02_02', p='w01_rcL02', field=True, label='Size', minValue=0, maxValue=100, step=.1, cw3=[30,50,100], cc="w01_changeUI_command(w01_objectsData)")
    cmds.checkBox( 'w01_rcL02_03', p='w01_rcL02', label='min', bgc=[0,.8,0], changeCommand="w01_minMax_cc('w01_rcL02_03','w01_rcL02_04', w01_objectsData)" )
    cmds.checkBox( 'w01_rcL02_04', p='w01_rcL02', label='max', bgc=[0,.8,0], changeCommand="w01_minMax_cc('w01_rcL02_03','w01_rcL02_04', w01_objectsData)")
    cmds.radioButtonGrp( 'w01_12', p='w01_rcL02', label='By', numberOfRadioButtons=2, bgc=[.15,.15,.15], labelArray2=['value', 'percent'], cw=([1,15],[2,50],[2,50]), select=2, changeCommand="w01_By_cc( 'w01_12', 'w01_rcL02_02', w01_objectsData)" )   #cat=([2,'left',4] ),
    
    
    #row 3
    cmds.floatSliderGrp( 'w01_rcL02_05', p='w01_rcL02', field=True, label='Count', minValue=0, maxValue=100, step=.1, cw3=[30,50,100], changeCommand="w01_changeUI_command(w01_objectsData)")
    cmds.checkBox( 'w01_rcL02_06', p='w01_rcL02', label='min', bgc=[0,.8,0], changeCommand="w01_minMax_cc('w01_rcL02_06','w01_rcL02_07', w01_objectsData)"  )
    cmds.checkBox( 'w01_rcL02_07', p='w01_rcL02', label='max', bgc=[0,.8,0], changeCommand="w01_minMax_cc('w01_rcL02_06','w01_rcL02_07', w01_objectsData)"  )
    cmds.radioButtonGrp( 'w01_13', p='w01_rcL02', label='By', numberOfRadioButtons=2, bgc=[.15,.15,.15], labelArray2=['value', 'percent'], cw=([1,15],[2,50],[2,50]), select=2, changeCommand="w01_By_cc( 'w01_13', 'w01_rcL02_05', w01_objectsData)"  )
    
    
    #row 4
    cmds.floatSliderGrp( 'w01_rcL02_08', p='w01_rcL02', field=True, label='Area', minValue=0, maxValue=100, step=.005, cw3=[30,50,100], changeCommand="w01_changeUI_command(w01_objectsData)")
    cmds.checkBox( 'w01_rcL02_09', p='w01_rcL02', label='min', bgc=[0,.8,0], changeCommand="w01_minMax_cc('w01_rcL02_09','w01_rcL02_10', w01_objectsData)"  )
    cmds.checkBox( 'w01_rcL02_10', p='w01_rcL02', label='max', bgc=[0,.8,0], changeCommand="w01_minMax_cc('w01_rcL02_09','w01_rcL02_10', w01_objectsData)"  )
    cmds.radioButtonGrp( 'w01_14', p='w01_rcL02', label='By', numberOfRadioButtons=2, bgc=[.15,.15,.15], labelArray2=['value', 'percent'], cw=([1,15],[2,50],[2,50]), select=2, changeCommand="w01_By_cc( 'w01_14', 'w01_rcL02_08', w01_objectsData)" )
    
    
    #row 5
    cmds.checkBox( 'w01_rcL02_11', p='w01_rcL02', label='SELECT', bgc=[.5,0,0], h=30,rs=False, changeCommand="w01_select_cc(w01_objectsData)") 
    cmds.text(                  p='w01_rcL02', enable=False,visible=False)
    cmds.text(                  p='w01_rcL02', enable=False,visible=False)
    cmds.button(     'w01_15',   p='w01_rcL02',label='Colse',bgc=[.4,.4,.4], rs=False, command='w01_15_closeCommand()\nw01_objectsData=()')
    
    
    
    #select type
    #edit formLayout
    cmds.formLayout( 'w01_formL', edit=True, attachForm=[('w01_rcL', 'top', 5), ('w01_rcL', 'bottom', 5),('w01_rcL', 'left', 5),\
                                                         ('w01_rcL02', 'top', 5), ('w01_rcL02', 'bottom', 5),('w01_rcL02', 'right', 5)],\
                                      attachControl=[('w01_rcL', 'right', 5, 'w01_rcL02')],\
                                      attachPosition=[('w01_rcL', 'right', 5, 18), ('w01_rcL02', 'left', 5, 18)] )
    
 
    cmds.showWindow( 'w01')
Example #46
0
    def ui(self):
        '''
        Launch a UI to display the marks that were recorded.
        '''

        with utl.MlUi(
                'ml_stopwatchReport',
                'Stopwatch Report',
                width=400,
                height=400,
                info='''This is the report from the stopwatch you just ran.
Adjust the start frame, and then press the frame buttons to jump to that frame.
The fields on the right can be used for notes.''',
                menu=False) as win:

            self.uiSlider = mc.intSliderGrp(
                field=True,
                label='Start Frame',
                value=self.startFrame,
                minValue=((-0.5 * self.frameMarks[-1]) + self.startFrame),
                maxValue=(self.frameMarks[-1] / 2) + self.startFrame,
                fieldMinValue=-1000,
                fieldMaxValue=1000,
                changeCommand=self.uiUpdateStartFrame)

            self.frameRateField = mc.intFieldGrp(label='Frame Rate',
                                                 value1=self.frameRate,
                                                 enable1=False,
                                                 extraLabel='fps',
                                                 annotation='')

            mc.scrollLayout()
            mc.rowColumnLayout(numberOfColumns=3,
                               columnWidth=[(1, 50), (2, 80), (3, 340)])
            mc.text('Frame')
            mc.text('Duration')
            mc.text('Notes')

            for i in range(3):
                mc.separator(style='single', height=15)

            self.uiButton = list()

            for i in range(len(self.frameMarks)):

                #frame button
                frame = self.frameMarks[i] + self.startFrame
                self.uiButton.append(
                    mc.button(
                        label=str(frame),
                        annotation='Go to frame %i' % frame,
                        command=
                        'import maya.cmds;maya.cmds.currentTime(%i,edit=True)'
                        % frame))

                #duration text
                if i:
                    mc.text(label=str(self.frameMarks[i] -
                                      self.frameMarks[i - 1]))
                else:
                    mc.text(label='Start')

                #notes field
                mc.textField()

            #add the stop
            mc.text(label='')
            mc.text(label='Stop')
            mc.setParent('..')
            mc.setParent('..')

            #next and prev buttons!
            mc.paneLayout(configuration='vertical2', separatorThickness=1)
            mc.button(label='<< Previous',
                      command=self.previousFrame,
                      annotation='Go to the previous frame in the list.')
            mc.button(label='Next >>',
                      command=self.nextFrame,
                      annotation='Go to the next frame in the list.')
	def TextureManage_UI(self):
		mr=cmds.pluginInfo("Mayatomr", q=True, l=True)
		if not mr:
			cmds.loadPlugin("Mayatomr")
			cmds.confirmDialog( title='load mr_V2', message='++++++"Mayatomr" was loaded,please Try again.++++++',b='colse')
			return 
		if cmds.window('TMM_win',ex=True):
			cmds.deleteUI('TMM_win')
		window=cmds.window('TMM_win',t='Texture Manage Master V1.0',wh=(420,500))
		tabs= cmds.tabLayout('main_tabs',innerMarginWidth=5, innerMarginHeight=5)
		Hand_mainscrollLayout=cmds.scrollLayout(cr=True)
		Hand_col=cmds.columnLayout('hand_c',adj=True,cat=['both',1],rs=5)
		Hand_refresh_col=cmds.columnLayout('hand_ref_c',adj=True,cat=['both',30],rs=10)
		Refresh_Files_butt=cmds.button('ref_f_s_b',l='Refresh Files For Select...',c=self.refreshButtonFun,h=30)
		cmds.text('sel_f_t',l='Select files you want to modify')
		cmds.setParent(Hand_col)
		Hand_scrollLayout=cmds.scrollLayout('Hand_scr',h=260)
		cmds.setParent(Hand_col)
		cmds.separator(style='in' )
		prj=cmds.workspace(q=True,rd=True)
		fileprj=cmds.workspace("sourceImages",q=True, rte=True)
		prjfile='%s%s/'%(prj,fileprj)
		self.Hand_tfb_TarDir=cmds.textFieldButtonGrp(label='   Target Directory:', text=prjfile, buttonLabel='Folder...',adj=2,cl3=['left','left','left'],cw3=[90,220,30] )
		cmds.textFieldButtonGrp(self.Hand_tfb_TarDir,e=True,bc=lambda *args:self.openDirectory_function(self.Hand_tfb_TarDir))
		Hand_set_b=cmds.button('Hand_set_b',l='Set Path...',c=self.setPath_function)
		cmds.separator(style='in' )
		Hand_frame_swf=cmds.frameLayout('Hand_frame_switchFiles',label='Switch Files ("high","mid","low","draft")',cll=True,borderStyle='etchedOut')
		Hand_frame_col_swf=cmds.columnLayout('Hand_frame_col_switchFiles',adj=True,cat=['both',3],rs=2)
		Hand_Radio=cmds.radioButtonGrp('Hand_radiob',labelArray4=['high', 'mid', 'low','draft'], numberOfRadioButtons=4,sl=2)
		cmds.button('Switch_Selected_b',l='Switch For Selected',c=lambda *args:self.switchFiles('select'))
		cmds.button('Switch_All_b',l='Switch For All',c=lambda *args:self.switchFiles('all'))
		#cmds.textScrollList('file_coupleBack',allowMultiSelection=True,h=150)
		cmds.setParent(Hand_col)
		cmds.separator(style='in' )
		Hand_frame_pr=cmds.frameLayout(label='Root Replace',cll=True,cl=True,borderStyle='etchedOut')
		Hand_frame_col=cmds.columnLayout(adj=True,cat=['both',3],rs=2)
		self.Hand_tfb_OldRoot=cmds.textFieldButtonGrp(label='        Old Root:', text='', buttonLabel='Folder...',adj=2,cl3=['left','left','left'],cw3=[70,220,30] )
		cmds.textFieldButtonGrp(self.Hand_tfb_OldRoot,e=True,bc=lambda *args:self.openDirectory_function(self.Hand_tfb_OldRoot))
		self.Hand_tfb_NewRoot=cmds.textFieldButtonGrp(label='        New Root:', text=prjfile, buttonLabel='Folder...',adj=2,cl3=['left','left','left'],cw3=[70,220,30] )
		cmds.textFieldButtonGrp(self.Hand_tfb_NewRoot,e=True,bc=lambda *args:self.openDirectory_function(self.Hand_tfb_NewRoot))
		Hand_replace_b=cmds.button('Hand_r_b',l='Replace...',c=self.replacePartPath)
		
		cmds.setParent(tabs)
		Aoto_mainscrollLayout=cmds.scrollLayout(cr=True)
		Aoto_col=cmds.columnLayout('aoto_c',adj=True,cat=['both',2],rs=5)
		self.Aoto_camera=cmds.optionMenu( label='Camera Name:')
		self.addmenuItems()
		Aoto_frame_fct=cmds.frameLayout(label='Form Camera To Obj Distance ',cll=True,borderStyle='etchedOut')
		Aoto_frame_fct_col=cmds.columnLayout(adj=True,cat=['both',3],rs=5)
		Aoto_row_n=cmds.rowLayout(nc=2, cw2=(150,80), adjustableColumn=2, columnAttach=[(1, 'right', 0), (2, 'right', 150)] )
		Aoto_near_text=cmds.text(l='Near (<=)')
		self.Aoto_near_float=cmds.floatField(value=50,min=0,pre=2)
		cmds.setParent(Aoto_frame_fct_col)
		Aoto_row_n=cmds.rowLayout(nc=2, cw2=(150,80), adjustableColumn=2, columnAttach=[(1, 'right', 0), (2, 'right', 150)] )
		Aoto_middle_text=cmds.text(l='Middle ( > Near && <=)')
		self.Aoto_middle_float=cmds.floatField(value=200,min=0,pre=2)
		cmds.setParent(Aoto_frame_fct_col)
		Aoto_Far=cmds.text(l='Far (>Middle)')
		cmds.setParent(Aoto_col)
		cmds.separator(style='in' )
		Aoto_frame_fs=cmds.frameLayout(label='Frame steps ',cll=True,borderStyle='etchedOut')
		Aoto_frame_fs_col=cmds.columnLayout(adj=True,cat=['both',3],rs=5)
		self.Aoto_near=cmds.intFieldGrp(l='Frame steps', value1=5,cl2=['right','left'],cw2=[150,70])
		cmds.setParent(Aoto_col)
		cmds.separator(style='in' )
		Aoto_setpath=cmds.button(l='Aoto Set texture Path',c=self.AotoSetTexturePath,h=30)
		cmds.separator(style='in' )
		Aoto_setsubdivisionLe=cmds.button(l='Aoto Set Subdivision Proxy',c=self.AotoSetSubdivisionProxy,h=30)
		cmds.separator(style='in' )
		Aoto_frame_coupBack=cmds.frameLayout(label='Couple Back ',borderStyle='etchedOut')
		self.Aoto_scroll_coupBack=cmds.scrollLayout(h=195)
		cmds.button(l='Select the problem of mapping files...',p=Aoto_col,h=30,c=self.selectProblemFiles)

		cmds.setParent(tabs)
		Help_mainscrollLayout=cmds.scrollLayout(cr=True)
		Help_col=cmds.columnLayout('help_c',adj=True,cat=['both',2],rs=5)
		help_text=u'''
工作描述:\n                                                          
    1.贴图管理插件,转换和管理场景中使用的文件贴图。\n\n
..................................................\n\n
使用方法:\n
    1. 刷新选择物体的贴图,在场景选择您需要查找贴图的物体,单击Refresh Files For Select按钮。在下面的(Select Files you want tomodify)列表中反馈出与选择物体有关的贴图有在的文件夹。\n
    2. 改变贴图途径,在(Select Files you want tomodify)列表中选择需要更改的贴图,在Target Directory中填入新的贴图路径(可以单击Folder按钮搜索,也可以用复制的方式),单击Set Path按钮执行。\n
    3. 切换贴图的大小,(1.选择物体切换,在场景选择需要切换的模型,选择相应的模式(“high”,“mid”,“low”),单击Switch For Selected 按钮执行;2.所有贴图切换,选择相应的模式(“high”,“mid”,“low”),单击Switch For All 按钮执行。)。\n
    4. 替换贴图途径,在(Select Files you want tomodify)列表中选择需要更改的贴图,在Old Rood 中填入原始的部分路径(可以单击Folder按钮搜索),在New Rood 中填入新的部分路径(可以单击Folder按钮搜索),单击Replace按钮执行。\n
    5. 自动切换贴图大小(根据距离),在(CameraName中选择摄像机,在Near(<=)和 Middle(>Near &&<=)中填入物体离摄像机的距离),单击Aoto Set texture Path按钮切换。\n
    6. 自动更改细分代理的级别(根据距离),在(CameraName中选择摄像机,在Near(<=)和 Middle(>Near &&<=)中填入物体离摄像机的距离),单击Aoto Set Subdivision Proxy按钮更改。\n
\n\n
'''
		Help_scroll_descr=cmds.scrollField(ww=True,tx=help_text,editable=False,h=395)
		cmds.setParent(Help_col)
		Help_frame_about=cmds.frameLayout(label=u'关于“Texture Manage Master” ',borderStyle='in')
		cmds.text(l=u'   工具名字 :                              Texture Manage Master',align='left')
		cmds.text(l=u'   更新时间 :                              2012 年 9 月',align='left')
		cmds.text(l=u'   作者 :                                     郑卫福',align='left')
		cmds.text(l=u'   版本 :                                     v1.0',align='left')
		cmds.text(l=u'   电子邮箱 :                              [email protected]',align='left')
		cmds.text(l=u'   maya版本 :                             maya2011以上',align='left')
		cmds.setParent(tabs)
		cmds.tabLayout('main_tabs',e=True,tl=((Hand_mainscrollLayout,'HandPart'),(Aoto_mainscrollLayout,'AotoPart'),(Help_mainscrollLayout,'Help')))
		cmds.window('TMM_win',e=True,wh=(420,562))
		cmds.showWindow('TMM_win')
Example #48
0
	def readFileXYZ(self, filePath):
		""" Read terrain file, but don't do anything with the data yet.
			ASCII X,Y,Z format data.
		"""
		startTime = time.time()
		data = np.genfromtxt(filePath, skip_header=self.checkFileHeader(filePath))

		# Calculate metadata
		count = data.shape[0]
		minX = min(data[:,0])
		minY = min(data[:,1])
		minZ = min(data[:,2])
		maxX = max(data[:,0])
		maxY = max(data[:,1])
		maxZ = max(data[:,2])
		lenX = maxX - minX
		lenY = maxY - minY
		resX = self.getRes(data[:,0])
		resY = self.getRes(data[:,1])
		dimX = (lenX/resX)+1
		dimY = (lenY/resY)+1
		name = os.path.splitext(os.path.basename(mc.textField("filePath", q=True, tx=True)))[0]

		if resX == resY: # Check X and Y resolution match
			res = resX

			# Update info text fields
			mc.textFieldGrp("format", edit=True, text=self.format)
			mc.textFieldGrp("arr_dim", edit=True, text="%d (%d x %d)" %(count, dimX, dimY))
			mc.floatFieldGrp("rx", edit=True, value=[minX, maxX, lenX, 0])
			mc.floatFieldGrp("ry", edit=True, value=[minY, maxY, lenY, 0])
			mc.floatFieldGrp("res", edit=True, value=[res, 0, 0, 0])

			# Create terrain data (instance of terrainMap class)
			self.DEM = terrainMap((dimX, dimY), (minX, minY), res)
			self.DEM.compileFromXYZ(data)
			self.DEM.printMap()
			self.updateTileInfo()

			# Complete progress bar and end clock
			#mc.progressBar(self.gMainProgressBar, edit=True, endProgress=True) # Complete progress bar
			totalTime = time.time() - startTime
			print "Read %d points in %f seconds.\n" %(count, totalTime)
			#self.data = data

			# Enable UI once data is loaded
			mc.columnLayout("Data_Options", edit=True, enable=True)
			mc.columnLayout("Terrain_Generation_Options", edit=True, enable=True)
			mc.button("btnGenerate", edit=True, enable=True)

			self.setupTerrainScene(max(lenX, lenY)*2)
			self.createGroup(name)

			# Generate preview plane
			if mc.checkBox("prv", query=True, value=True):
				previewSubdivs = mc.intFieldGrp("prvSubds", query=True, value=True)
				previewPlane = self.DEM.createPreview(name, (previewSubdivs[0], previewSubdivs[1]))
				if previewPlane:
					mc.parent(previewPlane[0], "%s|%s" %("terrain_grp", name), relative=True)
					#mel.eval("FrameSelected;")
					print "Preview plane created. Press the 'F' key to frame the viewport."

		else:
			mc.error("Resolution mismatch in X and Y axes.")
			return False
Example #49
0
    def save_preset(self, pPolyNumberField,
                    pTreeDepthField,
                    pTreeSegmentLength,
                    pLengthDecrease,
                    pRadius,
                    pRadDecrease,
                    pBranches,
                    pBranches_a,
                    pFoliageSze,
                    pFoliageRes,
                    pSeed,
                    pFoliageC,
                    pTreeC,
                    pFoliageN,
                    pFoliageSpread,
                    pFirstSegmentL,
                    pTreeType,
                    pBranchChance,
                    pAngleChance,
                    pTurnChance,
                    pTurnAmount,
                    pAngleAmount,
                    *pArgs
                    ):
        polycount = cmds.intSliderGrp(pPolyNumberField, query=True, value=True)
        tree_depth = cmds.intSliderGrp(pTreeDepthField, query=True, value=True)
        segment_length = cmds.floatSliderGrp(pTreeSegmentLength, query=True, value=True)
        length_dec = cmds.floatSliderGrp(pLengthDecrease, query=True, value=True)
        radius = cmds.floatSliderGrp(pRadius, query=True, value=True)
        radius_d = cmds.floatSliderGrp(pRadDecrease, query=True, value=True)
        branches = cmds.intSliderGrp(pBranches, query=True, value=True)
        branches_a = cmds.floatSliderGrp(pBranches_a, query=True, value=True)
        foliage_s = cmds.floatSliderGrp(pFoliageSze, query=True, value=True)
        foliage_r = cmds.intSliderGrp(pFoliageRes, query=True, value=True)
        p_seed = cmds.intFieldGrp(pSeed, query=True, value=True)
        treeCor = cmds.colorSliderGrp(pTreeC, query=True, rgbValue=True)
        foliageCor = cmds.colorSliderGrp(pFoliageC, query=True, rgbValue=True)
        foliage_n = cmds.intSliderGrp(pFoliageN, query=True, value=True)
        foliage_spread = cmds.floatSliderGrp(pFoliageSpread, query=True, value=True)
        first_segment_l = cmds.floatSliderGrp(pFirstSegmentL, query=True, value=True)
        tree_type = cmds.radioButtonGrp(pTreeType, query=True, select=True)
        branch_chance = cmds.floatSliderGrp(pBranchChance, query=True, value=True)
        angle_chance = cmds.floatSliderGrp(pAngleChance, query=True, value=True)
        turn_chance = cmds.floatSliderGrp(pTurnChance, query=True, value=True)
        turn_amount = cmds.floatSliderGrp(pTurnAmount, query=True, value=True)
        angle_amount = cmds.floatSliderGrp(pAngleAmount, query=True, value=True)

        basicFilter = "*.txt"
        exportPath = pm.fileDialog2(fm=0, fileFilter=basicFilter, okc='createPreset', cap='Create preset file',
                                    dir=cmds.internalVar(upd=True))[0]
        pm.optionVar['pbExportPath'] = exportPath
        #print exportPath

        # write to file
        path = cmds.internalVar(upd=True) + "preset.txt"
        file = open(exportPath, 'w')

        # controlType, controlName, query, value
        file.writelines(str(["intSliderGrp", "polyNumberField", "v", str(polycount)]) + "\n")
        file.writelines(str(["intSliderGrp", "treeDepthField", "v", str(tree_depth)]) + "\n")
        file.writelines(str(["floatSliderGrp", "treeSegmentLength", "v", str(segment_length)]) + "\n")

        file.writelines(str(["floatSliderGrp", "treeLengthDecrease", "v", str(length_dec)]) + "\n")
        file.writelines(str(["floatSliderGrp", "trunkRadius", "v", str(radius)]) + "\n")
        file.writelines(str(["floatSliderGrp", "radiusDecrease", "v", str(radius_d)]) + "\n")

        file.writelines(str(["intSliderGrp", "treeBranches", "v", str(branches)]) + "\n")
        file.writelines(str(["floatSliderGrp", "treeBranches_a", "v", str(branches_a)]) + "\n")
        file.writelines(str(["floatSliderGrp", "treeFoliageSze", "v", str(foliage_s)]) + "\n")

        file.writelines(str(["intSliderGrp", "treeFoliageRes", "v", str(foliage_r)]) + "\n")
        file.writelines(str(["intFieldGrp", "randomSeed", "v1", str(p_seed)]) + "\n")
        file.writelines(str(["colorSliderGrp", "treeColor", "rgbValue", str(treeCor)]) + "\n")

        file.writelines(str(["colorSliderGrp", "foliageColor", "rgbValue", str(foliageCor)]) + "\n")
        file.writelines(str(["intSliderGrp", "treeFoliageNumber", "v", str(foliage_n)]) + "\n")
        file.writelines(str(["floatSliderGrp", "treeFoliageSpread", "v", str(foliage_spread)]) + "\n")

        file.writelines(str(["floatSliderGrp", "treeFirstSegmentLength", "v", str(first_segment_l)]) + "\n")
        file.writelines(str(["radioButtonGrp", "treeTypeSelect", "select", str(tree_type)]) + "\n")
        file.writelines(str(["floatSliderGrp", "branchingChance", "v", str(branch_chance)]) + "\n")

        file.writelines(str(["floatSliderGrp", "branchAngleChance", "v", str(angle_chance)]) + "\n")
        file.writelines(str(["floatSliderGrp", "branchTurnChance", "v", str(turn_chance)]) + "\n")
        file.writelines(str(["floatSliderGrp", "branchTurnRAmount", "v", str(turn_amount)]) + "\n")
        file.writelines(str(["floatSliderGrp", "branchAngleRAmount", "v", str(angle_amount)]) + "\n")

        file.close()
Example #50
0
 def changeTextFld(*args):
     cmds.intFieldGrp("randomSeed", edit=True, v1=random.randint(0, 9999))
Example #51
0
class ConvertColorCode(object):
    u"""カラーコードからMayaのUI用の色情報形式に変換する"""
    _WINDOW_NAME = "surume_utility_convert_color_code_window"
    _COLOR_FORMAT = "[{0}, {1}, {2}]"

    def __init__(self):
        u"""initialize."""
        self.color_code_field = None
        self.decimal_point_field = None
        self.result_field = None
        self.color_preview = None

    @staticmethod
    def show_ui(*args):
        u"""Windowを表示"""
        ConvertColorCode()._create_ui()

    def _create_ui(self):
        u"""UIを生成"""
        safe_delete_window(self._WINDOW_NAME)
        win = cmds.window(self._WINDOW_NAME,
                          t="Convert Color Code",
                          mb=True,
                          w=480,
                          h=128)
        cmds.menu(l="Option")
        cmds.menuItem(l="ColorEditor", c=self.get_color_from_editor)
        cmds.columnLayout(adj=True, rs=2)
        self.color_code_field = cmds.textFieldButtonGrp(l="Color code",
                                                        bl="Convert",
                                                        bc=self._convert)
        self.decimal_point_field = cmds.intFieldGrp(l="Decimal point",
                                                    nf=1,
                                                    v1=2)
        self.result_field = cmds.textFieldGrp(l="Result")

        cmds.setParent("..")

        cmds.columnLayout(adj=True)
        self.color_preview = cmds.text(l="", h=24)
        cmds.setParent("..")
        cmds.showWindow(win)

    def _convert(self, *args):
        u"""カラーコードを変換"""
        code = cmds.textFieldButtonGrp(self.color_code_field, q=True, tx=True)
        if len(code) == 7 and code.startswith("#"):
            code = code[1:]
        if len(code) != 6:
            return
        try:
            int(code, 16)
        except ValueError, e:
            print(e)
            return
        decimal_point = cmds.intFieldGrp(self.decimal_point_field,
                                         q=True,
                                         v1=True)
        r = round(int(code[0:2], 16) / 255, decimal_point)
        g = round(int(code[2:4], 16) / 255, decimal_point)
        b = round(int(code[4:6], 16) / 255, decimal_point)
        bgc = self._COLOR_FORMAT.format(str(r), str(g), str(b))
        cmds.textFieldGrp(self.result_field, e=True, tx=bgc)
        cmds.text(self.color_preview, e=True, bgc=[r, g, b])
Example #52
0
my_window = cmds.window(window_name, title="WIDGETS!")

# the adj flag makes the buttons stretch to the width of the column
my_layout = cmds.columnLayout(parent=my_window, adj=True)

# make some buttons 
cmds.button(parent = my_layout, l = "button")
cmds.text(parent = my_layout, l = "text")

cmds.checkBox( label='checkBox' )
cmds.checkBoxGrp( numberOfCheckBoxes=3, label='checkBoxGrp', labelArray3=['One', 'Two', 'Three'] )

cmds.floatFieldGrp( numberOfFields=2, label='floatFieldGrp')
cmds.floatSliderGrp( label='floatSliderGrp', field=True )

cmds.intFieldGrp( numberOfFields=2, label='intFieldGrp')
cmds.intSliderGrp( label='intSliderGrp', field=True )

cmds.textFieldGrp( label='textFieldGrp' , text='Text')
cmds.textFieldButtonGrp( label='textFieldButtonGrp', text='Text', buttonLabel='Button' )

cmds.optionMenuGrp( label='optionMenuGrp')
cmds.menuItem( label='Option1' )
cmds.menuItem( label='Option2' )
cmds.menuItem( label='Option3' )

collection = cmds.radioCollection()
collectionLayout = cmds.rowLayout(numberOfColumns=4)
cmds.text(parent = my_layout, l = "radioButton", p=collectionLayout)
rb1 = cmds.radioButton( label='One', p=collectionLayout)
rb2 = cmds.radioButton( label='Two', p=collectionLayout)
Example #53
0
    def create_ui(self, pWindowTitle, pApplyCallBack, pSavePreset, pLoadPreset):
        windowID = 'miniTree'
        if cmds.window(windowID, exists=True):
            cmds.deleteUI(windowID)

        cmds.window(windowID, title=pWindowTitle, sizeable=False, resizeToFitChildren=True, w = 100)

        cmds.rowColumnLayout(numberOfColumns=1)
        logopath = cmds.internalVar(upd=True) + "icons/mini_tree_logo.png"
        cmds.image(image=logopath)
        cmds.separator(h=10, style='none')
        cmds.setParent('..')

        form = cmds.formLayout()
        tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
        cmds.formLayout(form, edit=True,
                        attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'right', 0)))

        child1 = cmds.rowColumnLayout(numberOfColumns=1)

        cmds.separator(h=10, style='in')
        cmds.text(label='General', align='center')
        cmds.separator(h=10, style='in')

        polyNumberField = cmds.intSliderGrp("polyNumberField", label='Polygons:', min=3, max=20, value=4, step=1,
                                            field=True,
                                            annotation='Changes number of polygons in each tree segment')
        treeDepthField = cmds.intSliderGrp("treeDepthField", label='Levels (tree size):', min=1, max=8, value=3, step=1,
                                           field=True,
                                           annotation='Changes number of branching levels')
        treeFirstSegmentLength = cmds.floatSliderGrp("treeFirstSegmentLength", label='Base length:', min=0.1, max=5,
                                                     value=1, step=0.1,
                                                     field=True,
                                                     annotation='Increases/decreases the length of the first tree segment')
        cmds.separator(h=10, style='in')
        cmds.text(label='Branch length', align='center')
        cmds.separator(h=10, style='in')
        treeSegmentLength = cmds.floatSliderGrp("treeSegmentLength", label='Length:', min=0.2, max=20, value=5,
                                                step=0.1, field=True,
                                                annotation='Changes the initial length of each branch')

        treeLengthDecrease = cmds.floatSliderGrp("treeLengthDecrease", label='Decrease:', min=0.0, max=1, value=0.8,
                                                 step=0.01, field=True,
                                                 annotation='Affects how the length of each branch decreases as the tree grows')
        cmds.separator(h=10, style='in')
        cmds.text(label='Trunk/branch radius', align='center')
        cmds.separator(h=10, style='in')
        trunkRadius = cmds.floatSliderGrp("trunkRadius", label='Radius:', min=0.1, max=10, value=1, step=0.1,
                                          field=True,
                                          annotation='Changes the initial radius of the tree trunk')
        radiusDecrease = cmds.floatSliderGrp("radiusDecrease", label='Decrease:', min=0.0, max=1, value=0.45, step=0.01,
                                             field=True,
                                             annotation='Affects how the radius of the branches decreases as the tree grows')
        cmds.separator(h=10, style='in')
        cmds.text(label='Branching', align='center')
        cmds.separator(h=10, style='in')
        treeBranches = cmds.intSliderGrp("treeBranches", label='Max branches:', min=1, max=8, value=2, step=1,
                                         field=True,
                                         annotation='Changes the maximum number of branches that may occur when branching')
        treeBranches_a = cmds.floatSliderGrp("treeBranches_a", label='Branches angle:', min=0, max=math.pi, value=0.5,
                                             step=0.01,
                                             field=True, annotation='Manipulates the angle of braches')
        cmds.separator(h=10, style='in')
        cmds.text(label='Randomness', align='center')
        cmds.separator(h=10, style='in')
        branchingChance = cmds.floatSliderGrp("branchingChance", label='Branching chance:', min=0, max=1, value=0.9,
                                              step=0.01,
                                              field=True,
                                              annotation='Lower values increase a chance of a branch not appearing')
        cmds.separator(h=10, style='in')
        branchAngleChance = cmds.floatSliderGrp("branchAngleChance", label='Angle shift shance:', min=0, max=1,
                                                value=0.9,
                                                step=0.01,
                                                field=True,
                                                annotation='Chance of a branch angle deviating from the angle of all other branches')
        branchAngleRAmount = cmds.floatSliderGrp("branchAngleRAmount", label='Angle random amount:', min=0, max=math.pi,
                                                 value=math.pi / 6,
                                                 step=0.01,
                                                 field=True,
                                                 annotation='Angle of how much a branch angle can change randomly')
        cmds.separator(h=10, style='in')
        branchTurnChance = cmds.floatSliderGrp("branchTurnChance", label='Turn shift chance:', min=0, max=1, value=0.9,
                                               step=0.01,
                                               field=True,
                                               annotation='Chance of a branch turn deviating from the turn of all other branches')
        branchTurnRAmount = cmds.floatSliderGrp("branchTurnRAmount", label='Turn random amount:', min=0, max=math.pi,
                                                value=math.pi / 2,
                                                step=0.01,
                                                field=True, annotation='Angle of how much a branch can turn randomly')

        cmds.separator(h=10, style='in')
        cmds.text(label='Colour', align='center')
        cmds.separator(h=10, style='in')
        treeColor = cmds.colorSliderGrp("treeColor", label='Tree colour:', rgb=(0.4, 0.3, 0.3),
                                        annotation='Double click the colour to open the palette, changes tree colour')
        cmds.separator(h=10, style='none')

        cmds.setParent('..')

        child2 = cmds.rowColumnLayout(numberOfColumns=1)

        cmds.separator(h=10, style='in')
        cmds.text(label='General', align='center')
        cmds.separator(h=10, style='in')
        treeFoliageSze = cmds.floatSliderGrp("treeFoliageSze", label='Size:', min=0.1, max=6, value=1, step=0.01,
                                             field=True,
                                             annotation='Size of each foliage sphere')
        treeFoliageRes = cmds.intSliderGrp("treeFoliageRes", label='Resolution:', min=0, max=4, value=1, step=1,
                                           field=True,
                                           annotation='Subdivides each of the foliage spheres')
        cmds.separator(h=10, style='in')
        cmds.text(label='More foliage', align='center')
        cmds.separator(h=10, style='in')
        treeFoliageNumber = cmds.intSliderGrp("treeFoliageNumber", label='Spheres number:', min=1, max=20, value=1,
                                              step=1, field=True,
                                              annotation='Number of foliage spheres per branch')
        treeFoliageSpread = cmds.floatSliderGrp("treeFoliageSpread", label='Randomise positions:', min=0, max=5,
                                                value=0, step=0.01,
                                                field=True,
                                                annotation='Randomise the foliage spheres position (necessary when changing foliage number)')

        cmds.separator(h=10, style='in')
        cmds.text(label='Colour', align='center')
        cmds.separator(h=10, style='in')
        foliageColor = cmds.colorSliderGrp("foliageColor", label='Foliage colour:', rgb=(0.30, 0.7, 0.40),
                                           annotation='Double click the colour to open the palette, changes foliage colour')
        cmds.separator(h=10, style='none')

        cmds.setParent('..')

        cmds.tabLayout(tabs, edit=True, tabLabel=((child1, 'Tree'), (child2, 'Foliage')))
        cmds.setParent('..')
        cmds.setParent('..')

        cmds.rowColumnLayout(numberOfColumns=1)

        treeTypeSelect = cmds.radioButtonGrp("treeTypeSelect", label='Tree type', sl=1, labelArray2=['Normal', 'Pine'],
                                             numberOfRadioButtons=2)
        cmds.separator(h=10, style='none')

        def changeTextFld(*args):
            cmds.intFieldGrp("randomSeed", edit=True, v1=random.randint(0, 9999))

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

        cmds.rowColumnLayout(numberOfColumns=2)
        cmds.button(label='Randomize seed', command=changeTextFld, annotation='Changes seed value to a random value')
        randomSeed = cmds.intFieldGrp("randomSeed", label='Seed:', numberOfFields=1, value1=9981,
                                      annotation='Number affecting random generation of the tree')
        #cmds.separator(h=10, style='none')

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

        cmds.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 300),(2, 20), (3, 100)])
        cmds.button(label='Create tree', h = 60, align='center', annotation='Create a tree using the above settings',
                    command=functools.partial(pApplyCallBack,
                                              polyNumberField,
                                              treeDepthField,
                                              treeSegmentLength,
                                              treeLengthDecrease,
                                              trunkRadius,
                                              radiusDecrease,
                                              treeBranches,
                                              treeBranches_a,
                                              treeFoliageSze,
                                              treeFoliageRes,
                                              randomSeed,
                                              foliageColor,
                                              treeColor,
                                              treeFoliageNumber,
                                              treeFoliageSpread,
                                              treeFirstSegmentLength,
                                              treeTypeSelect,
                                              branchingChance,
                                              branchAngleChance,
                                              branchTurnChance,
                                              branchTurnRAmount,
                                              branchAngleRAmount
                                              ))
        cmds.separator(h=10, style='none')
        cmds.rowColumnLayout(numberOfColumns=1, columnWidth=[(1, 90)])

        cmds.button(label='Save preset', annotation='Saves current settings as a preset',
                    command=functools.partial(pSavePreset,
                                              polyNumberField,
                                              treeDepthField,
                                              treeSegmentLength,
                                              treeLengthDecrease,
                                              trunkRadius,
                                              radiusDecrease,
                                              treeBranches,
                                              treeBranches_a,
                                              treeFoliageSze,
                                              treeFoliageRes,
                                              randomSeed,
                                              foliageColor,
                                              treeColor,
                                              treeFoliageNumber,
                                              treeFoliageSpread,
                                              treeFirstSegmentLength,
                                              treeTypeSelect,
                                              branchingChance,
                                              branchAngleChance,
                                              branchTurnChance,
                                              branchTurnRAmount,
                                              branchAngleRAmount
                                              ))
        cmds.separator(h=10, style='none')
        cmds.button(label='Load preset', annotation='Loads current settings as a preset',
                                 command=functools.partial(pLoadPreset))
        cmds.separator(h=10, style='in')
        cmds.text('preset_text', label='default', align='center')
        cmds.setParent('..')
        cmds.setParent('..')
        cmds.helpLine()

        def cancelCallBack(*pArgs):
            if cmds.window(windowID, exists=True):
                cmds.deleteUI(windowID)

        # cmds.button(label='Cancel', command=cancelCallBack)
        cmds.showWindow()
Example #54
0
	def generateTerrain(self):
		""" Generate the terrain.
		"""
		startTime = time.time()

		# Get options
		tile = mc.checkBox("tileSplit", query=True, value=True)
		tileSize = mc.intFieldGrp("tileSize", query=True, value=True)
		#align = mc.checkBox("tileAlign", query=True, value=True)
		crop = mc.checkBox("crop", query=True, value=True)
		unit = mc.optionMenuGrp("units", query=True, value=True)
		#setUnits = mc.checkBox("setUnits", query=True, value=True)
		#orient = mc.checkBox("orient", query=True, value=True)
		#res = mc.floatFieldGrp("res", query=True, value=True)[0]
		res = self.DEM.res
		grpName = os.path.splitext(os.path.basename(mc.textField("filePath", q=True, tx=True)))[0]
		name = "%s_%d%s" %(os.path.splitext(os.path.basename(mc.textField("filePath", q=True, tx=True)))[0], res, unit)
		grp = "orient_scene"
		tilesProcessed = 0

		#self.setupTerrainScene()
		self.createGroup(grpName)

		if crop:
			#x_dim = mc.floatFieldGrp("cropX", query=True, value=True)
			#y_dim = mc.floatFieldGrp("cropY", query=True, value=True)

			#mc.select("crop_area")
			#bbox = mc.exactWorldBoundingBox()
			bbox = mc.xform("crop_area", query=True, boundingBox=True)

			# Round values off
			x_min = self.DEM.roundToRes(bbox[0])
			y_min = self.DEM.roundToRes(bbox[1])
			x_max = self.DEM.roundToRes(bbox[3])
			y_max = self.DEM.roundToRes(bbox[4])

			# Updade fields with rounded values
			mc.floatFieldGrp("cropX", edit=True, value=[x_min, x_max, 0, 0])
			mc.floatFieldGrp("cropY", edit=True, value=[y_min, y_max, 0, 0])

			offset = max(x_min, self.DEM.offset[0]), max(y_min, self.DEM.offset[1])
			dim = ((x_max-offset[0])/res)+1, ((y_max-offset[1])/res)+1

			DEMCrop = terrainMap(dim, offset, res)
			DEMCrop.compileFromSlice(self.DEM)
			DEMCrop.printMap()
			cropGeo = DEMCrop.createGeo("%s_crop" %name)
			if not cropGeo:
				return False
			mc.parent(cropGeo, "%s|%s" %("terrain_grp", grpName), relative=True)
			tilesProcessed += 1


		# Split into tiles and create geo
		elif tile:
			#print res
			dim = (tileSize[0]/res)+1, (tileSize[1]/res)+1
			tilesX = int(math.ceil(self.DEM.size[0]/tileSize[0]))
			tilesY = int(math.ceil(self.DEM.size[1]/tileSize[1]))
			nTiles = tilesX*tilesY
			#tileID = 1

			startOffsetX = self.DEM.offset[0]
			startOffsetY = self.DEM.offset[1]

			for j in range(tilesY):
				for i in range(tilesX):
					nameTile = "%s_tile%d_%d" %(name, i, j)
					status = "(tile %d of %d)" %(tilesProcessed+1, nTiles)
					offset = startOffsetX + i*tileSize[0], startOffsetY + j*tileSize[1]
					DEMTile = terrainMap(dim, offset, res)
					DEMTile.compileFromSlice(self.DEM)
					DEMTile.printMap()
					tileGeo = DEMTile.createGeo(nameTile, status)
					if not tileGeo:
						return False
					mc.parent(tileGeo, "%s|%s" %("terrain_grp", grpName), relative=True)
					tilesProcessed += 1

		# Else create geo for entire data set (can be slow!)
		else:
			fullGeo = self.DEM.createGeo(name)
			if not fullGeo:
				return False
			mc.parent(fullGeo, "%s|%s" %("terrain_grp", grpName), relative=True)
			tilesProcessed += 1

		totalTime = time.time() - startTime
		print "Generated %d tiles in %f seconds.\n" %(tilesProcessed, totalTime)
Example #55
0
def buttonpress():
    numOfDice = mc.intFieldGrp('numOfDice', query = True, value1 = True)
    count = 0
    while count < numDice:      
Example #56
0
#peaks intslider
peakSlide = cmds.intSliderGrp(field=True,
                              label="Number of Peaks:                ",
                              min=0,
                              max=400,
                              v=0,
                              cc="peak_val()")
cmds.separator(h=10, style='in')

#edit size text
cmds.text(label="Edit size:")
cmds.separator(h=5, style="none")

#Scale X,Y,Z
ScaleX = cmds.intFieldGrp(nf=1,
                          label='Scale:                                 X',
                          value1=0,
                          cc="Scale()")
ScaleY = cmds.intFieldGrp(nf=1,
                          label='Scale:                                 Y',
                          value1=0,
                          cc="Scale()")
ScaleZ = cmds.intFieldGrp(nf=1,
                          label='Scale:                                 Z',
                          value1=0,
                          cc="Scale()")
cmds.separator(h=5, style='in')

#Play Slider range
cmds.separator(h=4, style="none")
play_slider = cmds.intFieldGrp(nf=2,
                               label='Play slider range:                  ',
Example #57
0
    def __init__(self):
        cmds.window('NodeRenamerGUI', t='Node Renamer', s=False)
        cmds.columnLayout(adj=True)

        # Header Section
        cmds.iconTextButton(label="NODE RENAMER",
                            style="textOnly",
                            fn='boldLabelFont',
                            height=35,
                            backgroundColor=[0, 0, 0])
        cmds.separator(h=10, style='in')

        # Search And Replace Section
        self.search_field = cmds.textFieldGrp(label='Search ',
                                              cal=[1, 'right'],
                                              cw2=[65, 260])
        self.replace_field = cmds.textFieldGrp(label='Replace ',
                                               cal=[1, 'right'],
                                               cw2=[65, 260])
        cmds.button(label='Search And Replace',
                    w=165,
                    c=self._search_and_replace)
        cmds.separator(h=10, style='in')

        # Add Prefix Section
        self.prefix_field = cmds.textFieldGrp(label='Prefix ',
                                              cal=[1, 'right'],
                                              cw2=[65, 260])
        cmds.button(label='Add Prefix', w=165, c=self._add_prefix)
        cmds.separator(h=10, style='in')

        # Add Suffix Section
        self.suffix_field = cmds.textFieldGrp(label='Suffix ',
                                              cal=[1, 'right'],
                                              cw2=[65, 260])
        cmds.button(label='Add Suffix', w=165, c=self._add_suffix)
        cmds.separator(h=10, style='in')

        # Rename And Number Section
        self.rename_field = cmds.textFieldGrp(label='Rename ',
                                              cal=[1, 'right'],
                                              cw2=[65, 260])

        cmds.rowColumnLayout(numberOfColumns=2,
                             columnWidth=[(1, 125), (2, 120)])
        self.start_field = cmds.textFieldGrp(label='Start # ',
                                             cal=[1, 'right'],
                                             cw2=[65, 45])
        cmds.text(label='Enter Number or Alphabet',
                  font='smallPlainLabelFont',
                  al='left')

        self.padding_field = cmds.intFieldGrp(label='Padding ',
                                              cal=[1, 'right'],
                                              cw2=[65, 45])
        cmds.text(label='Number of Digits',
                  font='smallPlainLabelFont',
                  al='left')

        cmds.setParent('..')
        cmds.rowColumnLayout(numberOfColumns=2,
                             columnWidth=[(1, 160), (2, 160)],
                             columnSpacing=[(1, 3), (2, 3)])
        cmds.button(label='Rename And Number', c=self._rename_and_number)
        cmds.button(label='Clear End Numbers', c=self._clear_end_numbers)
        cmds.setParent('..')

        cmds.separator(h=10, style='in')

        # Footer Section
        cmds.text(label='Version: ' + __version__,
                  font='tinyBoldLabelFont',
                  height=20)
        cmds.showWindow()
Example #58
0
	def togglePreviewOptions(self, enable):
		""" Toggle the preview options UI widgets.
		"""
		mc.intFieldGrp("prvSubds", edit=True, enable=enable)
Example #59
0
    def Constraints(self, *args):
        # creat a loc
        # creat constrain from rootM to loc, all axes
        # bake anim for loc
        # rootm --> parent -w
        # rootm delete keyfarme
        # creat constrain from loc to root ,tx,tz, rz
        # parent(rootm, root) 
        # creat constrain from loc to root ,all axes

        # startNum = cmds.playbackOptions(q = True , ast = True)
        # endNum = cmds.playbackOptions(q = True , aet = True)

        # returnMess = cmds.confirmDialog( title='Confirm', message='烘焙时间轴为' + str(startNum) + '-' + str(endNum), button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' )
        # if returnMess == "No":
        #     return
        startNum = cmds.intFieldGrp("StartFrame", q = True, value1 = True)
        endNum = cmds.intFieldGrp("EndFrame", q = True, value1 = True)
        cmds.currentUnit( time='ntsc', linear='centimeter')
        cmds.currentTime( startNum )

        locPos = cmds.spaceLocator()
        cmds.parentConstraint( 'Root_M', locPos, mo = True)
        

        cmds.bakeResults( locPos, simulation=True, t = (startNum, endNum), hierarchy= "below",  sb = 1, dic = True, pok = True, ral = False, rwl = False, cp = True)

        cmds.parent( 'Root_M', world=True )
        keyframelist = cmds.ls(type='animCurveTL')+cmds.ls(type='animCurveTA')+cmds.ls(type='animCurveTU')
        for i in keyframelist:
            if not ('Root_M' not in i):
                cmds.delete(i)
        
        ty = cmds.checkBoxGrp("translateAxes", q = True, value2 = True)
        tx = cmds.checkBoxGrp("translateAxes", q = True, value1 = True)

        trans = []
        if not ty:
            trans += "y"
        if not tx:
            trans += "x"
        orientConA = None
        ry = cmds.checkBoxGrp("rotateAxes", q = True, value2 = True)
        rot = ["x","z"]
        if ry:
            orientConA = cmds.orientConstraint(locPos, 'Root', mo = True, skip=rot)

        # parentConA = cmds.parentConstraint( locPos, 'Root', st=trans, sr=rot, mo = True)
        pointConA = cmds.pointConstraint(locPos, 'Root', mo = True, skip=trans)
        

        cmds.bakeResults( 'Root', simulation=True, t = (startNum, endNum), hierarchy= "below",  sb = 1, dic = True, pok = True, ral = False, rwl = False, cp = True)
        cmds.delete(pointConA)
        cmds.delete(orientConA)

        cmds.parent( 'Root_M', 'Root' )
        parentConB = cmds.parentConstraint( locPos, 'Root_M', mo = True)
        cmds.bakeResults( 'Root_M', simulation=True, t = (startNum, endNum), hierarchy= "below",  sb = 1, dic = True, pok = True, ral = False, rwl = False, cp = True)
        cmds.delete(parentConB)
        cmds.delete(locPos)

        keyframelist = cmds.ls(type='animCurveTL')+cmds.ls(type='animCurveTA')+cmds.ls(type='animCurveTU')
        keyCurve = []
        for i in keyframelist:
            if 'Root_M' in i or 'Root' in i:
                keyCurve.append(i)
        cmds.filterCurve(keyCurve)
Example #60
0
def _get_int_from_ui(ui_item_name):
    """
    Get the integer from the given int field
    """
    integer = cmds.intFieldGrp(ui_item_name, query=True, value=True)
    return integer