def create_shots(with_cameras): cnt = 0 while pm.textField('%s%s' % (shot_name_name, str(cnt)), ex=1): cnt += 1 seqs = [seq for seq in pm.ls(type='sequencer') if seq.referenceFile() is None] if len(pm.ls(type='sequencer')) != 1: raise RuntimeError('There must be 1 sequencer in a scene.') seq = seqs[0] for i in range(0, cnt): shot_node_name = pm.textField('%s%s' % (shot_name_name, str(i)), q=1, text=1) start_frame = pm.intField('%s%s' % (start_frame_name, str(i)), q=1, v=1) end_frame = pm.intField('%s%s' % (end_frame_name, str(i)), q=1, v=1) shot_num = pm.textField('%s%s' % (shot_num_name, str(i)), q=1, text=1) shot = pm.createNode('shot', n=shot_node_name) shot.setAttr('startFrame', start_frame) shot.setAttr('sequenceStartFrame', start_frame) shot.setAttr('endFrame', end_frame) shot.setAttr('shotName', shot_num) seq.add_shot(shot) if with_cameras: camera_name = '%s%s' % (pm.textField('camera_prefix_name', q=1, text=1), str(i+1)) cam = pm.mel.eval('camera -n "%s";' % camera_name) pm.PyNode(cam[1]).setAttr('farClipPlane', 1000000) pm.PyNode(cam[1]).setAttr('focalLength', 35) pm.PyNode(cam[0]).attr('scaleX').lock() pm.PyNode(cam[0]).attr('scaleY').lock() pm.PyNode(cam[0]).attr('scaleZ').lock() shot.set_camera(pm.PyNode(cam[1]))
def __init__(self): global offsetCurveOptions with pdil.ui.singleWindow(self.id): with columnLayout(): self.mode = radioButtonGrp( nrb=3, la3=['Playback Range', 'User Defined', 'All'], on1=Callback(self.setPlaybackMode), on2=Callback(self.setUserMode), on3=Callback(self.setAllMode), ) with rowColumnLayout(nc=2) as self.range: self.start = intField() self.end = intField() with rowColumnLayout(nc=2): #checkBox(l='Autokey', en=False) button(label='Apply', c=Callback(self.apply)) if offsetCurveOptions.uiMode == 1: self.setPlaybackMode() elif offsetCurveOptions.uiMode == 2: self.setUserMode() elif offsetCurveOptions.uiMode == 3: self.setAllMode()
def createGuideCallback(self, *args): fromScene = pm.checkBox(self.getFromSceneCheckbox, q=True, v=True) rigName = pm.textFieldGrp(self.characterNameTextField, tx=True, q=True) fingersSetup = self.getFingerSetup() hasTailChk = pm.checkBox(self.hasTailCheckbox, q=True, v=True) tailJnts = pm.intField(self.tailJointsIntField, q=True, v=True) spineJnts = pm.intField(self.spineJointsIntField, q=True, v=True) if not hasTailChk: tailJnts = 0 self.quadrupedInstance = quadruped.Quadruped( rigName=rigName, spineJnts=spineJnts, tailJnts=tailJnts, handFingers=fingersSetup[0], footFingers=fingersSetup[1]) if fromScene: self.quadrupedInstance.getDictsFromScene() fingerSetup = self.getFingerSetupFromScene() self.setFingerSetup(fingerSetup=fingerSetup) self.quadrupedInstance.generateGuides() guideGrp = pm.PyNode('GUIDES') guideGrp.visibility.set(True) try: rigGrp = pm.PyNode(self.quadrupedInstance.name.upper()) rigGrp.visibility.set(False) except: logger.warn('no rig yet')
def _get_settings_for_animation(robot): """ Get the animation parameters start frame, end frame, framerate, and total time in seconds from Maya. :return: """ start_frame = pm.intField("i_programStartFrame", query=True, value=True) end_frame = pm.intField("i_programEndFrame", query=True, value=True) framerate = mimic_utils.get_maya_framerate() # Define the animation time in seconds. animation_time_sec = ((end_frame) - start_frame) / framerate # Raise warning if end frame and start frame incompatible if end_frame <= start_frame: warning = 'End Frame must be larger than Start Frame' raise mimic_utils.MimicError(warning) ''' # Raise warning if no keyframes are set closest_ik_key = mimic_utils.get_closest_ik_keyframe(robot, start_frame)[0] if not type(closest_ik_key) == float: warning = 'You must set an IK or FK keyframe to ensure ' \ 'proper evaluation when saving a program; ' \ 'no program written' raise mimic_utils.MimicError(warning) ''' # All good, create output dictionary animation_settings = {'Start Frame': start_frame, 'End Frame': end_frame, 'Framerate': framerate, 'Animation Time (sec)': animation_time_sec} return animation_settings
def exec_button(*args): path = pmc.fileDialog2(fileFilter='*.abc') if path: path = path[0] else: exit("Canceled") #query ui values framemode = pmc.radioCollection('framemode', query=True, sl=True) preroll = pmc.checkBox('preroll', q=True, value=True) qstart = pmc.intField('start', q=True, value=True) qend = pmc.intField('end', q=True, value=True) preframe = pmc.intField('prerollstart', q=True, value=True) step = pmc.intField('step', q=True, value=True) toguerilla = pmc.checkBox('guerilla', q=True, value=True) #export with maUtils abc_export marilla.maUtils.abc_export(path=path,framemode=framemode,preroll=preroll, qstart=qstart, qend=qend, preframe=preframe, step=step, nodes=pmc.ls(sl=True)) #send to guerilla if toguerilla: command=("local mod = Document:modify(); mod.createref ('{filename}'" ",'{path}',nil,{{prefixnodes=false,containschildren=false}}); " "mod.finish()").format( filename=os.path.basename(path).split('.')[0], path=path) try: sock = marilla.utils.sockette.SendCommand(port=1978, command=command) sock.send() except: raise SystemError("Maybe Guerilla is closed ? ") if pmc.window('exportabc', exists=True): pmc.deleteUI('exportabc')
def createRigCallback(self, *args): reaply = pm.checkBox(self.reapplySkinCheckbox, q=True, v=True) armRibChk= pm.checkBox(self.hasArmRibbonsCheckbox,q=True, v=True) armRibbons = pm.intField(self.armRibbonJointsIntField, q=True, v=True) armOffset = pm.floatFieldGrp(self.armRibbonFirstJointOffsetFloatField, q=True, v1=True) legRibChk= pm.checkBox(self.hasLegRibbonsCheckbox,q=True, v=True) legRibbons = pm.intField(self.legRibbonJointsIntField, q=True, v=True) legOffset = pm.floatFieldGrp(self.legRibbonFirstJointOffsetFloatField, q=True, v1=True) spineJnts = pm.intField(self.spineJointsIntField, q=True, v=True) if not legRibChk: legRibbons=0 if not armRibChk: armRibbons=0 if reaply: self.bipedInstance.saveSkin() self.bipedInstance.generateRig(armRibbons=armRibbons, armOffsetStart=armOffset, armOffsetEnd=armOffset, legRibbons=legRibbons, legOffsetStart=legOffset, legOffsetEnd=legOffset, parentModules=True, spineJnts=spineJnts) if reaply: try: self.bipedInstance.loadSkin() except: logger.warn('no rig...')
def leftHandBake(mayaFalse): #deprecated #hikCreateAuxEffector Character1_Ctrl_LeftWristEffector; #bake the left hand controller pm.setKeyframe('Controller_LeftHand_Locator', t=0) pm.setAttr('Controller_LeftHand_Locator.blendParent1', 1) #pm.setAttr('Character1_Ctrl_LeftWristEffector.rt', 1) #pm.setAttr('Character1_Ctrl_LeftWristEffector.rr', 0) for i in range( pm.intField('fromFrame', q=True, value=True), (1 + pm.intField('toFrame', q=True, value=True))): #copying keys from controller pm.currentTime(i, update=True) pm.setKeyframe('Character1_Ctrl_LeftWristEffectorAux1', at='translateX', v=pm.getAttr('Controller_LeftHand_Locator.tx', time=i)) pm.setKeyframe('Character1_Ctrl_LeftWristEffectorAux1', at='translateY', v=pm.getAttr('Controller_LeftHand_Locator.ty', time=i)) pm.setKeyframe('Character1_Ctrl_LeftWristEffectorAux1', at='translateZ', v=pm.getAttr('Controller_LeftHand_Locator.tz', time=i)) pm.setKeyframe('Character1_Ctrl_LeftWristEffectorAux1', at='rotateX', v=pm.getAttr('Controller_LeftHand_Locator.rx', time=i)) pm.setKeyframe('Character1_Ctrl_LeftWristEffectorAux1', at='rotateY', v=pm.getAttr('Controller_LeftHand_Locator.ry', time=i)) pm.setKeyframe('Character1_Ctrl_LeftWristEffectorAux1', at='rotateZ', v=pm.getAttr('Controller_LeftHand_Locator.rz', time=i))
def _get_settings_for_animation(robot): """ Get the animation parameters start frame, end frame, framerate, and total time in seconds from Maya. :return: """ start_frame = pm.intField("i_programStartFrame", query=True, value=True) end_frame = pm.intField("i_programEndFrame", query=True, value=True) framerate = mimic_utils.get_maya_framerate() # Define the animation time in seconds. animation_time_sec = ((end_frame) - start_frame) / framerate # Raise warning if end frame and start frame incompatible if end_frame <= start_frame: warning = 'End Frame must be larger than Start Frame' raise mimic_utils.MimicError(warning) # Create output dictionary animation_settings = { 'Start Frame': start_frame, 'End Frame': end_frame, 'Framerate': framerate, 'Animation Time (sec)': animation_time_sec } return animation_settings
def __init__(self): title = 'pbRenderableCurve' version = 1.02 if pm.window('pbRCurve', exists=True): pm.deleteUI('pbRCurve') with pm.window('pbRCurve', title='{0} | {1}'.format(title, version), s=False) as window: with pm.columnLayout(): with pm.frameLayout(l='Selection:', cll=True, bs='out'): with pm.columnLayout(): self.selField = pm.textFieldGrp(text='No Curves Selected', ed=False, l='Curve:', cw2=[72, 192]) with pm.rowLayout(nc=2): self.bRenderable = pm.checkBox(l='Renderable', cc=self.bcRenderable) with pm.frameLayout(l='Mesh Settings:', cll=True, bs='out') as self.meshUI: with pm.columnLayout(): with pm.rowLayout(nc=4): self.useNormal = pm.checkBox(l='Use Normal', cc=self.bcUseNormal) self.normalVector = [pm.intField(width=62, en=False, value=0, cc=self.setNormal), pm.intField(width=62, en=False, value=1, cc=self.setNormal), pm.intField(width=62, en=False, value=0, cc=self.setNormal)] self.meshAttrs = [AttrSlider(maxValue=128, name='Thickness', obj=getCurves, type_='float', fmn=0.0001), AttrSlider(value=3, minValue=3, maxValue=64, name='Sides', obj=getCurves, fmn=3, fmx=100), AttrSlider(minValue=1, maxValue=32, name='Samples', obj=getCurves, fmn=1, fmx=128)] with pm.frameLayout('Shell Settings:', cll=True, bs='out') as self.shellUI: with pm.columnLayout(): self.bShell = pm.checkBox(l='Enable Shell', cc=self.bcShell) self.shellAttrs = [AttrSlider(value=1, minValue=-64, maxValue=64, name='ShellThickness', obj=getCurves, type_='float'), AttrSlider(value=1, minValue=1, maxValue=64, name='ShellDivisions', obj=getCurves, fmn=1, fmx=32)] window.show() pm.scriptJob(event=['SelectionChanged', self.refresh], protected=True, p=window) self.refresh()
def __init__(self): respresets = [4096, 2048, 1024, 512, 256, 128, 64, 32] with pm.frameLayout(l='Options', cll=True, cl=False, bs='out'): with pm.columnLayout(): pm.text('Map Size:') pm.separator(st='in', width=160, height=8) with pm.rowColumnLayout(nc=3, cw=[20, 60]): pm.text(l='Width:') self.width = pm.intField(v=1024, width=42) with pm.optionMenu(): for i in respresets: pm.menuItem(l=i) pm.text(l='Height:') self.height = pm.intField(v=1024, width=42) with pm.optionMenu(): for i in respresets: pm.menuItem(l=i) pm.button(l='Get Map Size') pm.separator(st='in', width=160, height=8) with pm.columnLayout(): self.compSpace = pm.checkBox(l='Retain Component Spaceing', cc=lambda *args: pm.texMoveContext('texMoveContext', e=True, scr=self.compSpace.getValue()), v=pm.texMoveContext('texMoveContext', q=True, scr=True)) self.pixelUnits = pm.checkBox(l='Transform In Pixels')
def getTimeRange(self, *args): # get time range aPlayBackSliderPython = pm.mel.eval('$tmpVar=$gPlayBackSlider') timeRange = pm.timeControl( aPlayBackSliderPython, q=True, rangeArray=True ) if timeRange[1] - timeRange[0] < 2.0: timeRange = [ pm.playbackOptions( q=True, minTime=True), pm.playbackOptions( q=True, maxTime=True) ] pm.intField( self.startFrameIntField, e=True, value=timeRange[0] ) pm.intField( self.endFrameIntField, e=True, value=timeRange[1] )
def refresh(): State._slideParams['start'] = pm.intField(State._wnd.startField, query=True, value=True) State._slideParams['end'] = pm.intField(State._wnd.endField, query=True, value=True) State._slideParams['X'] = pm.floatField(State._wnd.xSlideField, query=True, value=True) State._slideParams['Y'] = pm.floatField(State._wnd.ySlideField, query=True, value=True) State._slideParams['Z'] = pm.floatField(State._wnd.zSlideField, query=True, value=True) pm.iconTextScrollList(State._wnd.selectedObjectsList, edit=True, removeAll=True) pm.iconTextScrollList(State._wnd.selectedObjectsList, edit=True, append=list(State._selectedObjects))
def autoKey(attr, time): ##Get attrs from ui easeInFrames = pm.intField("EaseInIntFeild", q=True, v=True) holdInFrames = pm.intField("HoldInIntFeild", q=True, v=True) holdOutFrames = pm.intField("HoldOutIntFeild", q=True, v=True) easeOutFrames = pm.intField("EaseOutIntFeild", q=True, v=True) InTangentType = pm.optionMenu("EaseInTangetType_optmenu", q=True, v=True) OutTangentType = pm.optionMenu("EaseOutTangetType_optmenu", q=True, v=True) pm.cutKey(attr, t=":") initKey = pm.setKeyframe(attr, v=1, t=time, inTangentType=InTangentType, outTangentType=OutTangentType) if easeInFrames > 0: pm.setKeyframe( attr, v=0, t=[time - easeInFrames - holdInFrames], outTangentType=InTangentType) ##ease in @UndefinedVariable else: initKey if holdInFrames > 0: pm.setKeyframe( attr, v=1, t=(time - holdInFrames), inTangentType=InTangentType, outTangentType=InTangentType) ##inHold @UndefinedVariable else: initKey if holdOutFrames > 0: pm.setKeyframe( attr, v=1, t=(time + holdOutFrames), inTangentType=OutTangentType, outTangentType=OutTangentType) ##outHold @UndefinedVariable else: initKey if easeOutFrames > 0: pm.setKeyframe( attr, v=0, t=[time + easeOutFrames + holdOutFrames], inTangentType=OutTangentType) ##ease out @UndefinedVariable else: initKey
def create(self): ''' this creates the gui components for the node ''' pm.setParent(self.layout) # layout for all other frame layouts self.temp_layout = pm.columnLayout(adjustableColumn= False, width= 340) # this will list all animCurve nodes associated with an object # because anim nodes are named object_attr # but if the object is renamed after it's been keyed the anim node # will still have it's old name # by listing the anim nodes of the object * naming wont be an issue anim_nodes = pm.keyframe( '%s' % (self.node), query=True, name=True ) for anim_node in anim_nodes: pm.setParent(self.temp_layout) # getting the amount of keyframes for the curve node count = pm.keyframe( '%s' % (anim_node) , query=True, keyframeCount=True ) # translate U my_ui = Anim_UI(node= '%s' % (anim_node), count = count) my_ui.create() # creating a new string node = '%s' % (anim_node) # getting the attr the curve node is for # the insert and delete key methods need an attr to act on # all anim nodes are named object_attr # so i'm splitting to get just hte attr part node_attr = node.split('_')[-1] # indsert key # this will build the section for key insertion pm.setParent('..') pm.text(label= 'Insert Key') pm.rowColumnLayout(numberOfColumns= 3, columnWidth= ([1,113], [2,113], [3,113])) pm.text(label= 'Key Position') insert_field = pm.intField() pm.button(label= 'Insert', command= pm.Callback(self.insert_key, attr= '%s.%s' % (self.node, node_attr), value= insert_field)) # delete key # this will build the section for key deletion pm.setParent('..') pm.text(label= 'Delete Key') pm.rowColumnLayout(numberOfColumns= 3, columnWidth= ([1,113], [2,113], [3,113])) pm.text(label= 'Key Index') delete_field = pm.intField() pm.button(label= 'Delete', command= pm.Callback(self.delete_key, attr= '%s.%s' % (self.node, node_attr), index= delete_field))
def create(self, stationary_count, offset_count): ''' Create the fgshooter window. ''' if pm.window(self.window_name, exists=True): pm.deleteUI(self.window_name) pm.window(self.window_name, title=self.window_title) main_form = pm.formLayout(numberOfDivisions=2) self.column = pm.columnLayout(adjustableColumn=True) # Render Camera self.render_camera_field = pm.checkBoxGrp(label="Include Render Camera", value1=self.render_camera, changeCommand=self.updateRenderCamera) # Stationary Cameras pm.separator(height=20, style="in") pm.rowLayout(numberOfColumns=3, columnWidth3=(140, 80, 80), columnAlign=(1, 'right'), columnAttach3=("right", "both", "both")) pm.text("Stationary Cameras") self.stationary_field = pm.intField(value=stationary_count) pm.button(label="Update", height=22, command=self.update) pm.setParent('..') self.stationary = [] i = 0 while i < stationary_count: self.stationary.append(pm.floatFieldGrp(value1=self.stationary_frames[i], label="frame")) i += 1 # Offset Cameras pm.separator(height=20, style="in") pm.rowLayout(numberOfColumns=3, columnWidth3=(140, 80, 80), columnAlign=(1, 'right'), columnAttach3=("right", "both", "both")) pm.text("Offset Cameras") self.offset_field = pm.intField(value=offset_count) pm.button(label="Update", height=22, command=self.update) pm.setParent('..') self.offset = [] i = 0 while i < offset_count: self.offset.append(pm.intFieldGrp(value1=self.offset_frames[i], label="frame offset")) i += 1 pm.setParent('..') # remove/apply buttons self.remove_button = pm.button(label="Remove All", height=30, command=self.remove) self.apply_button = pm.button(label="Apply / Refresh", height=30, command=self.apply) pm.formLayout(main_form, edit=True, attachForm=[(self.column, "top", 2),(self.column, "left", 2),(self.column, "right", 2), (self.remove_button, "bottom", 2), (self.remove_button, "left", 2), (self.apply_button, "bottom", 2), (self.apply_button, "right", 2)], attachControl=(self.remove_button, "right", 1, self.apply_button), attachPosition=[ (self.remove_button, "right", 0, 1), (self.apply_button, "left", 1, 1)] ) pm.setParent('..') pm.showWindow()
def applyCache( self, *args ): startFrame = pm.intField( self.startFrameIntField, q=True, value=True ) endFrame = pm.intField( self.endFrameIntField, q=True, value=True ) cacheFolder = pm.textField( self.cacheFolderTextField, q=True, text=True ) objs = pm.ls( sl=True ) for obj in objs: # if cache node exsits update address of cache node and frame range if self.findCacheNode( obj ): self.replaceCache( cacheNode=self.findCacheNode( obj ), newCacheFolder=cacheFolder, cacheName=obj.getShape(), startFrame=startFrame, endFrame=endFrame ) # if cache node doesn't exists, check and see if there is a cache file for the selected object and attach it to the object elif self.cacheFileExists( obj ): self.assignCacheFile( obj )
def initialiseLayout(self): """ define the layout of the ui, also find every module under the TOOL_FOLDER, create a button for each module found""" #======================================================================= #DEFINE LAYOUT #======================================================================= self.widgets["toplevel_column"] = pm.columnLayout(adj=True) # ASSET LAYOUT pm.setParent(self.widgets["toplevel_column"]) pm.frameLayout(label='Asset', collapsable=False, labelVisible=False) h = pm.horizontalLayout(ratios=[1,5]) pm.text("Search :") self.widgets['assets_searchFilter_textField'] = pm.textField(cc=self.refresh_asset_textScroll) h.redistribute() pm.setParent("..") self.widgets['assets_textScroll'] = pm.textScrollList(ams=True, h=200, selectCommand=self.select_asset_callback) # IMAGE LAYOUT pm.setParent(self.widgets["toplevel_column"]) pm.frameLayout(label='Image', collapsable=True, labelVisible=True) pm.scrollLayout(h=130) pm.popupMenu() pm.menuItem(label='Open Thumbnail Directory', c=self.thumbnail_directory_open_callback) self.widgets['thumbnails_brower'] = pm.horizontalLayout() self.widgets['thumbnails_brower'].redistribute() # pm.setParent(self.widgets["toplevel_column"]) pm.frameLayout(label='Settings', collapsable=True, labelVisible=True) pm.rowColumnLayout(numberOfColumns=4) pm.text(label='Zoom', w=100) self.widgets['zoom_field'] = pm.floatField(minValue=1, value=1, precision=2, w=100) pm.separator(style='none') pm.separator(style='none') pm.text(label='Width', w=100) self.widgets['width_field'] = pm.intField(value=100, w=100) pm.text(label='Height', w=100) self.widgets['height_field'] = pm.intField(value=100, w=100) pm.text(label='Offset W', w=100) self.widgets['shiftWidth_field'] = pm.floatField( value=0, precision=2, w=100) pm.text(label='Offset H', w=100) self.widgets['shiftHeight_field'] = pm.floatField( value=0, precision=2, w=100) # pm.setParent(self.widgets["toplevel_column"]) pm.button(label='Generate Thumbnails', c=self.generate_thumbnail) #INITIAL self.refresh_asset_textScroll()
def getTimeRange(self, *args): # get time range aPlayBackSliderPython = pm.mel.eval('$tmpVar=$gPlayBackSlider') timeRange = pm.timeControl(aPlayBackSliderPython, q=True, rangeArray=True) if timeRange[1] - timeRange[0] < 2.0: timeRange = [ pm.playbackOptions(q=True, minTime=True), pm.playbackOptions(q=True, maxTime=True) ] pm.intField(self.startFrameIntField, e=True, value=timeRange[0]) pm.intField(self.endFrameIntField, e=True, value=timeRange[1])
def createRigCallback(self, *args): reaply = pm.checkBox(self.reapplySkinCheckbox, q=True, v=True) armRibChk = pm.checkBox(self.hasArmRibbonsCheckbox, q=True, v=True) armRibbons = pm.intField(self.armRibbonJointsIntField, q=True, v=True) armOffset = pm.floatFieldGrp(self.armRibbonFirstJointOffsetFloatField, q=True, v1=True) legRibChk = pm.checkBox(self.hasLegRibbonsCheckbox, q=True, v=True) legRibbons = pm.intField(self.legRibbonJointsIntField, q=True, v=True) legOffset = pm.floatFieldGrp(self.legRibbonFirstJointOffsetFloatField, q=True, v1=True) parentModulesSel = pm.radioButtonGrp(self.modulesConnectionRadioButton, q=True, sl=True) spineJnts = pm.intField(self.spineJointsIntField, q=True, v=True) print 'parent', parentModulesSel if parentModulesSel == 1: parentModules = True else: parentModules = False print armRibbons, legRibbons if not legRibChk: legRibbons = 0 if not armRibChk: armRibbons = 0 if reaply: self.quadrupedInstance.saveSkin() self.quadrupedInstance.generateRig(armRibbons=armRibbons, armOffsetStart=armOffset, armOffsetEnd=armOffset, legRibbons=legRibbons, legOffsetStart=legOffset, legOffsetEnd=legOffset, parentModules=parentModules, spineJnts=spineJnts) if reaply: try: self.quadrupedInstance.loadSkin() except: logger.error('nao tem rig ainda...')
def __init__(self): self._window = pm.window(title='Vibrate', widthHeight=VibrateWindow._size, sizeable=False, maximizeButton=False) self._wrapper = pm.rowColumnLayout(numberOfColumns=1, columnWidth=[(1, VibrateWindow._size[0]), (2, VibrateWindow._size[0])], height=VibrateWindow._size[1]) self._form = pm.formLayout(parent=self._wrapper, height=470) self._execBtn = pm.button(label='Set Vibration', parent=self._wrapper, command=State.setVibration) self._clearBtn = pm.button(label='Clear Vibration', parent=self._wrapper, command=State.clearVibration) self._tabs = pm.tabLayout(innerMarginWidth=5, innerMarginHeight=5) self._subform = pm.formLayout(self._form, edit=True, attachForm=((self._tabs, 'top', 0), (self._tabs, 'left', 0), (self._tabs, 'bottom', 0), (self._tabs, 'right', 0))) self._tabObjects = pm.rowColumnLayout(numberOfColumns=1) pm.button(label='Add selected from scene', command=State.addSelectedObjectsFromScene) pm.button(label='Remove selected in scene', command=State.removeSelectedObjectInScene) pm.button(label='Remove selected in list', command=State.removeSelectedObjectsInList) pm.button(label='Remove all', command=State.removeAllObjects) self.selectedObjectsList = pm.iconTextScrollList(allowMultiSelection=True, height=(VibrateWindow._size[1] - 150)) pm.setParent('..') self._tabVibration = pm.rowColumnLayout(numberOfColumns=1) pm.rowLayout(numberOfColumns=2, columnWidth=[(1, 60), (2, 190)]) pm.text(label='Start frame:') self.startField = pm.intField(minValue=-999999, maxValue=999999, step=1, value=0) pm.setParent('..') pm.rowLayout(numberOfColumns=2, columnWidth=[(1, 60), (2, 190)]) pm.text(label='End frame:') self.endField = pm.intField(minValue=-999999, maxValue=999999, step=1, value=1) pm.setParent('..') pm.rowLayout(numberOfColumns=2, columnWidth=[(1, 60), (2, 190)]) pm.text(label='X Force:') self.xForceField = pm.floatField(minValue=0.0, maxValue=999999.9, step=0.1, value=1.0) pm.setParent('..') pm.rowLayout(numberOfColumns=2, columnWidth=[(1, 60), (2, 190)]) pm.text(label='Y Force:') self.yForceField = pm.floatField(minValue=0.0, maxValue=999999.9, step=0.1, value=1.0) pm.setParent('..') pm.rowLayout(numberOfColumns=2, columnWidth=[(1, 60), (2, 190)]) pm.text(label='Z Force:') self.zForceField = pm.floatField(minValue=0.0, maxValue=999999.9, step=0.1, value=1.0) pm.setParent('..') pm.rowLayout(numberOfColumns=2, columnWidth=[(1, 60), (2, 190)]) pm.text(label='Speed:') self.speedField = pm.floatField(minValue=0.0, maxValue=999999.9, step=0.2, value=1.0) pm.setParent('..') pm.tabLayout(self._tabs, edit=True, tabLabel=((self._tabObjects, 'Objects'), (self._tabVibration, 'Vibration')))
def MakeSimpleIntField(intAttribute, annotation=None): """ Creates & returns a labelled integer input field for given IntAttribute instance. :param intAttribute: IntAttribute instance. :param annotation: toolTip annotation, or None. """ if(not isinstance(intAttribute, at.IntAttribute)): raise TypeError("Expected %s, got %s" % (at.IntAttribute, type(intAttribute))) rowLayout = MakeRowLayout(3) MakeText(intAttribute.attributeLabel, annotation) intField = pm.intField(value=intAttribute.value) if(intAttribute.minimumValue is not None): intField.setMinValue(intAttribute.minimumValue) if(intAttribute.maximumValue is not None): intField.setMaxValue(intAttribute.maximumValue) if(annotation is not None): intField.setAnnotation(annotation) elif(intAttribute.annotation is not None): intField.setAnnotation(intAttribute.annotation) intField.changeCommand(lambda *args: intAttribute._setValue(intField.getValue())) intAttribute.updateUiCommand = intField.setValue intAttribute.uiEnableMethod = intField.setEnable SetAsChildLayout(rowLayout) return (rowLayout, intField)
def load(): objIn = State._openLoadFile('objects') State._selectedObjects = pickle.load(objIn) objIn.close() vibIn = State._openLoadFile('slide') State._slideParams = pickle.load(vibIn) vibIn.close() pm.intField(State._wnd.startField, edit=True, value=State._slideParams['start']) pm.intField(State._wnd.endField, edit=True, value=State._slideParams['end']) pm.floatField(State._wnd.xSpeedField, edit=True, value=State._slideParams['X']) pm.floatField(State._wnd.ySpeedField, edit=True, value=State._slideParams['Y']) pm.floatField(State._wnd.zSpeedField, edit=True, value=State._slideParams['Z']) State.refresh()
def rope_UI(*args): """ Rope tool UI """ if pm.window("mGear_rope_window", exists = True): pm.deleteUI("mGear_rope_window") window = pm.window("mGear_rope_window", title="mGear rope rig generator", w=350, h=150, mxb=False, sizeable=False) pm.rowColumnLayout( numberOfColumns=2, columnAttach=(1, 'right', 0), columnWidth=[(1, 100), (2, 250)] ) pm.text("Nb of deformers: ") nbDeformers = pm.intField( "nbDeformers", annotation="number of deformers", w=50, value= 10) pm.text(label="Keep position " ) pm.checkBox("keepRatio", label=" (base on ratio) ") pm.text(label="Name: " ) RopeName = pm.textField("RopeName", text="Rope") pm.separator(h=10) pm.button(label="Build the rope!", w=150, h=50, command=build_rope) pm.separator(h=10) pm.separator(h=10) pm.separator(h=10) pm.text(label="Instructions: Select ctl crv + upv crv", align="left" ) pm.showWindow(window)
def addJointsToCurve(self, *args): self.jointsList = [] self.jointsListGRP = [] try: numOfJoints = pm.intField(self.loadNumJoints, q = True, v = True) self.selectedCurve = pm.ls(sl = True)[0] incr = float((numOfJoints - 1)) incr = 1/incr #calculate incrementation print incr incrTemp = 0.0 for i in range(numOfJoints): pm.select(clear = True) j = pm.joint(radius = 0.25, n = self.selectedCurve + "Joint") self.jointsList.append(j) jGRP = pm.group(j, n = j + "GRP") self.jointsListGRP.append(jGRP) #attach to motion path motionPath = pm.pathAnimation(jGRP, self.selectedCurve, fractionMode = True, follow = True ) pm.setAttr(motionPath +".u", incrTemp) pm.cutKey(motionPath) incrTemp += incr print incrTemp if incrTemp >= 1.0: incrTemp = 1.0 facialAnimations.allJoints.append(self.jointsList) self.curvesGRP = pm.group(self.jointsListGRP, n = self.selectedCurve + "_Face_jointsGRP") except: pass print "Curve not selected"
def UI_custom(self): numJoints = len(self.jointInfo) pm.rowLayout(numberOfColumns = 2, columnWidth = [1, 100], adjustableColumn = 2) pm.text(label = "Number of Joints: ") self.numberOfJointsField = pm.intField(value = numJoints, minValue = 2, changeCommand = self.ChangeNumberOfJoints) pm.setParent('..') joints = self.GetJoints() self.CreateRotationOrderUIControl(joints[0]) pm.separator(style = 'in') pm.text(label = "Orientation: ", align = "left") pm.rowLayout(numberOfColumns = 3) pm.attrEnumOptionMenu(attribute = "%s:module_grp.sao_local" %self.moduleNamespace, label = "Local: ") pm.text(label = " will be oriented to ") pm.attrEnumOptionMenu(attribute = "%s:module_grp.sao_world" %self.moduleNamespace, label = "World: ") pm.setParent('..') pm.separator(style = 'in') interpolating = False if pm.objExists("%s:interpolation_container" %self.moduleNamespace): interpolating = True pm.rowLayout(numberOfColumns = 2, columnWidth = [1, 80], adjustableColumn = 2) pm.text(label = "Interpolate: ") pm.checkBox(label = "", value = interpolating, onCommand = partial(self.SetupInterpolation, True), offCommand = self.DeleteInterpolation)
def ChangeNumberOfJoints(self, *args): self.blueprint_UI_instance.DeleteScriptJob() # Collect information from current spline module joints = self.GetJoints() numJoints = len(joints) newNumJoints = pm.intField(self.numberOfJointsField, query = True, value = True) startPos = pm.xform(self.GetTranslationControl(joints[0]), query = True, worldSpace = True, translation = True) endPos = pm.xform(self.GetTranslationControl(joints[numJoints - 1]), query = True, worldSpace = True, translation = True) hookObj = self.FindHookObjectForLock() rotateOrder = pm.getAttr("%s.rotateOrder" %joints[0]) sao_local = pm.getAttr("%s:module_grp.sao_local" %self.moduleNamespace) sao_world = pm.getAttr("%s:module_grp.sao_world" %self.moduleNamespace) # Delete current spline module self.Delete() # Create new spline module with new joint count newInstance = Spline(self.userSpecifiedName, hookObj, newNumJoints, startPos, endPos) newInstance.Install() # Apply previous attribute values newJoints = newInstance.GetJoints() pm.setAttr("%s.rotateOrder" %newJoints[0], rotateOrder) pm.setAttr("%s:module_grp.sao_local" %newInstance.moduleNamespace, sao_local) pm.setAttr("%s:module_grp.sao_world" %newInstance.moduleNamespace, sao_world) self.blueprint_UI_instance.CreateScriptJob() pm.select("%s:module_transform" %newInstance.moduleNamespace, replace = True)
def randPlacement(self, objectList, *args): input_randomizeRadius = pm.intField(self.widgets['randomizeRadius'], q=True, v=True) max = input_randomizeRadius min = input_randomizeRadius * -1 # loop through for object in objectList: # spread randomNumberX = rand.randint(min, max) randomNumberZ = rand.randint(min, max) randomRotate = rand.randint(0, 360) randomScale = rand.uniform( (pm.floatField( self.widgets['randomizeScaleMIN'], q=True, v=True)), (pm.floatField( self.widgets['randomizeScaleMAX'], q=True, v=True))) pm.setAttr(object + '.tx', randomNumberX) pm.setAttr(object + '.tz', randomNumberZ) pm.setAttr(object + '.ry', randomRotate) pm.setAttr(object + '.sx', randomScale) pm.setAttr(object + '.sy', randomScale) pm.setAttr(object + '.sz', randomScale)
def __init__(self): self.windows_name = 'cgru_afanasy_wnd' if pm.window(self.windows_name, exists=True): pm.deleteUI(self.windows_name) self.window = pm.window(self.windows_name, t='Afanasy') with pm.columnLayout(adj=True): labels_width = 90 with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='Start Frame') pm.intField( 'cgru_afanasy__start_frame', v=pm.optionVar.get('cgru_afanasy__start_frame_ov', 1) ) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='End Frame') pm.intField( 'cgru_afanasy__end_frame', v=pm.optionVar.get('cgru_afanasy__end_frame_ov', 1) ) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='Frame Per Task') pm.intField( 'cgru_afanasy__frames_per_task', v=pm.optionVar.get('cgru_afanasy__frames_per_task_ov', 1) ) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='By Frame') pm.intField( 'cgru_afanasy__by_frame', v=pm.optionVar.get('cgru_afanasy__by_frame_ov', 1) ) pm.checkBox('cgru_afanasy__paused', l='Start Paused', v=0) pm.checkBox( 'cgru_afanasy__separate_layers', l='Submit Render Layers as Separate Tasks', v=1 ) pm.button( l='LAUNCH', c=self.launch ) pm.checkBox( 'cgru_afanasy__close', l='Close After', v=1 ) pm.showWindow(self.window)
def uvmp_snapshot_window_update(*args, **kwargs): ''' update the snapshot window on user interaction ''' checkBoxState = pm.checkBox(prefix + '_custom_snapshot_size', query=True, value=True) # toggle input based on checkbox pm.intField(prefix + '_snapshot_width', edit=True, enable=checkBoxState) pm.intField(prefix + '_snapshot_height', edit=True, enable=checkBoxState) pm.optionMenu(prefix + '_optionMenu_width', edit=True, enable=(not checkBoxState)) pm.optionMenu(prefix + '_optionMenu_height', edit=True, enable=(not checkBoxState)) if not checkBoxState: # update custom fields with dropdown values width = int( pm.optionMenu(prefix + '_optionMenu_width', query=True, value=True)) height = int( pm.optionMenu(prefix + '_optionMenu_height', query=True, value=True)) pm.intField(prefix + '_snapshot_width', edit=True, value=width) pm.intField(prefix + '_snapshot_height', edit=True, value=height) selWidth = pm.optionMenu(prefix + '_optionMenu_width', query=True, select=True) selHeight = pm.optionMenu(prefix + '_optionMenu_height', query=True, select=True) snapWidth = pm.intField(prefix + '_snapshot_width', query=True, value=True) snapHeight = pm.intField(prefix + '_snapshot_height', query=True, value=True) lct_cfg.set('lcUVToolsSnapshotCustom', checkBoxState) lct_cfg.set('lcUVToolsSnapshotSelHeight', selHeight) lct_cfg.set('lcUVToolsSnapshotSelWidth', selWidth) lct_cfg.set('lcUVToolsSnapshotCustomHeight', snapHeight) lct_cfg.set('lcUVToolsSnapshotCustomWidth', snapWidth)
def rp_Twist(): """..............................................................................................//""" ncj = int(pm.intField('NCJ', q=1, v=1)) # > control joints # > selection list s = pm.ls(sl=1) rp_check(s) cj = pm.ls((s[0] + "_ctj_*"), typ="joint") # > twist and roll if pm.checkBoxGrp('MRL', q=1, v1=1): if pm.getAttr(s[0] + "_tw_hl.dtce") == 1: pm.setAttr((s[0] + "_tw_hl.dtce"), 0) pm.disconnectAttr((cj[0] + ".wm[0]"), (s[0] + "_tw_hl.dwum")) pm.disconnectAttr((cj[(ncj - 1)] + ".wm[0]"), (s[0] + "_tw_hl.dwue")) rl = str(pm.createNode('multiplyDivide', n=(s[0] + "_roll"))) pm.connectAttr((cj[0] + ".rx"), (rl + ".i1x"), f=1) pm.setAttr((rl + ".i2x"), (-1)) pm.connectAttr((cj[0] + ".rx"), (s[0] + "_tw_hl" + ".rol"), f=1) tw = str(pm.createNode('plusMinusAverage', n=(s[0] + "_twist"))) pm.connectAttr((rl + ".ox"), (tw + ".i1[0]"), f=1) pm.connectAttr((cj[(ncj - 1)] + ".rx"), (tw + ".i1[1]"), f=1) pm.connectAttr((tw + ".o1"), (s[0] + "_tw_hl" + ".twi"), f=1) # > advanced twist elif pm.objExists(s[0] + "_twist"): pm.delete((s[0] + "_twist"), (s[0] + "_roll")) pm.disconnectAttr((cj[0] + ".rx"), (s[0] + "_tw_hl" + ".rol")) pm.setAttr((s[0] + "_tw_hl.dtce"), 1) pm.setAttr((s[0] + "_tw_hl.dwut"), 4) pm.setAttr((s[0] + "_tw_hl.dwua"), 0) pm.connectAttr((cj[0] + ".wm[0]"), (s[0] + "_tw_hl.dwum")) pm.connectAttr((cj[(ncj - 1)] + ".wm[0]"), (s[0] + "_tw_hl.dwue")) pm.setAttr((s[0] + "_tw_hl.dwuy"), 1) pm.setAttr((s[0] + "_tw_hl.dwvy"), 1) pm.setAttr((s[0] + "_tw_hl.dwuz"), 0) pm.setAttr((s[0] + "_tw_hl.dwvz"), 0) pm.setAttr((s[0] + "_tw_hl" + ".rol"), 0) pm.setAttr((s[0] + "_tw_hl" + ".twi"), 0) pm.select(s[0])
def load(): objIn = State._openLoadFile('objects') State._selectedObjects = pickle.load(objIn) objIn.close() vibIn = State._openLoadFile('vibration') State._vibrationParams = pickle.load(vibIn) vibIn.close() pm.intField(State._wnd.startField, edit=True, value=State._vibrationParams['start']) pm.intField(State._wnd.endField, edit=True, value=State._vibrationParams['end']) pm.floatField(State._wnd.xForceField, edit=True, value=State._vibrationParams['X']) pm.floatField(State._wnd.yForceField, edit=True, value=State._vibrationParams['Y']) pm.floatField(State._wnd.zForceField, edit=True, value=State._vibrationParams['Z']) pm.floatField(State._wnd.speedField, edit=True, value=State._vibrationParams['speed']) State.refresh()
def create(self): current_time = pm.keyframe('%s' % (self.node), query=True, index=(self.index, self.index), timeChange=True)[0] self.int_field = pm.intField(value=int(current_time), changeCommand=pm.Callback( self.change_time))
def applyCache(self, *args): startFrame = pm.intField(self.startFrameIntField, q=True, value=True) endFrame = pm.intField(self.endFrameIntField, q=True, value=True) cacheFolder = pm.textField(self.cacheFolderTextField, q=True, text=True) objs = pm.ls(sl=True) for obj in objs: # if cache node exsits update address of cache node and frame range if self.findCacheNode(obj): self.replaceCache(cacheNode=self.findCacheNode(obj), newCacheFolder=cacheFolder, cacheName=obj.getShape(), startFrame=startFrame, endFrame=endFrame) # if cache node doesn't exists, check and see if there is a cache file for the selected object and attach it to the object elif self.cacheFileExists(obj): self.assignCacheFile(obj)
def create(self): ''' # this creates the int field ''' current_time = pm.keyframe( '%s' % (self.node) , query=True, index= (self.index, self.index), timeChange= True )[0] self.int_field = pm.intField(value= int(current_time), annotation= 'change the time for the keyframe', changeCommand= pm.Callback(self.change_time))
def create_shots(with_cameras): cnt = 0 while pm.textField('%s%s' % (shot_name_name, str(cnt)), ex=1): cnt += 1 seqs = [ seq for seq in pm.ls(type='sequencer') if seq.referenceFile() is None ] if len(pm.ls(type='sequencer')) != 1: raise RuntimeError('There must be 1 sequencer in a scene.') seq = seqs[0] for i in range(0, cnt): shot_node_name = pm.textField('%s%s' % (shot_name_name, str(i)), q=1, text=1) start_frame = pm.intField('%s%s' % (start_frame_name, str(i)), q=1, v=1) end_frame = pm.intField('%s%s' % (end_frame_name, str(i)), q=1, v=1) shot_num = pm.textField('%s%s' % (shot_num_name, str(i)), q=1, text=1) shot = pm.createNode('shot', n=shot_node_name) shot.setAttr('startFrame', start_frame) shot.setAttr('sequenceStartFrame', start_frame) shot.setAttr('endFrame', end_frame) shot.setAttr('shotName', shot_num) seq.add_shot(shot) if with_cameras: camera_name = '%s%s' % (pm.textField( 'camera_prefix_name', q=1, text=1), str(i + 1)) cam = pm.mel.eval('camera -n "%s";' % camera_name) pm.PyNode(cam[1]).setAttr('farClipPlane', 1000000) pm.PyNode(cam[1]).setAttr('focalLength', 35) pm.PyNode(cam[0]).attr('scaleX').lock() pm.PyNode(cam[0]).attr('scaleY').lock() pm.PyNode(cam[0]).attr('scaleZ').lock() shot.set_camera(pm.PyNode(cam[1]))
def duplicateAlongPath(self, *args): ''' ------------------------------------------ position along curve ------------------------------------------ ''' inputX = pm.intField(self.widgets['numberOfDuplicates'], q=True, v=True) GOD_object = pm.ls(sl=True)[0] curve = pm.textFieldButtonGrp(self.widgets['curvePath'], q=True, tx=True) pathLength = pm.arclen(curve, ch=False) randomON = pm.checkBox(self.widgets['RandomPathDistance'], q=True, v=True) n = 0 pathIncrement = 1.0 / inputX for increment in range(inputX): object = pm.duplicate(GOD_object, rc=True) objGroup = pm.group(object) motionPath = pm.pathAnimation(objGroup, fm=True, f=True, fa='x', ua='y', wut='scene', c=curve) pm.delete(pm.listConnections(motionPath + '.uValue')) value = rand.uniform(n, (n + pathIncrement)) if randomON == True: pm.setAttr(motionPath + '.uValue', value) randomRotate = rand.randint(0, 360) randomScale = rand.uniform( (pm.floatField(self.widgets['randomizeScaleMINPath'], q=True, v=True)), (pm.floatField(self.widgets['randomizeScaleMAXPath'], q=True, v=True))) print object pm.setAttr(object[0] + '.ry', randomRotate) pm.setAttr(object[0] + '.sx', randomScale) pm.setAttr(object[0] + '.sy', randomScale) pm.setAttr(object[0] + '.sz', randomScale) else: pm.setAttr(motionPath + '.uValue', n) n = n + pathIncrement pm.parent(objGroup, 'ROOT_enviroment_01')
def create_psd_driver_cmd (self, *args): prefix = pm.textField(self.widgets['psd_prefix_textField'], q=True, text=True) base_obj = pm.textField(self.widgets['psd_base_obj_textField'], q=True, text=True) parent_obj = pm.textField(self.widgets['psd_parent_obj_textField'], q=True, text=True) target_obj = pm.textField(self.widgets['psd_target_obj_textField'], q=True, text=True) start_angle = pm.intField(self.widgets['psd_start_angle_intField'], q=True, v=True) create_psd_driver(prefix=prefix, start_angle=start_angle, base_object=base_obj, target_object=target_obj, parent_object=parent_obj) return
def snapping(*args): list = pm.ls(sl=True, head=1) groupinto = pm.ls(sl=True, tail=1) textFieldData_ik_suffix = pm.textField(textFieldEntry_ik_suffix, editable=True, query=True, text=True) ik_suffix = textFieldData_ik_suffix num_name_delete = pm.intField(intFieldEntry_num_name_delete, editable=True, query=True, value=True) for n in groupinto: pm.duplicate(list, name=('snapping')) pm.group('snapping', n='readytosnap') pm.parent('readytosnap', n) pm.setAttr('readytosnap.translateX', 0) pm.setAttr('readytosnap.translateY', 0) pm.setAttr('readytosnap.translateZ', 0) pm.setAttr('readytosnap.rotateX', 0) pm.setAttr('readytosnap.rotateY', 0) pm.setAttr('readytosnap.rotateZ', 90) pm.parent('readytosnap', world=True) newname = n.split('_') number_name = len(newname) new_name_first = newname[0] + '_' for i in range(0, number_name): if i > number_name - num_name_delete - 1 or i == number_name - num_name_delete - 1: new_name = new_name_first print 'naming error' break else: if i < number_name - num_name_delete - 1: new_name_second = newname[i + 1] + '_' new_name = new_name_first + new_name_second new_name_first = new_name else: break pm.rename('readytosnap', new_name + '{0}_pad'.format(ik_suffix)) pm.rename('snapping', new_name + '{0}'.format(ik_suffix))
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 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 gui(): if (cmds.window(win, ex=1)): cmds.deleteUI(win) if (cmds.windowPref(win, ex=1)): cmds.windowPref(win, r=1) global polygon_choice, obj_no, area_no, scale_no cmds.window(win, s=1, vis=1, w=w, h=h) cmds.rowColumnLayout(w=w, h=h) cmds.text(l='') polygon_choice = pm.radioButtonGrp( la4=['Cube', 'Sphere', 'Cylinder', 'plane'], nrb=4, cw4=[67, 67, 67, 67], sl=1) cmds.text(l='', h=8) cmds.rowColumnLayout(nc=2) cmds.text(l='Number of Objects:') obj_no = pm.intField(v=10, w=w2) cmds.text(l='Area Scale:') area_no = pm.intField(v=11, w=w2) cmds.text(l='Max Object Scale:') scale_no = pm.intField(v=1, w=w2) cmds.text(l='') cmds.text(l='') cmds.button(l='do shit', c=do_shit) cmds.showWindow()
def ui_export_selection(exec_button): """create ui window for export to abc and guerilla """ if pmc.window('exportabc', exists=True): pmc.deleteUI('exportabc') pmc.window('exportabc', menuBar=True, width=200, height=50) pmc.columnLayout() pmc.radioCollection('framemode') pmc.radioButton('currentframe', label='Current frame') pmc.radioButton('timeslider', label='Time Slider') pmc.radioButton('startend', label='Start / End') pmc.separator() pmc.text(label='Start frame') pmc.intField('start') pmc.text(label='End frame') pmc.intField('end') pmc.separator() pmc.checkBox('preroll', label='Pre roll') pmc.intField('prerollstart') pmc.text(label='Step') pmc.floatField('step', value=1.0) pmc.separator() pmc.checkBox('guerilla', label='Send to Guerilla') pmc.separator() pmc.button('export', label='Export', width=250, c=exec_button) pmc.showWindow()
def preset(self, num): # Overwite textField values with pre-set values based on user's choice # Args: # num(int): Determines which set of values to use t_axiom = '' t_rule1 = '' t_rule2 = '' t_itr = 0 t_angle = 0 if num == 1: t_axiom = 'F' t_rule1 = 'F=FF-[-F+F+F]+[+F-F-F]' t_itr = 4 t_angle = 22 self.is_flat = False elif num == 2: t_axiom = 'FX' t_rule1 = 'F=FF-[-F+F]+[+F-F]' t_rule2 = 'X=FF+[+F]+[-F]' t_itr = 4 t_angle = 25 self.is_flat = False elif num == 3: t_axiom = 'X' t_rule1 = 'X=F-[[X]+X]+F[+FX]-X' t_rule2 = 'F=FF' t_itr = 4 t_angle = 25 self.is_flat = False pm.textField('AxiomField', tx=t_axiom, edit=True) pm.textField('RuleField1', tx=t_rule1, edit=True) pm.textField('RuleField2', tx=t_rule2, edit=True) pm.intField('IterationsField', v=t_itr, edit=True) pm.floatField('AngleField', v=t_angle, edit=True)
def padding(*args): list = pm.ls(sl=True) num_name_delete = pm.intField(intFieldEntry_num_name_delete, editable=True, query=True, value=True) for n in list: pm.group(em=True, name='empty') pm.parent('empty', n) pm.setAttr('empty.translateX', 0) pm.setAttr('empty.translateY', 0) pm.setAttr('empty.translateZ', 0) pm.setAttr('empty.rotateX', 0) pm.setAttr('empty.rotateY', 0) pm.setAttr('empty.rotateZ', 0) pm.parent('empty', world=True) pm.parent(n, 'empty') newname = n.split('_') number_name = len(newname) new_name_first = newname[0] + '_' for i in range(0, number_name): if i > number_name - num_name_delete - 1 or i == number_name - num_name_delete - 1: new_name = new_name_first print 'naming error' break else: if i < number_name - num_name_delete - 1: new_name_second = newname[i + 1] + '_' new_name = new_name_first + new_name_second new_name_first = new_name else: break pm.rename('empty', new_name + '00_pad')
def uvmp_snapshot_execute(*args, **kwargs): ''' takes the snapshot and opens it in photoshop, deletes the popup window if necessary ''' texDim = [ pm.intField(prefix + '_snapshot_width', q=True, v=True), pm.intField(prefix + '_snapshot_height', q=True, v=True) ] path = pm.workspace(q=True, rd=True) fileName = prefix + '_temp_uvsnapshot.tga' snapShotFile = os.path.join(path, fileName) lcTexture.TextureEditor().uvSnapshot( snapShotFile, texDim[0], texDim[1], bool(pm.menuItem(prefix + '_checkBox_antiAlias', q=True, cb=True))) if pm.menuItem(prefix + '_checkBox_openPS', q=True, cb=True): lcPath.Path.openImage(snapShotFile) else: lcUtility.Utility.lc_print( 'Created UV Snapshot: {}'.format(snapShotFile)) if pm.control(prefix + '_Snapshot', exists=True): pm.deleteUI(prefix + '_Snapshot')
def load(): objIn = State._openLoadFile('objects') State._selectedObjects = pickle.load(objIn) objIn.close() matIn = State._openLoadFile('materials') State._selectedMaterials = pickle.load(matIn) matIn.close() patIn = State._openLoadFile('pattern') patList = pickle.load(patIn) patIn.close() State._wnd.setSelectedPattern(patList.pop()) patList = patList.pop() + [patList.pop(),] for v in [State._wnd.rK, State._wnd.rS, State._wnd.rM, State._wnd.rL, State._wnd.rB, State._wnd.rA]: pm.floatField(v, edit=True, value=patList.pop()) pm.intField(State._wnd.rN, edit=True, value=patList.pop()) State.refresh() State._wnd.randomAlgoChanged(None)
def build(self): template = pm.uiTemplate('MovieTemplate', force = 1) template.define(pm.frameLayout, bv = 1, lv = 0, mh = 5, mw = 2) with pm.window('ImportMovieWin', title = 'ImportMovieWin', wh = (300, 120), s = 0) as win: with template: with pm.columnLayout(rs = 3, adj = 1): with pm.frameLayout(): self.path = pm.textFieldButtonGrp( label='Path', text='', buttonLabel='Browse', cw3 = (30,155,20), adjustableColumn3 = 2, cl3 = ('left', 'center', 'right'), bc = self.browse, cc = self.getPath ) with pm.frameLayout(): with pm.rowColumnLayout(nc = 2, cw = [(1, 70), (2, 50)], cs = (5, 5)): pm.text(l = 'Offset Frame:', w = 60) self.frameOffset = pm.intField() with pm.frameLayout(): with pm.rowColumnLayout(nc = 3, cw = [(1, 100), (2, 100), (3, 100)]): pm.button(l = 'Import', c = self.importBtnCmd) pm.button(l = 'Modify', c = self.modifyBtnCmd) pm.button(l = 'Delete', c = self.deleteBtnCmd)
def get_variables(self): # Obtain user input and store them in variables to use later self.iterations = pm.intField('IterationsField', q=True, v=True) self.angle = pm.floatField('AngleField', q=True, v=True) self.axiom = pm.textField('AxiomField', q=True, tx=True) # Get all rules from user input self.rules = [] for i in range(1, self.number_of_rules + 1): temp = pm.textField('RuleField{0}'.format(i), q=True, tx=True) if temp: self.rules.append(temp) self.check_input(self.iterations, self.axiom, self.rules)
def __init__(self): self.windows_name = 'cgru_afanasy_wnd' if pm.window(self.windows_name, exists=True): pm.deleteUI(self.windows_name) self.window = pm.window(self.windows_name, t='Afanasy') with pm.columnLayout(adj=True): labels_width = 90 with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='Start Frame') pm.intField('cgru_afanasy__start_frame', v=pm.optionVar.get('cgru_afanasy__start_frame_ov', 1)) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='End Frame') pm.intField('cgru_afanasy__end_frame', v=pm.optionVar.get('cgru_afanasy__end_frame_ov', 1)) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='Frame Per Task') pm.intField('cgru_afanasy__frames_per_task', v=pm.optionVar.get( 'cgru_afanasy__frames_per_task_ov', 1)) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='By Frame') pm.intField('cgru_afanasy__by_frame', v=pm.optionVar.get('cgru_afanasy__by_frame_ov', 1)) pm.checkBox('cgru_afanasy__paused', l='Start Paused', v=0) pm.checkBox('cgru_afanasy__separate_layers', l='Submit Render Layers as Separate Tasks', v=1) pm.button(l='LAUNCH', c=self.launch) pm.checkBox('cgru_afanasy__close', l='Close After', v=1) pm.showWindow(self.window)
def createUI( SWindowTitle, pApplyCallback ): windowID = 'texdenWindowID' # If Window is Already Open, Delete it and Open a New One if pm.window( windowID, exists=True ): pm.deleteUI( windowID ) # Init Window pm.window( windowID, title=SWindowTitle, sizeable=False, resizeToFitChildren=True ) pm.rowColumnLayout( numberOfColumns=3, columnWidth=[ (1, 95), (2, 75), (3, 75) ], columnOffset=[ (1, 'right', 3) ]) pm.text( label='Texels Per Unit' ) # Field for Desired Texel Density, Default = 1.0, min = 0.0, invisible slider step 1.0 DensityField = pm.floatField( value=1.0, minValue=0.0, step=1.0, annotation="This is the Desired Texel Density" ) pm.separator( h=10, style='none' ) pm.text( label='Texture Resolution' ) # Field for Texture Resolution, Default 1 ResolutionField = pm.intField( value=1, minValue=1, step=1, annotation="This is Texture Resolution" ) pm.separator(h=10, style='none' ) # Formatting pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) pm.button( label='Apply', command=functools.partial(pApplyCallback, DensityField, ResolutionField) ) def cancelCallback( *Args ): if pm.window( windowID, exists=True ): pm.deleteUI( windowID ) pm.button( label='Cancel', command=cancelCallback ) pm.showWindow()
def prompt_ui(): win = pm.window(title="Create Geosphere", width=200) layout = pm.formLayout() rlayout = pm.rowLayout(parent=layout, numberOfColumns=2) iter_field_lbl = pm.text("Iterations", parent=rlayout) iter_field = pm.intField(min=1, max=5, step=1, v=1, parent=rlayout) quads_chbox = pm.checkBox(label="Create Quads?", v=False, parent=layout) def on_ok(*args): create(quads_chbox.getValue(), iter_field.getValue()) win.delete() ok_button = pm.button(label="Create mah Geosphere!", command=on_ok, parent=layout) layout.redistribute() win.show()
def rightInfo_area(): leftInfo_layout = pm.rowColumnLayout(nr=3) ################## TEXT and MENU #################### leftTop_layout = pm.rowColumnLayout(nc=3, cal=[[1, 'left'], [3, 'right']]) pm.text(l='Sort Method') pm.text(l='', w=35) # GUI SPACER global sortMethod_menu sortMethod_menu = pm.optionMenu(bgc=primary_componentColor, w=110, ann='Pick the way your lights are organized', cc=refreshWindow) # NOT CONNECTED pm.menuItem(l="Intensity (H-L)", ann='Sort lights based on intensity from Highest to Lowest') pm.menuItem(l="Intensity (L-H)", ann='Sort lights based on intensity from Lowest to Highest') pm.menuItem(l="Name (A-Z)", ann='Sort lights based on name from A to Z') pm.menuItem(l="Name (Z-A)", ann='Sort lights based on name from Z to A') pm.menuItem(l="Type", ann='Sort lights based on light type') pm.menuItem(l="----------", enable=False) pm.menuItem(l="Area", ann='Show only Area Lights') pm.menuItem(l="Spot", ann='Show only Spot Lights') pm.menuItem(l="Directional", ann='Show only Directional Lights') pm.menuItem(l="Point", ann='Show only Point Lights') pm.menuItem(l="IBL", ann='Show only IBL') pm.setParent(leftInfo_layout) ################## SPACE #################### leftMid_layout = pm.rowColumnLayout(nc=1, h=3) pm.text(l='') # GUI SPACER pm.setParent(leftInfo_layout) ################## TEXT and INTFIELD #################### leftBottom_layout = pm.rowColumnLayout(nc=3, cal=[[1, 'left'], [3, 'right']]) pm.text(l='Lights In Scene:') pm.text(l='', w=77) # GUI SPACER global num_lights num_lights = pm.intField(editable=False, w=50, bgc=secondary_componentColor, ann='There are currently {0} lights in the scene'.format(len(lights))) pm.setParent(main_layout)
def makeUi(self): ############################ self.win = pm.window('Hair Grabber 2', title='Hair Grabber 2') with self.win: self.col = pm.columnLayout() with self.col: self.row1 = pm.rowLayout(nc=7) with self.row1: self.tipBtn = pm.button(label="tip", width=70, c= lambda x: self.selectBatch(self.tip), ann = 'grabs the tips of a plane or multiple planes' ) self.rootBtn = pm.button(label="root", width=70, c= lambda x: self.selectBatch(self.root), ann = 'grabs the roots of a plane or multiple planes' ) self.middleBtn = pm.button(label="middle", width=70,c= lambda x: self.selectBatch(self.middle) , ann = 'grabs the middle edgeloop of a plane or multiple plains. if the mid checkbox is selected,'\ 'the randT slider above it will control the positioning of the edgeloop in relation to the edge or tip' ) self.middle2Btn = pm.button(label="length", width=60, c = lambda x: self.selectBatch(self.middle2), ann = 'grabs the length edgeloops of the plane or planes.' ) self.transformBtn = pm.button(label="Transform", width=60, c= lambda x: self. transform(), ann = 'selects the transform node if any other component like verts or faces is selected' ) self.edgeFlowBtn = pm.button(label="edgeFlow", width=60, c= lambda x: self.edgeFlow(), ann = 'goes over edgeloops and performs edgeflow on each. it returns a smoother transition in case the geo is jagged'\ 'if the checkbox to the right is selected it also iterates over the length edgeloops ' ) self.lenCheckBox = pm.checkBox(label = '||', value = False , ann = 'length edgeloops activated') self.row2 = pm.rowLayout(nc=7) with self.row2: self.pivotBtn = pm.button(label="pivot", width=70, c = lambda x: self.pivot(), ann = 'sets the pivot for each selected geo plane to its first row of faces and alligns to its normal' ) self.snapPivotBtn = pm.button(label='snapPivot', width=70, c=lambda x: self.snapPivot(), ann = 'if geo is fed in to the haircap field it will snap selected transforms to the closest point on that geo.' ) self.snapBtn = pm.button(label="snap", width=70, c=lambda x: self.snap() , ann = 'if geo is fed in to the haircap field it snaps the verts of whatever geo is selected to it.'\ ' if specific verts selected it will only snap them') self.fillBtn = pm.button(label="fill", width=70, c=lambda x: self.fill( self.amountField.getValue()+1 ), ann = 'duplicates the selected geo. if one is selected itll fill the surroundings of that geo.'\ 'if multiple pices are selected itll iterate from the first one to the next and fill the in betweens' 'you can controll the offset and random rotation with both sliders, and input the amount of'\ 'copies using the amount field to its right' ) self.amountField = pm.intField( 'amount', w = 40, annotation = 'times' , value = 1 ,minValue=1 , maxValue=30) self.transferCheckBox = pm.checkBox(label = 'uv', value = False , ann = 'transfers the UVs from map1 of the haircap to the newly created objects, or if active same function works for transfer button') self.transferBtn = pm.button(label="transfer", width=63, c=lambda x: self.transfer(), ann = 'transfers uvs for current UVsets to selection from last selected, or '\ 'transfers the UVs from map1 of the haircap to the selected objects if uv checkBox is on ' ) self.row3 = pm.rowLayout(nc=5) with self.row3: self.randSliderT = pm.floatSlider( horizontal = True,width = 168, min=0, max=10, value=0, cc = lambda x:self.middleCond(), ann = 'controls the random translate values and affected by the 3 axes under it. if mid is on'\ 'the field will select the edgeloop of selected geo accordint to the placement on the slider'\ 'as well as the percentage of the random transform select button' ) self.Text3 = pm.button(label="randT", width=44, c=lambda x: self.randomize(pm.selected(), transRot = 0 ), ann = ' randomly translates values and affected by the 3 axes under it' ) self.randSliderR = pm.intSlider( horizontal = True,width = 168, min=0, max=90, value=0, step=1 , ann = 'controls the random rotation values and affected by the 3 axes under it. set to max value of 90') self.Text4 = pm.button(label="randR", width=44, c=lambda x: self.randomize(pm.selected(), transRot = 1 ), ann = ' randomly rotates values and affected by the 3 axes under it' ) self.row4 = pm.rowLayout(nc=9) with self.row4: self.midCtrlCheckBox = pm.checkBox(label = 'mid', value = False ) self.TXCheckBox = pm.checkBox(label = ' TX ', value = True ) self.TYCheckBox = pm.checkBox(label = ' TY ', value = True ) self.TZCheckBox = pm.checkBox(label = ' TZ ', value = True ) self.RandTransBtn = pm.button(label="random transform select", width=130, c=lambda x: self.randomTransformSel(pm.selected()), ann = 'uses the left transform slider to select a percent of previously selected geo' ) self.RXCheckBox = pm.checkBox(label = ' RX ', value = True ) self.RYCheckBox = pm.checkBox(label = ' RY ', value = True ) self.RZCheckBox = pm.checkBox(label = ' RZ ', value = True ) self.row5 = pm.rowLayout(nc=8) with self.row5: self.Text1 = pm.text("UVset") self.UvSetSearchName = pm.textField('name of UV set', w = 93, it = "Alpha", ann = 'uses UVs that are upright to determine the roots and tips of a geo plane. a separate UVset can be created'\ 'and loaded to this field.') self.grabUVBtn = pm.button(label="grab", width=30, c=lambda x: self.grabUV() , ann = 'gets the current active UVset of selected object') self.fixUVBtn = pm.button(label="unfold inner", width=73, c=lambda x: self.UVFix() , ann = 'attempts to fix UVs if in the modelling process they get mangled. when the checkbox to the right'\ 'is activated it also flattens the length boarders to the average of tips and roots to give rectangular result.') self.squareCheckBox = pm.checkBox(label = '[]', value = True, ann = 'flattens the length boarders to the average of tips and roots to give rectangular result to UVs' ) self.Text2 = pm.text("haircap") self.capName = pm.textField('name of haircap', w = 93, it = "geo_head", ann = 'write down or select geo and use grab button to the right to feed it to the script.' ) self.grabCapBtn = pm.button(label="grab", width=30, c=lambda x: self.grabCap() , ann = 'grabs the name of active geo' ) self.win.show()
def show(self): if pm.window(self.windows_name, exists=True): pm.deleteUI(self.windows_name) self.window = pm.window(self.windows_name, t='Afanasy') with pm.columnLayout(adj=True): labels_width = 90 with pm.rowLayout(nc=4, adj=2, cw4=(labels_width, 40, 15, 15)): pm.text(l='Start Frame') start_time_int_field = pm.intField( 'cgru_afanasy__start_frame', v=pm.optionVar.get('cgru_afanasy__start_frame_ov', 1) ) pm.button( l='<', ann='Use minimum animation range', c=functools.partial( self.set_field_value, start_time_int_field, functools.partial( pm.playbackOptions, q=True, min=True ) ) ) pm.button( l='<<', ann='Use minimum playback range', c=functools.partial( self.set_field_value, start_time_int_field, functools.partial( pm.playbackOptions, q=True, ast=True ) ) ) with pm.rowLayout(nc=4, adj=2, cw4=(labels_width, 40, 15, 15)): pm.text(l='End Frame') end_time_int_field = pm.intField( 'cgru_afanasy__end_frame', v=pm.optionVar.get('cgru_afanasy__end_frame_ov', 1) ) pm.button( l='<', ann='Use maximum animation range', c=functools.partial( self.set_field_value, end_time_int_field, functools.partial( pm.playbackOptions, q=True, max=True ) ) ) pm.button( l='<<', ann='Use maximum playback range', c=functools.partial( self.set_field_value, end_time_int_field, functools.partial( pm.playbackOptions, q=True, aet=True ) ) ) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='Frame Per Task') pm.intField( 'cgru_afanasy__frames_per_task', v=pm.optionVar.get('cgru_afanasy__frames_per_task_ov', 1) ) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='By Frame') pm.intField( 'cgru_afanasy__by_frame', v=pm.optionVar.get('cgru_afanasy__by_frame_ov', 1) ) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='Host Mask') pm.textField( 'cgru_afanasy__hosts_mask', text=pm.optionVar.get('cgru_afanasy__hosts_mask_ov', '') ) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='Host Exclude') pm.textField( 'cgru_afanasy__hosts_exclude', text=pm.optionVar.get('cgru_afanasy__hosts_exclude_ov', '') ) with pm.rowLayout(nc=2, adj=2, cw2=(labels_width, 50)): pm.text(l='Life Time (hours)') pm.intField( 'cgru_afanasy__life_time', v=pm.optionVar.get('cgru_afanasy__life_time_ov', -1) ) pm.checkBox('cgru_afanasy__paused', l='Start Paused', v=0) pm.checkBox( 'cgru_afanasy__separate_layers', l='Submit Render Layers as Separate Tasks', v=pm.optionVar.get('cgru_afanasy__separate_layers_ov', 1) ) pm.button( l='LAUNCH', c=self.launch ) pm.checkBox( 'cgru_afanasy__close', l='Close After', v=1 ) pm.showWindow(self.window)
def launch(self, *args, **kwargs): """launch renderer command """ # do nothing if there is no window (called externally) if not self.window: return # warn the user about the ignore settings try: dAO = pm.PyNode('defaultArnoldRenderOptions') ignore_attrs = [ 'ignoreSubdivision', 'ignoreDisplacement', 'ignoreBump', 'ignoreMotionBlur' ] attr_values = [ (attr, dAO.getAttr(attr)) for attr in ignore_attrs if dAO.getAttr(attr) is True ] if any(attr_values): msg_text = '<br>'.join( map( lambda x: '%s: %s' % (x[0], x[1]), attr_values ) ) response = pm.confirmDialog( title='Ignore These Settings?', message='You have ignored:<br><br>%s<br><br><b>Is that ok?</b>' % msg_text, button=['Yes', 'No'], defaultButton='No', cancelButton='No', dismissString='No' ) if response == 'No': return except pm.MayaNodeError: # no Arnold pass # check if rendering with persp camera try: wrong_camera_names = [ 'perspShape', 'topShape', 'sideShape', 'fontShape', 'persp1Shape', 'perspShape1', ] renderable_cameras = [node for node in pm.ls(type='camera') if node.getAttr('renderable')] if any(map(lambda x: x.name() in wrong_camera_names, renderable_cameras)): response = pm.confirmDialog( title='Rendering with Persp?', message='You are rendering with <b>Persp Camera<b><br><br>Is that ok?</b>', button=['Yes', 'No'], defaultButton='No', cancelButton='No', dismissString='No' ) if response == 'No': return if len(renderable_cameras) > 1: response = pm.confirmDialog( title='Rendering more than one Camera?', message='You are rendering <b>more than one camera<b><br><br>Is that ok?</b>', button=['Yes', 'No'], defaultButton='No', cancelButton='No', dismissString='No' ) if response == 'No': return elif len(renderable_cameras) == 0: pm.confirmDialog( title='No <b>Renderable</b> camera!!!', message='There is no <b>renderable camera<b>!!!', button=['Ok'], defaultButton='Ok', cancelButton='Ok', dismissString='Ok' ) return except pm.MayaNodeError: # no default render globals node pass # get values start_frame = pm.intField('cgru_afanasy__start_frame', q=1, v=1) end_frame = pm.intField('cgru_afanasy__end_frame', q=1, v=1) frames_per_task = \ pm.intField('cgru_afanasy__frames_per_task', q=1, v=1) by_frame = pm.intField('cgru_afanasy__by_frame', q=1, v=1) hosts_mask = pm.textField('cgru_afanasy__hosts_mask', q=1, text=True) hosts_exclude = pm.textField('cgru_afanasy__hosts_exclude', q=1, text=True) separate_layers = \ pm.checkBox('cgru_afanasy__separate_layers', q=1, v=1) pause = pm.checkBox('cgru_afanasy__paused', q=1, v=1) life_time = pm.intField('cgru_afanasy__life_time', q=1, v=1) # check values if start_frame > end_frame: temp = end_frame end_frame = start_frame start_frame = temp frames_per_task = max(1, frames_per_task) by_frame = max(1, by_frame) # store without quota sign hosts_mask = hosts_mask.replace('"', '') hosts_exclude = hosts_exclude.replace('"', '') # store field values pm.optionVar['cgru_afanasy__start_frame_ov'] = start_frame pm.optionVar['cgru_afanasy__end_frame_ov'] = end_frame pm.optionVar['cgru_afanasy__frames_per_task_ov'] = frames_per_task pm.optionVar['cgru_afanasy__by_frame_ov'] = by_frame pm.optionVar['cgru_afanasy__hosts_mask_ov'] = hosts_mask pm.optionVar['cgru_afanasy__hosts_exclude_ov'] = hosts_exclude pm.optionVar['cgru_afanasy__separate_layers_ov'] = separate_layers pm.optionVar['cgru_afanasy__life_time_ov'] = life_time # get paths scene_name = pm.sceneName() datetime = '%s%s' % ( time.strftime('%y%m%d-%H%M%S-'), str(time.time() - int(time.time()))[2:5] ) filename = '%s.%s.mb' % (scene_name, datetime) project_path = pm.workspace(q=1, rootDirectory=1) # get output paths, set the RenderPass token to Beauty, # this will at least guarantee to get something outputs = \ pm.renderSettings( fullPath=1, firstImageName=1, lastImageName=1, leaveUnmatchedTokens=1, customTokenString="RenderPass=Beauty" ) job_name = os.path.basename(scene_name) logger.debug('%ss %se %sr' % (start_frame, end_frame, by_frame)) logger.debug('scene = %s' % scene_name) logger.debug('file = %s' % filename) logger.debug('job_name = %s' % job_name) logger.debug('project_path = %s' % project_path) logger.debug('outputs = %s' % outputs) if pm.checkBox('cgru_afanasy__close', q=1, v=1): pm.deleteUI(self.window) drg = pm.PyNode('defaultRenderGlobals') render_engine = drg.getAttr('currentRenderer') job = af.Job(job_name) stored_log_level = None if render_engine == 'arnold': # set the verbosity level to warning+info aro = pm.PyNode('defaultArnoldRenderOptions') stored_log_level = aro.getAttr('log_verbosity') aro.setAttr('log_verbosity', 1) # set output to console aro.setAttr("log_to_console", 1) elif render_engine == 'redshift': # set the verbosity level to detailed+info redshift = pm.PyNode('redshiftOptions') stored_log_level = redshift.logLevel.get() redshift.logLevel.set(2) # save file pm.saveAs( filename, force=1, type='mayaBinary' ) # rename back to original name pm.renameFile(scene_name) # create the render command mrc = MayaRenderCommandBuilder( name=job_name, file_full_path=filename, render_engine=render_engine, project=project_path, by_frame=by_frame ) # submit renders blocks = [] if separate_layers: # render each layer separately rlm = pm.PyNode('renderLayerManager') layers = [layer for layer in rlm.connections() if layer.renderable.get()] for layer in layers: mrc_layer = copy.copy(mrc) layer_name = layer.name() mrc_layer.name = layer_name mrc_layer.render_layer = layer_name # create a new block for this layer block = af.Block( layer_name, renderer_to_block_type.get(render_engine, 'maya') ) block.setFiles( afcommon.patternFromDigits( afcommon.patternFromStdC( afcommon.patternFromPaths(outputs[0], outputs[1]) ) ).split(';') ) block.setNumeric( start_frame, end_frame, frames_per_task, by_frame ) block.setCommand(mrc_layer.build_command()) blocks.append(block) else: # create only one block block = af.Block( 'All Layers', renderer_to_block_type.get(render_engine, 'maya') ) block.setFiles( afcommon.patternFromDigits( afcommon.patternFromStdC( afcommon.patternFromPaths(outputs[0], outputs[1]) ) ).split(';') ) block.setNumeric( start_frame, end_frame, frames_per_task, by_frame ) block.setCommand(mrc.build_command()) blocks.append(block) job.setFolder('input', os.path.dirname(filename)) job.setFolder('output', os.path.dirname(outputs[0])) job.setHostsMask(hosts_mask) job.setHostsMaskExclude(hosts_exclude) if life_time > 0: job.setTimeLife(life_time * 3600) job.setCmdPost('deletefiles "%s"' % os.path.abspath(filename)) if pause: job.offline() # add blocks job.blocks.extend(blocks) status, data = job.send() if not status: pm.PopupError('Something went wrong!') print('data: %s' % data) # restore log level if render_engine == 'arnold': aro = pm.PyNode('defaultArnoldRenderOptions') aro.setAttr('log_verbosity', stored_log_level) # disable set output to console aro.setAttr("log_to_console", 0) elif render_engine == 'redshift': redshift = pm.PyNode('redshiftOptions') redshift.logLevel.set(stored_log_level)
def __init__(self,_parent,_guiInstance, _settings): """ Method: __init__ A method called when the class is instanciated, sets up the attributes Inputs: self: A pointer to the instance of the object being created. _parent: The parent ui element for the layout _guiInstance: The instance of the GUI class _settings: A struct containing all of the relevant information for the generation of the tab """ #initialise the base class ptb.TabBase.__init__(self,_parent,_guiInstance,_settings.m_tabName, _settings.m_rigElement, 'arm', _settings.m_baseName) #and initialise variables to stor the settings that are not stores by a ui element self.m_doSideSpecify = _settings.m_doSideSpecify self.m_sideSpecifier = _settings.m_sideSpecifier self.m_ikExt = _settings.m_ikExt self.m_fkExt = _settings.m_fkExt self.m_jntExt = _settings.m_jntExt self.m_ctrlExt = _settings.m_ctrlExt #-------------step 1 text generate-------------# self.m_step1Label = pm.text(label="1:", fn = "boldLabelFont") self.m_step1Text = pm.text(label = "Build the joints", ann = "Build the template joint chain for your arm, \ndon't worry about twist joints", al = "left", fn = "smallBoldLabelFont", w = 120, ww = True) #-------------step 1 control generate-------------# self.m_jointToolButton = pm.button(l = "Joint Tool", c = 'pm.runtime.JointTool()') #-------------step 2 text generate-------------# self.m_step2Label = pm.text(label="2:", fn = "boldLabelFont") self.m_step2Text = pm.text(label = "Override limb name?", ann = "Can be left at Arm if you wish", al = "left", fn = "smallBoldLabelFont", w = 120, ww = True) #-------------step 2 control generate-------------# self.m_nameOverrideCheck = pm.checkBox(ann = "override the limb name?", v = False, l = "", onc = pm.Callback(self.nameTextEnable, True), ofc = pm.Callback(self.nameTextEnable, False)) self.m_nameOverrideText = pm.textField(tx = _settings.m_limbName, ann = "Enter the name of the rig here", en = False) #-------------step 3 text generate-------------# self.m_step3Label = pm.text(label="3:", fn = "boldLabelFont") self.m_step3Text = pm.text(label = "Select and load the template joints", ann = "The joints must be in an unbroken and single hirerarchy\n there must not be more than one child of any selected\n joint also selected", al = "left", fn = "smallBoldLabelFont", h = 20, ww = True) #-------------step 3 control generate-------------# self.m_jointTable = pm.textScrollList(ams = True) for tempJnt in _settings.m_jntList: self.m_jointTable.append(tempJnt) self.m_loadJointsButton = pm.button(l = "Load Joints", c = pm.Callback(self.loadJoints)) #-------------step 4 text generate-------------# self.m_step4Label = pm.text(label="4:", fn = "boldLabelFont") self.m_step4Text = pm.text(label = "Select, in the box below, which joints, if any, you want to be the root of a twist chain", ann = "Note: If the last joint is selected \nit will be disregarded as it not \nwithin the scope of this joint chain", al = "left", fn = "smallBoldLabelFont", h = 20, ww = True) #-------------step 5 text generate-------------# self.m_step5Label = pm.text(label="5:", fn = "boldLabelFont") self.m_step5Text = pm.text(label = "Select options and generate", al = "left", fn = "smallBoldLabelFont", h = 20, ww = True) #-------------step 5 control generate-------------# self.m_ikCheck = pm.checkBox(l = "IK", ann = "Generate an IK chain?", v = _settings.m_doIK) self.m_fkCheck = pm.checkBox(l = "FK", ann = "Generate an FK chain?", v = _settings.m_doFK) self.m_numTwistText = pm.text(label = "Number of twist joints to be generated:", al = "left", ann = "Enter the number of twist joints to\n generate in each twist chain\n ignored if no joints selected to be\n the roots of twist chains", fn = "smallBoldLabelFont", h = 20, ww = True) self.m_numTwistJntsVal = pm.intField(v = _settings.m_numTwistJnts, ann = "Enter the number of twist joints to\n generate in each twist chain\n ignored if no joints selected to be\n the roots of twist chains") self.m_genRigButton = pm.button(l = "Generate Rig", c = pm.Callback(self.genChain)) self.m_reGenRigButton = pm.button(l = "Regenerate Rig", c = pm.Callback(self.reGenChain)) #-------------misc control generate-------------# self.m_closeButton = pm.button(l = "Close Tab", c = pm.Callback(self.m_gui.closeCurrentTab)) #-------------step 1 text attach-------------# self.m_topLayout.attachForm(self.m_step1Label, 'left', 20) self.m_topLayout.attachForm(self.m_step1Label, 'top', 22) self.m_topLayout.attachForm(self.m_step1Text,'top', 22) self.m_topLayout.attachControl(self.m_step1Text,'left', 20, self.m_step1Label) #-------------step 1 controls attach-------------# self.m_topLayout.attachForm(self.m_jointToolButton, 'top', 20) self.m_topLayout.attachForm(self.m_jointToolButton, 'right', 20) self.m_topLayout.attachControl(self.m_jointToolButton, 'left', 20, self.m_step1Text) #-------------step 2 text attach-------------# self.m_topLayout.attachForm(self.m_step2Label, 'left', 20) self.m_topLayout.attachControl(self.m_step2Label, 'top', 20, self.m_jointToolButton) self.m_topLayout.attachControl(self.m_step2Text, 'top', 23, self.m_jointToolButton) self.m_topLayout.attachControl(self.m_step2Text, 'left', 20, self.m_step2Label) #-------------step 2 control attach-------------# self.m_topLayout.attachControl(self.m_nameOverrideCheck,'left', 20, self.m_step2Text) self.m_topLayout.attachControl(self.m_nameOverrideCheck,'top',23,self.m_jointToolButton) self.m_topLayout.attachControl(self.m_nameOverrideText,'left', 20, self.m_nameOverrideCheck) self.m_topLayout.attachControl(self.m_nameOverrideText,'top',20,self.m_jointToolButton) self.m_topLayout.attachForm(self.m_nameOverrideText, 'right', 20) #-------------step 3 text attach-------------# self.m_topLayout.attachForm(self.m_step3Label, 'left', 20) self.m_topLayout.attachControl(self.m_step3Label, 'top', 20, self.m_nameOverrideText) self.m_topLayout.attachPosition(self.m_step3Text, 'right', 20, 50) self.m_topLayout.attachControl(self.m_step3Text, 'top', 20, self.m_nameOverrideText) self.m_topLayout.attachControl(self.m_step3Text, 'left', 20, self.m_step3Label) #-------------step 3 control attach-------------# self.m_topLayout.attachForm(self.m_jointTable, 'left', 30) self.m_topLayout.attachPosition(self.m_jointTable, 'right', 20, 50) self.m_topLayout.attachForm(self.m_jointTable,'bottom', 20) self.m_topLayout.attachControl(self.m_jointTable,'top', 20, self.m_step4Text) self.m_topLayout.attachForm(self.m_loadJointsButton, 'left', 20) self.m_topLayout.attachControl(self.m_loadJointsButton, 'right', 20, self.m_genRigButton) self.m_topLayout.attachControl(self.m_loadJointsButton, 'top', 20,self.m_step3Text) #-------------step 4 text attach-------------# self.m_topLayout.attachForm(self.m_step4Label, 'left', 20) self.m_topLayout.attachControl(self.m_step4Label, 'top', 20, self.m_loadJointsButton) self.m_topLayout.attachControl(self.m_step4Text, 'top', 20, self.m_loadJointsButton) self.m_topLayout.attachControl(self.m_step4Text, 'left', 20, self.m_step4Label) self.m_topLayout.attachControl(self.m_step4Text, 'right', 20, self.m_closeButton) #-------------step 5 text attach-------------# self.m_topLayout.attachPosition(self.m_step5Label, "left", 20,50) self.m_topLayout.attachControl(self.m_step5Label, "top", 20, self.m_nameOverrideText) self.m_topLayout.attachControl(self.m_step5Text, "left", 20,self.m_step5Label) self.m_topLayout.attachControl(self.m_step5Text, "top", 20, self.m_nameOverrideText) self.m_topLayout.attachForm(self.m_step5Text, 'right', 20) #-------------step 5 control attach-------------# self.m_topLayout.attachForm(self.m_ikCheck, 'right',20) self.m_topLayout.attachForm(self.m_fkCheck, 'right',20) self.m_topLayout.attachPosition(self.m_ikCheck, 'left' , 40 , 50) self.m_topLayout.attachPosition(self.m_fkCheck, 'left' , 40 , 50) self.m_topLayout.attachControl(self.m_ikCheck, 'top', 10, self.m_step5Text) self.m_topLayout.attachControl(self.m_fkCheck, 'top', 10, self.m_ikCheck) self.m_topLayout.attachPosition(self.m_numTwistText, 'left', 40, 50) self.m_topLayout.attachControl(self.m_numTwistText, 'top', 20, self.m_fkCheck) self.m_topLayout.attachControl(self.m_numTwistText, 'right', 20 ,self.m_numTwistJntsVal) self.m_topLayout.attachForm(self.m_numTwistJntsVal, 'right', 20) self.m_topLayout.attachControl(self.m_numTwistJntsVal, 'top', 20, self.m_fkCheck) self.m_topLayout.attachForm(self.m_genRigButton, 'right', 20) self.m_topLayout.attachPosition(self.m_genRigButton, 'left', 20, 50) self.m_topLayout.attachControl(self.m_genRigButton, 'bottom', 20,self.m_reGenRigButton) self.m_topLayout.attachForm(self.m_reGenRigButton, 'right', 20) self.m_topLayout.attachPosition(self.m_reGenRigButton, 'left', 20, 50) self.m_topLayout.attachControl(self.m_reGenRigButton, 'bottom', 20, self.m_closeButton) #-------------misc control attach-------------# self.m_topLayout.attachForm(self.m_closeButton, 'right', 20) self.m_topLayout.attachPosition(self.m_closeButton, 'left', 20, 50) self.m_topLayout.attachForm(self.m_closeButton, 'bottom', 20)
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 _createIntRandParam(name): pm.rowLayout(numberOfColumns=2, columnWidth=[(1, 50), (2, 200)]) pm.text(label=name + ':') field = pm.intField(name, minValue=-999999, maxValue=999999, step=1, enable=False) pm.setParent('..') return field