def SJ_SpShaderMakerwdUI(): ''' 2.2更新说明:修复刷新tx的bug,修复udim与串联转换的bug,增加生成arnold材质自动生成tx的选择 2.3更新说明:增加目标路径排除'roughness','Height','Normal','f0'贴图批量生成tx功能 ''' if pm.window('spshader',ex=True): pm.deleteUI('spshader',wnd=True) pm.window('spshader',t='SPshaderForMayaMakerV2.3') pm.columnLayout(adj=True,w=600) pm.text(l='一键生成spForMaya材质',fn='fixedWidthFont',h=50,annotation="2.3更新说明:增加目标路径排除'roughness','Height','Normal','f0'贴图批量生成tx功能") pm.textScrollList("piclist",allowMultiSelection=1) pm.text(l='',fn='fixedWidthFont',h=30,annotation="") pm.textField('sptexpath',tx="D:/test",h=30,annotation="") pm.button(l='获取路径下的贴图列表',c=spaddfile,bgc=[0.5,1,0.8],h=50,annotation="输入贴图路径,获取路径下的贴图,并选中贴图") pm.text(l='~~~~~~~~~~~~~~~~~~',fn='fixedWidthFont',h=20,annotation="") pm.flowLayout( columnSpacing=0) pm.checkBox("autocb" ,label='生成arnold材质并自动转tx',h=50,w=300,ann="不转换height,f0,specularRoughness贴图为tx") pm.checkBox("seledcb" ,label='切换为刷新路径\\列表模式',ann="当列表为空时,刷新路径文件夹里最新修改的贴图;当列表内已获取贴图信息时,刷新列表中选中的贴图为tx!!",h=50,w=150,ed=1) pm.setParent( '..' ) pm.flowLayout( columnSpacing=0) pm.button(l='生成arnold材质',c=arnoldspshmaker,bgc=[1,0.5,0.5],h=50,annotation="选择列表中的贴图名字,点击确定生成arnold材质球",w=300) pm.button(l='刷新贴图为tx',c=fleshtx,bgc=[1,0.5,0.5],h=50,annotation=" 默认刷新三分钟内修改的贴图tx",w=300) pm.setParent( '..' ) pm.button(l='刷新目标路径的tx',c=pathtx,bgc=[1,0.5,0.5],h=50,annotation=" 默认不对Roughness,f0,Normal,Height这四种贴图进行tx转换",w=300) pm.button(l='选择列表中的贴图名字,生成vray材质',c=vrayspshmaker,bgc=[1,1,0.5],h=50,annotation="点击确定生成vray材质球") pm.text(l='~~~~~~~~~~~~~~~~~~',fn='fixedWidthFont',h=20,annotation="") pm.button(l='多uv材质udim模式与串联式节点互转',c=udimexnode,bgc=[0.8,0.6,0.8],h=50,annotation=" 选择需要转换的file节点,点击确定;当file节点为udim模式时则转换为节点串联模式,反之亦然") pm.showWindow()
def SJ_furDisplaySwitchwdUI(): if pm.window('furdisplay',ex=True): pm.deleteUI('furdisplay',wnd=True) pm.window('furdisplay',t='furDisplayToolV2.1') pm.columnLayout(adj=True) pm.text(l='毛发显隐V2.1',fn='fixedWidthFont',h=50,annotation="更新说明V2.1:增加hair和yeti混合情况的显隐切换",w=80) pm.flowLayout( columnSpacing=0) pm.checkBox("allsw" ,label='切换所有yeti毛发显隐',ann="",h=50,w=140) pm.checkBox("all" ,label='强制所有毛发显示 \n(最终提交渲染模式)',ann="",h=50,w=130) pm.setParent( '..' ) pm.button(l='yeti毛发显隐切换',c=yetidisplays,h=50,w=80,ann="默认操作为切换选中目标显隐(无需选毛发节点,框选到控制器即可)!!") pm.showWindow()
def __init__(self): title = 'pbUV' ver = '1.00' if pm.window('pbUV', exists=True): pm.deleteUI('pbUV') window = pm.window('pbUV', s=True, title='{0} | {1}'.format(title, ver)) try: pane = pm.paneLayout('textureEditorPanel', paneSize=[1, 1, 1], cn='vertical2', swp=1) except: pane = pm.paneLayout('textureEditorPanel', paneSize=[1, 1, 1], cn='vertical2') uvtextureviews = pm.getPanel(scriptType='polyTexturePlacementPanel') if len(uvtextureviews): pm.scriptedPanel(uvtextureviews[0], e=True, unParent=True) with pm.columnLayout(p=pane): TransformUI() opts = GlobalOptions() SetEditorUI() DensityUI(opts) SnapshotUI(opts) pm.scriptedPanel(uvtextureviews[0], e=True, parent=pane) # Replace Default UV Editor Toolbar flowlayout = pm.melGlobals['gUVTexEditToolBar'] framelayout = pm.flowLayout(flowlayout, q=True, p=True) framelayout = pm.uitypes.FrameLayout(framelayout) pm.deleteUI(flowlayout) flowlayout = pm.flowLayout(p=framelayout) Tools01UI(flowlayout) CutSewUI(flowlayout) UnfoldUI(flowlayout) AlignUI(flowlayout) PushUI(flowlayout) SnapUI(flowlayout) LayoutUI(flowlayout) IsolateUI(flowlayout, uvtextureviews[0]) Opts01UI(flowlayout, uvtextureviews[0]) Opts02UI(flowlayout, uvtextureviews[0]) Opts03UI(flowlayout, uvtextureviews[0]) ManipUI(flowlayout) window.show()
def fx_prefixNameUI(): ''' {'load':'maya_fx','defaultOption':1,'CNname':'特效abc模型输出一键整理'} ''' if pm.window('fx_prefixNamewd',ex=True): pm.deleteUI('fx_prefixNamewd',wnd=True) pm.window('fx_prefixNamewd',t='fx_prefixName_ToolV1.0') pm.columnLayout(adj=True) pm.text(l='特效abc模型输出一键整理',fn='fixedWidthFont',annotation="",w=400,h=50,ann="") pm.textField('fx_prefixNametxt',tx="PrefixName",h=30,w=100,ann ="重命名名字") pm.setParent( '..' ) pm.flowLayout( columnSpacing=0) pm.checkBox("fx_prefixNamecb" ,label='是否对所有mesh执行规范',v=0,ann="默认不勾选为只针对选中大组内的模型进行规范",h=50,w=300) pm.setParent( '..' ) pm.button(l='执行规范',c=fx_prefixName,w=200,h=50,bgc=[0.4,0.7,0.5],ann="选择大组,执行命令") pm.showWindow()
def __init__(self): """A GUI Class Args: args (None): Just in case... """ self.name='aw_assimilator' self.width=200 self.height=120 self.title_blue_cl=[.1,.15,.2] self.close_red_cl=[0.5,0.2,0.2] self.go_green_cl=[.1,.4,.2] if pm.window(self.name, q=True, exists=True): pm.deleteUI(self.name) if pm.windowPref(self.name, ex=True): pm.windowPref(self.name, r=True) self.win = pm.window(self.name,widthHeight=(self.width, self.height),title=self.name) # Window creation self.column_layout = pm.columnLayout(w=self.width) # Text Spacers! pm.text(l="\nSelect Source then Targets\n", fn='boldLabelFont', al='center', w=self.width, bgc=self.title_blue_cl) pm.text(l="", al='center') pm.text(l="Ready?", al='center', w=self.width) pm.text(l="", al='center', w=self.width) # Make a button and assign a command to it self.flow_layout=pm.flowLayout(w=self.width) pm.button('assimilateBtn',command=lambda *args: self.aw_assimilator(),label="Yes!", p=self.flow_layout, w=self.width/2, bgc=self.go_green_cl) pm.button('assimilateKillBtn',command=lambda *args: pm.deleteUI(self.name),label="Cancel", p=self.flow_layout, w=self.width/2-3, bgc=self.close_red_cl) self.win.show()
def createList(self, parentWidget): self.parentWidget = parentWidget a = pm.scrollLayout(p=self.parentWidget, childResizable=True, h=200) self.widgetName = pm.flowLayout(p=a, backgroundColor=(.17, .17, .17), columnSpacing=5, h=1000, wrap=True, dropCallback=self.dropCallback) pm.popupMenu(parent=self.widgetName) pm.menuItem(label='add item', c=self.addItemCallBack)
def refreshList(self, path=None, task=None, code=None, itemMData=None): color = (0, 0, 0) createdColor = (.5, .5, .20) if not itemMData: print 'ERROR: No search item!!' self.item = itemMData childs = pm.flowLayout(self.widgetName, q=True, ca=True) if childs: for i in childs: pm.deleteUI(i) self.itemList = [] self.selectedItem = None for ns, component in itemMData['components'].iteritems(): type = component['type'] collection = database.getCollection(type, self.projectName) result = collection.find_one({ 'task': component['task'], 'code': component['code'] }) if not result: print 'component %s %s missing!' % (component['task'], component['code']) continue name = ns + ':' + database.getTaskShort( result['task']) + result['code'] + '_' + result['name'] if result['task'] == 'rig': createdColor = (0, .5, .20) elif result['task'] == 'uvs': createdColor = (.5, .5, .20) notCreatedColor = (.2, .2, .2) status = result['status'] if status == 'notCreated': color = notCreatedColor elif status == 'created': color = createdColor thumbPath = version.getThumb(result) x = ComponentWidget(name=name, itemName=result['name'], imgPath=thumbPath, label=result['task'], status=result['status'], parentWidget=self, color=color) self.itemList.append(x) x.task = result['task'] x.code = result['code'] x.addToLayout(self.viewOption)
def createList(self, parentWidget): self.parentWidget = parentWidget a = pm.scrollLayout(p=self.parentWidget, childResizable=True, h=200) self.widgetName = pm.flowLayout(p=a, backgroundColor=(.17, .17, .17), columnSpacing=5, h=1000, wrap=True) self.addMenus()
def SJ_scaleAnimationwdUI(): if pm.window('scaleani',ex=True): pm.deleteUI('scaleani',wnd=True) pm.window('scaleani',t='ScaleAnimationToolV1.0') pm.columnLayout(adj=True) pm.text(l='缩放动画工具V1.0 ',fn='fixedWidthFont',h=50,w=10) pm.flowLayout( columnSpacing=0) pm.text(l='起始帧 ',fn='fixedWidthFont',h=30,w=130) pm.text(l='结束帧 ',fn='fixedWidthFont',h=30,w=130) pm.setParent( '..' ) pm.flowLayout( columnSpacing=0) pm.textField('startnum',tx=u"1",w=130,h=30,ann="") pm.textField('endnum',tx=u"100",w=130,h=30,ann="") pm.setParent( '..' ) pm.button(l='获取key帧属性',c=getattr,bgc=[0.4,0.6,0.5],w=160,h=50) pm.textScrollList("keyattr",allowMultiSelection=1) pm.button(l='缩放动画',c=scaleani,bgc=[0.4,0.6,0.5],w=160,h=50) pm.button(l='去除小数点帧数',c=anisplits,bgc=[0.4,0.6,0.5],w=160,h=50) pm.showWindow()
def SJ_yetiCachewdUI(): if pm.window('yeticache',ex=True): pm.deleteUI('yeticache',wnd=True) pm.window('yeticache',t='yeticacheV3.1') pm.columnLayout(adj=True,w=240) pm.text(l='帧数区间(开始帧,结束帧,Sample',fn='fixedWidthFont',h=50,ann="更新说明V3.1:修复批量毛发路径中,与输出毛发缓存路径名字不匹配问题") pm.flowLayout( columnSpacing=0) pm.textField('rangenuma',tx="0",h=30,w=80) pm.textField('rangenumb',tx="1",h=30,w=80) pm.textField('rangesamnum',tx="1",h=30,w=80) pm.setParent( '..' ) pm.text(l='毛发缓存生成路径', fn='fixedWidthFont',h=50,ann="" ) pm.flowLayout( columnSpacing=0) pm.checkBox("switch" ,label='切换yeti1.3.19',ann="",h=50,w=120) pm.checkBox("single" ,label="单帧缓存指认",ann="",h=50,w=120) pm.setParent( '..' ) pm.textField('pathnum',tx="D:/textest/fur",h=30) pm.button(l=r'批量输出毛发缓存',c=yetiwritecache,h=50) pm.button(l=r'批量替换毛发缓存路径',c=changecache,h=50) pm.showWindow()
def __init__(self, title, widthHeight, tabs_names, frameLayoutPerTab, collapseStyle=0, descr=''): super(Exporter, self).__init__(title, widthHeight, tabs_names, frameLayoutPerTab) self.localProject = os.environ[ 'MAYA_PROJECT' ] self.localUser=os.environ[ 'USER' ] self.path = os.path.join(self.localProject+ "/export/GEO") self.scene_name = cmds.file(q=True, sn=True, shn=True).split('.')[0] self.folder_path = os.path.join(self.path, 'OBJ', self.localUser, self.scene_name) self.type = 'OBJ' self.extension = 'obj' self.curFr=1001 # GUI BUILDING # self.fl = self.frameLayouts[0][0].columnLayout col = pm.columnLayout(p=self.fl, h=self.wh[1]/2) flow_1=pm.flowLayout(p=col, w=self.wh[0]) self.type_om = win.AW_optionMenu(label="File Type", options=['OBJ','ZBRUSH', 'MUDBOX', 'FBX', 'MB', 'MA', 'ALEMBIC'], parent=flow_1, cc=self._updateDirectory) self.autoCheck = pm.checkBox(l='Auto-detect Folder', p=flow_1, v=1) pm.flowLayout(p=col, w=self.wh[0]) pm.text(l='Directory:') self.path_tf=pm.textField(w=self.wh[0]/1.3,cc=self._update_path_tf) pm.button(label='Browse',w=80, c=self._browser, bgc=self.col_fls[1]) self.path_tf.setText(self.folder_path) flow_3 = pm.flowLayout(w=self.wh[0], p=col) self.combined_cb = pm.checkBox(l='Export Per Object', v=1, cc=self._change_combined_cb, p=flow_3) pm.text(l='Combined Name:',p=flow_3,w=200) self.combined_tf = pm.textField(tx='', p=flow_3,w=300, editable=False) flow_4 = pm.flowLayout(w=self.wh[0],p=col) self.framesCheck = pm.checkBox(l='Frame Range', w=200,p=flow_4, v=0, cc=self._framesCallback) self.fr_st = pm.textField(editable=False,w=100,tx=str(int(pm.playbackOptions(ast=True, q=True))),p=flow_4) self.fr_end = pm.textField(editable=False,w=100,tx=str(int(pm.playbackOptions(aet=True, q=True))),p=flow_4) pm.text(l='\n', p=col) flow_col = pm.flowLayout(p=col, w=self.wh[0]) col_1 = pm.columnLayout(p=flow_col, w=self.wh[0]/2) col_2 = pm.columnLayout(p=flow_col, w=self.wh[0]/2) self.export_btn = pm.button(label='Export', bgc=self.col_fls[4], c=self._export, p=col_1, w=self.wh[0]/4) flow_5 = pm.flowLayout(w=self.wh[0],p=col_2) self.recursiveCheck = pm.checkBox(l='Check all folders inside', v=1, p=flow_5) self.list_btn = pm.button(label='List Files in Directory', bgc=self.col_fls[5], c=partial(self._getDirectoryFiles,True), p=flow_5, w=self.wh[0]/4) self.import_btn = pm.button(label='Import Directory', bgc=self.col_fls[5], c=self._customImport, p=col_2, w=self.wh[0]/2.5) pm.text(l='\n',p=col) pm.button(label='Swap Namespace with Name', bgc=self.col_fls[6], c=self._swapNamespace, p=col_2,w=self.wh[0]/2.5)
def createList(self, parentWidget): self.parentWidget = parentWidget form = pm.formLayout(numberOfDivisions=100) a = pm.scrollLayout(childResizable=True) self.widgetName = pm.flowLayout(p=a, backgroundColor=(.17, .17, .17), columnSpacing=5, h=1000, wrap=True) pm.formLayout(form, edit=True, attachForm=[(a, 'left', 5), (a, 'bottom', 5), (a, 'right', 5), (a, 'top', 5)], attachControl=[], attachPosition=[], attachNone=()) self.addMenus()
def refreshList(self, path=None, task=None, code=None, itemMData=None): color = (0, 0, 0) x = None itemListProj = database.getProjectDict() if itemMData: self.path = itemMData['path'] self.task = itemMData['task'] self.type = itemMData['type'] else: self.path = path self.task = task self.type = database.getTaskType(task[0]) logger.debug('task %s, type %s' % (task[0], self.type)) collection = database.getCollection(self.type) if code: result = collection.find({'path': self.path, 'code': code}) else: if self.task == ['asset']: result = collection.find({'path': self.path, 'task': 'model'}) elif self.task == ['shot']: result = collection.find({'path': self.path, 'task': 'layout'}) else: result = collection.find({ 'path': self.path, 'task': { '$in': self.task } }) flowChilds = pm.flowLayout(self.widgetName, q=True, ca=True) if flowChilds: for i in flowChilds: pm.deleteUI(i) self.itemList = [] self.selectedItem = None for itemMData in result: logger.debug(itemMData) if not code and (task == 'asset' or task == 'shot'): templateToUse = [ x for x in itemListProj['assetNameTemplate'] if x != '$task' ] name = database.templateName(itemMData, template=templateToUse) taskLabel = task.upper() createdColor = (0, .2, .50) notCreatedColor = (0, .2, .50) else: name = database.templateName(itemMData) taskLabel = itemMData['task'].upper() notCreatedColor = (.2, .2, .2) createdColor = (1, .8, .20) status = itemMData['status'] if status == 'notCreated': color = notCreatedColor elif status == 'created': color = createdColor thumbPath = version.getThumb(itemMData) x = ItemBase(name=name, itemName=itemMData['name'], imgPath=thumbPath, label=taskLabel, status=itemMData['status'], parentWidget=self, color=color) x.infoWidget = self.infoWidget if code: x.task = itemMData['task'] x.workVer = itemMData['workVer'] x.publishVer = itemMData['publishVer'] else: x.task = itemMData['task'] x.workVer = 0 x.publishVer = 0 x.code = itemMData['code'] self.itemList.append(x) x.addToLayout(self.viewOption)
def lcTb_open_tool(windowName, heightAdjust, commandString='', *args, **kwargs): ''' ''' prefix = conf['prefix'] if lcUtility.Utility.maya_version_check(): if pm.columnLayout(prefix + '_columLayout_holder', exists=True): pm.deleteUI(prefix + '_columLayout_holder') if pm.formLayout('fl_form', exists=True): pm.deleteUI('fl_form') if pm.columnLayout('fl_form_shelf', exists=True): pm.deleteUI('fl_form_shelf') if pm.columnLayout('fl_form_tool', exists=True): pm.deleteUI('fl_form_tool') pm.setParent(prefix + '_columnLayout_main') pm.columnLayout(prefix + '_columLayout_holder', rowSpacing=0) pm.formLayout('fl_form', numberOfDivisions=100) pm.picture('fl_form_header', image=os.path.join( iconPath, 'header_{}.png'.format(lct_conf['release']))) if lct_conf['release'] == 'dev': pm.symbolButton('fl_form_reload', image=os.path.join(iconPath, 'reload.png'), command=functools.partial( lcTb_open_tool_new_window, shelfCommand)) pm.columnLayout('fl_form_shelf') shelfHeight = 32 fl_flow_layout = pm.flowLayout(width=204, height=shelfHeight + 4, wrap=True, columnSpacing=0) # list published tools except lcToolbox toolList = lcUtility.Utility.buildPublishList(inline=False) toolCount = 0 for item in toolList: if item[0] != 'lcToolbox': toolCount = toolCount + 1 toolName = item[0] toolPrefix = item[1] toolAnnotation = item[2] toolHeight = int(item[5]) toolIcon = os.path.normpath( os.path.join(srcPath, toolName, toolName + '.png')) shelfIcon = os.path.normpath( os.path.join(srcPath, toolName, 'icons', toolName + '_shelf.png')) toolShelfCommand = "import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI()".format( toolName, toolPrefix) toolExecString = unicode( "import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI(asChildLayout=True)" .format(toolName, toolPrefix)) toolButton = pm.symbolButton(prefix + '_' + toolName, image=toolIcon, annotation=toolAnnotation, command=functools.partial( lcTb_open_tool, windowName, toolHeight, toolExecString)) popup = pm.popupMenu(prefix + '_' + toolName + 'popup', parent=toolButton) pm.menuItem(l='Open in new window', parent=popup, command=functools.partial( lcTb_open_tool_new_window, toolShelfCommand)) pm.menuItem(l='Add to shelf', parent=popup, command=functools.partial( lcShelf.Shelf.makeShelfButton, toolName, toolShelfCommand, shelfIcon, toolAnnotation)) if pm.window( toolName, ex=True ): # if i have the tool window open seperately use the return arrow icon pm.symbolButton( prefix + '_' + toolName, edit=True, image=os.path.normpath( os.path.join(srcPath, toolName, 'icons', toolName + '_Return.png')), command=functools.partial(lcTb_open_tool, windowName, toolHeight, toolExecString)) # if i am loading a specific tool back into the window update its icon to standard if commandString and toolName in commandString: pm.symbolButton( toolButton, edit=True, image=os.path.normpath( os.path.join(srcPath, toolName, 'icons', toolName + '_Release.png')), command=functools.partial(lcTb_open_tool_new_window, toolShelfCommand)) rowCount = max(1, math.ceil(toolCount / 5.0)) shelfHeight = shelfHeight * rowCount + 4 pm.flowLayout(fl_flow_layout, edit=True, height=shelfHeight) pm.setParent('fl_form') fl_form_tool = pm.columnLayout('fl_form_tool', width=224, columnOffset=('left', 10)) pm.separator(style='double', h=5, w=205) if not commandString: pm.picture(image=os.path.join(iconPath, 'none.png')) else: exec commandString in locals() lct_cfg.set('lcToolboxCurrentTool', commandString) lct_cfg.set('lcToolboxHeight', heightAdjust) if lct_conf['release'] == 'dev': pm.formLayout('fl_form', edit=True, attachForm=[('fl_form_header', 'top', 0), ('fl_form_shelf', 'top', 54), ('fl_form_shelf', 'left', 25), ('fl_form_reload', 'top', 0), ('fl_form_reload', 'left', 103)], attachControl=[(fl_form_tool, 'top', 0, 'fl_form_shelf')]) else: pm.formLayout('fl_form', edit=True, attachForm=[('fl_form_header', 'top', 0), ('fl_form_shelf', 'top', 54), ('fl_form_shelf', 'left', 25)], attachControl=[(fl_form_tool, 'top', 0, 'fl_form_shelf')]) pm.setParent(prefix + '_columLayout_holder') pm.picture('fl_form_footer', image=os.path.join( iconPath, 'footer_{}.png'.format(lct_conf['release']))) pm.window(windowName, edit=True, height=heightAdjust + shelfHeight + 122) # +conf['height'])#, width=mainWindow.width) else: pm.separator(style='none', h=30) pm.text(l='Your Maya Version:', al='center', w=231, h=25, font='boldLabelFont') pm.text(l='{}'.format(versions.shortName()), al='center', w=231, h=10, font='boldLabelFont') pm.separator(style='none', h=10) pm.text( l='You must have\nMaya 2014 or greater\nto run the\nLEOCOV Toolbox', al='center', w=231, h=60, font='boldLabelFont') pm.window(windowName, edit=True, height=231)
mtpPluto = cmds.pathAnimation( planetPluto, orbitOfPluto, f=True, fa='x', fm=True, ua='y', stu=1.0, etu=4800 ) linear_cycle( mtpMercury ) linear_cycle( mtpVenus ) linear_cycle( mtpEarth ) linear_cycle( mtpMars ) linear_cycle( mtpJupiter ) linear_cycle( mtpSaturn ) linear_cycle( mtpUranus ) linear_cycle( mtpNeptune ) linear_cycle( mtpPluto ) cmds.playbackOptions( max=4800 ) pmc.deleteUI(win) win = pmc.window( title="Animation" ) gridLayout = pmc.gridLayout( nr=2, nc=1, cwh=(180, 80) ) strText = 'if you want animation to be fast click on the "Fast animation" button, else if you want animation to be slower click in "Slow animation" button' ExpText = pmc.text( label = strText, align='left', ww=True, parent=gridLayout ) flowLayout = pmc.flowLayout( columnSpacing=20, parent=gridLayout ) btnSlow = pmc.button( label='Slow animation', parent=flowLayout, command=lambda *args: slowAnimation(win) ) btnFast = pmc.button( label='Fast animation', parent=flowLayout, command=lambda *args: fastAnimation(win) ) pmc.windowPref( win, wh=( 180, 100) , le=300, te=300 ) win.show()
stu=1.0, etu=4800) linear_cycle(mtpMercury) linear_cycle(mtpVenus) linear_cycle(mtpEarth) linear_cycle(mtpMars) linear_cycle(mtpJupiter) linear_cycle(mtpSaturn) linear_cycle(mtpUranus) linear_cycle(mtpNeptune) linear_cycle(mtpPluto) cmds.playbackOptions(max=4800) pmc.deleteUI(win) win = pmc.window(title="Animation") gridLayout = pmc.gridLayout(nr=2, nc=1, cwh=(180, 80)) strText = 'if you want animation to be fast click on the "Fast animation" button, else if you want animation to be slower click in "Slow animation" button' ExpText = pmc.text(label=strText, align='left', ww=True, parent=gridLayout) flowLayout = pmc.flowLayout(columnSpacing=20, parent=gridLayout) btnSlow = pmc.button(label='Slow animation', parent=flowLayout, command=lambda *args: slowAnimation(win)) btnFast = pmc.button(label='Fast animation', parent=flowLayout, command=lambda *args: fastAnimation(win)) pmc.windowPref(win, wh=(180, 100), le=300, te=300) win.show()
def __init__(self): ui_labelWidth = 140 ui_inputWidth = 240 if pm.window(WIN_NAME, exists=True): pm.deleteUI(WIN_NAME, window=True) with pm.window( WIN_NAME, title=WIN_TITLE, maximizeButton=False, menuBar=True, menuBarVisible=True ) as self.window: pm.setUITemplate('DefaultTemplate', pushTemplate=True) pm.menu(label='Edit', tearOff=False) pm.menuItem(label='Reset Settings', command=self.ui_resetSettings) pm.menu(label='Help', tearOff=False) pm.menuItem(label='Help on ' + WIN_TITLE, command=self.ui_showHelp) with pm.formLayout() as self.ui_LAY_mainForm: with pm.tabLayout(tabsVisible=False) as self.ui_TAB_top: pm.tabLayout(self.ui_TAB_top, e=True, height=1) with pm.formLayout() as self.ui_LAY_attachForm: with pm.tabLayout(tabsVisible=False, scrollable=True, innerMarginWidth=4) as self.ui_TAB_inner: with pm.columnLayout(adjustableColumn=True) as self.ui_LAY_mainColumn: with pm.frameLayout( label='Control Panel', collapsable=True, collapse=False, marginHeight=3 ) as self.ui_LAY_frameControlPanel: with pm.rowColumnLayout( numberOfColumns=12, columnSpacing=([3, 2], [4, 2], [5, 2], [6, 2]), rowSpacing=[1, 5], # Label X Y Z XYZ Mag Sep Reset Bias Sep Min Max columnWidth=[(1, 60), (2, 20), (3, 20), (4, 20), (5, 80), (6, 60), (7, 20), (8, 20), (9, 120), (10, 20), (11, 60), (12, 60)] ) as self.ui_LAY_mainRowColumn: # ----- Header Row ----- pm.text(label='') pm.text(label='') pm.text(label='') pm.text(label='') pm.text(label='') pm.text(label='Magnitude', ) pm.text(label='') pm.text(label='') pm.text(label='Bias', ) pm.text(label='') pm.text(label='Min', ) pm.text(label='Max', ) # ----- Translate Row ----- pm.text(label='Translate ', align='right') pm.button(label='X', command=pm.Callback(self.randomizeTranslate, ['tx'])) pm.button(label='Y', command=pm.Callback(self.randomizeTranslate, ['ty'])) pm.button(label='Z', command=pm.Callback(self.randomizeTranslate, ['tz'])) pm.button(label='XYZ', command=pm.Callback(self.randomizeTranslate, ['tx', 'ty', 'tz'])) self.ui_FLTFLD_translateMagnitude = pm.floatField('ui_FLTFLD_translateMagnitude', changeCommand=self.ui_refresh, value=10) pm.text(label='') self.ui_BTN_translateBiasReset = pm.button(label='0') pm.setUITemplate('DefaultTemplate', popTemplate=True) # strange slider group visual with default template self.ui_INTSLGRP_translateBias = pm.intSliderGrp( 'ui_INTSLGRP_translateBias', columnWidth=[1, 30], field=True, minValue=-100, maxValue=100, fieldMinValue=-100, fieldMaxValue=100, value=0, step=1, fieldStep=1, sliderStep=1, changeCommand=self.ui_refresh, dragCommand=self.ui_refresh ) pm.setUITemplate('DefaultTemplate', pushTemplate=True) pm.button(self.ui_BTN_translateBiasReset, edit=True, command=pm.Callback(self.ui_resetBias, self.ui_INTSLGRP_translateBias)) pm.text(label='=') self.ui_FLTFLD_translateMin = pm.floatField(enable=False, value=-5) self.ui_FLTFLD_translateMax = pm.floatField(enable=False, value=95) # ----- Rotate Row ----- pm.text(label='Rotate ', align='right') pm.button(label='X', command=pm.Callback(self.randomizeRotate, ['rx'])) pm.button(label='Y', command=pm.Callback(self.randomizeRotate, ['ry'])) pm.button(label='Z', command=pm.Callback(self.randomizeRotate, ['rz'])) pm.button(label='XYZ', command=pm.Callback(self.randomizeRotate, ['rx', 'ry', 'rz'])) self.ui_FLTFLD_rotateMagnitude = pm.floatField('ui_FLTFLD_rotateMagnitude', changeCommand=self.ui_refresh, value=90) pm.text(label='') self.ui_BTN_rotateBiasReset = pm.button(label='0') pm.setUITemplate('DefaultTemplate', popTemplate=True) # strange slider group visual with default template self.ui_INTSLGRP_rotateBias = pm.intSliderGrp( 'ui_INTSLGRP_rotateBias', columnWidth=[1, 30], field=True, minValue=-100, maxValue=100, fieldMinValue=-100, fieldMaxValue=100, value=0, step=1, fieldStep=1, sliderStep=1, changeCommand=self.ui_refresh, dragCommand=self.ui_refresh ) pm.setUITemplate('DefaultTemplate', pushTemplate=True) pm.button(self.ui_BTN_rotateBiasReset, edit=True, command=pm.Callback(self.ui_resetBias, self.ui_INTSLGRP_rotateBias)) pm.text(label='=') self.ui_FLTFLD_rotateMin = pm.floatField(enable=False, value=-5) self.ui_FLTFLD_rotateMax = pm.floatField(enable=False, value=95) # ----- Scale Row ----- pm.text(label='Scale ', align='right') pm.button(label='X', command=pm.Callback(self.randomizeScale, ['sx'])) pm.button(label='Y', command=pm.Callback(self.randomizeScale, ['sy'])) pm.button(label='Z', command=pm.Callback(self.randomizeScale, ['sz'])) pm.flowLayout(columnSpacing=2) pm.button(label='XYZ', command=pm.Callback(self.randomizeScale, ['sx', 'sy', 'sz'])) pm.button(label='Uniform', command=pm.Callback(self.randomizeScale, ['uniform'])) pm.setParent('..') self.ui_FLTFLD_scaleMagnitude = pm.floatField('ui_FLTFLD_scaleMagnitude', changeCommand=self.ui_refresh, value=2) pm.text(label='') self.ui_BTN_scaleBiasReset = pm.button(label='0') pm.setUITemplate('DefaultTemplate', popTemplate=True) # strange slider group visual with default template self.ui_INTSLGRP_scaleBias = pm.intSliderGrp( 'ui_INTSLGRP_scaleBias', columnWidth=[1, 30], field=True, minValue=-100, maxValue=100, fieldMinValue=-100, fieldMaxValue=100, value=0, step=1, fieldStep=1, sliderStep=1, changeCommand=self.ui_refresh, dragCommand=self.ui_refresh ) pm.setUITemplate('DefaultTemplate', pushTemplate=True) pm.button(self.ui_BTN_scaleBiasReset, edit=True, command=pm.Callback(self.ui_resetBias, self.ui_INTSLGRP_scaleBias)) pm.text(label='=') self.ui_FLTFLD_scaleMin = pm.floatField(enable=False, value=-5) self.ui_FLTFLD_scaleMax = pm.floatField(enable=False, value=95) with pm.frameLayout( label='Seed Control', collapsable=True, collapse=False, marginHeight=3 ) as self.ui_LAY_frameSeedControl: with pm.columnLayout(adjustableColumn=False): with pm.rowLayout( numberOfColumns=2, columnWidth2=[ui_labelWidth, ui_inputWidth], columnAttach=[1, 'right', 5] ): pm.text(label='Use Seed') self.ui_CHK_useSeed = pm.checkBox( 'ui_CHK_useSeed', value=True, label='', changeCommand=self.ui_refresh ) with pm.rowLayout( numberOfColumns=2, columnWidth2=[ui_labelWidth, ui_inputWidth], columnAttach=[1, 'right', 5] ): pm.text(label='Seed') pm.setUITemplate('DefaultTemplate', popTemplate=True) # strange slider group visual with default template self.ui_INTSLGRP_seedValue = pm.intSliderGrp( 'ui_INTSLGRP_seedValue', field=True, minValue=1, maxValue=10000, fieldMinValue=1, fieldMaxValue=10000, value=1234, step=1, fieldStep=1, sliderStep=1 ) pm.setUITemplate('DefaultTemplate', pushTemplate=True) # pm.setParent(self.ui_mainForm) self.ui_BTN_close = pm.button( label='Close', command=self.ui_close ) pm.setUITemplate('DefaultTemplate', popTemplate=True) self.ui_LAY_attachForm.attachForm(self.ui_TAB_inner, 'top', 0) self.ui_LAY_attachForm.attachForm(self.ui_TAB_inner, 'left', 0) self.ui_LAY_attachForm.attachForm(self.ui_TAB_inner, 'right', 0) self.ui_LAY_attachForm.attachForm(self.ui_TAB_inner, 'bottom', 0) self.ui_LAY_mainForm.attachForm(self.ui_TAB_top, 'top', 0) self.ui_LAY_mainForm.attachForm(self.ui_TAB_top, 'left', 0) self.ui_LAY_mainForm.attachForm(self.ui_TAB_top, 'right', 0) self.ui_LAY_mainForm.attachControl(self.ui_TAB_top, 'bottom', 5, self.ui_BTN_close) self.ui_LAY_mainForm.attachNone(self.ui_BTN_close, 'top') self.ui_LAY_mainForm.attachForm(self.ui_BTN_close, 'left', 5) self.ui_LAY_mainForm.attachForm(self.ui_BTN_close, 'bottom', 5) self.ui_LAY_mainForm.attachForm(self.ui_BTN_close, 'right', 5) self.prefSaver = prefsaver.PrefSaver(serializers.SerializerOptVar(OPT_VAR_NAME)) self.ui_initSettings() self.ui_loadSettings() self.window.show() pm.refresh()