def updateImagePlaneEditSliders(self, *args): #update opacity slider try: currentOpacity = pm.getAttr(self.currentImgPlane[0] + ".alphaGain") pm.floatSliderGrp('opacitySlider', e=True, value=currentOpacity) currentColorOffset = pm.getAttr(self.currentImgPlane[0] + ".colorOffsetR") pm.floatSliderGrp('colorOffsetSlider', e=True, value=currentColorOffset) #currentSizeX = pm.getAttr(self.currentImgPlane[0] +".sizeX") #sliderMin= pm.floatSliderGrp('sizeSlider',q=True, minValue=True) #sliderMax= pm.floatSliderGrp('sizeSlider',q=True, maxValue=True) #currentSizeX = pm.util.clamp(currentSizeX, sliderMin, sliderMax) #pm.floatSliderGrp('sizeSlider',e=True, value=currentSizeX) #currentOffsetX = pm.getAttr(self.currentImgPlane[0] +".offsetX") #sliderMin= pm.floatSliderGrp('offsetXSlider',q=True, minValue=True) #sliderMax= pm.floatSliderGrp('offsetXSlider',q=True, maxValue=True) #3currentOffsetX = pm.util.clamp(currentOffsetX, sliderMin, sliderMax) #pm.floatSliderGrp('offsetXSlider',e=True, value=currentOffsetX) #currentOffsetY = pm.getAttr(self.currentImgPlane[0] +".offsetY") #sliderMin= pm.floatSliderGrp('offsetYSlider',q=True, minValue=True) #sliderMax= pm.floatSliderGrp('offsetYSlider',q=True, maxValue=True) #currentOffsetY = pm.util.clamp(currentOffsetY, sliderMin, sliderMax) #pm.floatSliderGrp('offsetYSlider',e=True, value=currentOffsetY) except: sys.stderr.write( 'Error Updating Image Plane Edit Panel. (in updateImagePlaneEditSliders)' ) return
def __sceneToCalc(*args): """ Copies the DMC-related V-Ray globals settings to the calculator UI.""" # V-ray globals globals = pm.PyNode('vraySettings') # V-ray scene settings to dictionary settings = { 'dmc_min_subdiv': globals.dmcMinSubdivs.get(), 'dmc_max_subdiv': globals.dmcMaxSubdivs.get(), 'dmc_threshold': globals.dmcs_adaptiveThreshold.get(), 'adaptive_min': globals.dmcs_adaptiveMinSamples.get(), 'adaptive_amt': globals.dmcs_adaptiveAmount.get(), 'subdivs_mult': globals.dmcs_subdivsMult.get() } # Transfer scene settings to UI pm.intSliderGrp('min_subdivs_in', e=True, v=settings['dmc_min_subdiv']) pm.intSliderGrp('max_subdivs_in', e=True, v=settings['dmc_max_subdiv']) pm.floatSliderGrp('thresh_val_in', e=True, v=settings['dmc_threshold']) pm.intSliderGrp('adapt_min_in', e=True, v=settings['adaptive_min']) pm.floatSliderGrp('adapt_amt_in', e=True, v=settings['adaptive_amt']) pm.floatFieldGrp('subdivs_mult_in', e=True, v=(settings['subdivs_mult'], 0, 0, 0)) # .. and refresh __uiUpdate() return True
def options_box_setup(self): self.optvars.add('zSplitBlendShapesBlendDistance', 'float', 2) self.optvars.add('zSplitBlendShapesPlane', 'int', 2) self.optvars.add('zSplitBlendShapesPlaneOrigin', 'float', 0) self.optvars.add('zSplitBlendShapesNamingPattern', 'string', '<name>_<L|R>') parent = pm.columnLayout(adjustableColumn=1) pm.optionMenuGrp('sbsList', label='Blend shape:', cc=self.fill_blend_target) self.fill_blend_shapes('sbsList|OptionMenu', False) pm.optionMenuGrp('sbsLeftOutput', label='Left output:') self.fill_blend_shapes('sbsLeftOutput|OptionMenu', True) pm.optionMenuGrp('sbsRightOutput', label='Right output:') self.fill_blend_shapes('sbsRightOutput|OptionMenu', True) # If something is selected, try to find a blend shape to select by default. selection = pm.ls(sl=True) if selection: history = pm.listHistory(selection) blend_shapes = pm.ls(history, type='blendShape') if blend_shapes: default_blend_shape = blend_shapes[0] self.select_blend_shape(default_blend_shape) pm.optionMenuGrp('sbsTargetList', label='Blend target:') self.fill_blend_target() pm.floatSliderGrp('sbsBlendDistance', label='Blend distance', field=True, min=0, max=10, fieldMinValue=0, fieldMaxValue=1000) pm.radioButtonGrp('sbsPlane', label='Plane:', numberOfRadioButtons=3, labelArray3=('XY', 'YZ', 'XZ')) pm.floatSliderGrp('sbsPlaneOrigin', label='Plane origin', v=0, min=0, max=1000) pm.textFieldGrp('sbsNamingPattern', label='Naming pattern')
def rh_dynamicJoint(): #Create a variable for the window name winName = 'DynamicJoint' winTitle = 'rh_DynamicJoint_prototype_v0.23' #Delete the window if it exists if pm.window(winName, exists = True): pm.deleteUI(winName, window = True) #Build the main window pm.window(winName, title = winTitle, sizeable = True) #name field pm.textFieldGrp('NameTFG',label = 'Set up name:', text = 'Ribbon45hp', ed = True) pm.columnLayout(adjustableColumn = True) #side pm.radioButtonGrp('ColSel',nrb = 3,label = 'Side:',la3 = ['l','m','r'],sl = 1) pm.columnLayout(adjustableColumn = True) #axis pm.radioButtonGrp('AxisSel',nrb = 3,label = 'Axis:',la3 = ['x','y','z'],sl = 1) pm.columnLayout(adjustableColumn = True) #ccSize pm.floatSliderGrp('Cc_Size',label = 'Control Size:',f = True,min = 1,max = 10,fmn = 1,fmx = 100,v = 1) pm.columnLayout(adjustableColumn = True) #joint number pm.intSliderGrp('Joint_Num',label = 'Number Of Joints:',f = True,min = 4,max = 49,fmn = 1,fmx = 100,v = 4) pm.columnLayout(adjustableColumn = True) #inbound pm.button(label = 'Ready For Tasking', command = 'inbound()') pm.columnLayout(adjustableColumn = True) #bringTheRain pm.button(label = 'Target Acquire', command = 'bringTheRain()') pm.columnLayout(adjustableColumn = True) #Show the window pm.showWindow(winName) pm.window(winName, edit = True, width = 378, height = 210)
def callback(cmd, _): if not (cmd.count('softSelect ') and pm.window('softselectskin', exists=True)): return current_radius = pm.softSelect(q=True, softSelectDistance=True) current_curve = pm.softSelect(q=True, softSelectCurve=True) try: pm.floatSliderGrp(slider, e=True, value=current_radius) pm.gradientControlNoAttr(curve, e=True, asString=current_curve) except NameError: pass
def jointsLayout(): global nameField, suffixField, jointNameField, jointSuffixField pm.setParent(rigging) frameLayout(label = 'Joints') joints = pm.columnLayout() rcl(nc = 4) button(jointTool, True, label = 'Joint Tool', width = 4) button(insertJointTool, True, label = 'Insert Joint', width = 4) button(mirrorJointsYZ, True, label = 'Mirror Jnts', width = 4) button(padding, True, label = 'Padding', width = 4) pm.setParent(joints) pm.text("Joint Renamer:", w = windowWidth) rcl(nc = 4) pm.text(l = "Name:", w = windowWidth/4) jointNameField = pm.textField(w = windowWidth/4) pm.text("Suffix:", w = windowWidth/4) jointSuffixField = pm.textField(w = windowWidth/4) pm.setParent(joints) rcl(nc = 1) renameButton = pm.button(l = "Rename Joints", w = windowWidth, c = pm.Callback(jointRenamer)) pm.setParent(joints) rcl(nc = 1) pm.columnLayout(adj = True, cal = "left", co = ["left", -50]) pm.floatSliderGrp(w = windowWidth, min = 0.01, max = 10.00, l = "Joint Size", pre = 2, f = True, v = .50, cc = jointSize, dc = jointSize, adj = True) rcl(nc = 1) pm.text(l = "Constraints:", w = windowWidth) pm.setParent(joints) rcl(nc = 5) global parentCheckbox, aimCheckbox, orientCheckbox, pointCheckbox, scaleCheckbox button(parentConstraintOn, True, label = 'Parent', width = 5) button(aimConstraintOn, True, label = 'Aim', width = 5) button(orientConstraintOn, True, label = 'Orient', width = 5) button(pointConstraintOn, True, label = 'Point', width = 5) button(scaleConstraintOn, True, label = 'Scale', width = 5) pm.setParent(joints) rcl(nc = 5) parentCheckbox = pm.checkBox(l = "Offset", w = windowWidth/5, v = True) aimCheckbox = pm.checkBox(l = "Offset", w = windowWidth/5, v = False) orientCheckbox = pm.checkBox(l = "Offset", w = windowWidth/5, v = False) pointCheckbox = pm.checkBox(l = "Offset", w = windowWidth/5, v = False) scaleCheckbox = pm.checkBox(l = "Offset", w = windowWidth/5, v = False) pm.setParent(joints) rcl(nc = 1) button(poleVectorConstraint, True, label = 'Pole Vector', width = 1) pm.setParent(joints) rcl(nc = 1) pm.setParent(joints) pm.columnLayout(adj = True, cal = "left", co = ["left", -50]) pm.floatSliderGrp(w = windowWidth, min = 0.01, max = 10.00, l = "IK Size", pre = 2, f = True, v = .50, cc = ikSize, dc = ikSize, adj = True) pm.setParent("..") rcl(nc = 2) button(rpIkHandleTool, True, label = "IK (RP)", width = 2) button(scIkHandleTool, True, label = "IK (SC)", width = 2) pm.setParent(joints) pm.setParent(rigging)
def option_box_save(self): self.optvars['zSplitBlendShapesBlendDistance'] = pm.floatSliderGrp( 'sbsBlendDistance', q=True, v=True) self.optvars['zSplitBlendShapesPlane'] = pm.radioButtonGrp('sbsPlane', q=True, select=True) self.optvars['zSplitBlendShapesPlaneOrigin'] = pm.floatSliderGrp( 'sbsPlaneOrigin', q=True, v=True) self.optvars['zSplitBlendShapesNamingPattern'] = pm.textFieldGrp( 'sbsNamingPattern', q=True, text=True)
def multi_SpotLightSettings(): # Spot Light Settings pm.rowColumnLayout(nc=2) pm.text(l='Spot Light Settings', w=102, al='left', en=False) pm.separator(w=marginWidth-102, h=14) pm.setParent(multiLight_layout) multi_coneAngle = pm.floatSliderGrp('hp3dConeAngleSlider', label='Cone Angle', field=True, min=0.0057, max=179.9943, v=40.000, pre=3, cw=[3, 20], dc=fun.partial(multi_floatChange, '.coneAngle', 'spotLight', 'hp3dConeAngleSlider')) multi_penumbraAngle = pm.floatSliderGrp('hp3dPenumbraAngleSlider', label='Penumbra Angle', field=True, min=-10.000, max=10.000, v=0.000, pre=3, cw=[3, 20], dc=fun.partial(multi_floatChange, '.penumbraAngle', 'spotLight', 'hp3dPenumbraAngleSlider')) multi_dropoff = pm.floatSliderGrp('hp3dDropoffSlider', label='Dropoff', field=True, min=0, max=255.000, v=0.000, pre=3, cw=[3, 20], dc=fun.partial(multi_floatChange, '.dropoff', 'spotLight', 'hp3dDropoffSlider')) pm.setParent(multiLight_layout)
def multi_ShadowSettings(): # Shadow Settings pm.rowColumnLayout(nc=2) pm.text(l='Shadow Settings', w=90, al='left', en=False) pm.separator(w=marginWidth-90, h=14) pm.setParent(multiLight_layout) multi_lightRadius = pm.floatSliderGrp('hp3dLightRadiusSlider', label='Light Radius', field=True, max=10.000, v=1.000, pre=3, cw=[3, 20], dc=fun.partial(multi_floatChange, '.lightRadius', 'spot & point', 'hp3dLightRadiusSlider')) multi_lightAngle = pm.floatSliderGrp('hp3dLightAngleSlider', label='Light Angle', field=True, max=10.000, v=1.000, pre=3, cw=[3, 20], dc=fun.partial(multi_floatChange, '.lightAngle', 'directionalLight', 'hp3dLightAngleSlider')) multi_shadowRays = pm.intSliderGrp('hp3dShadowRaysSlider', label='Shadow Rays', field=True, max=64, v=1, cw=[3, 20], dc=fun.partial(multi_intChange, '.shadowRays', 'all', 'hp3dShadowRaysSlider')) multi_rayDepth = pm.intSliderGrp('hp3dRayDepthSlider', label='Ray Depth Limit', field=True, max=15, v=3, cw=[3, 20], dc=fun.partial(multi_intChange, '.rayDepthLimit', 'all', 'hp3dRayDepthSlider')) pm.setParent(multiLight_layout)
def gui(): ''' Triggers the interface for zoomerate. ''' # Warning this is causeing issues with 2012 panel = pm.getPanel(wf=True) try: whichCam = pm.modelPanel(panel, q=1, camera=True) except RuntimeError: whichCam = pm.modelPanel('modelPanel4', q=1, camera=True) print 'Using: %s' % whichCam whichCamShape = pm.ls(whichCam, dag=True, shapes=True, ap=True) # Figure out what cameras to use when building the menu cameras = pm.ls(ca=True) diffCams = [] diffCams.extend(whichCamShape) diffCams.extend(cameras) print diffCams, len(diffCams) win_name = 'zoomer_win2' if pm.window(win_name, ex=True): pm.deleteUI(win_name) win = pm.window(win_name, s=0, ip=True, iconName='zoomer', w=400, h=180, t='Camera zoomeratro v1.0') main = pm.columnLayout() pm.frameLayout(borderVisible=True, labelVisible=True, labelAlign='cener', label='Zoom Options', marginWidth=5, marginHeight=5) pm.columnLayout() global which_cam_menu which_cam_menu = pm.optionMenuGrp(label='Camera to Zoom', cc=connect) pm.menuItem(label=whichCamShape[0]) for i in xrange(len(diffCams)-1): pm.menuItem(label=cameras[i]) horizontal_attr = '%s.horizontalFilmOffset' % whichCamShape[0] vertical_attr = '%s.verticalFilmOffset' % whichCamShape[0] overscan_attr = '%s.overscan' % whichCamShape[0] global horizontal_slider, vertical_slider, overscan_slider horizontal_slider = pm.floatSliderGrp(field=True, label='Horizontal', min=-3, max=3, pre=3, step=0.001) vertical_slider = pm.floatSliderGrp(field=True, label='Vertical', min=-3, max=3, pre=3, step=0.001) overscan_slider = pm.floatSliderGrp(field=True, label='Overscan', min=-3, max=3, pre=3, step=0.001) pm.connectControl(horizontal_slider, horizontal_attr) pm.connectControl(vertical_slider, vertical_attr) pm.connectControl(overscan_slider, overscan_slider) pm.button(label='Reset', c=reset) win.show()
def option_box_apply(self): kwargs = {} blend_shape = pm.optionMenuGrp('sbsList', q=True, v=True) blend_shape = pm.ls(blend_shape)[0] leftOutput = None rightOutput = None if pm.optionMenuGrp('sbsLeftOutput', q=True, sl=True) != 1: # "Same deformer as source" leftOutput = pm.optionMenuGrp('sbsLeftOutput', q=True, v=True) leftOutput = pm.ls(leftOutput)[0] if pm.optionMenuGrp('sbsRightOutput', q=True, sl=True) != 1: # "Same deformer as source" rightOutput = pm.optionMenuGrp('sbsRightOutput', q=True, v=True) rightOutput = pm.ls(rightOutput)[0] blendShapeTarget = '' if pm.optionMenuGrp('sbsTargetList', q=True, sl=True) != 1: # "All" blendShapeTarget = pm.optionMenuGrp('sbsTargetList', q=True, v=True) distance = pm.floatSliderGrp('sbsBlendDistance', q=True, v=True) origin = pm.floatSliderGrp('sbsPlaneOrigin', q=True, v=True) plane = pm.radioButtonGrp('sbsPlane', q=True, sl=True) kwargs['naming_pattern'] = pm.textFieldGrp('sbsNamingPattern', q=True, text=True) plane_to_axis = { 1: 2, 2: 0, 0: 1, } axis = plane_to_axis[plane] if blendShapeTarget != "": func = split_blend_shape_from_deformer kwargs['blendTarget'] = blendShapeTarget else: func = split_all_blend_shape_targets kwargs['blend_shape'] = blend_shape if leftOutput: kwargs['outputBlendShapeLeft'] = leftOutput if rightOutput: kwargs['outputBlendShapeRight'] = rightOutput split_args = {} kwargs['split_args'] = split_args split_args['fade_distance'] = distance split_args['axis'] = axis split_args['axis_origin'] = origin func(**kwargs)
def __uiGrok(): """UI parser""" ui = {} ui['subdivs_mult'] = pm.floatFieldGrp('subdivs_mult_in', q=True, v=True)[0] #ui['mode_select'] = pm.radioButtonGrp( 'mode_sel_in', q=True, sl=True ) ui['dmc_min_subdivs'] = pm.intSliderGrp('min_subdivs_in', q=True, v=True) ui['dmc_max_subdivs'] = pm.intSliderGrp('max_subdivs_in', q=True, v=True) ui['dmc_threshold'] = pm.floatSliderGrp('thresh_val_in', q=True, v=True) ui['adaptive_amt'] = pm.floatSliderGrp('adapt_amt_in', q=True, v=True) ui['adaptive_min'] = pm.intSliderGrp('adapt_min_in', q=True, v=True) ui['subdivs'] = pm.intSliderGrp('subdivs_in', q=True, v=True) return ui
def __init__(self): # Make a new window win_title = "Control Creator" win_title_safe = win_title.replace(" ", "_") if pm.window(win_title_safe, q=True, exists=True): pm.deleteUI(win_title_safe) window = pm.window(win_title_safe, title=win_title, toolbox=True, backgroundColor=(0.158, 0.254, 0.290)) window.show() with pm.verticalLayout(): pm.text( "1. Select joint in scene\n\n 2. Click controller shape that you want for it" ) pm.button("Cube", command=lambda x: create_control("cube")) pm.button("Circle", command=lambda x: create_control("circle")) with pm.horizontalLayout() as scale_layout: self.scale_float = pm.floatSliderGrp(field=True, maxValue=2, value=1.1, step=0.01) pm.button("Scale Control", command=self.increment_scale) scale_layout.redistribute(4, 2)
def multi_floatChange(attr, lightType, component, *args): value = pm.floatSliderGrp(component, q=True, v=True) sel_lights = pm.ls(sl=True, lights=True, dag=True) new_list = sortBy_type(sel_lights, lightType) for each in new_list: pm.setAttr(each+attr, value)
def multi_BasicSettings(): # Basic Settings pm.text(l='', h=5) multi_nameField = pm.textFieldGrp('hp3dNameField', l='Name', text='', cw=[2, 150], cc=fun.partial(multi_nameChange, 'hp3dNameField'), fcc=True) pm.rowColumnLayout(nc=2) pm.text(l='Basic Settings', w=75, al='left', en=False) pm.separator(w=marginWidth-75, h=14) pm.setParent(multiLight_layout) multi_color = pm.colorSliderGrp('hp3dColorSlider', label='Color', rgb=(1, 1, 1), cw=[3, 20], dc=fun.partial(multi_colorChange, '.color', 'all', 'hp3dColorSlider')) multi_intensity = pm.floatSliderGrp('hp3dIntensitySlider', label='Intensity', field=True, v=1.000, fmx=1000000000, pre=3, cw=[3, 20], dc=fun.partial(multi_floatChange, '.intensity', 'all', 'hp3dIntensitySlider')) # pm.text(l='', h=3) # GUI SPACER pm.rowColumnLayout(nc=2) pm.text(l='', w=142) # GUI SPACER global multi_illDefault_box multi_illDefault_box = pm.checkBox(l='Illuminates by Default', v=1, cc=multi_illDefault) pm.setParent(multiLight_layout) pm.rowColumnLayout(nc=3) pm.text(l='', w=142) # GUI SPACER multi_emitDiff_box = pm.checkBox('hp3dEmitDiffCheckbox', l='Emit Diffuse', v=1, w=120, cc=fun.partial(multi_checkboxChange, '.emitDiffuse', 'all', 'hp3dEmitDiffCheckbox')) multi_emitSpec_box = pm.checkBox('hp3dEmitSpecCheckbox', l='Emit Specular', v=1, cc=fun.partial(multi_checkboxChange, '.emitSpecular', 'all', 'hp3dEmitSpecCheckbox')) pm.setParent(multiLight_layout) pm.rowColumnLayout(nc=3) pm.text(l='Decay Rate', w=140, al='right') pm.text(l='', w=3) multi_decayRate_menu = pm.optionMenu('hp3dDecayRateMenu', bgc=primary_componentColor, cc=fun.partial(multi_menuChange, '.decayRate', 'not directional', 'hp3dDecayRateMenu')) pm.menuItem(l='No Decay', da=0) pm.menuItem(l='Linear', da=1) pm.menuItem(l='Quadratic', da=2) pm.menuItem(l='Cubic', da=3) pm.setParent(multiLight_layout)
def createTrail(): if pm.window('trailUI',ex=1): pm.deleteUI('trailUI') pm.window('trailUI') pm.columnLayout(adj=1) fsSample = pm.floatSliderGrp('sampleSlider', label='Sample by', cw=(1,70), adj=1, en=1,minValue=0.01, maxValue=100, fieldMinValue=0.01, fieldMaxValue=100,pre=2, field=1, v=1) pm.separator (height=4,style="in") startFrame = pm.playbackOptions(q=1,min=1) currentFrame = pm.currentTime(q=1) if currentFrame > startFrame: startFrame = currentFrame pm.intSliderGrp('startFrameSlider', label='Start frame', cw=(1,70), adj=1, en=1,minValue=0, maxValue=100, fieldMinValue=0, fieldMaxValue=10000, field=1, v=startFrame) pm.popupMenu(button=3,pmc = functools.partial(setTime,'start')) pm.intSliderGrp('endFrameSlider', label='End frame', cw=(1,70), adj=1, en=1,minValue=0, maxValue=100, fieldMinValue=0, fieldMaxValue=10000, field=1, v=startFrame+30) pm.popupMenu(button=3,pmc = functools.partial(setTime,'end')) pm.intSliderGrp('trailDivisions', label='Trail divisions', cw=(1,70), adj=1, en=1,minValue=1, maxValue=100, fieldMinValue=1, fieldMaxValue=10000, field=1, v=40) pm.separator (height=4,style="in") cbUvDistorted = pm.checkBox('cbUV',l='UV distorted',v=1) pm.separator (height=4,style="in") rowBtn = pm.rowColumnLayout(numberOfRows=1) pm.button(l='Create Trail',command=functools.partial(createTrailMesh)) pm.button(l='Rebuil uvs',c=functools.partial(createTrailUv,'')) pm.button(l='ELP !!!',c=openHelpPage) pm.showWindow('trailUI')
def jntToCrv(self, jnts=None, size=1.0, shape='sphere', *args): if not jnts: try: jnts = pm.ls(sl=True) except: pass if not jnts: pm.warning( 'ehm_tools...JntToCrv: select joints to create control curve for them.' ) else: jnts = pm.ls(jnts) try: # if in UI mode, get info from UI shape = pm.optionMenuGrp(self.shapeType, q=True, value=True) size = pm.floatSliderGrp(self.sizeSlider, q=True, value=True) except: pass shapeCmd = {'sphere': SphereCrv, 'cube': CubeCrv, 'circle': Circle8Crv} self.newShapes = [] for jnt in jnts: # if not (jnt.type()=='joint') : # pm.warning('ehm_tools...JntToCrv: %s is not a joint, skipped!'% jnt) # else: currentCircle = shapeCmd[shape](size=size) shapeNode = currentCircle.getShape() pm.select(shapeNode, jnt) pm.parent(add=True, shape=True) pm.delete(currentCircle) self.newShapes.append(jnt.getShape())
def __init__(self, name): self.name = name if pm.window(self.name, q=True, exists=True): pm.deleteUI(self.name) self.window = pm.window(self.name, width=300) pm.columnLayout(columnOffset=("both", 20), height=100, rowSpacing=10) pm.separator() self.scale = pm.floatSliderGrp(label="Camera Scale", field=True, value=0.1, precision=3, columnAlign=(1, "left")) self.single = pm.checkBoxGrp(label="Export Single Frame", value1=False, columnAlign=(1, "left")) self.houexp = pm.checkBoxGrp(label="Export Houdini Camera", value1=True, columnAlign=(1, "left")) self.mayaexp = pm.checkBoxGrp(label="Export Maya Camera", value1=True, columnAlign=(1, "left")) self.range = pm.intFieldGrp( numberOfFields=2, label="Frame Range", value1=int(pm.playbackOptions(query=True, min=True)), value2=int(pm.playbackOptions(query=True, max=True)), columnAlign=(1, "left")) pm.separator() pm.rowLayout(numberOfColumns=2, width=300, adjustableColumn=1) pm.button(label="Export", width=300, command=self.exportCamera) pm.showWindow(self.name)
def spine_init ( self, size=5.0, limbName='spine', mode='biped', numOfJnts=4 , *args ): self.spine_initJnts=[] self.tmpCrv = None try:# if in UI mode, get number of joints from UI size = pm.floatSliderGrp( self.spineSizeF, q=True, value=True) limbName = pm.textField( self.limbNameTF, q=True, text=True) selectedMode = pm.radioCollection( self.characterModeRC, q=True, select=True) mode = pm.radioButton( selectedMode, q=True, label=True ).lower() numOfJnts = pm.intSliderGrp( self.numOfInitJntsIS, q=True, value=True) except: pass curveCVs=[] curveCVsCount=[] for i in range(numOfJnts): pm.select (clear=True) if mode=='biped': jntPos = ( 0, size+(size*1.0/(numOfJnts-1)*i), 0 ) elif mode=='quadruped': jntPos = ( 0, size, (size*1.0/(numOfJnts-1)*i)-size/2.0 ) else: pm.error('ehm_tools...Spine: mode arg accepts "biped" or "quadruped" only!') self.spine_initJnts.append( pm.joint ( p = jntPos , name = "%s_%s_initJnt"%(limbName,i+1) ) ) curveCVs.append( jntPos ) curveCVsCount.append( i ) self.tmpCrv = pm.curve( d=1, p=curveCVs , k=curveCVsCount ) self.tmpCrv.getShape().template.set(True) pm.skinCluster( self.spine_initJnts,self.tmpCrv)
def gui(): win = pm.window(w=200, h=300, title="Values") main = pm.columnLayout() global border_slider border_slider = pm.floatSliderGrp( field=True, min=0.01, max=10, dc=border_size ) # border_slider now contains the slider object. win.show()
def gui(): win = pm.window(w=200, h=300, title='Values') main = pm.columnLayout() global border_slider border_slider = pm.floatSliderGrp( field=True, min=0.01, max=10, dc=border_size) # border_slider now contains the slider object. win.show()
def showUI(self): self.interface = {} windowTitle = 'Out Placeholder' if pmc.window(windowTitle.replace(" ", "_"), exists=True): pmc.deleteUI(windowTitle.replace(" ", "_"), window=True) columWidth = [[1,60], [2,60], [3,250]] self.interface['mainWindow'] = pmc.window(windowTitle, title=windowTitle) self.interface['layout'] = pmc.verticalLayout() self.interface['text'] = pmc.text(l=str(self.shaders.keys()), fn='boldLabelFont', h=30) self.interface['rotate'] = pmc.floatSliderGrp(label='Rotate UV', value=0, field=True, columnWidth=columWidth, step=0.01, minValue=-360.0, maxValue=360.0, fieldMinValue=-360.0, fieldMaxValue=360.0, dragCommand=functools.partial(self.rotate), changeCommand=functools.partial(self.rotate)) self.interface['repeat'] = pmc.floatSliderGrp(label='Repeat UV', value=1, field=True, columnWidth=columWidth, step=0.01, minValue=0.001, maxValue=10.0, fieldMinValue=0.001, fieldMaxValue=10.0, dragCommand=functools.partial(self.repeat), changeCommand=functools.partial(self.repeat)) self.interface['offsetV'] = pmc.floatSliderGrp(label='Offset U', value=0, field=True, columnWidth=columWidth, step=0.01, minValue=-1.0, maxValue=1.0, fieldMinValue=-1.0, fieldMaxValue=1.0, fs=0.01, dragCommand=functools.partial(self.offsetU), changeCommand=functools.partial(self.offsetU)) self.interface['offsetV'] = pmc.floatSliderGrp(label='Offset V', value=0, field=True, columnWidth=columWidth, step=-0.01, minValue=-1.0, maxValue=1.0, fieldMinValue=-1.0, fieldMaxValue=1.0, fs=0.01, dragCommand=functools.partial(self.offsetV), changeCommand=functools.partial(self.offsetV)) self.interface['execute'] = cmds.button(l='Get the (real) power!', c=functools.partial(self.execute)) self.interface['layout'].redistribute() self.interface['mainWindow'].show()
def UI(self): # create window if pm.window( 'ehm_JntToCrv_UI', exists=True ): pm.deleteUI( 'ehm_JntToCrv_UI' ) pm.window( 'ehm_JntToCrv_UI', title='Create Curve Shape On Joints', w=270, h=100, mxb=False, mnb=False, sizeable=False ) # main layout mainLayout = pm.columnLayout(w=270, h=130) formLayout = pm.formLayout(w=260, h=120) frameLayout = pm.frameLayout(borderStyle='etchedIn', labelVisible=False) pm.setParent( formLayout ) # num of joints slider self.shapeType = pm.optionMenuGrp( label='shape type: ' , h=30 , columnAttach2=('left','left') , columnOffset2=(20,0) , columnWidth2=(90,60) ) pm.menuItem(label="sphere") pm.menuItem(label="cube") pm.menuItem(label="circle") # size of shapes self.sizeSlider = pm.floatSliderGrp( label='shape size: ' , value=1 , minValue=0.0 , maxValue=20 , fieldMaxValue=10000, h=30, field=True , columnAttach3=('left','left','left' ) , columnOffset3=(20,0,0 ) , columnWidth3=(80,50,80) ) # button button = pm.button( label='apply', w=100, h=30, c=partial( self.jntToCrv, None, 1.0 , 'sphere' ) ) # place controls pm.formLayout( formLayout, edit=True, attachForm=(frameLayout,'left', 3) ) pm.formLayout( formLayout, edit=True, attachForm=(frameLayout,'right', 3) ) pm.formLayout( formLayout, edit=True, attachForm=(frameLayout,'top', 3) ) pm.formLayout( formLayout, edit=True, attachForm=(frameLayout,'bottom', 38) ) pm.formLayout( formLayout, edit=True, attachForm=(self.shapeType,'left', 0) ) pm.formLayout( formLayout, edit=True, attachForm=(self.shapeType,'top', 8) ) pm.formLayout( formLayout, edit=True, attachForm=(self.sizeSlider,'left', 5) ) pm.formLayout( formLayout, edit=True, attachForm=(self.sizeSlider,'top', 40) ) pm.formLayout( formLayout, edit=True, attachForm=(button,'left', 5) ) pm.formLayout( formLayout, edit=True, attachForm=(button,'right', 5) ) pm.formLayout( formLayout, edit=True, attachForm=(button,'bottom', 5) ) # show window pm.showWindow( 'ehm_JntToCrv_UI' )
def on_opacity_change(self, *args): try: sliderValue = pm.floatSliderGrp('opacitySlider', q=True, value=True) pm.setAttr(self.currentImgPlane[0] + ".alphaGain", sliderValue) except: sys.stderr.write('Error opacity_change.') return
def UI(self): # create window if pm.window( 'ehm_CtrlForThis_UI', exists=True ): pm.deleteUI( 'ehm_CtrlForThis_UI' ) pm.window( 'ehm_CtrlForThis_UI', title='Create Control For Objects', w=280, h=100, mxb=False, mnb=False, sizeable=False ) # main layout mainLayout = pm.columnLayout(w=280, h=130) formLayout = pm.formLayout(w=270, h=120) frameLayout = pm.frameLayout(borderStyle='etchedIn', labelVisible=False) pm.setParent( formLayout ) # num of joints slider self.shapeType = pm.optionMenuGrp( label='shape type: ' , h=30 , columnAttach2=('left','left') , columnOffset2=(20,0) , columnWidth2=(90,60) ) pm.menuItem(label="sphere") pm.menuItem(label="cube") pm.menuItem(label="circle") # size of shapes self.sizeSlider = pm.floatSliderGrp( label='shape size: ' , value=1 , minValue=0.0 , maxValue=20 , fieldMaxValue=10000, h=30, field=True , columnAttach3=('left','left','left' ) , columnOffset3=(20,0,0 ) , columnWidth3=(80,60,120) ) # button button = pm.button( label='apply', w=100, h=30, c=partial( self.ctrlForThis, None, 1.0 , 'sphere' ) ) # place controls pm.formLayout( formLayout, edit=True, attachForm=(frameLayout,'left', 3) ) pm.formLayout( formLayout, edit=True, attachForm=(frameLayout,'right', 3) ) pm.formLayout( formLayout, edit=True, attachForm=(frameLayout,'top', 3) ) pm.formLayout( formLayout, edit=True, attachForm=(frameLayout,'bottom', 38) ) pm.formLayout( formLayout, edit=True, attachForm=(self.shapeType,'left', 0) ) pm.formLayout( formLayout, edit=True, attachForm=(self.shapeType,'top', 8) ) pm.formLayout( formLayout, edit=True, attachForm=(self.sizeSlider,'left', 5) ) pm.formLayout( formLayout, edit=True, attachForm=(self.sizeSlider,'top', 40) ) pm.formLayout( formLayout, edit=True, attachForm=(button,'left', 5) ) pm.formLayout( formLayout, edit=True, attachForm=(button,'right', 5) ) pm.formLayout( formLayout, edit=True, attachForm=(button,'bottom', 5) ) # show window pm.showWindow( 'ehm_CtrlForThis_UI' )
def Pr(self,*args): #Read Parameters: subx = pm.intSliderGrp(self.GlobalVars["SubX"], q = True, value = True) suby = pm.intSliderGrp(self.GlobalVars["SubY"], q = True, value = True) grav = pm.floatSliderGrp(self.GlobalVars["GraV"], q = True, value = True) print subx print suby print grav
def __init__(self, value, min, max, name, ceObj): self.name = name self.ceObj = ceObj self.undoState = False self.attr = pm.floatSliderGrp(field=True, l=self.name, value=value, pre=3, enable=False, minValue=min, maxValue=max, dc=lambda *args: self.set(cc=False), cc=lambda *args: self.set(cc=True), cw3=[96, 64, 128]) pm.scriptJob(event=['Undo', self.get], protected=True, p=self.attr)
def on_offsetY_change(self, *args): self.disconnectMover() try: sliderValue = pm.floatSliderGrp('offsetYSlider', q=True, value=True) pm.setAttr(self.currentImgPlane[0] + ".offsetY", sliderValue) except: sys.stderr.write('Error offsetY_change.') return
def on_size_change(self, *args): self.disconnectMover() try: sliderValue = pm.floatSliderGrp('sizeSlider', q=True, value=True) print("onchange") pm.setAttr(self.currentImgPlane[0] + ".sizeX", sliderValue) except: sys.stderr.write('Error on_size_change.') return
def on_colorOffset_change(self, *args): try: sliderValue = pm.floatSliderGrp('colorOffsetSlider', q=True, value=True) pm.setAttr(self.currentImgPlane[0] + ".colorOffsetR", sliderValue) pm.setAttr(self.currentImgPlane[0] + ".colorOffsetG", sliderValue) pm.setAttr(self.currentImgPlane[0] + ".colorOffsetB", sliderValue) except: sys.stderr.write('Error colorOffset_change.') return
def ModuleWeights_sliderCallback(self, _controlledAttribute, _weightAttributes, *args): value = float(args[0]) currentTotalWeight = 0.0 for attr in _weightAttributes: if attr != _controlledAttribute: currentTotalWeight += pm.getAttr("%s.%s" %(self.settingsLocator, attr)) if currentTotalWeight + value > 1.0: value = 1.0 - currentTotalWeight pm.setAttr("%s.%s" %(self.settingsLocator, _controlledAttribute), value) pm.floatSliderGrp(self.UIElements[_controlledAttribute], edit = True, value = value) newTotalWeight = currentTotalWeight + value creationPoseWeight = 1.0 - newTotalWeight pm.setAttr("%s.creationPoseWeight" %self.settingsLocator, creationPoseWeight) self.ModuleWeights_updateMatchingButton()
def gui(): # Creating a window. win = pm.window(w=150, h=100) main = pm.columnLayout() # Interface components go after the main layout, # Different components simular flags # They all have a rectangle bounding box! pm.button(w=150, command=work) pm.textFieldButtonGrp(label='Float Attribute', buttonLabel='Apply', buttonCommand=work) pm.intField(w=150, changeCommand=work) pm.floatSliderGrp(changeCommand=work) pm.floatSliderGrp(cc=work, dc=work) # Showing a window win.show()
def __init__(self, value=0, minValue=0, maxValue=32, name=None, obj=None, type_='int', en=False, fmx=10000, fmn=-10000): self.name = name self.obj = obj self.undoState = False if type_ == 'float': self.attr_ = pm.floatSliderGrp(field=True, l=self.name, value=value, minValue=minValue, maxValue=maxValue, cc=self.set, dc=self.set, pre=5, cw3=[72, 64, 128], en=en, fmx=fmx, fmn=fmn) elif type_ == 'int': self.attr_ = pm.intSliderGrp(field=True, l=self.name, value=value, minValue=minValue, maxValue=maxValue, cc=self.set, dc=self.set, cw3=[72, 64, 128], en=en, fmn=fmn, fmx=fmx)
def gui(): # Creating a window. win = pm.window(w=150, h=100) main = pm.columnLayout() # Interface components go after the main layout, # Different components simular flags # They all have a rectangle bounding box! pm.button(w=150, command=work) pm.textFieldButtonGrp( label='Float Attribute', buttonLabel='Apply', buttonCommand=work) pm.intField(w=150, changeCommand=work) pm.floatSliderGrp(changeCommand=work) pm.floatSliderGrp(cc=work, dc=work) # Showing a window win.show()
def createSliderObj( self ): """ creates a Slider Element """ # control=str(mel.scriptedPanel(self.__name__, # q=1,control=1)) # mel.setParent(control) # mel.setParent(self.panelUIpath) if mel.scrollLayout(self._scrollField, ex=True): # mel.setParent(control+'|'+self._scrollField+'|'+self._rowColumn) mel.setParent( self._ActionCol) mel.separator(h=10,style="none") ObjUIpath = mel.frameLayout(mw=10,l="Sliders") mel.columnLayout('sampleCol',adj=True) mel.separator(h=10,style="none") mel.floatSliderGrp('fsg1',v=self.gSampleState['fsg1'], l="Property A",f=True) mel.floatSliderGrp('fsg2',v=self.gSampleState['fsg2'], l="Property B",f=True) mel.floatSliderGrp('fsg3',v=self.gSampleState['fsg3'], l="Property C",f=True) mel.separator(h=10,style="none") # mel.setParent('..') # mel.setParent('..') return ObjUIpath
def settings(): """setup vray before baking""" global size size = pm.intSliderGrp("baker_size", q=True, v=True) pm.optionVar(intValue=("vrayBakeType", 2)) pm.optionVar(intValue=("vraySkipNodesWithoutBakeOptions", 0)) pm.optionVar(intValue=("vrayAssignBakedTextures", 0)) pm.optionVar(stringValue=("vrayBakeOutputPath", textures_dir)) pm.optionVar(intValue=("vrayBakeType", 2)) try: options = nt.VRayBakeOptions("vrayDefaultBakeOptions") except pm.MayaNodeError: options = pm.createNode("VRayBakeOptions", n="vrayDefaultBakeOptions") options.setAttr("resolutionX", size) options.setAttr("outputTexturePath", textures_dir, type="string") options.setAttr("filenamePrefix", "") # ao material if not pm.objExists("ao_material"): material = pm.createNode("VRayMtl", n="ao_material") texture = pm.createNode("VRayDirt", n="ao_texture") texture.connectAttr("outColor", material.attr("color")) texture.connectAttr("outColor", material.attr("illumColor")) else: texture = nt.DependNode("ao_texture") texture.setAttr("radius", pm.floatSliderGrp("baker_radius", q=True, v=True)) texture.setAttr("falloff", pm.floatSliderGrp("baker_falloff", q=True, v=True)) texture.setAttr("subdivs", pm.intSliderGrp("baker_sub", q=True, v=True)) # shadows catch material if not pm.objExists("shadow_material"): material = pm.createNode("VRayMtl", n="shadow_material") material.setAttr("color", (1, 1, 1))
def CreateClothWindow(self,*args): if pm.window("cloth", exists = True): pm.deleteUI("cloth") cloth = pm.window("Create Cloth", t = "Create Cloth", w = 400, h = 600) pm.columnLayout(adj = True, cal = "center", columnAttach=('both', 25)) pm.separator(h = 30) pm.text("Cloth Simulation with PBD and exact CCD", font = "boldLabelFont") pm.separator(h = 30) pm.frameLayout(label = "Cloth Subdivisions", collapsable = True, borderStyle = "etchedIn") self.GlobalVars["SubX"] = pm.intSliderGrp(l = "Subdivision X", min = 1, max = 20, value = 10, field = True) self.GlobalVars["SubY"] = pm.intSliderGrp(l = "Subdivision Y", min = 1, max = 20, value = 10, field = True) pm.setParent("..") pm.frameLayout(label = "Position Constraints", collapsable = True, borderStyle = "etchedIn") pm.gridLayout(numberOfColumns = 2, cellWidthHeight = (180,20)) self.GlobalVars["Locator_LeftTopCorner"] = pm.checkBox(label = "Locator_LeftTopCorner") self.GlobalVars["Locator_RightTopCorner"] = pm.checkBox(label = "Locator_RightTopCorner") self.GlobalVars["Locator_RightBottomCorner"] = pm.checkBox(label = "Locator_RightBottomCorner") self.GlobalVars["Locator_LeftBottomCorner"] = pm.checkBox(label = "Locator_LeftBottomCorner") self.GlobalVars["Locator_Middle"] = pm.checkBox(label = "Locator_Middle") pm.setParent("..") pm.setParent("..") pm.frameLayout(label = "Gravity", collapsable = True, borderStyle = "etchedIn") self.GlobalVars["GraV"] = pm.floatSliderGrp(l = "Gravity", min = 0.0, max = 9.8, field = True) pm.setParent("..") pm.frameLayout(label = "Wind Force", collapsable = True, borderStyle = "etchedIn") self.GlobalVars["Wind_X"] = pm.floatSliderGrp(l = "Wind Force_X", min = -10.0, max = 10, value = 0.0, field = True) self.GlobalVars["Wind_Y"] = pm.floatSliderGrp(l = "Wind Force_Y", min = -10.0, max = 10, value = 0.0, field = True) self.GlobalVars["Wind_Z"] = pm.floatSliderGrp(l = "Wind Force_Z", min = -10.0, max = 10, value = 0.0, field = True) self.GlobalVars["Noise"] = pm.floatSliderGrp(l = "Noise", min = 0.0, max = 2, value = 0.0, field = True) pm.setParent("..") pm.separator(h = 10) self.GlobalVars["DefaultText"] = pm.checkBox(label = "Default Texture") pm.separator(h = 10) pm.button(l = "Create", c = self.CreateCloth) pm.showWindow(cloth)
def spine_init(self, size=5.0, limbName='spine', mode='biped', numOfJnts=4, *args): self.spine_initJnts = [] self.tmpCrv = None try: # if in UI mode, get number of joints from UI size = pm.floatSliderGrp(self.spineSizeF, q=True, value=True) limbName = pm.textField(self.limbNameTF, q=True, text=True) selectedMode = pm.radioCollection(self.characterModeRC, q=True, select=True) mode = pm.radioButton(selectedMode, q=True, label=True).lower() numOfJnts = pm.intSliderGrp(self.numOfInitJntsIS, q=True, value=True) except: pass curveCVs = [] curveCVsCount = [] for i in range(numOfJnts): pm.select(clear=True) if mode == 'biped': jntPos = (0, size + (size * 1.0 / (numOfJnts - 1) * i), 0) elif mode == 'quadruped': jntPos = (0, size, (size * 1.0 / (numOfJnts - 1) * i) - size / 2.0) else: pm.error( 'ehm_tools...Spine: mode arg accepts "biped" or "quadruped" only!' ) self.spine_initJnts.append( pm.joint(p=jntPos, name="%s_%s_initJnt" % (limbName, i + 1))) curveCVs.append(jntPos) curveCVsCount.append(i) self.tmpCrv = pm.curve(d=1, p=curveCVs, k=curveCVsCount) self.tmpCrv.getShape().template.set(True) pm.skinCluster(self.spine_initJnts, self.tmpCrv)
def createCurveFromPoints(vert1, vert2): startFrame = pm.intSliderGrp('startFrameSlider', q=1, v=1) endFrame = pm.intSliderGrp('endFrameSlider', q=1, v=1) points = [] tempPos = [0, 0, 0] sample = pm.floatSliderGrp('sampleSlider', q=1, v=1) for f in drange(startFrame, endFrame + 1, sample): pm.currentTime(f) pos = getMidPointPos(vert1, vert2) if pos != tempPos: points.append(pos) tempPos = pos crvName = vert1.name().split('.')[0] + '_trail_crv' crv = pm.curve(name=crvName, ep=points) pm.currentTime(startFrame) return crv
def createCurveFromPoints(vert1,vert2): startFrame = pm.intSliderGrp('startFrameSlider',q=1,v=1) endFrame = pm.intSliderGrp('endFrameSlider',q=1,v=1) points = [] tempPos = [0,0,0] sample = pm.floatSliderGrp('sampleSlider',q=1,v=1) for f in drange(startFrame,endFrame+1,sample): pm.currentTime(f) pos = getMidPointPos(vert1, vert2) if pos != tempPos: points.append(pos) tempPos = pos crvName = vert1.name().split('.')[0] + '_trail_crv' crv = pm.curve(name = crvName, ep=points) pm.currentTime(startFrame) return crv
def SetupActiveModuleControls(self): existingControls = pm.columnLayout(self.UIElements["activeModuleColumn"], query = True, childArray = True) if existingControls != None: pm.deleteUI(existingControls) largeButtonSize = 100 enumOptionWidth = self.windowWidth - (2 * largeButtonSize) self.settingsLocator = "%s:SETTINGS" %self.selectedBlueprintModule activeModuleAttribute = "%s.activeModule" %self.settingsLocator currentEntries = pm.attributeQuery("activeModule", node = self.settingsLocator, listEnum = True) enable = True if currentEntries[0] == "None": enable = False self.UIElements["activeModue_rowLayout"] = pm.rowLayout(numberOfColumns = 3, adjustableColumn = 1, columnAttach3 = ("both", "both", "both"), columnWidth3 = (enumOptionWidth, largeButtonSize, largeButtonSize), parent = self.UIElements["activeModuleColumn"]) attributes = pm.listAttr(self.settingsLocator, keyable = False) weightAttributes = [] for attr in attributes: if attr.find("_weight") != -1: weightAttributes.append(attr) self.UIElements["activeModule"] = pm.attrEnumOptionMenu(label = "Active Module", width = enumOptionWidth, attribute = activeModuleAttribute, changeCommand = partial(self.ActiveModule_enumCallback, weightAttributes), enable = enable, parent = self.UIElements["activeModue_rowLayout"]) self.UIElements["keyModuleWeights"] = pm.button(label = "Key All", command = partial(self.KeyModuleWeights, weightAttributes), enable = enable, parent = self.UIElements["activeModue_rowLayout"]) self.UIElements["graphModuleWeights"] = pm.button(label = "Graph Weights", command = self.GraphModuleWeights, enable = enable, parent = self.UIElements["activeModue_rowLayout"]) self.UIElements["moduleWeights_frameLayout"] = pm.frameLayout(collapsable = True, collapse = False, label = "Module Weights", height = 100, collapseCommand = self.ModuleWeights_UICollapse, expandCommand = self.ModuleWeights_UIExpand, parent = self.UIElements["activeModuleColumn"]) pm.scrollLayout("frame_scroll", horizontalScrollBarThickness = 0, parent = self.UIElements["moduleWeights_frameLayout"]) pm.columnLayout("frameScroll_column", adjustableColumn = True, parent = "frame_scroll") pm.attrFieldSliderGrp(attribute = "%s.creationPoseWeight" %self.settingsLocator, enable = False, parent = "frameScroll_column") pm.separator(style = "in", parent = "frameScroll_column") for attr in weightAttributes: self.UIElements[attr] = pm.floatSliderGrp(label = attr, field = True, precision = 4, minValue = 0.0, maxValue = 1.0, value = pm.getAttr("%s.%s" %(self.settingsLocator, attr)), changeCommand = partial(self.ModuleWeights_sliderCallback, attr, weightAttributes), parent = "frameScroll_column") parentUIElement = self.UIElements["moduleWeights_frameLayout"] self.Create_moduleWeightScriptJob(parentUIElement, weightAttributes) self.ModuleWeights_updateMatchingButton()
def bringTheRain(): global jointGuides,setUpName,axis,size,side axisSel = pm.radioButtonGrp('AxisSel',q = True,sl = True) size = pm.floatSliderGrp('Cc_Size',q = True,v = True) if axisSel == 1: axis = 'x' elif axisSel == 2: axis = 'y' elif axisSel == 3: axis = 'z' jointGuidesGrp.v.set(0) guidePos = [x.getTranslation(space = 'world') for x in jointGuides] guideRot = [x.getRotation(space = 'world') for x in jointGuides] bc = BoneChain(baseName = setUpName,side = side,type = 'jj') bc.fromList(guidePos,guideRot,autoOrient = 1) fk = FkChain(baseName = setUpName + 'Fk',side = side,size = size,type = 'fk',aimAxis = axis) fk.fromList(guidePos,guideRot,autoOrient = 1) ik = dynamicIkChain(baseName = setUpName + 'DynIk',side = side,type = 'ik') ik.fromList(guidePos,guideRot,autoOrient = 1) #create main Cc mainCtrl = Control(side,setUpName,size = size * 1.5,aimAxis = axis) mainCtrl.circleCtrl() pm.xform(mainCtrl.controlGrp,ws = 1,matrix = ik.chain[0].worldMatrix.get()) # jjPos = pm.xform(ik.chain[0],query=1,ws=1,rp=1) # pm.move(jjPos[0],jjPos[1],jjPos[2],mainCtrl.controlGrp) blendData = BoneChain.blendTwoChains(fk.chain,ik.chain,bc.chain, mainCtrl.control,'Dynamic',setUpName,side) lockAndHideAttr(mainCtrl.control , ['sx','sy','sz']) jointGuidesGrp.setParent(ik.dynMainGrp) ik.hairFol[0].setParent(mainCtrl.control) ik.chain[0].setParent(mainCtrl.control) fk.chain[0].setParent(mainCtrl.control) bc.chain[0].setParent(mainCtrl.control)
def __scaleCv(self,*args): scaleValue = pm.floatSliderGrp(self.sizeFloatSlider,q=1,v=1) if(scaleValue > 0): scaleValue = scaleValue+1 if(scaleValue<0): scaleValue = 1-abs(scaleValue)/2 sel = pm.ls(sl = 1) pm.select(cl = 1) for cv in sel: pm.select(cv + '.cv[*]',add = 1) pm.scale(scaleValue,scaleValue,scaleValue,r=1) pm.select(cl = 1) for obj in sel: pm.select(obj,add = 1)
def create(self): with pm.columnLayout(adj=True, parent=self.uiparent, rs=2) as self.masterCol: with pm.rowColumnLayout(nc=2, co=[(1, 'left', 77), (2, 'left', 5)]): pm.text(l='Rig Scale: ') self.rigSizeFloatSliderGrp = pm.floatSliderGrp(f=True, v=1, max=5, min=0.01, fs=0.01, cw=([1,33], [2,110]), pre=2) with pm.rowColumnLayout(nc=4, co=[(1, 'left', 105), (2, 'left', 5), (3, 'left', 12), (4, 'left', 5)]): pm.text(l='elem') self.elemTxtFld = pm.textField(w=65, ed=True) pm.text(l='side') with pm.optionMenu(w=40) as self.sideMenu: pm.menuItem(l='') pm.menuItem(l='LFT') pm.menuItem(l='RGT') with pm.rowColumnLayout(nc=3, co=[(1, 'left', 95), (2, 'left', 5), (3, 'left', 5)]): pm.text(l='parent') self.rigParentTxtFld = pm.textField(w=142, ed=False) self.loadParentButt = pm.button(l='<<', c=pm.Callback(self.loadRigParent)) with pm.columnLayout(adj=True) as self.mainCol: #waiting for extensions from different rig modules pass with pm.frameLayout(label='Rig Groups', borderStyle='out', mh=5, mw=5, cll=True, cl=True, w=375): with pm.rowColumnLayout(nc=3, co=[(1, 'left', 80), (2, 'left', 5), (3, 'left', 5)]): pm.text(l='animGrp') self.animGrpTxtFld = pm.textField(ed=False) self.loadAnimGrpButt = pm.button(l='<<', c=pm.Callback(self.loadAnimGrp)) pm.text(l='jntGrp') self.jntGrpTxtFld = pm.textField(ed=False) self.loadJntGrpButt = pm.button(l='<<', c=pm.Callback(self.loadJntGrp)) pm.text(l='ikhGrp') self.ikhGrpTxtFld = pm.textField(ed=False) self.loadIkhGrpButt = pm.button(l='<<', c=pm.Callback(self.loadIkhGrp)) pm.text(l='skinGrp') self.skinGrpTxtFld = pm.textField(ed=False) self.loadSkinGrpButt = pm.button(l='<<', c=pm.Callback(self.loadSkinGrp)) pm.text(l='stillGrp') self.stillGrpTxtFld = pm.textField(ed=False) self.loadStillGrpButt = pm.button(l='<<', c=pm.Callback(self.loadStillGrp))
def jntToCrv ( self, jnts=None, size=1.0, shape='sphere', *args ): if not jnts: try: jnts = pm.ls(sl=True) except: pass if not jnts: pm.warning('ehm_tools...JntToCrv: select joints to create control curve for them.') else: jnts = pm.ls( jnts ) try:# if in UI mode, get info from UI shape = pm.optionMenuGrp( self.shapeType, q=True, value= True ) size = pm.floatSliderGrp( self.sizeSlider, q=True, value= True ) except: pass shapeCmd = { 'sphere': SphereCrv ,'cube' : CubeCrv ,'circle': Circle8Crv } self.newShapes = [] for jnt in jnts: # if not (jnt.type()=='joint') : # pm.warning('ehm_tools...JntToCrv: %s is not a joint, skipped!'% jnt) # else: currentCircle = shapeCmd[shape]( size=size ) shapeNode = currentCircle.getShape() pm.select ( shapeNode , jnt ) pm.parent ( add = True , shape = True ) pm.delete (currentCircle) self.newShapes.append( jnt.getShape() )
def gui(): ''' Triggers the interface for zoomerate. ''' # Warning this is causeing issues with 2012 panel = pm.getPanel(wf=True) try: whichCam = pm.modelPanel(panel, q=1, camera=True) except RuntimeError: whichCam = pm.modelPanel('modelPanel4', q=1, camera=True) print 'Using: %s' % whichCam whichCamShape = pm.ls(whichCam, dag=True, shapes=True, ap=True) # Figure out what cameras to use when building the menu cameras = pm.ls(ca=True) diffCams = [] diffCams.extend(whichCamShape) diffCams.extend(cameras) print diffCams, len(diffCams) win_name = 'zoomer_win2' if pm.window(win_name, ex=True): pm.deleteUI(win_name) win = pm.window(win_name, s=0, ip=True, iconName='zoomer', w=400, h=180, t='Camera zoomeratro v1.0') main = pm.columnLayout() pm.frameLayout(borderVisible=True, labelVisible=True, labelAlign='cener', label='Zoom Options', marginWidth=5, marginHeight=5) pm.columnLayout() global which_cam_menu which_cam_menu = pm.optionMenuGrp(label='Camera to Zoom', cc=connect) pm.menuItem(label=whichCamShape[0]) for i in xrange(len(diffCams) - 1): pm.menuItem(label=cameras[i]) horizontal_attr = '%s.horizontalFilmOffset' % whichCamShape[0] vertical_attr = '%s.verticalFilmOffset' % whichCamShape[0] overscan_attr = '%s.overscan' % whichCamShape[0] global horizontal_slider, vertical_slider, overscan_slider horizontal_slider = pm.floatSliderGrp(field=True, label='Horizontal', min=-3, max=3, pre=3, step=0.001) vertical_slider = pm.floatSliderGrp(field=True, label='Vertical', min=-3, max=3, pre=3, step=0.001) overscan_slider = pm.floatSliderGrp(field=True, label='Overscan', min=-3, max=3, pre=3, step=0.001) pm.connectControl(horizontal_slider, horizontal_attr) pm.connectControl(vertical_slider, vertical_attr) pm.connectControl(overscan_slider, overscan_slider) pm.button(label='Reset', c=reset) win.show()
def uIGenerator(self): if pm.window(self.myWinName, query=True, exists=True): pm.deleteUI(self.myWinName) try: if pm.windowPref(self.myWinName, query=True, exists=True) and self.window_development: pm.windowPref(self.myWinName, remove=True) except RuntimeError: pass myWindow = pm.window(self.myWinName, title='Object Instancer', widthHeight=[600, 300]) base = pm.verticalLayout() with base: with pm.verticalLayout() as header: title = pm.text(label='Object Instancer'.upper()) pm.separator() with pm.verticalLayout() as target: self.targetInstances = pm.intSliderGrp( label="Target Instances", field=True, minValue=0, maxValue=1000, changeCommand=self.storeTargetInstances) pm.separator() with pm.verticalLayout() as randomization: title3 = pm.text(label='Randomization') self.rotation = pm.checkBoxGrp( numberOfCheckBoxes=3, label="Rotation ", labelArray3=("RotateX", "RotateY", "RotateZ"), changeCommand=self.storeRotations) self.translation = pm.checkBoxGrp( numberOfCheckBoxes=3, label="Translation ", labelArray3=("TransX", "TransY", "TransZ"), changeCommand=self.storeTranslation) pm.separator() with pm.verticalLayout() as Randomness: self.rRPecentage = pm.floatSliderGrp( label="Rotation Randomness", field=True, minValue=0, maxValue=100) self.tRPecentage = pm.floatSliderGrp( label="Translation Randomness", field=True, minValue=0, maxValue=100) with pm.horizontalLayout() as Button: pm.button(label='Generate', backgroundColor=[0, 1, 0.5], align='left', command=self.generate) base.redistribute(.4) header.redistribute(1, .1) myWindow.show()
def __init__(self): try: pm.deleteUI( 'PipeGenWin' ) except: pass win = pm.window('PipeGenWin') with win: with pm.columnLayout(): with pm.frameLayout( l='Creation', labelVisible=False): with pm.columnLayout(): with pm.rowLayout( nc=3, cw3=[80, 80, 240], cal=([1,'center'], [2,'right'])): pm.button( l='Create', w=80, c= lambda *args: self.newPipeCB()) pm.text( l='Name' ) self.createGrp = pm.textField( text='pipe', w=90) pm.separator(w=400) with pm.rowLayout( nc=2, cw2=[80, 320], cal=[1,'center']): #text( l='Segments' ) pm.button( l='Extend', w=80, c = lambda *args: self.extendPipeCB() ) self.numSegments = pm.intSliderGrp( cw3=[80,40,50], l='Segments', value=1, field=1, min=1, max=20 ) with pm.frameLayout( l='Pipe Properties', labelVisible=True): with pm.columnLayout(): self.pipeRadius = pm.floatSliderGrp( l='Radius', value=.22, field=True, precision = 3, min=.0001, max=10 ) self.subdivAxis = pm.intSliderGrp( l='Axis Segments', value=16, field=True, min=3, max=80 ) with pm.frameLayout( l='Connector Properties', labelVisible=True): with pm.columnLayout(): self.connectorRadius = pm.floatSliderGrp( l='Connector Radius', value=.1, field=True, precision = 3, min=0, max=10 ) self.connectorThickness = pm.floatSliderGrp( l='Connector Height', value=.2, field=True, precision = 3, min=.001, max=10 ) self.connectorOffset = pm.floatSliderGrp( l='Connector Offset', value=.001, field=True, precision = 3, min=0, max=4 ) with pm.frameLayout( l='Joint Properties', labelVisible=True): with pm.columnLayout(): self.jointRadius = pm.floatSliderGrp( l='Radius', value=0, field=True, precision = 3, min=0, max=10 ) self.subdivJoint = pm.intSliderGrp( l='Joint Segments', value=8, field=True, min=1, max=80 ) self.jointLength = pm.floatSliderGrp( l='Joint Length', value=1.2, field=True, precision = 3, min=0.0001, max=10 )
def ModuleWeights_timeUpdateScriptJobCallback(self, _weightAttributes): for attr in _weightAttributes: value = pm.getAttr("%s.%s" %(self.settingsLocator, attr)) pm.floatSliderGrp(self.UIElements[attr], edit = True, value = value) self.ModuleWeights_updateMatchingButton()
def UI(self): width = 570 height = 280 # create window if pm.window( 'ehm_BipedLimb_UI', exists=True ): pm.deleteUI( 'ehm_BipedLimb_UI' ) pm.window( 'ehm_BipedLimb_UI', title='Rig Biped Limbs', w=width, h=height, mxb=False, mnb=False, sizeable=True ) # main layout baseForm = pm.formLayout() frameLayout = pm.frameLayout(borderStyle='etchedIn', labelVisible=False) pm.formLayout( baseForm, edit=True, attachForm=(frameLayout,'left', 6) ) pm.formLayout( baseForm, edit=True, attachForm=(frameLayout,'right', 6) ) pm.formLayout( baseForm, edit=True, attachForm=(frameLayout,'top', 6) ) pm.formLayout( baseForm, edit=True, attachForm=(frameLayout,'bottom', 38) ) # pm.scrollLayout( horizontalScrollBarThickness=16, verticalScrollBarThickness=16) formLayout = pm.formLayout(w=width, h=height) # spine size self.BipedLimbSizeT = pm.text( label="Limb Size: ") self.BipedLimbSizeF = pm.floatSliderGrp(adjustableColumn=4,min=0, max=20, fieldMaxValue=10000, value=5, field=True ) # character mode radio buttons self.limbModeText = pm.text(label='Limb Mode: ', align='right') self.limbModeRC = pm.radioCollection() self.armRB = pm.radioButton(label="Arm", select=True ) self.legRB = pm.radioButton(label="Leg") # number of joints self.numOfJntsText = pm.text( label='Number of joints: ', align='right') self.numOfJntsIS = pm.intSliderGrp( field=True, value=6, maxValue=20, fieldMaxValue=1000 ) # extras check boxes self.extrasText = pm.text( label='Extras: ', align='right' ) self.bendyCB = pm.checkBox( label="Bendy", value=True ) # buttons self.initButton = pm.button( label='Place joints', h=30, c=partial( self.bipedLimb_init, 10, 'arm', 'L' ), parent=baseForm ) self.packButton = pm.button( label='Finish Rig', h=30, c=partial( self.bipedLimb_pack, 1.0, 'FKIK', True, 6, True, 'arm' ), parent=baseForm ) self.closeButton = pm.button( label='Close', h=30, c= self.closeUI , parent=baseForm ) # place spine size pm.formLayout( formLayout, edit=True, attachPosition=(self.BipedLimbSizeT,'right', 0, 28 ) ) pm.formLayout( formLayout, edit=True, attachForm=(self.BipedLimbSizeT,'top', 17 ) ) pm.formLayout( formLayout, edit=True, attachPosition=(self.BipedLimbSizeF,'left', 0, 30 ) ) pm.formLayout( formLayout, edit=True, attachPosition=(self.BipedLimbSizeF,'right', 15, 100 ) ) pm.formLayout( formLayout, edit=True, attachForm=(self.BipedLimbSizeF,'top', 15 ) ) # place character mode pm.formLayout( formLayout, edit=True, attachPosition=(self.limbModeText,'right', 0 , 28) ) pm.formLayout( formLayout, edit=True, attachControl=(self.limbModeText,'top', 17, self.BipedLimbSizeT) ) pm.formLayout( formLayout, edit=True, attachPosition=(self.armRB,'left', 0, 30 ) ) pm.formLayout( formLayout, edit=True, attachPosition=(self.armRB,'right', 15, 100 ) ) pm.formLayout( formLayout, edit=True, attachControl=(self.armRB,'top', 15, self.BipedLimbSizeT) ) pm.formLayout( formLayout, edit=True, attachPosition=(self.legRB,'left', 0, 30 ) ) pm.formLayout( formLayout, edit=True, attachPosition=(self.legRB,'right', 15, 100 ) ) pm.formLayout( formLayout, edit=True, attachControl=(self.legRB,'top', 35, self.BipedLimbSizeT) ) # place number of joints pm.formLayout( formLayout, edit=True, attachPosition=(self.numOfJntsText,'right', 0 , 28) ) pm.formLayout( formLayout, edit=True, attachControl=(self.numOfJntsText,'top', 17, self.legRB) ) pm.formLayout( formLayout, edit=True, attachPosition=(self.numOfJntsIS,'left', 0, 30 ) ) pm.formLayout( formLayout, edit=True, attachPosition=(self.numOfJntsIS,'right', 15, 100 ) ) pm.formLayout( formLayout, edit=True, attachControl=(self.numOfJntsIS,'top', 12, self.legRB ) ) # place check boxes pm.formLayout( formLayout, edit=True, attachPosition=(self.extrasText,'right', 0 , 28) ) pm.formLayout( formLayout, edit=True, attachControl=(self.extrasText,'top', 17, self.numOfJntsIS) ) pm.formLayout( formLayout, edit=True, attachPosition=(self.bendyCB,'left', 0, 30 ) ) pm.formLayout( formLayout, edit=True, attachPosition=(self.bendyCB,'right', 15, 100 ) ) pm.formLayout( formLayout, edit=True, attachControl=(self.bendyCB,'top', 15, self.numOfJntsIS ) ) # place buttons pm.formLayout( baseForm, edit=True, attachPosition=(self.initButton,'left', 3, 0) ) pm.formLayout( baseForm, edit=True, attachPosition=(self.initButton,'right', 1, 33) ) pm.formLayout( baseForm, edit=True, attachForm=(self.initButton,'bottom', 3) ) pm.formLayout( baseForm, edit=True, attachPosition=(self.packButton,'left', 1, 33) ) pm.formLayout( baseForm, edit=True, attachPosition=(self.packButton,'right', 3, 66) ) pm.formLayout( baseForm, edit=True, attachForm=(self.packButton,'bottom', 3) ) pm.formLayout( baseForm, edit=True, attachPosition=(self.closeButton,'left', 1, 66) ) pm.formLayout( baseForm, edit=True, attachPosition=(self.closeButton,'right', 3, 100) ) pm.formLayout( baseForm, edit=True, attachForm=(self.closeButton,'bottom', 3) ) # show window pm.showWindow( 'ehm_BipedLimb_UI' )
def __init__(self, baseFilePath, placerMapping, indMapping, meshNames): ''' create UI and init vars ''' self.imageRefPath = baseFilePath self.placerMapping = placerMapping self.indMapping = indMapping self.mesh = meshNames['face'] self.lf_eye = meshNames['leftEye'] self.rt_eye = meshNames['rightEye'] self.locTweakWidgets = {} self.placementGrp = None with pm.menu(l='Options') as menuOptions: pm.menuItem(l='Refresh') pm.menuItem(l='Reset') with pm.menu(l='Help') as menuHelp: pm.menuItem(l='Documentation') pm.menuItem(l='About') with pm.tabLayout() as mainTab: with pm.columnLayout(adj=True) as geoSelectionLayout: pass with pm.columnLayout(adj=True) as jntPlacementLayout: with pm.verticalLayout(ratios=(1,10,1), spacing=10) as jntPlacementVertLayout: #self.chk_symmetry = pm.checkBox(l='Symmetry', v=True) with pm.horizontalLayout() as startPlacementLayout: self.btn_startJntPlacement = pm.button(l='Start Joint Placement', c=pm.Callback(self.startJointPlacement), w=180) self.img_jntReference = pm.image(image=self.imageRefPath+'default.jpg') with pm.rowLayout(numberOfColumns=3, adj=2) as jntRowLayout: self.btn_jntScrollLt = pm.button(l='<<', w=40, en=False) self.txt_jntCurrent = pm.text(label='Click "Start Joint Placement" above to begin.', align='center') self.btn_jntScrollRt = pm.button(l='>>', w=40, c=pm.Callback(self.selectNextItem), en=False) pm.separator(style='in') with pm.horizontalLayout(ratios=(1,5), spacing=5): with pm.verticalLayout(): # left labels self.locTweakWidgets['txt_position'] = pm.text(label='Position', align='right', en=False) self.locTweakWidgets['txt_orient'] = pm.text(label='Orient', align='right', en=False) self.locTweakWidgets['txt_scale'] = pm.text(label='Scale', align='right', en=False) self.locTweakWidgets['txt_mirror'] = pm.text(label='Mirror', align='right', en=False) with pm.verticalLayout(): # right buttons with pm.horizontalLayout(): self.locTweakWidgets['btn_prevCV'] = pm.button(l='Prev CV', en=False, c=pm.Callback(self.stepCV, -1)) self.locTweakWidgets['btn_nextCV'] = pm.button(l='Next CV', en=False, c=pm.Callback(self.stepCV, 1)) self.locTweakWidgets['btn_snapToVtx'] = pm.button(l='Snap to Vtx', en=False) self.locTweakWidgets['btn_user'] = pm.button(l='User', en=False) with pm.horizontalLayout(): self.locTweakWidgets['btn_normal'] = pm.button(l='Normal', en=False) self.locTweakWidgets['btn_normal_yup'] = pm.button(l='Normal + Y-up', en=False) self.locTweakWidgets['btn_world'] = pm.button(l='World', en=False) self.locTweakWidgets['btn_orient_user'] = pm.button(l='User', en=False) with pm.horizontalLayout(): self.locTweakWidgets['float_scale'] = pm.floatSliderGrp(f=True, min=0.01, max=1.0, v=0.5, pre=2, fmx=10.0, en=False, dc=pm.Callback(self.editLocScale)) with pm.horizontalLayout(): self.locTweakWidgets['btn_mirLtToRt'] = pm.button(l='Left to Right', en=False, c=pm.Callback(self.mirrorLocs)) self.locTweakWidgets['btn_mirRtToLt'] = pm.button(l='Right to Left', en=False) pm.separator(style='in') with pm.verticalLayout(spacing=5) as buildRigVertLayout: self.btn_updateLocs = pm.button(l='Update All Locators', en=False) self.btn_buildRig = pm.button(l='Build Rig', c=pm.Callback(self.buildRig), en=False) with pm.columnLayout(adj=True) as deformationLayout: pass with pm.columnLayout(adj=True) as motionLayout: pass with pm.columnLayout(adj=True) as actionsLayout: pass mainTab.setTabLabel((geoSelectionLayout,'Geometry')) mainTab.setTabLabel((jntPlacementLayout,'Joints')) mainTab.setTabLabel((deformationLayout,'Deformation')) mainTab.setTabLabel((motionLayout,'Motion')) mainTab.setTabLabel((actionsLayout,'Action Units')) mainTab.setSelectTab(jntPlacementLayout) self.show()
def bipedLimb_pack( self, ctrlSize=1.0, FKIKMode='FKIK', mirror=True, numOfSegs=6, bendy=True, mode='arm', *args ): try:# if in UI mode, get number of joints from UI ctrlSize = pm.floatSliderGrp( self.spineSizeF, q=True, value=True) selectedMode = pm.radioCollection( self.characterModeRC, q=True, select=True) mode = pm.radioButton( selectedMode, q=True, label=True ).lower() numOfSegs = pm.intSliderGrp( self.numOfJntsIS, q=True, value=True) bendy = pm.checkBox( self.bendyCB, q=True, value=True ) except: pass bipedLimbJnts = [] FKIKstuff = [] OSbipedLimbJnts = [] OSFKIKstuff = [] #============================================================================ # find some info for naming and control sizes side = self.BipedLimbInitJnts[0].name()[0] limbLen = Dist( self.BipedLimbInitJnts[0] , self.BipedLimbInitJnts[1] ) otherSide = 'R' if side == 'R': otherSide = 'L' #============================================================================ # getting info from selected objects if mode == 'arm': firstInitJnt = self.BipedLimbInitJnts[0] secondInitJnt = self.BipedLimbInitJnts[1] thirdInitJnt = self.BipedLimbInitJnts[2] forthInitJnt = self.BipedLimbInitJnts[3] armPos = self.worldPos( firstInitJnt ) elbowPos = self.worldPos( secondInitJnt ) handPos = self.worldPos( thirdInitJnt ) handEndPos = self.worldPos( forthInitJnt ) elif mode == 'leg': firstInitJnt = self.BipedLimbInitJnts[0] secondInitJnt = self.BipedLimbInitJnts[1] thirdInitJnt = self.BipedLimbInitJnts[2] heelInitJnt = self.BipedLimbInitJnts[3] forthInitJnt = self.BipedLimbInitJnts[4] toeEndInitJnt = self.BipedLimbInitJnts[5] outsideInitJnt = self.BipedLimbInitJnts[6] insideInitJnt = self.BipedLimbInitJnts[7] upLegPos = self.worldPos( firstInitJnt ) kneePos = self.worldPos( secondInitJnt ) anklePos = self.worldPos( thirdInitJnt ) ballPos = self.worldPos( forthInitJnt ) toeEndPos = self.worldPos( toeEndInitJnt ) heelPos = self.worldPos( heelInitJnt ) outsidePos = self.worldPos( outsideInitJnt ) insidePos = self.worldPos( insideInitJnt ) #============================================================================ # create arm or leg joints if mode == 'arm': pm.select ( cl = True ) upLimbJnt =pm.joint ( p = armPos , name = ( side + "_upArm_jnt" ) ) midLimbJnt = pm.joint ( p = elbowPos , name = ( side + "_elbow_jnt" ) ) pm.joint( upLimbJnt, e=True, zso=True, oj='xyz', sao='yup') butLimbJnt = pm.joint ( p = handPos , name = ( side + "_hand_jnt" ) ) pm.joint( midLimbJnt, e=True, zso=True, oj='xyz', sao='yup') handEndJnt = pm.joint ( p = handEndPos , name = ( side + "_hand_end_jnt" ) ) pm.joint( butLimbJnt, e=True, zso=True, oj='xyz', sao='yup') bipedLimbJnts = [ upLimbJnt, midLimbJnt, butLimbJnt, handEndJnt ] elif mode == 'leg': pm.select ( cl = True ) upLimbJnt =pm.joint ( p = upLegPos , name = ( side + "_upLeg_jnt" ) ) midLimbJnt = pm.joint ( p = kneePos , name = ( side + "_knee_jnt" ) ) pm.joint( upLimbJnt, e=True, zso=True, oj='xzy', sao='xup') butLimbJnt = pm.joint ( p = anklePos , name = ( side + "_ankle_jnt" ) ) pm.joint( midLimbJnt, e=True, zso=True, oj='xzy', sao='xup') ballJnt = pm.joint ( p = ballPos , name = ( side + "_ball_jnt" ) ) pm.joint( butLimbJnt, e=True, zso=True, oj='xzy', sao='xup') toeEndJnt = pm.joint ( p = toeEndPos , name = ( side + "_toeEnd_jnt" ) ) pm.joint( ballJnt, e=True, zso=True, oj='xzy', sao='xup') pm.select(clear=True) heelJnt = pm.joint ( p = heelPos , name = ( side + "_heel_jnt" ) ) pm.select(clear=True) outsideJnt = pm.joint ( p = outsidePos , name = ( side + "_outside_jnt" ) ) pm.select(clear=True) insideJnt = pm.joint ( p = insidePos , name = ( side + "_inside_jnt" ) ) bipedLimbJnts = [ upLimbJnt, midLimbJnt, butLimbJnt, ballJnt, toeEndJnt, heelJnt,outsideJnt,insideJnt ] #============================================================================ # find the pole vector position # orient joints and set preferred angle # find pole vector position PVposition = FindPVposition( objs= (upLimbJnt, midLimbJnt, butLimbJnt) ) if mode == 'arm': # arm mode ................................................. if PVposition: # arm is bent! # create and position aim locator aimLoc = pm.spaceLocator() PVposition = FindPVposition( objs= (upLimbJnt, midLimbJnt, butLimbJnt) ) aimLoc.translate.set( PVposition ) else: # arm is not bent! # create and position aim locator aimLoc = pm.spaceLocator() pm.parent( aimLoc, midLimbJnt ) pm.makeIdentity( aimLoc, t=True, r=True, s=True ) aimLoc.translateZ.set( -limbLen*1.5 ) pm.parent( aimLoc, w=True) aimLoc.rotate.set( 0,0,0 ) # rotate the aim to match the rotation of the arm pm.delete( pm.aimConstraint( midLimbJnt, aimLoc, worldUpType="object", aimVector=(1,0,0), upVector=(0,1,0), worldUpObject= butLimbJnt ) ) # orient joints according to aim locator for jnt in ( upLimbJnt, midLimbJnt, butLimbJnt ): OriJnt( jnt=jnt, upAim=aimLoc , aimAxis='-z' ) # set preferred angle midLimbJnt.preferredAngleY.set( -90 ) poleVectorTransform = None footRotate = None elif mode == 'leg': # leg mode ................................................. if PVposition: # leg is bent! # create and position aim locator aimLoc = pm.spaceLocator() PVposition = FindPVposition( objs= (upLimbJnt, midLimbJnt, butLimbJnt) ) aimLoc.translate.set( PVposition ) else: # leg is not bent! PVposition = self.PVbyToeJnt( upLimbJnt, midLimbJnt, toeEndJnt ) # create and position aim locator aimLoc = pm.spaceLocator() aimLoc.translate.set( PVposition ) # position aim in front of the foot # rotate the aim to match the rotation of the arm pm.delete( pm.aimConstraint( midLimbJnt, aimLoc, worldUpType="object", aimVector=(1,0,0), upVector=(0,1,0), worldUpObject= butLimbJnt ) ) # orient joints according to aim locator for jnt in bipedLimbJnts[:-4]: OriJnt( jnt=jnt, upAim=aimLoc , aimAxis='-y' ) # set preferred angle midLimbJnt.preferredAngleZ.set( 90 ) # find foot Y rotation to pass to rigIK and rigFKIK footRotateY = ProjectedAim( objs=( butLimbJnt , toeEndJnt ) ) footRotate = ( 0, footRotateY, 0 ) # pole vector transformations to be passed to rigIK and rigFKIK PVposition = pm.xform( aimLoc, q=True, ws=True, t=True ) PVrotation = pm.xform( aimLoc, q=True, ws=True, ro=True ) poleVectorTransform = ( PVposition, PVrotation ) #============================================================================ # If mirror is ON if mirror == True: # mirror joints OSjnts = pm.mirrorJoint( upLimbJnt, mirrorYZ=True , mirrorBehavior=True, searchReplace=( "L", "R" ) ) if mode=='leg': OSjnts.append( pm.mirrorJoint( heelJnt, mirrorYZ=True , mirrorBehavior=True, searchReplace=( "L", "R" ) ) ) OSjnts.append( pm.mirrorJoint( outsideJnt, mirrorYZ=True , mirrorBehavior=True, searchReplace=( "L", "R" ) ) ) OSjnts.append( pm.mirrorJoint( insideJnt, mirrorYZ=True , mirrorBehavior=True, searchReplace=( "L", "R" ) ) ) OSbipedLimbJnts = pm.ls( OSjnts ) # transforms of mirrored pole vector OSaimLoc = MirrorObjLikeJnt( aimLoc )[0] OSPVposition = pm.xform( OSaimLoc, q=True, ws=True, t=True ) OSPVrotation = pm.xform( OSaimLoc, q=True, ws=True, ro=True ) OSpoleVectorTransform = ( OSPVposition, OSPVrotation ) # transforms of mirrored hand or foot control footNull = pm.group(em=True) if mode=='leg': footNull.translate.set( anklePos ) footNull.rotate.set( footRotate ) elif mode=='arm': footNull.translate.set( handPos ) OShandTransforms = MirrorObjLikeJnt( objs=footNull, returnValue=True ) OSfootRotate = OShandTransforms[0][1] pm.delete( footNull ) #============================================================================ # create IK, FK rigs and blend them # FK mode ============= if FKIKMode == 'FK': RigFK( jnts = OSbipedLimbJnts, side = side ) # other side if mirror: RigFK( jnts = OSbipedLimbJnts, side=otherSide ) # IK mode ============= elif FKIKMode == 'IK': armRigStuff = RigIK( jnts=bipedLimbJnts , mode=mode , side = side , poleVectorTransform=poleVectorTransform , footRotate=footRotate , rigHandOrFoot=True , ctrlSize = ctrlSize ) # other side if mirror: OSarmRigStuff = RigIK( jnts=OSbipedLimbJnts , mode=mode , side=otherSide , poleVectorTransform=OSpoleVectorTransform , mirrorMode=True , footRotate=OSfootRotate , rigHandOrFoot=True , ctrlSize = ctrlSize ) # FKIK mode ============= elif FKIKMode == 'FKIK': # for i in ( bipedLimbJnts, mode, side, poleVectorTransform, footRotate ): # print i # return None FKIKstuff = RigFKIK( jnts=bipedLimbJnts , mode=mode , side=side , poleVectorTransform=poleVectorTransform , footRotate=footRotate , rigHandOrFoot=True , ctrlSize = ctrlSize ) # other side if mirror: OSFKIKstuff = RigFKIK( jnts=OSbipedLimbJnts , mode=mode , side=otherSide , poleVectorTransform=OSpoleVectorTransform , mirrorMode=True , footRotate=(0,0,0) , rigHandOrFoot=True ) ''' OSFKIKstuff = RigFKIK( jnts=OSbipedLimbJnts , mode=mode , side=otherSide , poleVectorTransform=OSpoleVectorTransform , mirrorMode=True , footRotate=OSfootRotate , rigHandOrFoot=True ) ''' #============================================================================ # rig bendy limbs bendies = RigBendyLimb( jnts=bipedLimbJnts[:3] , bendyCtrl=FKIKstuff[3] , numOfSegs= numOfSegs , side=side ) if mirror: OSbendies = RigBendyLimb( jnts=OSbipedLimbJnts[:3] , bendyCtrl=OSFKIKstuff[3] , numOfSegs= numOfSegs , isMirroredJoint=True , side=otherSide ) # clean up pm.delete( self.BipedLimbInitJnts, aimLoc ) bendies[-1].setParent( FKIKstuff[-1] ) if mirror: pm.delete( OSaimLoc ) OSbendies[-1].setParent( OSFKIKstuff[-1] )
def bipedLimb_init( self, BipedLimbSize=10, mode='arm', side='L', *args ): self.BipedLimbInitJnts = [] try:# if in UI mode, get number of joints from UI BipedLimbSize = pm.floatSliderGrp( self.BipedLimbSizeF, q=True, value=True) selectedMode = pm.radioCollection( self.limbModeRC, q=True, select=True) mode = pm.radioButton( selectedMode, q=True, label=True ).lower() except: pass if mode == 'arm': pm.select( clear = True ) self.BipedLimbInitJnts.append( pm.joint ( p = ( BipedLimbSize * 3 / 14.0 , BipedLimbSize*13 / 14.0 , 0) , name = "%s_uparm_initJnt"%side ) ) self.BipedLimbInitJnts.append( pm.joint ( p = ( BipedLimbSize * 7 / 14.0 , BipedLimbSize*13 / 14.0 , 0) , name = "%s_elbow_initJnt"%side ) ) pm.joint( self.BipedLimbInitJnts[0], e=True, zso=True, oj='xyz', sao='yup') self.BipedLimbInitJnts.append( pm.joint ( p = ( BipedLimbSize * 11 / 14.0 , BipedLimbSize*13 / 14.0 , 0) , name = "%s_hand_initJnt"%side ) ) pm.joint( self.BipedLimbInitJnts[1], e=True, zso=True, oj='xyz', sao='yup') self.BipedLimbInitJnts.append( pm.joint ( p = ( BipedLimbSize * 12 / 14.0 , BipedLimbSize*13 / 14.0 , 0) , name = "%s_handEnd_initJnt"%side ) ) pm.joint( self.BipedLimbInitJnts[2], e=True, zso=True, oj='xyz', sao='yup') pm.select ( clear=True ) elif mode == 'leg': pm.select( clear = True ) self.BipedLimbInitJnts.append( pm.joint(p=(BipedLimbSize*2/7.0, BipedLimbSize*7/7.0, 0), name = "L_initUplegJnt") ) self.BipedLimbInitJnts.append( pm.joint(p=(BipedLimbSize*2/7.0, BipedLimbSize*4/7.0, 0), name = "L_initKneeJnt") ) pm.joint( self.BipedLimbInitJnts[0], e=True, zso=True, oj='xzy', sao='xup' ) self.BipedLimbInitJnts.append( pm.joint(p=(BipedLimbSize*2/7.0, BipedLimbSize*1/7.0, 0), name = "L_initAnkleJnt") ) pm.joint( self.BipedLimbInitJnts[1], e=True, zso=True, oj='xzy', sao='xup') self.BipedLimbInitJnts.append( pm.joint(p=(BipedLimbSize*2/7.0,0,BipedLimbSize*-1/7.0), name = "L_initHeelJnt") ) pm.joint( self.BipedLimbInitJnts[2], e=True, zso=True, oj='xzy', sao='xup') pm.pickWalk( d='up' ) self.BipedLimbInitJnts.append( pm.joint(p=(BipedLimbSize* 2/7.0, BipedLimbSize*0.5/7.0, BipedLimbSize*1/7.0), name = "L_initBallJnt") ) pm.joint( self.BipedLimbInitJnts[3], e=True, zso=True, oj='xzy', sao='xup') self.BipedLimbInitJnts.append( pm.joint(p=(BipedLimbSize*2/7.0,0,BipedLimbSize*2/7.0), name = "L_initToeEndJnt") ) pm.joint( self.BipedLimbInitJnts[4], e=True, zso=True, oj='xzy', sao='xup') pm.pickWalk( d='up' ) self.BipedLimbInitJnts.append( pm.joint(p=(BipedLimbSize*2.5/7.0,0,BipedLimbSize*1/7.0), name = "L_initOutFootJnt") ) pm.joint( self.BipedLimbInitJnts[4], e=True, zso=True, oj='xzy', sao='xup') pm.pickWalk( d='up' ) self.BipedLimbInitJnts.append( pm.joint(p=(BipedLimbSize*1.5/7.0,0,BipedLimbSize*1/7.0), name = "L_initInFootJnt") ) pm.joint( self.BipedLimbInitJnts[4], e=True, zso=True, oj='xzy', sao='xup') pm.select ( clear=True )
def ui_createUI(self): self.winName = WIN_NAME self.winTitle = WIN_TITLE if pm.window(WIN_NAME, exists=True): pm.deleteUI(WIN_NAME, window=True) with pm.window(WIN_NAME, title=WIN_TITLE, maximizeButton=False, menuBar=True, menuBarVisible=True) as self.window: pm.setUITemplate('DefaultTemplate', pushTemplate=True) with pm.formLayout() as self.ui_LAY_mainForm: with pm.tabLayout(tabsVisible=False) as self.ui_TAB_top: pm.tabLayout(self.ui_TAB_top, e=True, height=1) with pm.formLayout() as self.ui_LAY_attachForm: with pm.tabLayout( tabsVisible=False, scrollable=True, innerMarginWidth=4) as self.ui_TAB_inner: with pm.columnLayout(adjustableColumn=True ) as self.ui_LAY_mainColumn: with pm.frameLayout( label='Control Panel', collapsable=True, collapse=False, marginHeight=3, ): with pm.columnLayout( adjustableColumn=True): with pm.rowLayout( numberOfColumns=2, columnWidth2=[ UI_LABEL_WIDTH, UI_INPUT_WIDTH ], columnAttach=[1, 'right', 5]): pm.text( label='Curvature Threshold') pm.setUITemplate( 'DefaultTemplate', popTemplate=True ) # strange slider group visual with default template self.ui_FLTSLGRP_curveThresh = pm.floatSliderGrp( 'ui_FLTSLGRP_curveThresh', field=True, minValue=0.001, maxValue=0.2, fieldMinValue=0.001, fieldMaxValue=10, value=0.09, step=0.001, fieldStep=0.001, sliderStep=0.001, changeCommand=self. ui_FLTSLGRP_curveThresh_change, dragCommand=self. ui_FLTSLGRP_curveThresh_change) pm.setUITemplate('DefaultTemplate', pushTemplate=True) with pm.rowLayout( numberOfColumns=2, columnWidth2=[ UI_LABEL_WIDTH, UI_INPUT_WIDTH ], columnAttach=[1, 'right', 5]): pm.text(label='Grow Angle') pm.setUITemplate( 'DefaultTemplate', popTemplate=True ) # strange slider group visual with default template self.ui_FLTSLGRP_growAngle = pm.floatSliderGrp( 'ui_FLTSLGRP_growAngle', field=True, minValue=0, maxValue=10, fieldMinValue=0, fieldMaxValue=30, value=5, step=0.001, fieldStep=0.001, sliderStep=0.001, changeCommand=self. ui_FLTSLGRP_growAngle_change, dragCommand=self. ui_FLTSLGRP_growAngle_change) pm.setUITemplate('DefaultTemplate', pushTemplate=True) with pm.frameLayout( label='Display', collapsable=True, collapse=False, marginHeight=3, ): with pm.columnLayout( adjustableColumn=True): with pm.rowLayout( numberOfColumns=2, columnWidth2=[ UI_LABEL_WIDTH, UI_INPUT_WIDTH ], columnAttach=[1, 'right', 5]): pm.text(label='Display Curvature') self.ui_CHK_displayCurve = pm.checkBox( 'ui_CHK_highlight', label='', changeCommand=self. ui_CHK_displayCurve_change) with pm.rowLayout( numberOfColumns=2, columnWidth2=[ UI_LABEL_WIDTH, UI_INPUT_WIDTH ], columnAttach=[1, 'right', 5]): pm.text(label='Curvature Scale') pm.setUITemplate( 'DefaultTemplate', popTemplate=True ) # strange slider group visual with default template self.ui_FLTSLGRP_curveScale = pm.floatSliderGrp( 'ui_FLTSLGRP_curveScale', field=True, minValue=0.001, maxValue=1, fieldMinValue=0.001, fieldMaxValue=10, value=1, step=0.001, fieldStep=0.001, sliderStep=0.001, changeCommand=self. ui_FLTSLGRP_curveScale_change, dragCommand=self. ui_FLTSLGRP_curveScale_change) pm.setUITemplate('DefaultTemplate', pushTemplate=True) self.ui_BTN_ok = pm.button(label='OK', command=self.onOkClicked) self.ui_BTN_cancel = pm.button(label='Cancel', command=self.onCancelClicked) self.ui_LAY_attachForm.attachForm(self.ui_TAB_inner, 'top', 0) self.ui_LAY_attachForm.attachForm(self.ui_TAB_inner, 'left', 0) self.ui_LAY_attachForm.attachForm(self.ui_TAB_inner, 'right', 0) self.ui_LAY_attachForm.attachForm(self.ui_TAB_inner, 'bottom', 0) self.ui_LAY_mainForm.attachForm(self.ui_TAB_top, 'top', 0) self.ui_LAY_mainForm.attachForm(self.ui_TAB_top, 'left', 0) self.ui_LAY_mainForm.attachForm(self.ui_TAB_top, 'right', 0) self.ui_LAY_mainForm.attachControl(self.ui_TAB_top, 'bottom', 5, self.ui_BTN_ok) self.ui_LAY_mainForm.attachNone(self.ui_BTN_ok, 'top') self.ui_LAY_mainForm.attachForm(self.ui_BTN_ok, 'left', 5) self.ui_LAY_mainForm.attachPosition(self.ui_BTN_ok, 'right', 2, 50) self.ui_LAY_mainForm.attachForm(self.ui_BTN_ok, 'bottom', 5) self.ui_LAY_mainForm.attachNone(self.ui_BTN_cancel, 'top') self.ui_LAY_mainForm.attachPosition(self.ui_BTN_cancel, 'left', 2, 50) self.ui_LAY_mainForm.attachForm(self.ui_BTN_cancel, 'right', 5) self.ui_LAY_mainForm.attachForm(self.ui_BTN_cancel, 'bottom', 5) pm.setUITemplate('DefaultTemplate', popTemplate=True) pm.scriptJob(uiDeleted=(self.window, self.onUiDeleted)) self.window.show() m.refresh()
def uiCreate(self): self.onCloseClicked() self.window = pm.window( WIN_NAME, title='PyMel Window', maximizeButton=False ) with self.window: with pm.formLayout() as uiLAY_mainForm: with pm.scrollLayout('uiLAY_mainScroll', childResizable=True) as self.uiLAY_mainScroll: with pm.columnLayout(adjustableColumn=True): with self.uiCreateFrame('uiLAY_frameCheckBoxes', 'Check Boxes (PMCheckBox)') as self.uiLAY_frameCheckBoxes: with pm.columnLayout(): pm.separator(style='none', height=2) with pm.rowLayout(numberOfColumns=3): pm.separator(width=140, style='none') self.uiCHK_test1 = pm.checkBox('uiCHK_test1', label='test1') self.uiCHK_test2 = pm.checkBox('uiCHK_test2', label='test2') with self.uiCreateFrame('uiLAY_frameCheckBoxGroups', 'Check Box Groups (PMCheckBoxGrp#)') as self.uiLAY_frameCheckBoxGroups: with pm.columnLayout(): pm.separator(style='none', height=2) self.uiCHKGRP_test1 = pm.checkBoxGrp( 'uiCHKGRP_test1', numberOfCheckBoxes=1, label='PMCheckBoxGrp1', label1='test1' ) self.uiCHKGRP_test2 = pm.checkBoxGrp( 'uiCHKGRP_test2', numberOfCheckBoxes=2, label='PMCheckBoxGrp2', labelArray2=('test1', 'test2') ) self.uiCHKGRP_test3 = pm.checkBoxGrp( 'uiCHKGRP_test3', numberOfCheckBoxes=3, label='PMCheckBoxGrp3', labelArray3=('test1', 'test2', 'test3') ) self.uiCHKGRP_test4 = pm.checkBoxGrp( 'uiCHKGRP_test4', numberOfCheckBoxes=4, label='PMCheckBoxGrp4', labelArray4=('test1', 'test2', 'test3', 'test4') ) with self.uiCreateFrame('uiLAY_frameColorSliders', 'Color Slider Groups (PMColorSliderGrp)') as self.uiLAY_frameColorSliders: with pm.columnLayout(): pm.separator(style='none', height=2) self.uiCLRGRP_test1 = pm.colorSliderGrp( 'uiCLRGRP_test1', label='test1' ) self.uiCLRGRP_test2 = pm.colorSliderGrp( 'uiCLRGRP_test2', label='test2' ) with self.uiCreateFrame('uiLAY_frameFloatFields', 'Float Fields (PMFloatField)') as self.uiLAY_frameFloatFields: with pm.columnLayout(): pm.separator(style='none', height=2) with pm.rowLayout(numberOfColumns=3): pm.separator(width=140, style='none') self.uiFLF_test1 = pm.floatField('uiFLF_test1') self.uiFLF_test2 = pm.floatField('uiFLF_test2') with self.uiCreateFrame('uiLAY_frameFloatFieldGroups', 'Float Field Groups (PMFloatFieldGrp#)') as self.uiLAY_frameFloatFieldGroups: with pm.columnLayout(): pm.separator(style='none', height=2) self.uiFLFGRP_test1 = pm.floatFieldGrp( 'uiFLFGRP_test1', numberOfFields=1, label='PMFloatFieldGrp1' ) self.uiFLFGRP_test2 = pm.floatFieldGrp( 'uiFLFGRP_test2', numberOfFields=2, label='PMFloatFieldGrp2' ) self.uiFLFGRP_test3 = pm.floatFieldGrp( 'uiFLFGRP_test3', numberOfFields=3, label='PMFloatFieldGrp3' ) self.uiFLFGRP_test4 = pm.floatFieldGrp( 'uiFLFGRP_test4', numberOfFields=4, label='PMFloatFieldGrp4' ) with self.uiCreateFrame('uiLAY_frameFloatScrollBars', 'Float Scroll Bars (PMFloatScrollBar)') as self.uiLAY_frameFloatScrollBars: with pm.columnLayout(adjustableColumn=True): pm.separator(style='none', height=2) self.uiFLSCRL_test1 = pm.floatScrollBar('uiFLSCRL_test1') self.uiFLSCRL_test2 = pm.floatScrollBar('uiFLSCRL_test2') with self.uiCreateFrame('uiLAY_frameFloatSliders', 'Float Sliders (PMFloatSlider)') as self.uiLAY_frameFloatSliders: with pm.columnLayout(adjustableColumn=True): pm.separator(style='none', height=2) self.uiFLTSLD_test1 = pm.floatSlider('uiFLTSLD_test1') self.uiFLTSLD_test2 = pm.floatSlider('uiFLTSLD_test2') with self.uiCreateFrame('uiLAY_frameFloatSliderGroups', 'Float Slider Groups (PMFloatSliderGrp)') as self.uiLAY_frameFloatSliderGroups: with pm.columnLayout(): pm.separator(style='none', height=2) self.uiFLSGRP_test1 = pm.floatSliderGrp( 'uiFLSGRP_test1', label='test1', field=True ) self.uiFLSGRP_test2 = pm.floatSliderGrp( 'uiFLSGRP_test2', label='test2', field=True ) with self.uiCreateFrame('uiLAY_frameIconTextCheckBoxes', 'Icon Text Check Boxes (PMIconTextCheckBox)') as self.uiLAY_frameIconTextCheckBoxes: with pm.columnLayout(): with pm.rowLayout(numberOfColumns=3): pm.separator(style='none', width=140) self.uiITCHK_test1 = pm.iconTextCheckBox( 'uiITCHK_test1', style='iconAndTextHorizontal', label='cube', image1='cube' ) self.uiITCHK_test2 = pm.iconTextCheckBox( 'uiITCHK_test2', style='iconAndTextHorizontal', label='cone', image1='cone' ) with self.uiCreateFrame('uiLAY_frameIconTextRadioButtons', 'Icon Text Radio Buttons (PMIconTextRadioButton)') as self.uiLAY_frameIconTextRadioButtons: with pm.columnLayout(): with pm.rowLayout(numberOfColumns=4): pm.separator(style='none', width=140) pm.iconTextRadioCollection() self.uiITRAD_test1 = pm.iconTextRadioButton( 'uiITRAD_test1', style='iconAndTextHorizontal', label='cube', image1='cube' ) self.uiITRAD_test2 = pm.iconTextRadioButton( 'uiITRAD_test2', style='iconAndTextHorizontal', label='cone', image1='cone' ) self.uiITRAD_test3 = pm.iconTextRadioButton( 'uiITRAD_test3', style='iconAndTextHorizontal', label='torus', image1='torus' ) with self.uiCreateFrame('uiLAY_frameIconTextScrollLists', 'Icon Text Scroll Lists (PMIconTextScrollList)') as self.uiLAY_frameIconTextScrollLists: with pm.columnLayout(): with pm.rowLayout(numberOfColumns=3): pm.separator(style='none', width=140) self.uiITSLST_test1 = pm.iconTextScrollList( 'uiITSLST_test1', allowMultiSelection=True, append=('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten') ) self.uiITSLST_test2 = pm.iconTextScrollList( 'uiITSLST_test2', allowMultiSelection=True, append=('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten') ) with self.uiCreateFrame('uiLAY_frameIntFields', 'Int Fields (PMIntField)') as self.uiLAY_frameIntFields: with pm.columnLayout(): pm.separator(style='none', height=2) with pm.rowLayout(numberOfColumns=3): pm.separator(width=140, style='none') self.uiINF_test1 = pm.intField('uiINF_test1') self.uiINF_test2 = pm.intField('uiINF_test2') with self.uiCreateFrame('uiLAY_frameIntFieldGroups', 'Int Field Groups (PMIntFieldGrp#)') as self.uiLAY_frameIntFieldGroups: with pm.columnLayout(): pm.separator(style='none', height=2) self.uiINFGRP_test1 = pm.intFieldGrp( 'uiINFGRP_test1', numberOfFields=1, label='PMIntFieldGrp1' ) self.uiINFGRP_test2 = pm.intFieldGrp( 'uiINFGRP_test2', numberOfFields=2, label='PMIntFieldGrp2' ) self.uiINFGRP_test3 = pm.intFieldGrp( 'uiINFGRP_test3', numberOfFields=3, label='PMIntFieldGrp3' ) self.uiINFGRP_test4 = pm.intFieldGrp( 'uiINFGRP_test4', numberOfFields=4, label='PMIntFieldGrp4' ) with self.uiCreateFrame('uiLAY_frameIntScrollBars', 'Int Scroll Bars (PMIntScrollBar)') as self.uiLAY_frameIntScrollBars: with pm.columnLayout(adjustableColumn=True): pm.separator(style='none', height=2) self.uiINSCRL_test1 = pm.intScrollBar('uiINSCRL_test1') self.uiINSCRL_test2 = pm.intScrollBar('uiINSCRL_test2') with self.uiCreateFrame('uiLAY_frameIntSliders', 'Int Sliders (PMIntSlider)') as self.uiLAY_frameIntSliders: with pm.columnLayout(adjustableColumn=True): pm.separator(style='none', height=2) self.uiINTSLD_test1 = pm.intSlider('uiINTSLD_test1') self.uiINTSLD_test2 = pm.intSlider('uiINTSLD_test2') with self.uiCreateFrame('uiLAY_frameIntSliderGroups', 'Int Slider Groups (PMIntSliderGrp)') as self.uiLAY_frameIntSliderGroups: with pm.columnLayout(): pm.separator(style='none', height=2) self.uiINSGRP_test1 = pm.intSliderGrp( 'uiINSGRP_test1', label='test1', field=True ) self.uiINSGRP_test2 = pm.intSliderGrp( 'uiINSGRP_test2', label='test2', field=True ) with self.uiCreateFrame('uiLAY_frameOptionMenus', 'Option Menus (PMOptionMenu)') as self.uiLAY_frameOptionMenus: with pm.columnLayout(): pm.separator(style='none', height=2) with pm.rowLayout(numberOfColumns=3): pm.separator(width=110, style='none') self.uiOPTMNU_test1 = pm.optionMenu('uiOPTMNU_test1', label='test1') pm.menuItem(label='one') pm.menuItem(label='two') pm.menuItem(label='three') self.uiOPTMNU_test2 = pm.optionMenu('uiOPTMNU_test2', label='test2') pm.menuItem(label='four') pm.menuItem(label='five') pm.menuItem(label='six') with self.uiCreateFrame('uiLAY_frameOptionMenuGroups', 'Option Menus Groups (PMOptionMenuGrp)') as self.uiLAY_frameOptionMenuGroups: with pm.columnLayout(): pm.separator(style='none', height=2) self.uiOPMGRP_test1 = pm.optionMenuGrp('uiOPMGRP_test1', label='test1', extraLabel='extraLabel') pm.menuItem(label='one') pm.menuItem(label='two') pm.menuItem(label='three') self.uiOPMGRP_test2 = pm.optionMenuGrp('uiOPMGRP_test2', label='test2', extraLabel='extraLabel') pm.menuItem(label='four') pm.menuItem(label='five') pm.menuItem(label='six') with self.uiCreateFrame('uiLAY_frameRadioButtons', 'Radio Buttons (PMRadioButton)') as self.uiLAY_frameRadioButtons: with pm.columnLayout(): with pm.rowLayout(numberOfColumns=4): pm.separator(style='none', width=140) pm.radioCollection() self.uiRAD_test1 = pm.radioButton('uiRAD_test1', label='test1') self.uiRAD_test2 = pm.radioButton('uiRAD_test2', label='test2') self.uiRAD_test3 = pm.radioButton('uiRAD_test3', label='test3') with self.uiCreateFrame('uiLAY_frameRadioButtonGroups', 'Radio Button Groups (PMRadioButtonGrp#)') as self.uiLAY_frameRadioButtonGroups: with pm.columnLayout(): pm.separator(style='none', height=2) self.uiRADGRP_test1 = pm.radioButtonGrp( 'uiRADGRP_test1', numberOfRadioButtons=1, label='PMRadioButtonGrp1', label1='test1' ) self.uiRADGRP_test2 = pm.radioButtonGrp( 'uiRADGRP_test2', numberOfRadioButtons=2, label='PMRadioButtonGrp2', labelArray2=('test1', 'test2') ) self.uiRADGRP_test3 = pm.radioButtonGrp( 'uiRADGRP_test3', numberOfRadioButtons=3, label='PMRadioButtonGrp3', labelArray3=('test1', 'test2', 'test3') ) self.uiRADGRP_test4 = pm.radioButtonGrp( 'uiRADGRP_test4', numberOfRadioButtons=4, label='PMRadioButtonGrp4', labelArray4=('test1', 'test2', 'test3', 'test4') ) with self.uiCreateFrame('uiLAY_frameSymbolCheckBoxes', 'Symbol Check Boxes (PMSymbolCheckBox)') as self.uiLAY_frameSymbolCheckBoxes: with pm.columnLayout(): with pm.rowLayout(numberOfColumns=3): pm.separator(style='none', width=140) self.uiSYMCHK_test1 = pm.symbolCheckBox( 'uiSYMCHK_test1', image='polyCube' ) self.uiSYMCHK_test2 = pm.symbolCheckBox( 'uiSYMCHK_test2', image='polyCone' ) with self.uiCreateFrame('uiLAY_frameScriptTables', 'Script Tables (PMScriptTable)') as self.uiLAY_frameScriptTables: with pm.columnLayout(): with pm.rowLayout(numberOfColumns=3): pm.separator(style='none', width=140) self.uiSCRTBL_test1 = pm.scriptTable( 'uiSCRTBL_test1', selectionMode=3, rows=4, columns=2 ) self.uiSCRTBL_test2 = pm.scriptTable( 'uiSCRTBL_test2', selectionMode=3, rows=4, columns=2 ) with self.uiCreateFrame('uiLAY_frameScrollField', 'Scroll Field (PMScrollField)') as self.uiLAY_frameScrollField: with pm.columnLayout(): with pm.rowLayout(numberOfColumns=3): pm.separator(style='none', width=140) self.uiSCRFLD_test1 = pm.scrollField( 'uiSCRFLD_test1', wordWrap=True ) self.uiSCRFLD_test2 = pm.scrollField( 'uiSCRFLD_test2', wordWrap=True ) with self.uiCreateFrame('uiLAY_frameShelfTabLayout', 'Shelf Tab Layout (PMShelfTabLayout)') as self.uiLAY_frameShelfTabLayout: with pm.columnLayout(adjustableColumn=True): with pm.shelfTabLayout('uiSHLTAB_test1') as self.uiSHLTAB_test1: with pm.shelfLayout('test1'): pass with pm.shelfLayout('test2'): pass with pm.shelfLayout('test3'): pass with pm.shelfTabLayout('uiSHLTAB_test2') as self.uiSHLTAB_test2: with pm.shelfLayout('test4'): pass with pm.shelfLayout('test5'): pass with pm.shelfLayout('test6'): pass with self.uiCreateFrame('uiLAY_frameTabLayout', 'Tab Layout (PMTabLayout)') as self.uiLAY_frameTabLayout: with pm.columnLayout(adjustableColumn=True): with pm.tabLayout('uiTAB_test1') as self.uiTAB_test1: with pm.rowLayout(numberOfColumns=1) as uiLAY_tabRow1: pass with pm.rowLayout(numberOfColumns=1) as uiLAY_tabRow2: pass with pm.rowLayout(numberOfColumns=1) as uiLAY_tabRow3: pass pm.tabLayout( self.uiTAB_test1, edit=True, tabLabel=((uiLAY_tabRow1, 'test1'), (uiLAY_tabRow2, 'test2'), (uiLAY_tabRow3, 'test3'),) ) with pm.tabLayout('uiTAB_test2') as self.uiTAB_test2: with pm.rowLayout(numberOfColumns=1) as uiLAY_tabRow4: pass with pm.rowLayout(numberOfColumns=1) as uiLAY_tabRow5: pass with pm.rowLayout(numberOfColumns=1) as uiLAY_tabRow6: pass pm.tabLayout( self.uiTAB_test2, edit=True, tabLabel=((uiLAY_tabRow4, 'test4'), (uiLAY_tabRow5, 'test5'), (uiLAY_tabRow6, 'test6'),) ) with self.uiCreateFrame('uiLAY_frameTextFields', 'Text Fields (PMTextField)') as self.uiLAY_frameTextFields: with pm.columnLayout(): pm.separator(style='none', height=2) with pm.rowLayout(numberOfColumns=3): pm.separator(width=140, style='none') self.uiTXT_test1 = pm.textField('uiTXT_test1') self.uiTXT_test2 = pm.textField('uiTXT_test2') with self.uiCreateFrame('uiLAY_frameTextFieldButtonGroups', 'Text Field Button Groups (PMTextFieldButtonGrp)') as self.uiLAY_frameTextFieldButtonGroups: with pm.columnLayout(): pm.separator(style='none', height=2) self.uiTXBTGR_test1 = pm.textFieldButtonGrp( 'uiTXBTGR_test1', label='test1', buttonLabel='button1' ) self.uiTXBTGR_test2 = pm.textFieldButtonGrp( 'uiTXBTGR_test2', label='test2', buttonLabel='button2' ) with self.uiCreateFrame('uiLAY_frameTextFieldGroups', 'Text Field Groups (PMTextFieldGrp)') as self.uiLAY_frameTextFieldGroups: with pm.columnLayout(): pm.separator(style='none', height=2) self.uiTXTGRP_test1 = pm.textFieldGrp( 'uiTXTGRP_test1', label='test1' ) self.uiTXTGRP_test2 = pm.textFieldGrp( 'uiTXTGRP_test2', label='test2' ) with self.uiCreateFrame('uiLAY_frameTextScrollLists', 'Text Scroll Lists (PMTextScrollList)') as self.uiLAY_frameTextScrollLists: with pm.columnLayout(): with pm.rowLayout(numberOfColumns=3): pm.separator(style='none', width=140) self.uiTXTLST_test1 = pm.textScrollList( 'uiTXTLST_test1', allowMultiSelection=True, append=('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten') ) self.uiTXTLST_test2 = pm.textScrollList( 'uiTXTLST_test2', allowMultiSelection=True, append=('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten') ) self.uiBTN_savePrefs = pm.button( label='Save Prefs', height=MAIN_BUTTONS_HEIGHT, command=self.onSavePrefsClicked ) self.uiBTN_loadPrefs = pm.button( label='Load Prefs', height=MAIN_BUTTONS_HEIGHT, command=self.onLoadPrefsClicked ) self.uiBTN_resetPrefs = pm.button( label='Reset Prefs', height=MAIN_BUTTONS_HEIGHT, command=self.onResetPrefsClicked ) uiLAY_mainForm.attachForm(self.uiLAY_mainScroll, 'top', 2) uiLAY_mainForm.attachForm(self.uiLAY_mainScroll, 'left', 2) uiLAY_mainForm.attachForm(self.uiLAY_mainScroll, 'right', 2) uiLAY_mainForm.attachControl(self.uiLAY_mainScroll, 'bottom', 2, self.uiBTN_savePrefs) uiLAY_mainForm.attachNone(self.uiBTN_savePrefs, 'top') uiLAY_mainForm.attachForm(self.uiBTN_savePrefs, 'left', 2) uiLAY_mainForm.attachPosition(self.uiBTN_savePrefs, 'right', 2, 33) uiLAY_mainForm.attachForm(self.uiBTN_savePrefs, 'bottom', 2) uiLAY_mainForm.attachNone(self.uiBTN_loadPrefs, 'top') uiLAY_mainForm.attachPosition(self.uiBTN_loadPrefs, 'left', 2, 33) uiLAY_mainForm.attachPosition(self.uiBTN_loadPrefs, 'right', 2, 66) uiLAY_mainForm.attachForm(self.uiBTN_loadPrefs, 'bottom', 2) uiLAY_mainForm.attachNone(self.uiBTN_resetPrefs, 'top') uiLAY_mainForm.attachPosition(self.uiBTN_resetPrefs, 'left', 2, 66) uiLAY_mainForm.attachForm(self.uiBTN_resetPrefs, 'right', 2) uiLAY_mainForm.attachForm(self.uiBTN_resetPrefs, 'bottom', 2) self.window.setTitle(self.window.__class__)
def main(*args): if pm.window('riggingToolkitWindow', exists = True): pm.deleteUI('riggingToolkitWindow', window = True) print 'Pre-existing window ToolKit deleted' if pm.dockControl('riggingToolkitDockControl', exists = True): pm.deleteUI('riggingToolkitDockControl', control = True) #Declarations global windowWidth global windowHeight global jointChainLenField global nameField global suffixField global typeIndex global stretchyCheckBox global newNameField global newSuffixField windowWidth = 325 windowHeight = 100000 allowedAreas = ['left', 'right'] buttonIndex = 0 typeIndex = 0 childFrameWidth = windowWidth - 5 window_object = pm.window('riggingToolkitWindow', t = 'Rigging Toolkit', width = windowWidth, height = windowHeight, sizeable = False) scrollFieldColumnLayout = pm.rowColumnLayout(nc = 1) scrollField = pm.scrollLayout(w = 350, h = 600) mainColumnLayout = pm.rowColumnLayout(nc = 1) jointFrameLayout = pm.frameLayout('jointLayout', cll = True, cl = False, width = windowWidth, l = 'Joint Layout') jointChainColumn = pm.rowColumnLayout(nc = 2) pm.text(l = 'Name', al = 'center', width = windowWidth/2) pm.text(l = 'Suffix', al = 'center', width = windowWidth/2) nameField = pm.textField() suffixField = pm.textField() pm.setParent(jointFrameLayout) worldColumn = pm.rowColumnLayout(nc = 2) pm.button(l = 'Define World', w = (windowWidth/6) * 5, c = defineWorld) pm.button(l = 'Set', w = windowWidth/6, c = setWorld) pm.setParent(jointFrameLayout) jointChainColumnSecondary = pm.rowColumnLayout(nc = 2) jointChainLenField = pm.textField(w = windowWidth/8, tx = '5') jointChainButton = pm.button(l = 'Create Joint Chain', c = createJointChain, w = ((windowWidth/8)*7)) pm.setParent(jointFrameLayout) radioButtonRColmn = pm.rowColumnLayout(nc = 2) jntChnTypRadioCollection = pm.radioCollection() normChain = pm.radioButton(l = 'Normal', w = windowWidth/2, onc = lambda *args: buttonIndexUpdate(0)) ribnChain = pm.radioButton(l = 'Ribbon', w = windowWidth/2, onc = lambda *args: buttonIndexUpdate(1)) pm.setParent(mainColumnLayout) jointSetupFrmLyt = pm.frameLayout('jointSetup', cll = True, cl = True, w = windowWidth, l = 'Joint Setup') separatorText('Spine Setup') spineTypeClmnLyt = pm.rowColumnLayout(nc = 2) pm.button(l = 'Schleifer', c = schleiferify, w = (windowWidth/2)) pm.button(l = 'Ribbon', c = folliclify, w = windowWidth/2) pm.setParent(jointSetupFrmLyt) separatorText('Switch Setup') fkIkSpineClmnLyt = pm.rowColumnLayout(nc = 2) pm.button(l = 'Fk', c = lambda *args: makeFk( False, pm.ls(selection = True)[0]), w = windowWidth/2) pm.button(l = 'Ik', c = lambda *args: makeIk( False, pm.ls(selection = True)[0]), w = windowWidth/2) pm.setParent(jointSetupFrmLyt) pm.button(l = 'Fk Ik', c = makeFkIk, w = windowWidth) stretchyCheckBox = pm.checkBox(l = 'Stretchy', v = 0) footRollSetup = pm.frameLayout('footRollSetup', cll = True, cl = True, w = windowWidth, l = 'FootRoll Setup') separatorText('Setup') footRollRowCol = pm.rowColumnLayout( nc = 2) pm.button(l = 'Setup', c = setupFootRoll, w = childFrameWidth * 0.7) pm.button(l = 'Accept', c = acceptFootRoll, w = childFrameWidth * .3) pm.setParent(mainColumnLayout) miscFrmLyt = pm.frameLayout('miscTools', cll = True, cl = True, w = windowWidth, l = 'Miscellaneous Tools') renameFrmLyt = pm.frameLayout('renameTool', cll = True, cl = True, w = windowWidth, l = 'Joint Tools') jointChainColumn = pm.rowColumnLayout(nc = 2) pm.text(l = 'Name', al = 'center', width = windowWidth/2) pm.text(l = 'Suffix', al = 'center', width = windowWidth/2) newNameField = pm.textField(w = windowWidth/2, pht = "Type Name Here") newSuffixField = pm.textField(w = windowWidth/2, pht = "Type Suffix Here") pm.setParent(renameFrmLyt) pm.button(l = 'Rename', c = jointChainRename, w = windowWidth) pm.button(l = 'Pad', c = createPad, w = windowWidth) pm.button(l = 'Select hierarchy', c = lambda *args: pm.select(hi = True), w = windowWidth) pm.setParent(miscFrmLyt) ctrlsFrmLyt = pm.frameLayout('ctrlTools', cll = True, cl = True, w = windowWidth, l = 'Control Tools') separatorText('Controls') pm.button(l = 'Edit Controls', c = editControls, w = windowWidth) pm.button(l = 'SDK Creator', c = lambda *args: customSdk.gui(), w = windowWidth) pm.setParent(miscFrmLyt) visualScaleFrmLyt = pm.frameLayout(label = 'Visual Scale', cll = True, cl = True) separatorText('Visual Scale') jointSize = 1.00 ikSize = 1.00 pm.columnLayout(columnOffset = ['left', -100], adjustableColumn = True, cal = 'left') jointSizeSliderObject = pm.floatSliderGrp(min = 0.001, max = 10, l = 'Joint Size', pre = 2, f = True, v = jointSize, cc = changeJointScale, dc = changeJointScale, adjustableColumn = True,) ikSizeSliderObject = pm.floatSliderGrp(min = 0.001, max = 10, l = 'IK Size', f = True, v = ikSize, cc = changeIKScale, dc = changeIKScale, adjustableColumn = True) pm.setParent(miscFrmLyt) facialFrame = pm.frameLayout('facialTools', cll = True, cl = True, w = windowWidth, l = 'Facial Tools') separatorText('Direct Connect') directConRowCol = pm.rowColumnLayout(nc = 3) pm.button(l = 'Trans', c = conTrans, w = windowWidth/3) pm.button(l = 'Rot', c = conRot, w = windowWidth/3) pm.button(l = 'Scale', c = conScale, w = windowWidth/3) pm.setParent(miscFrmLyt) geoFrame = pm.frameLayout('geometryTools', cll = True, cl = True, w = windowWidth, l = 'Geometry Tools') pm.text(l = 'Geometry', al = 'center', w = windowWidth) pm.rowColumnLayout(nc = 2) pm.button(l = 'Reference', c = refGeo, w = windowWidth/2) pm.button(l = 'Unreference', c = unRefGeo, w = windowWidth/2) pm.setParent(geoFrame) pm.text(l = 'Accessories', al = 'center', w = windowWidth) pm.rowColumnLayout(nc = 2) pm.button(l = 'Hide', c = hideAcc, w = windowWidth/2) pm.button(l = 'Unhide', c = unHideAcc, w = windowWidth/2) pm.dockControl('riggingToolkitDockControl', l = 'Rigging Toolkit', area = 'right', content = window_object, allowedArea = allowedAreas)