def doStartMayaProgressBar(stepMaxValue=100, statusMessage='Calculating....', interruptableState=True): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Tools to do a maya progress bar. This function and doEndMayaProgressBar are a part of a set. Example usage: mayaMainProgressBar = guiFactory.doStartMayaProgressBar(int(number)) for n in range(int(number)): if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) : break mc.progressBar(mayaMainProgressBar, edit=True, status = (n), step=1) guiFactory.doEndMayaProgressBar(mayaMainProgressBar) ARGUMENTS: stepMaxValue(int) - max number of steps (defualt - 100) statusMessage(string) - starting status message interruptableState(bool) - is it interuptible or not (default - True) RETURNS: mayaMainProgressBar(string) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ mayaMainProgressBar = mel.eval('$tmp = $gMainProgressBar') mc.progressBar(mayaMainProgressBar, edit=True, beginProgress=True, isInterruptable=interruptableState, status=statusMessage, maxValue=stepMaxValue) return mayaMainProgressBar
def checkUpdates(self, gui, layout, *args): if self.tryUpdate(): if not G.GT_wasUpdated: hasUpdate = self.hasUpdate() if hasUpdate != False: cmds.iconTextButton(label="Updating...", style='textOnly', h=gui.hb, parent=layout) cmds.progressBar("aToolsProgressBar", maxValue=100, width=50, parent=layout) if hasUpdate == "offline_update": offlinePath = aToolsMod.loadInfoWithUser("userPrefs", "offlinePath") offlineFolder = offlinePath[0] offlineFilePath = "%s%saTools.zip"%(offlineFolder, os.sep) downloadUrl = "file:///%s%saTools.zip"%(offlineFolder, os.sep) fileModTime = os.path.getmtime(offlineFilePath) offline = [offlineFilePath, fileModTime] else: downloadUrl = DOWNLOAD_URL offline = None function = lambda *args:self.updateaTools(downloadUrl, offline) G.deferredManager.sendToQueue(function, 1, "checkUpdates") return self.warnUpdate()
def updateTemplate(i_customizationNetwork, **kws): assert i_customizationNetwork.mClass == 'cgmMorpheusMakerNetwork', "Not a customization Network" assert i_customizationNetwork.mPuppet.mClass == 'cgmMorpheusPuppet', "Puppet isn't there" d_customizationData = verify_customizationData(i_customizationNetwork) i_Morpheus = i_customizationNetwork.mPuppet if not d_customizationData: return False mayaMainProgressBar = gui.doStartMayaProgressBar(len(l_modulesToDoOrder)) for moduleKey in l_modulesToDoOrder: if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True): break mc.progressBar(mayaMainProgressBar, edit=True, status="Setting:'%s'..." % (moduleKey), step=1) i_module = i_Morpheus.getModuleFromDict(d_moduleCheck[moduleKey]) if not i_module: log.warning("Cannot find Module: '%s'" % moduleKey) return False log.debug("Building: '%s'" % moduleKey) i_module.doSize(sizeMode='manual', posList=d_customizationData.get(moduleKey)) i_module.doTemplate(tryTemplateUpdate=True, **kws) gui.doEndMayaProgressBar(mayaMainProgressBar) #Close out this progress bar
def progressStart(msg, max): cmds.progressBar(gMainProgressBar, e=True, bp=True, ii=True, st=msg, max=max)
def StartProgressBar(self, statusMessage, maximumValue): Cmds.progressBar(self.progressBar, edit=True, beginProgress=True, isInterruptable=True, status=statusMessage, maxValue=maximumValue)
def stretch_arm_l(): window = cmds.window(title='Creating...') cmds.columnLayout() progressControl = cmds.progressBar(maxValue=1, width=300) cmds.showWindow(window) #Stretch_Arm_L import stretch_arm_l reload(stretch_arm_l) stretch_arm_l.Stretch_Arm_L() cmds.progressBar(progressControl, edit=True, step=1) cmds.pause(sec=0) #Stretch_Arm_R import stretch_arm_r reload(stretch_arm_r) stretch_arm_r.Stretch_Arm_R() #Scale_Arms MDS = ['MD_Scale_MS_Arm_L', 'MD_Scale_MS_Arm_R'] for MD in MDS: Name = MD.split('MS_')[1] Mult(MD) Distancia = cmds.getAttr('distanceDimension_Stretch_Master_' + Name + '.distance') cmds.setAttr(Node + '.input2X', Distancia) Connect('C_mainA_ctl_0.scaleX', Node + '.input1X') Connect(Node + '.outputX', 'MD_Stretch_' + Name + '.input2X') Connect(Node + '.outputX', 'C_Stretch_' + Name + '.secondTerm') cmds.select(cl=True) cmds.progressBar(progressControl, edit=True, step=1) cmds.pause(sec=0) cmds.deleteUI(window, control=True)
def __enter__(self): if not self.disable: cmds.progressBar(self._gMainProgressBar, edit=True, beginProgress=True, isInterruptable=self._interruptable, maxValue=self._maxValue)
def walkParticlesProjection(camera, particles, step=1, start=None, end=None, pBar=None): if start is None: start = cmds.playbackOptions(q=True, minTime=True) if end is None: end = cmds.playbackOptions(q=True, maxTime=True) start = int(start) end = int(end) #pStep = 0 if pBar is None else int(100 / (end - start + 1)) pStep = 1 coords = None for frame in xrange(start, end + 1): #log("... FRAME %d ..." % frame) cmds.currentTime(frame) points = getParticlesProjection(camera, particles, step) pid = 0 if coords is None: coords = [None] * len(points) for point in points: if coords[pid] is None: coords[pid] = [None] * (end - start + 1) coords[pid][frame - start] = point pid += 1 if pBar: cmds.progressBar(pBar, e=1, s=pStep) return coords
def writeGeo(self, folder, progress = False, show_msg = True): part_num = len(self.parts) if progress: window = mc.window(t = 'Writing %s to geo' % self.name) mc.columnLayout() progressControl = mc.progressBar(maxValue = part_num * 2, width = 300) mc.showWindow(window) for part in self.parts: if not part.hasGeoDate: part.createGeoDate() part.updateGeoDate() if progress: mc.progressBar(progressControl, edit=True, step=1) for i in range(part_num): part = self.parts[i] part_obj_name = os.path.join(folder, '%s.geo' % part.partName()) # part_obj_name = os.path.join(folder, '%s.geo' % part.name(reformat = True)) part.writeGeo(part_obj_name) if progress: mc.progressBar(progressControl, edit=True, step=1) if progress: mc.deleteUI(window) if show_msg: print "Write %s to obj done." % self.name return True
def getInformation(): objectsInScene = mc.ls(shapes = True) progressWindow = mc.window(title = "Fetching objects...") mc.columnLayout() progressControl = mc.progressBar(maxValue = len(objectsInScene) - 1, width = 300) mc.showWindow(progressWindow) for objectInScene in objectsInScene: try: objectName = objectInScene # Vertex Count objectVertexCount = mc.polyEvaluate(objectInScene, v = True) #Triangle Count objectTriangleCount = mc.polyEvaluate(objectInScene, t = True) # Shading shadingEngine = mc.listConnections(objectInScene, type="shadingEngine") materials = mc.ls(mc.listConnections(shadingEngine),materials = True) except Exception as e: pass informationContainerList.append(informationContainer(objectName, objectVertexCount, objectTriangleCount, materials)) mc.progressBar(progressControl, edit = True, step= 1) mc.deleteUI(progressWindow)
def sequence_stepped(self, frame): # Refresh IPR self.IPRUpdate() # step progressBar gMainProgressBar = mel.eval('$tmp = $gMainProgressBar') cmds.progressBar(gMainProgressBar, edit=True, step=1)
def statusBarWindow(maxValue=None, text='', selfDelete=False, edit=False, step=1, **args): if selfDelete: cmds.deleteUI('Processing', wnd=True) else: if edit: cmds.progressBar('progressBar', e=edit, s=step) cmds.text('textProg', e=True, label=text) else: cmds.window('Processing', wh=[310, 45], sizeable=False) cmds.formLayout('formProgressBar', height=30, parent='Processing') cmds.progressBar('progressBar', maxValue=maxValue, s=step, width=300, parent='formProgressBar', **args) cmds.text('textProg', label=text, parent='formProgressBar') cmds.formLayout('formProgressBar', e=True, af=[('progressBar', 'top', 5), ('progressBar', 'left', 5), ('progressBar', 'right', 5), ('textProg', 'left', 10), ('textProg', 'bottom', 5), ('textProg', 'right', 10)]) cmds.showWindow('Processing')
def pythonScripts(): if cmds.menu("pythonScripts_menu", exists=True): # print ("Removing old pythonScripts menu...") cmds.deleteUI("pythonScripts_menu") gMainWindow = maya.mel.eval("$gMainWindow=$gMainWindow") gMainProgressBar = maya.mel.eval("$gMainProgressBar=$gMainProgressBar") mainDir = findFile("pythonScripts.py") timer = maya.mel.eval("timerX") cmds.waitCursor(state=True) # print "" cmds.progressBar( gMainProgressBar, edit=True, beginProgress=True, isInterruptable=True, status="Creating pythonScripts...", maxValue=100, ) pMenu = cmds.menu("pythonScripts_menu", parent=gMainWindow, tearOff=True, aob=True, label="pythonScripts") gen_pythonScripts(mainDir, pMenu) cmds.waitCursor(state=False) endTime = maya.mel.eval("timerX -st %(timer)s" % vars()) cmds.progressBar(gMainProgressBar, edit=True, endProgress=True)
def __exit__(self, exc_type, exc_value, traceback): if not self.disable: cmds.progressBar(self._gMainProgressBar, edit=True, endProgress=True) if exc_type: log.exception('%s : %s'%(exc_type, exc_value)) del(self) return False # False so that the exceptiopn gets re-raised
def hSewUvs(self, *args): nodes = mc.ls(sl=True) edges = mc.ls(mc.polyListComponentConversion(te=True), fl=True) a = [] b = [] for edge in edges: mc.select(edge) uvs = mc.ls(mc.polyListComponentConversion(tuv=True), fl=True) for uv in uvs: p = mc.polyEditUV(uv, query=True) a.append(p) if len(a) == 4: if a[0] == a[1] and a[2] == a[3]: b.append(edge) elif a[0] == a[2] and a[1] == a[3]: b.append(edge) elif a[0] == a[3] and a[1] == a[2]: b.append(edge) a = [] mc.progressBar(self.progress, edit=True, step=1, maxValue=len(edges)) mc.select(b) mc.SewUVs() mc.select(nodes)
def pythonScripts(): if (cmds.menu ('pythonScripts_menu', exists=True)): print ("Removing old pythonScripts menu...") cmds.deleteUI ('pythonScripts_menu') gMainWindow = maya.mel.eval('$temp1=$gMainWindow') gMainProgressBar = maya.mel.eval('$temp=$gMainProgressBar') mainDir = findFile('pythonScripts.py') timer = cmds.timerX() cmds.waitCursor (state=True) print "" cmds.progressBar (gMainProgressBar, edit=True, beginProgress=True, isInterruptable=True, status="Creating pythonScripts...", maxValue=100) pMenu = (cmds.menu ('pythonScripts_menu', parent=gMainWindow, tearOff=True, aob=True, label="pythonScripts")) gen_pythonScripts(mainDir, pMenu) cmds.waitCursor (state=False) endTime = cmds.timerX(startTime=timer) cmds.progressBar (gMainProgressBar, edit=True, endProgress=True,) print ("pythonTools has now been updated in: " + str(endTime) + " seconds...!")
def progressEnd(win, pc) : ''' end the progress ''' if win is None or pc is None : return m.progressBar( pc, e=True, ep=True) m.deleteUI(win)
def progressBar_start(): global __gMainProgressBar if __gMainProgressBar != "": cmds.progressBar(__gMainProgressBar, edit=True, beginProgress=True, step=1)
def InitWindow( self ): self._window = cmds.window( self.windowID, title = 'FBX Exporter', sizeable=False, resizeToFitChildren=True ) cmds.columnLayout() cmds.rowColumnLayout( numberOfColumns=3, columnWidth=[(1,self.Layout.CLWIDTH), (2,self.Layout.CLWIDTH), (3,self.Layout.CLWIDTH)], \ rowSpacing=[(1,self.Layout.SPACING), (2,self.Layout.SPACING), (3,self.Layout.SPACING)] ) cmds.text( label='Export current scene' ) cmds.separator(visible=False) cmds.separator(visible=False) cmds.button( 'Export All', width=self.Layout.BWIDTH, command=self.button_ExportAll_pressed ) cmds.button( 'Export Selected', width=self.Layout.BWIDTH, command=self.button_ExportSelected_pressed ) cmds.button( 'Open Current Scene', width=self.Layout.BWIDTH, command=self.button_OpenCurrentScene_pressed ) cmds.text( label='Batch export' ) cmds.separator(visible=False) cmds.separator(visible=False) cmds.button( 'Add Folder', width=self.Layout.BWIDTH, command=self.button_AddFolder_pressed ) cmds.button( 'Export All Files', width=self.Layout.BWIDTH, command=self.button_ExportAllFiles_pressed ) cmds.button( 'Delete Selected', width=self.Layout.BWIDTH, command=self.button_DeleteSelected_pressed ) cmds.separator() cmds.separator() cmds.separator() cmds.setParent( '..' ) cmds.rowColumnLayout( numberOfColumns=1, columnWidth=(1,3*self.Layout.CLWIDTH) ) cmds.progressBar('ProgressBar', width=3*self.Layout.BWIDTH ) cmds.textScrollList( 'scrollList', allowMultiSelection=False) cmds.setParent( '..' ) cmds.rowColumnLayout( numberOfColumns=3, columnWidth=[(1,self.Layout.CLWIDTH), (2,self.Layout.CLWIDTH), (3,self.Layout.CLWIDTH)], \ rowSpacing=[(1,self.Layout.SPACING), (2,self.Layout.SPACING), (3,self.Layout.SPACING)] ) cmds.separator() cmds.separator() cmds.separator() cmds.separator(visible=False) cmds.separator(visible=False) cmds.button( 'Close', width=self.Layout.BWIDTH, command=self.button_Close_pressed )
def doStartMayaProgressBar(stepMaxValue = 100, statusMessage = 'Calculating....',interruptableState = True): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Tools to do a maya progress bar. This function and doEndMayaProgressBar are a part of a set. Example usage: mayaMainProgressBar = guiFactory.doStartMayaProgressBar(int(number)) for n in range(int(number)): if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) : break mc.progressBar(mayaMainProgressBar, edit=True, status = (n), step=1) guiFactory.doEndMayaProgressBar(mayaMainProgressBar) ARGUMENTS: stepMaxValue(int) - max number of steps (defualt - 100) statusMessage(string) - starting status message interruptableState(bool) - is it interuptible or not (default - True) RETURNS: mayaMainProgressBar(string) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ mayaMainProgressBar = mel.eval('$tmp = $gMainProgressBar'); mc.progressBar(mayaMainProgressBar, edit=True, endProgress=True) mc.progressBar( mayaMainProgressBar, edit=True, beginProgress=True, isInterruptable=interruptableState, status=statusMessage, minValue = 0, maxValue= stepMaxValue ) return mayaMainProgressBar
def epb_run(self): """ Run our "Extreme Progressbar window" :return: """ # If it does not equal the end if self.cur != self.end: cm.progressBar("extremePBandJ", e=1, pr=self.cur) # Update the information _elapsed = round(time() - self.start_time, 3) _estleft = float( (self.cur + 0.0) / ((self.end + 0.0) - (self.start + 0.0))) cm.text("timeleft", e=1, label="\tTime Left : {}\t|\t".format(_estleft)) cm.text("elapsed", e=1, label="Elapsed : {}\t|\t".format(_elapsed)) cm.text("numleft", e=1, label="Completed : {}/{}".format(self.cur + 1, self.end)) else: # We have reached the end, so run the end script ExtremeProgressBar().epb_end()
def percentage(consumed_bytes, total_bytes): id = files_dict[path_temp]["id"] if total_bytes: rate = int(100 * (float(consumed_bytes) / float(total_bytes))) cmds.progressBar(eval('control_progress_' + str(id)), edit=True, pr=rate)
def writeObj(self, file_name, progress = False, show_msg = True, scale = mcore.scene_scale()): all_parts = self.parts() part_num = len(all_parts) if progress: window = mc.window(t = 'Writing %s to obj' % self.set_name) mc.columnLayout() progressControl = mc.progressBar(maxValue = part_num, width = 300) mc.showWindow(window) f = open(file_name, 'w') vo = 1 vto = 1 vno = 1 for i in range(len(all_parts)): part = all_parts[i] # part.toObjStream(f, group = part.name(reformat = True), v_offset = vo, vt_offset = vto, vn_offset = vno, show_msg = not progress) part.toObjStream(f, group = part.partName(), v_offset = vo, vt_offset = vto, vn_offset = vno, show_msg = not progress, scale = scale) vo += part.numPoints() vto += part.numUVs() vno += part.numNormals() if progress: mc.progressBar(progressControl, edit=True, step=1) f.close() if progress: mc.deleteUI(window) if show_msg: print "Write %s to obj done." % self.set_name return True
def updateTemplate(i_customizationNetwork,**kws): assert i_customizationNetwork.mClass == 'cgmMorpheusMakerNetwork', "Not a customization Network" assert i_customizationNetwork.mPuppet.mClass == 'cgmMorpheusPuppet',"Puppet isn't there" d_customizationData = verify_customizationData(i_customizationNetwork) i_Morpheus = i_customizationNetwork.mPuppet if not d_customizationData: return False mayaMainProgressBar = gui.doStartMayaProgressBar(len(l_modulesToDoOrder)) for moduleKey in l_modulesToDoOrder: if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) : break mc.progressBar(mayaMainProgressBar, edit=True, status = "Setting:'%s'..."%(moduleKey), step=1) i_module = i_Morpheus.getModuleFromDict(d_moduleCheck[moduleKey]) if not i_module: log.warning("Cannot find Module: '%s'"%moduleKey) return False log.debug("Building: '%s'"%moduleKey) i_module.doSize(sizeMode = 'manual', posList = d_customizationData.get(moduleKey)) i_module.doTemplate(tryTemplateUpdate = True, **kws) gui.doEndMayaProgressBar(mayaMainProgressBar)#Close out this progress bar
def create_animation(self, start, end, step): # how many times there is an extrusion maxVal = ((end-start)/step)*self.perIter # init progress bar if (cmds.window("bar" , exists=True)): cmds.deleteUI("bar") bar = cmds.window("bar", t="Creating Animation", width=600) cmds.columnLayout() progressControl = cmds.progressBar(maxValue=maxVal, width=600) progress= 1 cmds.showWindow( bar ) # the number of times there has been an extrusion numExt = 1 # iterate over all frames specified for i in xrange(start, end, step): # run procedure as specified by perIter for j in xrange(self.perIter): duration = random.randint(self.minDuration, self.maxDuration) self.set_key_extrusion(i, i+duration, numExt) # get the newly created faces after extruding self.recollect_faces() numExt += 1 progress += 1 cmds.progressBar(progressControl, edit=True, pr=progress) cmds.deleteUI("bar")
def main(selection, *args): print "COMPUTING FRAMES..." id = 0 for item in selection: #Progress bar cmds.separator(height=10, style="none") cmds.separator(height=10, style="none") cmds.text(label="") progressControl = cmds.progressBar(h=25, width=385, max=len(selection)) cmds.separator(height=10, style="none") cmds.separator(height=10, style="none") cmds.progressBar(progressControl, edit=True, step=1) copyUVSet(item) modifyUVs(item, id) print str(id + 1) + "/" + str(len(selection)) + " PROCESSED" id += 1 print "COMBINGING MESHES..." cmds.select(selection) cmds.polyUnite(muv=True) cmds.progressBar(progressControl, edit=True, step=1) cmds.DeleteHistory() print "FINSIHED"
def update_button(bucket): global files_dict update_list = [] for f in files_dict.keys(): if files_dict[f]["update"] == "N": update_list.append(f) for i in update_list: oss_path_temp = files_dict[i]["oss_path"] path_temp = i def percentage(consumed_bytes, total_bytes): id = files_dict[path_temp]["id"] if total_bytes: rate = int(100 * (float(consumed_bytes) / float(total_bytes))) cmds.progressBar(eval('control_progress_' + str(id)), edit=True, pr=rate) result = bucket.put_object_from_file(oss_path_temp, path_temp, progress_callback=percentage) if result.status == 200: temp_id = str(files_dict[path_temp]["id"]) cmds.text(eval('control_status_' + temp_id), edit=True, ebg=True, bgc=[0.0, 1.0, 0.0], l="Y") id = files_dict[path_temp]["id"] cmds.progressBar(eval('control_progress_' + str(id)), edit=True, pr=100)
def AlgorithmhUi(x, y): """ Algorithmus Windows zum erstellen der Animation :param x: Die Reihe im Regal :param y: Die Spalte im Regal """ winID = "AlgorithmUI" if cmds.window(winID, exists=True): cmds.deleteUI(winID) # Create the window algorithmWindow = cmds.window("AlgorithmUI", title="Animation erzeugen", h=200, w=400, sizeable=False) # Layout erstellen mainLayout = cmds.columnLayout(w=400, h=200) # TODO: Inhalt fuellen cmds.separator(style='none', height=25) # Laying out the rowColumnLayout table1 = cmds.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 10), (2, 380), (3, 10)]) cmds.separator(style='none', width=10) maxvalue = 4 progressControl = cmds.progressBar(maxValue=maxvalue, width=380) cmds.separator(style='none', width=10) cmds.setParent('..') # To see Progress in % on ProgressBar cmds.progressBar(progressControl, edit=True, step=1) cmds.separator(style='none', width=50, height=15) # TODO: Fill code, change with actual Code table3 = cmds.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 100), (2, 200), (3, 100)]) cmds.separator(style='none', width=10) def test(*_): for i in range(1, maxvalue + 1): if (i == 1): cmds.progressBar(progressControl, edit=True, step=1) printAlgorithmAnimation(1) elif (i == 2): cmds.progressBar(progressControl, edit=True, step=1) printAlgorithmAnimation(2) elif (i == 3): cmds.progressBar(progressControl, edit=True, step=1) printAlgorithmAnimation(3) elif (i == 4): cmds.progressBar(progressControl, edit=True, step=1) printAlgorithmAnimation(4) cmds.button(label='Starte Algorithmus', command=test, width=200) cmds.separator(style='none', width=10) cmds.setParent('..') cmds.showWindow(winID)
def remoteMayaUI(*args): if MC.window("remoteMayaUI_WIN", ex=1): MC.deleteUI("remoteMayaUI_WIN") MC.window("remoteMayaUI_WIN", t="REMOTE MAYA", tlb=1, s=0, mb=0) MC.columnLayout() MC.rowLayout("HOLDER", nc=4, enable=1) 0; MC.text(label=" Episode") 0; MC.optionMenu("EPISODES_OPTIONMENU", changeCommand=refreshShotList) 0; MC.text("SHOT_TEXT", label=" Shot", enable=0) 0; MC.optionMenu("SHOTS_OPTIONMENU", changeCommand="pass", enable=0) MC.menuItem(label="", p="SHOTS_OPTIONMENU", enable=0) episodePath = "Y:/01_SAISON_4/09_EPISODES/03_Fabrication_2D/" episodeList = [x for x in os.listdir(episodePath) if len(x) >= 3 and x[:3] == "YKR"] 0; MC.setParent("..") MC.menuItem("VOID", label="...", p="EPISODES_OPTIONMENU") for episode in episodeList: MC.menuItem(label=episode, p="EPISODES_OPTIONMENU") MC.rowLayout(nc=2) 0; MC.text(l="", w=68) 0; QtButton(handle="INSPECT", label="INSPECT", action=inspectShot, lineColor=(100,240,100), background=(60,120,60), borderRadius=14, paddingTBLR=(0,0,0,0), margin=0, w=120, h=30, fontFamily="Arial", fontSize=16, fontWeight="bold") MC.setParent("..") MC.textField("COMMAND_TEXTFIELD", text = "", changeCommand=mayaClient.manualCommand) MC.scrollField("PNG_UNIVERSAL_LOG", h=430, font="plainLabelFont", editable=False, wordWrap=True, text="Ready...\n", bgc=(.2,.2,.2)) MC.progressBar("PNG_PROGRESS_BAR", h=16, w=260, manage=0) MC.showWindow("remoteMayaUI_WIN") MC.window("remoteMayaUI_WIN", edit=True, w=600, h=300)
def _create_tree(self,obj_list='',tx=0,ty=0,tz=0,rx=10,ry=10,rz=10,sx=0,sy=0,sz=0,*args): cmds.progressBar(self.progress,e=1,step=0,vis=1) cmds.textScrollList(self.new_obj_list,e=1,ra=1) grp_obj_list = [] dup_obj_str = [] pp = pmel.PyNode('emittedParticlesShape') priticle_id = range(len(pp.particleIds())) sel_obj = obj_list if sel_obj: for p in priticle_id: rand_tx = random.uniform(-tx,tx) rand_ty = random.uniform(-ty,ty) rand_tz = random.uniform(-tz,tz) rand_rx = random.uniform(-rx,rx) rand_ry = random.uniform(-ry,ry) rand_rz = random.uniform(-rz,rz) rand_sx = random.uniform(0,sx) rand_sy = random.uniform(0,sy) rand_sz = random.uniform(0,sz) random_sel_obj = random.randint(0,len(sel_obj)-1) priticle_trans = pmel.getParticleAttr(n_particle_create[0].pt[p],a=1,at='position') obj = pmel.duplicate(sel_obj[random_sel_obj]) grp_obj_list.append(obj) pmel.xform(obj,t=priticle_trans) tx_get = obj[0].tx.get() ty_get = obj[0].ty.get() tz_get = obj[0].tz.get() rx_get = obj[0].rx.get() ry_get = obj[0].ry.get() rz_get = obj[0].rz.get() sx_get = obj[0].sx.get() sy_get = obj[0].sy.get() sz_get = obj[0].sz.get() obj[0].tx.set(tx_get+rand_tx) obj[0].ty.set(ty_get+rand_ty) obj[0].tz.set(tz_get+rand_tz) obj[0].rx.set(rx_get+rand_rx) obj[0].ry.set(ry_get+rand_ry) obj[0].rz.set(rz_get+rand_rz) obj[0].sx.set(sx_get+rand_sx) obj[0].sy.set(sy_get+rand_sy) obj[0].sz.set(sz_get+rand_sz) dup_obj_str.append(str(obj[0])) cmds.textScrollList(self.new_obj_list,e=1,a=str(obj[0]),si=str(obj[0])) cmds.progressBar(self.progress,maxValue=len(priticle_id)-1,e=1,step=1) cmds.refresh() return grp_obj_list
def progressBar_init(_max): global __gMainProgressBar try: __gMainProgressBar = mel.eval('$tmp = $gMainProgressBar') if __gMainProgressBar != "": cmds.progressBar(__gMainProgressBar, edit=True, isInterruptable=True, maxValue=_max) except: __gMainProgressBar = ""
def progressBar_set(self,**kws): if not self._str_progressBar:self.progressBar_start() if kws.get('status'): str_bfr = kws.get('status') kws['status'] = "%s > %s"%(self._str_progressBarReportStart,str_bfr) if 'beginProgress' not in kws.keys():kws['beginProgress'] = 1 try:mc.progressBar(self._str_progressBar,edit = True,**kws) except Exception,error:log.error("%s > failed to set progress bar status | %s"%(self._str_reportStart,error))
def setText(self, text): if not self.disable: if self.ismain: cmds.progressBar(self._gMainProgressBar, edit=True, status=text) else: cmds.progressWindow(edit=True, status=text)
def progressInc(pc) : ''' update the progress ''' if pc is None : return if m.progressBar( pc, q=True, isCancelled=True) : return False; m.progressBar(pc, e=True, step=1) return True
def endProgressBar(self): if self.gMainProgressBar: from maya.app.renderSetup.model.renderLayerSwitchObservable import RenderLayerSwitchObservable RenderLayerSwitchObservable.getInstance( ).removeRenderLayerSwitchObserver(self.stepProgressBar) cmds.progressBar(self.gMainProgressBar, edit=True, endProgress=True)
def setProgress(self, value): if not self.disable: if self.ismain: cmds.progressBar(self._gMainProgressBar, edit=True, progress=int(value)) else: cmds.progressWindow(edit=True, progress=int(value))
def export(self, path, start, end, step, scale): #open file res = True try: mddFile = open(path, 'wb') except IOError: self.par.msg2(1, 'Error open file ' + path) return False #get objects selection = om.MSelectionList() om.MGlobal.getActiveSelectionList(selection) pivotFilterSelection = self.filterObjects(selection) #first frame cmds.currentTime(start, edit=True) vertexPositionList = self.getPoints(selection, scale, pivotFilterSelection) #variables fps = float(mel.eval('currentTimeUnitToFPS')) self.par.msg2(2, 'FPS:', fps) numframes = int((end - start + 1)/step) numverts = len(vertexPositionList)/3 self.pointCount = numverts print 'Frames', numframes print 'Point count', numverts #start write to file mddFile.write(struct.pack(">2i", numframes, numverts)) times = [(frame/fps)*step for frame in xrange(numframes)] # print times mddFile.write(struct.pack(">%df" % numframes, *times)) mddFile.write(struct.pack(">%df" % (numverts*3), *[v for v in vertexPositionList])) prev = 0 #write sequence cmds.progressBar(self.par.progress, edit=True, pr=0) frame = start while frame < end+1: # if cmds.progressBar(self.par.progress, q=1, ic=1): if self.par.isCacneled(): self.par.caselExport() res = False break rng = end-start prc = (frame*100.0)/(end-start) cmds.progressBar(self.par.progress, edit=True, pr=int(prc)) prev = int(prc) cmds.currentTime(frame, edit=True) self.par.statusMsg('Write cache frame '+str(frame)) vertexPositionList = self.getPoints(selection, scale, pivotFilterSelection) if not (numverts*3) == len(vertexPositionList): om.MGlobal.displayError('TOPOLOGY HAS CHANGED!!!') self.par.msg2(1, 'TOPOLOGY HAS CHANGED!!!') res = False break mddFile.write(struct.pack(">%df" % (numverts*3), *[v for v in vertexPositionList])) frame += step #close file mddFile.close() cmds.currentTime(start, edit=True) return res
def utilityCreateProgress(status="", maximum=0): instance = mel.eval("$tmp = $gMainProgressBar") cmds.progressBar(instance, edit=True, beginProgress=True, isInterruptable=False, status=status, maxValue=max(1, maximum)) return instance
def sequence_stopped(self): # Stop ipr when finished self.stop() # Restore default progressive refinement cmds.setAttr("defaultArnoldRenderOptions.progressive_rendering", self.defaultRefinement) # kill progressBar cmds.progressBar(self.gMainProgressBar, edit=True, endProgress=True)
def makeProgBar(length): global gMainProgressBar gMainProgressBar = mel.eval('$tmp = $gMainProgressBar') cmds.progressBar(gMainProgressBar, edit=True, beginProgress=True, isInterruptable=True, minValue=0, maxValue=abs(length))
def progressBar_iter(self,**kws): if not self._str_progressBar:self.progressBar_start() if kws.get('status'): str_bfr = kws.get('status') kws['status'] = "%s > %s"%(self._str_progressBarReportStart,str_bfr) if 'step' not in kws.keys():kws['step'] = 1 if 'beginProgress' not in kws.keys():kws['beginProgress'] = 1 kws['edit'] = 1 mc.progressBar(self._str_progressBar, **kws)
def _hide_progress_bar(): """ Hides the progress bar. """ # Hide the main progress bar (normally in the Help Line). cmds.progressBar(_get_main_progress_bar_name(), edit=True, endProgress=True)
def mainQP(self, *args): sum = self.numOfSKItem() self.core.progressBarWin( sum ) for item in self.core.qpCharacter: mc.progressBar(self.core.progressControl, edit=True, step=1.0) newItem = item.replace( 'QP', 'SK' ) reNode = mc.referenceQuery( newItem, referenceNode=True) mm.eval( 'proxySwitch "%s";'%reNode ) self.core.close()
def show_window(): global progressControl global current_obj global radio_col UV_window = cmds.window(title="Maya Checker Size Tool", iconName='Short Name', rtf=1, s=1, widthHeight=(300, 100), mxb=0) if cmds.window(UV_window, ex=True): cmds.deleteUI(UV_window, window=True) UV_window = cmds.window(title="Maya Checker Size Tool", iconName='Short Name', rtf=1, s=1, widthHeight=(300, 100), mxb=0) cmds.columnLayout(adjustableColumn=True) cmds.frameLayout(label="Get Size", w=30, h=80, mh=5, mw=5, bs="etchedOut") cmds.columnLayout(adjustableColumn=True) UV_get_but = cmds.button(label='Pick Checker Size', en=True, annotation='Store the checker size', command='get_sel_faces_UV_ratio(1)') current_obj = cmds.text(w=175, l='', al='center') cmds.setParent('..') cmds.setParent('..') cmds.frameLayout(label="Set Size", w=30, h=110, mh=5, mw=5, bs="etchedOut") cmds.columnLayout(adjustableColumn=True) UV_set_but = cmds.button( label='Set Checker Size of object(s)', en=True, annotation='Change checker size of one or more meshes', command='set_UV_ratio(1)') UV_shell_but = cmds.button( label='Set Checker Size of shells (Single object)', en=True, annotation='Change checker size of object with several shells', command='set_shell_button()') cmds.rowLayout(numberOfColumns=2, columnWidth2=(100, 100)) radio_col = cmds.radioCollection() cmds.radioButton('radio_Face', label='Face shells', al='left') cmds.radioButton('radio_UV', label='UV shells', al='left') cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') cmds.columnLayout(adjustableColumn=True) progressControl = cmds.progressBar(maxValue=20, width=300) cmds.progressBar(progressControl, edit=True, visible=False) cmds.text(w=175, l='[email protected] ', al='right') cmds.setParent('..') cmds.setParent('..') cmds.showWindow(UV_window)
def docancel(): global gMainProgressBar, useAmbient, allLights, amb, disableUndos if disableUndos: cmds.undoInfo(state=True) if useAmbient: cmds.delete(cmds.listRelatives(amb, parent=True)[0]) if allLights != None and len(allLights) > 0: cmds.sets(allLights, add="defaultLightSet") print "Voxelizer cancelled at frame %s."%cmds.currentTime(q=True) cmds.progressBar(gMainProgressBar, edit=True, endProgress=True) return 0
def init(status, maxValue): """ Initialize Progress Bar """ # Check Interactive Session if OpenMaya.MGlobal.mayaState(): return # Initialize Progress Bar gMainProgressBar = mel.eval('$tmp = $gMainProgressBar') cmds.progressBar(gMainProgressBar, e=True, bp=True, ii=True, status=status, maxValue=maxValue)
def creatCharacterGeoCacheSelect(self, *args): sum = self.selectCharacter() count = len(sum) self.core.progressBarWin( count ) for j in sum: mc.progressBar(self.core.progressControl, edit=True, step=1.0) if self.doCreateCharacterGeoCache(int(j)) == 'Failed export:': continue self.failExport.append(self.core.skCacheListName[int(j)-1]) self.core.close()
def run(self): # cmds.waitCursor(status=1) cmds.progressBar(self._progress_bar, e=1, bp=1, ii=self._interruptable, status=self._status, min=self._start, max=self._end) cmds.refresh()
def creatPropGeoCacheSelect(self, *args): num = self.selectProp() count = len(num) try: self.core.progressBarWin( count ) for i in num: mc.progressBar(self.core.progressControl, edit=True, step=1.0) self.doCreateGeoCache(int(i)) self.core.close() except:pass
def creatCharacterGeoCacheSelect(self, *args): sum = self.selectCharacter() count = len(sum) try: self.core.progressBarWin( count ) for j in sum: mc.progressBar(self.core.progressControl, edit=True, step=1.0) self.doCreateCharacterGeoCache(int(j)) self.core.close() except:pass
def cleanDeformers(eightThreshold=0.001,showProgress=False): ''' Cleaning all deformers Prune small weights and membership ''' print('# Clean Rig: Cleaning Deformers (prune weights and membership)') # Start Timer timer = mc.timerX() deformerList = glTools.utils.deformer.getDeformerList(nodeType='weightGeometryFilter') if showProgress and interactive: mc.progressBar( gMainProgressBar,e=True,bp=True,ii=True,status=('Cleaning Deformers...'),maxValue=len(deformerList) ) # For Each Deformer for deformer in deformerList: # Clean Deformers try: glTools.utils.deformer.clean(deformer,threshold=weightThreshold) except: print('# Clean Rig: XXXXXXXXX ======== Unable to clean deformer "'+deformer+'"! ======== XXXXXXXXX') # Update Progress Bar if showProgress and interactive: if mc.progressBar(gMainProgressBar,q=True,isCancelled=True): mc.progressBar(gMainProgressBar,e=True,endProgress=True) raise UserInterupted('Operation cancelled by user!') mc.progressBar(gMainProgressBar,e=True,step=1) if showProgress and interactive: mc.progressBar(gMainProgressBar,e=True,endProgress=True) # Print Timed Result print('# Clean Rig: Clean Deformers - '+str(mc.timerX(st=timer)))
def cleanSkinClusters(showProgress=False): """ @param showProgress: """ # Start Timer timer = cmds.timerX() # Clean SkinClusters skinClusterList = cmds.ls(type='skinCluster') if showProgress and interactive: cmds.progressBar(gMainProgressBar, e=True, bp=True, ii=True, status=('Cleaning SkinClusters...'), maxValue=len(skinClusterList)) for skinCluster in skinClusterList: try: glTools.utils.skinCluster.clean(skinCluster, tolerance=0.001) except: print( '# Clean Rig: XXXXXXXXX ======== Unable to clean skinCluster "' + skinCluster + '"! ======== XXXXXXXXX') # Update Progress Bar if showProgress and interactive: if cmds.progressBar(gMainProgressBar, q=True, isCancelled=True): cmds.progressBar(gMainProgressBar, e=True, endProgress=True) raise UserInterupted('Operation cancelled by user!') cmds.progressBar(gMainProgressBar, e=True, step=1) if showProgress and interactive: cmds.progressBar(gMainProgressBar, e=True, endProgress=True) # Print Timed Result print('# Clean Rig: Clean SkinClusters - ' + str(cmds.timerX(st=timer)))
def renderAllLights(self, renderLights=[],useGroups=False): lights = cmds.ls(dag=True,visible=True,lights=True, type='mentalrayIblShape') #Check if there is any lights selected to only do those if renderLights == [] or renderLights == None: renderLights = cmds.ls( dag=True, sl=True , lights=True, type='mentalrayIblShape') #if there isn't any light selected just get all the lights if renderLights == []: renderLights = lights lightNames = "" for light in renderLights: lightNames = lightNames + light + '\n' windowName = 'ProgressWindow' if cmds.window(windowName, exists=True): cmds.deleteUI(windowName) window = cmds.window(windowName,t="Progress Report") cmds.columnLayout() cmds.iconTextStaticLabel( st='textOnly', l='Rendering Lights:' ) cmds.iconTextStaticLabel( st='textOnly', l=lightNames ) cmds.iconTextStaticLabel( st='textOnly', l='Process Bar' ) progressControl = cmds.progressBar(maxValue=len(renderLights), width=300) cmds.showWindow( window ) lights = self.sortLightsByType(lights) #-Revised--hide ibl node that is at the end of lights list (sorted previously) if cmds.objectType( lights[-1], isType='mentalrayIblShape' ) == True: cmds.setAttr('%s.visibleInFinalGather' % lights[-1], 0) cmds.setAttr('%s.visibleInEnvironment' % lights[-1], 0) cmds.hide(lights) lightCount = 0 if useGroups==True: renderLightsGroups = self.groupLightsByName(renderLights) cmds.progressBar(progressControl,edit=True, maxValue=len(renderLightsGroups.keys()), width=300) for group in renderLightsGroups: self.renderOnlyThisLight(renderLightsGroups[group]) progressInc = cmds.progressBar(progressControl, edit=True, pr=lightCount+1) lightCount+=1 else: print renderLights for light in renderLights: self.renderOnlyThisLight(light) progressInc = cmds.progressBar(progressControl, edit=True, pr=lightCount+1) lightCount+=1 cmds.showHidden(lights) #-Revised--since we sorted the lights by type we know that the lastone will be the IBL if cmds.objectType( lights[-1], isType='mentalrayIblShape' ) == True: cmds.setAttr('%s.visibleInFinalGather' % lights[-1], 1) cmds.setAttr('%s.visibleInEnvironment' % lights[-1], 1)