def rtb_shrink_wrap_verts(highresListDropdown, *args, **kwargs): ''' ''' global defaultString high = highresListDropdown.getValue() if not high == defaultString: pm.undoInfo(openChunk=True) live = pm.PyNode(high.replace('_high', '_live')) liveShape = live.getShape() sel = pm.ls(sl=True) if sel: verts = geometry.getVertsFromSelection(sel) if verts and verts[0].nodeType() == 'mesh': try: geometry.shrinkWrap(verts, liveShape, prefix + '_progress_control') except: pm.warning('You Should Not See This Error!') pm.progressBar(prefix + '_progress_control', edit=True, endProgress=True) else: pm.warning('No verts to shrink wrap!') pm.select(sel, r=True) pm.hilite(pm.PyNode(sel[0].split('.')[0]).getParent(), r=True) type = geometry.getMeshSelectionType(sel) geometry.switchSelectType(type) pm.undoInfo(closeChunk=True) else: pm.warning('Select a mesh from the dropdown list')
def execute_queue(self): """ Executes all items in the queue, one by one, in a controlled fashion """ self.log_warning("The Engine Queue is now deprecated! Please contact [email protected]") self._maya_progress_bar = maya.mel.eval('$tmp = $gMainProgressBar') # execute one after the other syncronously while len(self._queue) > 0: # take one item off current_queue_item = self._queue[0] self._queue = self._queue[1:] # set up the progress bar pm.progressBar( self._maya_progress_bar, edit=True, beginProgress=True, isInterruptable=False, status=current_queue_item["name"] ) self._current_progress = 0 # process it try: kwargs = current_queue_item["args"] # force add a progress_callback arg - this is by convention kwargs["progress_callback"] = self.report_progress # execute current_queue_item["method"](**kwargs) except: # error and continue # todo: may want to abort here - or clear the queue? not sure. self.log_exception("Error while processing callback %s" % current_queue_item) finally: pm.progressBar(self._maya_progress_bar, edit=True, endProgress=True)
def update_ordered_index(): ''' Update the MetaNode graph to ensure all objects are the latest version ''' try: update_list = [ x for x in pm.ls(type='network') if 'ControlProperty' in x.meta_type.get() and not x.hasAttr('ordered_index') ] main_progress_bar = pm.mel.eval('$tmp = $gMainProgressBar') pm.progressBar(main_progress_bar, edit=True, beginProgress=True, isInterruptable=True, status='Updating Network...', maxValue=len(update_list)) for property_node in update_list: pm.addAttr(property_node, ln='ordered_index', at='short') for property_node in update_list: pm.progressBar(main_progress_bar, edit=True, step=1) control = get_first_or_default( property_node.message.listConnections()) component_network = metadata.network_core.MetaNode.get_first_network_entry( control, metadata.network_core.ComponentCore) if component_network: component = rigging.rig_base.Component_Base.create_from_network_node( component_network.node) component.set_control_orders() except Exception, e: raise e
def preRenderProcedure(self): self.createGlobalsNode() if self.renderGlobalsNode.threads.get() == 0: # TODO this is windows only, search for another solution... numThreads = int(os.environ['NUMBER_OF_PROCESSORS']) # Let's reduce the number of threads to stay as interactive as possible. if self.ipr_isrunning: if numThreads > 4: numThreads = numThreads - 1 self.renderGlobalsNode.threads.set(numThreads) if self.renderGlobalsNode.useOptimizedTextures.get(): if not self.renderGlobalsNode.optimizedTexturePath.get(): try: optimizedPath = pm.workspace.path / pm.workspace.fileRules['renderData'] / "optimizedTextures" except: optimizedPath = path.path(tempfile.gettempdir()) / "optimizedTextures" if not os.path.exists(optimizedPath): optimizedPath.makedirs() self.renderGlobalsNode.optimizedTexturePath.set(str(optimizedPath)) optimizetextures.preRenderOptimizeTextures(optimizedFilePath=self.renderGlobalsNode.optimizedTexturePath.get()) if not self.ipr_isrunning: self.gMainProgressBar = pm.mel.eval('$tmp = $gMainProgressBar') pm.progressBar(self.gMainProgressBar, edit=True, beginProgress=True, isInterruptable=True, status='"Render progress:', maxValue=100)
def rtb_shrink_wrap_verts(highresListDropdown, *args, **kwargs): ''' ''' global defaultString high = highresListDropdown.getValue() if not high == defaultString: pm.undoInfo(openChunk=True) live = pm.PyNode(high.replace('_high', '_live')) liveShape = live.getShape() sel = pm.ls(sl=True) if sel: verts = geometry.getVertsFromSelection(sel) if verts and verts[0].nodeType() == 'mesh': try: geometry.shrinkWrap(verts, liveShape, prefix+'_progress_control') except: pm.warning('You Should Not See This Error!') pm.progressBar(prefix+'_progress_control', edit=True, endProgress=True) else: pm.warning('No verts to shrink wrap!') pm.select(sel, r=True) pm.hilite(pm.PyNode(sel[0].split('.')[0]).getParent(), r=True) type = geometry.getMeshSelectionType(sel) geometry.switchSelectType(type) pm.undoInfo(closeChunk=True) else: pm.warning('Select a mesh from the dropdown list')
def makeProgressBarWindow(self): self.window = pm.window(title=self.title, sizeable=False) pm.columnLayout() self.progressControls.append( pm.progressBar(maxValue=self.steps, width=300) ) self.progressControls.append( pm.progressBar(maxValue=self.steps, width=300) ) self.progressControls.append( pm.progressBar(maxValue=self.steps, width=300) ) pm.showWindow( self.window ) return [self.progressControls[0], self.progressControls[1], self.progressControls[2], self.window]
def report_progress(self, percent): """ Callback function part of the engine queue. This is being passed into the methods that are executing in the queue so that they can report progress back if they like """ # convert to delta value before passing to maya delta = percent - self._current_progress pm.progressBar(self._maya_progress_bar, edit=True, step=delta) self._current_progress = percent
def _update_export_progress_bar(start_frame, end_frame, frame_index): """ """ frame_range = end_frame - start_frame if (frame_range == 0): step = 0 else: export_bar_range = 100 step = ((frame_index - start_frame) * export_bar_range) / frame_range pm.progressBar('pb_exportProgress', edit=True, progress=int(step))
def vtxSearchProgress(self , vtxStart): vtxPrev = [vtxStart] while True: vtxNext = (self.getOverVertices(vtxPrev) - set(self.vtxDict)) if not vtxNext: return vtxPrev = vtxNext for v in vtxPrev: self.progress_current += self.progress_step pm.progressBar('progress' , edit=True , progress=round(self.progress_current))
def setMaxAmount(self, value): # chnage setting according to the new maxAmount if self._type == 1: self._maxAmount = value pmc.progressBar(self.gMainProgressBar, edit=True, maxValue=self._maxAmount) elif self._type == 2: self._maxAmount = value+1 self.ui['pgb'].setMaxValue(self._maxAmount) if self._amount >= self._maxAmount: self.terminate()
def vrayConvertToTiledEXR(): ''' Take all images that are NOT exr files and convert them to tiled exr files ''' # setup a window window = pm.window() pm.columnLayout() mayaVersion = re.search( '[0-9]+', re.search('maya[0-9]+', sys.argv[0].lower()).group(0)).group( 0) # look for the 2012 or 2013 etc in path name pathToVRayTools = os.path.normpath(os.environ[ 'VRAY_TOOLS_MAYA%s_x64' % (mayaVersion)]) # make sure we have the right vray tools path allFileNodes = cmds.ls(type='file') # look for file nodes progressControl = pm.progressBar( maxValue=len(allFileNodes) - 1, width=300) # make sure window is prepped for size if platform.system() == 'Windows': execFile = '"%s/img2tiledexr.exe"' % ( pathToVRayTools ) # needs quotes in case there are spaces in filename else: execFile = '"%s/img2tiledexr"' % ( pathToVRayTools ) # needs quotes in case there are spaces in filename if os.path.exists(os.path.normpath(execFile.replace('"', ''))) == False: print '%s does not exist. exiting.' % (execFile) sys.exit(1) nonFloatFiles = [] pm.showWindow(window) for curFile in allFileNodes: pm.progressBar(progressControl, edit=True, step=1) curFileName = cmds.getAttr(curFile + '.fileTextureName') if 'exr' not in os.path.splitext( curFileName)[1].lower(): #check for exr print 'Converting %s' % (curFileName) newFileName = '%s_tiled.exr' % (os.path.splitext(curFileName)[0]) subprocess.call(execFile + ' ' + curFileName + ' ' + newFileName, shell=True) #actually do the work if os.path.exists(newFileName): cmds.setAttr( curFile + '.fileTextureName', newFileName, type='string') # replace old filename with a new one if cmds.objExists(curFile + '.vrayFileGammaEnable'): cmds.setAttr( curFile + '.vrayFileGammaEnable', 0 ) # make sure the gamma correction is disabled if it's there else: print 'Skipping %s' % (curFileName)
def __create__(self): # if type equal 1 we use the main Progress Bar if self._type == 1: self.gMainProgressBar = pmc.melGlobals['$gMainProgressBar'] pmc.progressBar( self.gMainProgressBar, edit=True, beginProgress=True, isInterruptable=False, status=self.title, maxValue=self._maxAmount ) # if type equal 2 we use a window elif self._type == 2: pmc.waitCursor( state=True ) self._maxAmount += 1 self.__createUI__() self.progress(1)
def start_progress(): main_progress_bar = mel.eval('$tmp = $gMainProgressBar') pm.progressBar(main_progress_bar, edit=1, beginProgress=1, isInterruptable=1, status='"processing textures ..."', maxValue=5000) for j in range(1000): if pm.progressBar(main_progress_bar, query=True, isCancelled=True): break pm.progressBar(main_progress_bar, edit=True, step=1) return main_progress_bar
def terminate(self): """Terminate the progress bar""" # if main progress bar if self._type == 1: pmc.progressBar(self.gMainProgressBar, edit=True, endProgress=True) # if window progress bar elif self._type == 2: pmc.waitCursor( state=False ) if (pmc.window(self.ui['win'], exists=True)): self.ui['pgb'].step(self._maxAmount) pmc.deleteUI(self.ui['win'])
def rtb_vert_ops(highresListDropdown, operation, *args, **kwargs): ''' ''' global defaultString global lct_cfg mainProgBar = pm.mel.eval('$tmp = $gMainProgressBar') progBarList = [mainProgBar, prefix + '_progress_control'] high = highresListDropdown.getValue() if not high == defaultString or operation == 'relax': pm.undoInfo(openChunk=True) sel = pm.ls(sl=True) if sel: if operation == 'relax' and high == defaultString: shape = sel[0] liveShape = pm.PyNode(shape.split('.')[0]) else: live = pm.PyNode(high.replace('_high', '_live')) liveShape = live.getShape() verts = lcGeometry.Geometry.getVertsFromSelection(sel) if verts: # and verts[0].nodeType() == 'mesh': try: if operation == 'relax': lcGeometry.Geometry.relaxVerts(verts, liveShape, progBarList) if operation == 'shrink': lcGeometry.Geometry.shrinkWrap(verts, liveShape, progBarList) except: for bar in progBarList: pm.progressBar(bar, edit=True, en=False) pm.progressBar(bar, edit=True, endProgress=True) lcUtility.Utility.lc_print_exception( 'Shrink-wrap did not complete') else: lcUtility.Utility.lc_print('No verts to shrink wrap!', mode='warning') pm.select(sel, r=True) # pm.hilite(pm.PyNode(sel[0].split('.')[0]).getParent(), r=True) # type = lcGeometry.Geometry.getMeshSelectionType(sel[0]) # lcGeometry.Geometry.switchSelectType(type) pm.undoInfo(closeChunk=True) else: lcUtility.Utility.lc_print('Select a mesh from the dropdown list', mode='warning')
def __init__(self, id, max_value=100): super(UiProgressBar, self).__init__(id) self.id = pm.progressBar(id, maxValue=max_value) self.max_value = max_value self.progress = 0
def MakeProgressBar(initialStatus, maxValue=100, leftColumnWidth=__LEFT_COLUMN_WIDTH__, middleColumnWidth=__MIDDLE_COLUMN_WIDTH__, rightColumnWidth=__RIGHT_COLUMN_WIDTH__, annotation=None): """ Creates & returns an updatable progress bar with an associated 'status readout' text label to the right. :param initialStatus: initial text for the status label. :param maxValue: float, max value for progress bar. :param leftColumnWidth: float, width for title label to left of bar (text = "Status") :param middleColumnWidth: float, width of progress bar. :param rightColumnWidth: float, width of status readout label. :param annotation: toolTip annotation, or None. """ rowLayout = MakeRowLayout(3, leftColumnWidth=leftColumnWidth, middleColumnWidth=middleColumnWidth, rightColumnWidth=rightColumnWidth, makeAdjustable=False) MakeText("Status:", annotation) progressBar = pm.progressBar(maxValue=maxValue) statusLabel = pm.textField(text=initialStatus, editable=False) # if(barWidth is not None): # progressBar.setWidth(barWidth) if(annotation is not None): statusLabel.setAnnotation(annotation) progressBar.setAnnotation(annotation) SetAsChildLayout(rowLayout) return (rowLayout, statusLabel, progressBar)
def progress(self, amount=1): """Advance the progress bar""" self._amount += int(amount) # if main progress bar if self._type == 1: pmc.progressBar(self.gMainProgressBar, edit=True, step=amount) # if window progress bar elif self._type == 2: if (pmc.window(self.ui['win'], exists=True)): self.ui['pgb'].step(amount) # terminate if amount is bigger than maxAmount if self._amount >= self._maxAmount: self.terminate()
def __init__ (self,title,steps): self.window = pymel.window(title, sizeable=False) pymel.columnLayout() self.progressControls = [] self.progressbar = pymel.progressBar(maxValue=steps, width=300) pymel.showWindow( self.window ) self.progressbar.step(0)
def __init__(self, title, steps): self.window = pymel.window(title, sizeable=False) pymel.columnLayout() self.progressControls = [] self.progressbar = pymel.progressBar(maxValue=steps, width=300) pymel.showWindow(self.window) self.progressbar.step(0)
def vrayConvertToTiledEXR(): """ Take all images that are NOT exr files and convert them to tiled exr files """ # setup a window window = pm.window() pm.columnLayout() mayaVersion = re.search("[0-9]+", re.search("maya[0-9]+", sys.argv[0].lower()).group(0)).group( 0 ) # look for the 2012 or 2013 etc in path name pathToVRayTools = os.path.normpath( os.environ["VRAY_TOOLS_MAYA%s_x64" % (mayaVersion)] ) # make sure we have the right vray tools path allFileNodes = cmds.ls(type="file") # look for file nodes progressControl = pm.progressBar(maxValue=len(allFileNodes) - 1, width=300) # make sure window is prepped for size if platform.system() == "Windows": execFile = '"%s/img2tiledexr.exe"' % (pathToVRayTools) # needs quotes in case there are spaces in filename else: execFile = '"%s/img2tiledexr"' % (pathToVRayTools) # needs quotes in case there are spaces in filename if os.path.exists(os.path.normpath(execFile.replace('"', ""))) == False: print "%s does not exist. exiting." % (execFile) sys.exit(1) nonFloatFiles = [] pm.showWindow(window) for curFile in allFileNodes: pm.progressBar(progressControl, edit=True, step=1) curFileName = cmds.getAttr(curFile + ".fileTextureName") if "exr" not in os.path.splitext(curFileName)[1].lower(): # check for exr print "Converting %s" % (curFileName) newFileName = "%s_tiled.exr" % (os.path.splitext(curFileName)[0]) subprocess.call(execFile + " " + curFileName + " " + newFileName, shell=True) # actually do the work if os.path.exists(newFileName): cmds.setAttr( curFile + ".fileTextureName", newFileName, type="string" ) # replace old filename with a new one if cmds.objExists(curFile + ".vrayFileGammaEnable"): cmds.setAttr( curFile + ".vrayFileGammaEnable", 0 ) # make sure the gamma correction is disabled if it's there else: print "Skipping %s" % (curFileName)
def run(): defaultRenderGlobal = pm.PyNode('defaultRenderGlobals') begin = defaultRenderGlobal.startFrame.get() end =defaultRenderGlobal.endFrame.get() mainprocess = pm.mel.eval('$tmp = $gMainProgressBar') pm.progressBar(mainprocess, edit=True, beginProgress=True, isInterruptable=True, status='Rendering in foreground ...', minValue = int(begin), maxValue=int(end)) for x in range(int(begin), int(end)+2): if pm.progressBar(mainprocess, q=True, ic=True): break pm.progressBar(mainprocess, e=True, step=1) pm.currentTime(x) pm.arnoldRender(b=True, seq=str(x)) pm.refresh() pm.progressBar(mainprocess, edit=True, endProgress=True, ) pm.warning('BatchRender activeRenderLayer complete!')
def update(self, idx_value): if not self.progress_bar: return if isinstance(idx_value, basestring): idx_value = int(idx_value) # progress Bar if idx_value >= self.pb_value - 1: self.kill() else: pmc.progressBar( self.progress_bar, edit=True, status="%s : %s/%s" % (self.pb_title, idx_value, self.pb_value), progress=idx_value, )
def apply_voxel_weighting(obj, voxel_data, max_iterations, min_distance): start_time = time.clock() main_progress_bar = pm.mel.eval('$tmp = $gMainProgressBar') pm.progressBar(main_progress_bar, edit=True, beginProgress=True, isInterruptable=True, status='Applying Skin Weights...', maxValue=obj.vtx.count()) voxel_size = voxel_data['voxel_size'] joint_list = [ pm.nt.Joint(obj.namespace() + x) for x in voxel_data['joint_list'] ] skin_cluster = find_skin_cluster(obj) if find_skin_cluster( obj) else pm.skinCluster([obj] + joint_list, toSelectedBones=True) for index in xrange(0, obj.vtx.count()): if pm.progressBar(main_progress_bar, query=True, isCancelled=True): break pm.progressBar(main_progress_bar, edit=True, step=1) vertex_index_string = obj.name() + ".vtx[{0}]".format(index) vert_ws_vector = v1_math.vector.Vector( pm.xform(vertex_index_string, q=True, ws=True, t=True)) voxel_vector, voxel_pos = v1_shared.skin_weight_utils.get_voxel_vector( vert_ws_vector, voxel_size) normal_vector = v1_math.vector.Vector( pm.polyNormalPerVertex(vertex_index_string, q=True, xyz=True, relative=True)[:3]) voxel_list = [voxel_vector] voxel_list = v1_shared.skin_weight_utils.get_initial_search_voxels( voxel_list, voxel_vector, voxel_pos, voxel_size, normal_vector) weight_entry = v1_shared.skin_weight_utils.find_matching_point_from_voxels( vert_ws_vector, voxel_list, voxel_data, max_iterations, min_distance) if weight_entry: weighted_joint_list = [ pm.nt.Joint(obj.namespace() + x) for x in weight_entry[2] ] pm.skinPercent(skin_cluster, vertex_index_string, normalize=False, transformValue=zip(weighted_joint_list, weight_entry[1])) pm.select(obj) pm.mel.removeUnusedInfluences() pm.progressBar(main_progress_bar, edit=True, endProgress=True) print time.clock() - start_time
def create(self): pb = pmc.progressBar( self.progress_bar, edit=True, beginProgress=True, isInterruptable=True, status="%s : 0/%s" % (self.pb_title, self.pb_value), maxValue=self.pb_value, )
def _build_program_settings_frame(parent_layout): program_settings_frame = pm.frameLayout(label="Program Settings", collapsable=True) # Create Form Layout with embedded Tab Layout program_settings_form = pm.formLayout() program_settings_tab_layout = pm.tabLayout('program_settings_tab_layout') pm.formLayout(program_settings_form, edit=True, attachForm=[(program_settings_tab_layout, "top", 3), (program_settings_tab_layout, "bottom", 3), (program_settings_tab_layout, "left", 3), (program_settings_tab_layout, "right", 3)]) general_settings_tab_layout = _build_general_settings_tab( program_settings_tab_layout) proc_options_tab_layout = _build_proc_options_tab(program_settings_frame) tabs = [[general_settings_tab_layout, 'General'], [proc_options_tab_layout, 'Advanced']] assign_tabs(tabs, program_settings_tab_layout) program_settings_col = pm.columnLayout(adj=True, columnAttach=['both', 3]) # Output options pm.checkBox('cb_overwriteFile', label="Overwrite existing file", value=postproc_config.OPTS_OVERWRITE_EXISTING_FILE, annotation='If checked, an existing file with the input ' \ 'output name will be overwritten') pm.checkBox('cb_ignoreWarnings', label="Ignore warnings", value=postproc_config.OPTS_IGNORE_WARNINGS, annotation='If checked, all warnings will be ignored and ' \ 'a program will be written') pm.separator(height=3, style='none') pm.separator(height=3, style='none') pm.button('Analyze Program', command=mimic_program.analyze_program, height=25, annotation='Launches graphical analysis tool') pm.button('Save Program', command=mimic_program.save_program, height=25, annotation='Saves robot control program with input parameters') pm.separator(height=3, style='none') export_progress_bar = pm.progressBar('pb_exportProgress', isInterruptable=True, maxValue=100, visible=0) pm.setParent(parent_layout)
def main(neutral=None, target=None): ''' Generate separated blendshapes ''' # Get shaders shaders = _getShaders() # Create sets sets = _createSets(shaders=shaders) # _createBlend blend = pm.blendShape(target, neutral)[0] pm.setAttr('%s.%s' % (blend, target), 1) # Flood all weights to 0 pm.mel.eval("select -r %s.vtx[0:%s]" % (neutral.name(), (neutral.numVertices() - 1))) _floodWeightsOnSelected(blendNode=blend, value=0) # Get vertex weight dictionary weights = _createVertShaderMap(mesh=neutral, sets=sets) # Setup progressbar gMainProgressBar = pm.mel.eval('$tmp = $gMainProgressBar') pm.progressBar(gMainProgressBar, edit=True, beginProgress=True, isInterruptable=True, status='Creating blendshape targets from shaders ...', maxValue=len(sets)) # Generate target per set for s in sets: if pm.progressBar(gMainProgressBar, query=True, isCancelled=True): break # Select components pm.select(s, r=1) verts = pm.ls(sl=1, fl=1) # Flood blend deformer weights to 1 for v in verts: pm.select(v, r=1) num = int(v.split('[')[-1].split(']')[0]) w = float(1.0 / weights[num]) _floodWeightsOnSelected(blendNode=blend, value=w) # Create target _createTarget(mesh=neutral, name=s.replace('_set', 'Morph')) # Flood all weights to 0 pm.mel.eval("select -r %s.vtx[0:%s]" % (neutral.name(), (neutral.numVertices() - 1))) _floodWeightsOnSelected(blendNode=blend, value=0) pm.progressBar(gMainProgressBar, edit=True, step=1) pm.progressBar(gMainProgressBar, edit=True, endProgress=True)
def createProgressbarWindow(self, progressbarSize = 1): pm.select(cl = True) #Create ProgressbarUi Window self.progressbarWindow = pm.window(title = 'Progress', resizeToFitChildren = True) pm.columnLayout() self.progressControl = pm.progressBar(maxValue = progressbarSize, width = 300) pm.showWindow(self.progressbarWindow) pm.select(cl = True)
def window(self): self.win = 'progresswin' self.num = (len(self.folls)/100) if(pm.window(self.win, ex = True)): pm.deleteUI(self.win) if(pm.windowPref(self.win, ex = True)): pm.windowPref(self.win, remove = True) progressWin = pm.window(self.win, title = '' , sizeable = False, width = 300, backgroundColor = [.5, .5, .5]) pm.columnLayout(adjustableColumn = True) self.bar = pm.progressBar(minValue = 0, maxValue=100, width=300, step=1) progressWin.show()
def prune_skin_weights(obj): skin_cluster = find_skin_cluster(obj) joint_list = pm.skinCluster(skin_cluster, q=True, inf=True) main_progress_bar = pm.mel.eval('$tmp = $gMainProgressBar') pm.progressBar(main_progress_bar, edit=True, beginProgress=True, isInterruptable=True, status='Pruning Skin Weights...', maxValue=obj.vtx.count()) for index in xrange(0, obj.vtx.count()): pm.progressBar(main_progress_bar, edit=True, step=1) vertex_index_string = obj.name() + ".vtx[{0}]".format(index) skin_values = pm.skinPercent(skin_cluster, vertex_index_string, q=True, value=True) for i in xrange(0, len(skin_values)): if skin_values[i] < 0.0001: pm.skinPercent(skin_cluster, vertex_index_string, normalize=False, transformValue=(joint_list[i], 0)) pm.progressBar(main_progress_bar, edit=True, endProgress=True)
def multi_polyQuad(): args,counter = pm.ls(sl=True),1 w=400 window = pm.window(w=w,h=40) pm.columnLayout() progressMessage=pm.text(l='Running through Objects...',w=w) argName=pm.text(l='',w=w) progressControl = pm.progressBar(isInterruptable=True, beginProgress=True, maxValue=len(args), width=w) window.show() for arg in args: if pm.progressBar(progressControl, query=True, isCancelled=True ) : break progressMessage.setLabel('Cleaning up then Quadding object '+str(counter)+'/'+str(len(args))+':') argName.setLabel(arg) pm.select(arg,r=True) #cleanup mesh mel.eval('polyCleanupArgList 3 { "0","1","0","0","0","0","0","0","0","1e-05","0","1e-05","0","1e-05","0","1","0" };') #quad all polies pm.polyQuad(arg, a=30, kgb=False, ktb=False,khe=False,ws=True,ch=False) #merge all verts pm.polyMergeVertex((arg+'.vtx[0:'+str(pm.polyEvaluate(arg,v=True))+']'), d=.001,am=True,ch=0) pm.polyNormalPerVertex(arg,ufn=True) pm.polySoftEdge(arg,angle=68, ch=0) pm.progressBar(progressControl, edit=True, step=1) counter+=1 pm.progressBar(progressControl, edit=True, endProgress=True) pm.select(args, r=True) pm.selectMode(o=True) window.delete()
def main(neutral=None, target=None): ''' Generate separated blendshapes ''' # Get shaders shaders = _getShaders() # Create sets sets = _createSets(shaders=shaders) # _createBlend blend = pm.blendShape( target, neutral )[0] pm.setAttr('%s.%s'%(blend,target),1) # Flood all weights to 0 pm.mel.eval("select -r %s.vtx[0:%s]"%(neutral.name(), (neutral.numVertices()-1))) _floodWeightsOnSelected(blendNode=blend, value=0) # Get vertex weight dictionary weights = _createVertShaderMap(mesh=neutral,sets=sets) # Setup progressbar gMainProgressBar = pm.mel.eval('$tmp = $gMainProgressBar') pm.progressBar( gMainProgressBar, edit=True, beginProgress=True, isInterruptable=True, status='Creating blendshape targets from shaders ...', maxValue=len(sets) ) # Generate target per set for s in sets: if pm.progressBar(gMainProgressBar, query=True, isCancelled=True ) : break # Select components pm.select(s,r=1) verts = pm.ls(sl=1,fl=1) # Flood blend deformer weights to 1 for v in verts: pm.select(v,r=1) num = int(v.split('[')[-1].split(']')[0]) w = float(1.0/weights[num]) _floodWeightsOnSelected(blendNode=blend, value=w) # Create target _createTarget(mesh=neutral, name=s.replace('_set','Morph')) # Flood all weights to 0 pm.mel.eval("select -r %s.vtx[0:%s]"%(neutral.name(), (neutral.numVertices()-1))) _floodWeightsOnSelected(blendNode=blend, value=0) pm.progressBar(gMainProgressBar, edit=True, step=1) pm.progressBar(gMainProgressBar, edit=True, endProgress=True)
def apply_index_weighting(obj, weight_data): start_time = time.clock() main_progress_bar = pm.mel.eval('$tmp = $gMainProgressBar') pm.progressBar(main_progress_bar, edit=True, beginProgress=True, isInterruptable=True, status='Applying Skin Weights...', maxValue=obj.vtx.count()) joint_lists = weight_data['joint_lists'].values() weight_cloud = weight_data['weight_cloud'] transform = obj.getParent() if type(obj) == pm.nt.Mesh else obj combined_joint_list = [] for joint_list in joint_lists: combined_joint_list = combined_joint_list + joint_list combined_joint_list = list(set(combined_joint_list)) combined_joint_list = [ pm.nt.Joint(obj.namespace() + x) for x in combined_joint_list ] skin_cluster = find_skin_cluster(obj) if find_skin_cluster( obj) else pm.skinCluster([obj] + combined_joint_list, toSelectedBones=True) for weight_entry in weight_cloud.itervalues(): if pm.progressBar(main_progress_bar, query=True, isCancelled=True): break entry_obj = pm.PyNode(obj.namespace() + weight_entry[1]) if transform == entry_obj: pm.progressBar(main_progress_bar, edit=True, step=1) weight_values = weight_entry[0] weighted_joint_list = [ pm.nt.Joint(obj.namespace() + x) for x in weight_data['joint_lists'][weight_entry[1]] ] index = weight_entry[2] pm.skinPercent(skin_cluster, obj.vtx[index], normalize=False, transformValue=zip(weighted_joint_list, weight_values)) pm.select(obj) pm.mel.removeUnusedInfluences() pm.progressBar(main_progress_bar, edit=True, endProgress=True) print time.clock() - start_time
def load_weight(self): """ Function to load the skin weight on the selected mesh the function looks for a file in the selected directoy of the same name as mesh and loads the skin """ directory_path = self.get_directory() if directory_path is None: return selected_objects = pm.ls(sl=True) for i in selected_objects: skin_cluster = utilities.find_skin_cluster(i) if skin_cluster is not None: path = '{}/{}.skindata'.format(directory_path, i.name()) if not os.path.isfile(path): logging.warning( 'Skin data file doesnot exist of the name {}.skindata'. format(i.name())) return with open(path) as fileJson: try: loaded_dict_from_file = json.load(fileJson) except: logging.warning('Corrupt skin data. {}'.format(path)) return g_main_progress_bar = pm.mel.eval('$tmp = $gMainProgressBar') pm.progressBar(g_main_progress_bar, edit=True, beginProgress=True, isInterruptable=True, status='"loading skin info ...', maxValue=len(loaded_dict_from_file)) for vertex, skin_info in loaded_dict_from_file.iteritems(): for counter, joint in enumerate(skin_info['joint_list']): try: utilities.set_weight( skin_cluster=skin_cluster, vertices=vertex, joint=joint, value=skin_info['weight_list'][counter]) pm.progressBar(g_main_progress_bar, edit=True, step=1) except: logging.warning( 'Skin data not matching the selected mesh. {}'. format(i.name())) return pm.progressBar(g_main_progress_bar, edit=True, endProgress=True) logging.info('{} skin data loaded on {} sucessfully'.format( path, i.name()))
def save_weight(self): """ Function to save the skin weight of the selected mesh """ directory_path = self.get_directory() if directory_path is None: return selected_objects = pm.ls(sl=True) for i in selected_objects: vertex = dict() skin_cluster = utilities.find_skin_cluster(i) if skin_cluster is not None: pm.select(i) no_of_vertices = pm.polyEvaluate(v=True) shape_node = i.getShape() g_main_progress_bar = pm.mel.eval('$tmp = $gMainProgressBar') pm.progressBar(g_main_progress_bar, edit=True, beginProgress=True, isInterruptable=True, status='"Getting skin info ...', maxValue=no_of_vertices) for vertex_no in range(0, no_of_vertices): vertex_skin_info = dict() if pm.progressBar(g_main_progress_bar, query=True, isCancelled=True): break vertices_selection = '{}.vtx[{}]'.format( shape_node, str(vertex_no)) joint_list = list() weight_list = list() weight_list = utilities.get_weights_inf_from_vertices( skin_cluster=skin_cluster, vertices=vertices_selection) joint_list = utilities.get_joints_inf_from_vertices( skin_cluster=skin_cluster, vertices=vertices_selection) vertex_skin_info['joint_list'] = joint_list vertex_skin_info['weight_list'] = weight_list vertex[vertices_selection] = vertex_skin_info pm.progressBar(g_main_progress_bar, edit=True, step=1) pm.progressBar(g_main_progress_bar, edit=True, endProgress=True) path = '{}/{}.skindata'.format(directory_path, i.name()) with open(path, mode='w') as f: f.write(json.dumps(vertex, indent=4, separators=(',', ': '))) logging.info('{} skin saved'.format(i.name()))
def window(self): self.win = 'progresswin' self.num = (len(self.folls) / 100) if (pm.window(self.win, ex=True)): pm.deleteUI(self.win) if (pm.windowPref(self.win, ex=True)): pm.windowPref(self.win, remove=True) progressWin = pm.window(self.win, title='', sizeable=False, width=300, backgroundColor=[.5, .5, .5]) pm.columnLayout(adjustableColumn=True) self.bar = pm.progressBar(minValue=0, maxValue=100, width=300, step=1) progressWin.show()
def showProgressBar(self, action_count): """ Create a new progress bar and set the action count :param action_count: :return: """ gMainProgressBar = pm.mel.eval('$tmp = $gMainProgressBar') self._actionCount = action_count self._progressBar = pm.progressBar( gMainProgressBar, edit=True, beginProgress=True, status='Editing Rig', minValue=0, maxValue=action_count, )
def __createUI__(self): # window creation windowName = self.title.replace(' ', '') title = self.title # delete if exist if (pmc.window(windowName, exists=True)): pmc.deleteUI(windowName) self.ui['win'] = pmc.window(windowName, title=title, resizeToFitChildren=False, sizeable=False, retain=False, topLeftCorner=[10,100] ) pmc.columnLayout() self.ui['txt'] = pmc.text( label=' '+self.status, align='center', height=20 ) self.ui['pgb'] = pmc.progressBar( maxValue=self._maxAmount, width=100 ) pmc.separator( height=5, style='none' ) # show window self.ui['win'].show()
def update_progress(progress_bar): for j in range(500): if pm.progressBar(progress_bar, query=True, isCancelled=True): break pm.progressBar(progress_bar, edit=True, step=1)
def run(): # validate that we selected 1 skinned mesh and 1 non-skinned mesh sel = pm.ls(sl=True) if len(sel)!=2: raise Exception("copyWeightsToFurCards: select skin mesh, shift select fur cards. Aborted.") # src_mesh_trans = sel[0] src_mesh_shape = pm.listRelatives(src_mesh_trans, s=True)[0] if type(src_mesh_shape) != pm.nodetypes.Mesh: raise Exception("copyWeightsToFurCards: source object must be a skinned mesh.") # fur_trans = sel[1] fur_shape = pm.listRelatives(fur_trans, s=True)[0] if type(fur_shape) != pm.nodetypes.Mesh: raise Exception("copyWeightsToFurCards: target object must be a mesh.") # src_skincluster = getRelatedSkinCluster(src_mesh_trans) if type(src_skincluster) != pm.nodetypes.SkinCluster: raise Exception("copyWeightsToFurCards: source mesh must have a skinCluster deformer.") # fur_skincluster = getRelatedSkinCluster(fur_trans) if fur_skincluster != None: raise Exception("copyWeightsToFurCards: target mesh must not be skinned.") # bind the fur cards to the same influences as the source mesh src_influences = src_skincluster.getInfluence() pm.select(src_influences, r=True) pm.select(fur_trans, add=True) fur_skincluster = pm.skinCluster(tsb=True) # copy skin weights from source to fur cards pm.copySkinWeights( ss=str(src_skincluster), ds=str(fur_skincluster), noMirror=True, surfaceAssociation = "closestPoint", influenceAssociation = "oneToOne") # split mesh into list of vertex lists (1 per shell) vertex_shells = [] num_faces = pm.polyEvaluate(fur_trans,f=True) faces_checked = set(range(num_faces)) # gMainProgressBar = mel.eval('$tmp = $gMainProgressBar'); pm.progressBar( gMainProgressBar, edit=True, beginProgress=True, isInterruptable=True, status='Gathering vertex shells...', maxValue=num_faces ) # while len(faces_checked)>0: #progress if pm.progressBar(gMainProgressBar, query=True, isCancelled=True ) : return pm.progressBar(gMainProgressBar, edit=True, step=num_faces-len(faces_checked)) face = faces_checked.pop() shell_faces = pm.polySelect( fur_trans, extendToShell=face ) faces_checked = faces_checked.difference(shell_faces) face_vert_info = pm.polyInfo(faceToVertex=True) verts_in_shell = [] #pm.polyInfo returns horrible unicode format that must be parsed for face_verts_str in face_vert_info: verts_str = face_verts_str.split(":")[1] vert_strings = verts_str.split(" ") for v in vert_strings: try: v_id = int(v) verts_in_shell.append(v_id) except: pass vertex_shells.append(verts_in_shell) # now search for closest vertex in each shell... sel_list = OpenMaya.MSelectionList() sel_list.add(str(fur_shape)) nodeDagPath = sel_list.getDagPath(0) mfnMesh = OpenMaya.MFnMesh(nodeDagPath) space = OpenMaya.MSpace.kWorld pm.progressBar(gMainProgressBar, edit=True, step=0, status="Getting vertex positions...") verts = OpenMaya.MPointArray() verts = mfnMesh.getPoints(OpenMaya.MSpace.kWorld) pm.progressBar(gMainProgressBar, edit=True, status="Finding closest vertex per card...") pm.progressBar(gMainProgressBar, edit=True, step=0, maxValue=len(vertex_shells)) closest_vert_per_shell = [] for i,shell in enumerate(vertex_shells): #progress if pm.progressBar(gMainProgressBar, query=True, isCancelled=True ) : return pm.progressBar(gMainProgressBar, edit=True, step=i) closest_dist = None closest_vert = None for vert_id in shell: point = verts[vert_id] closestPoint, faceIdx = mfnMesh.getClosestPoint(point, space) dist = closestPoint.distanceTo(point) if closest_dist==None: closest_dist = dist closest_vert = vert_id elif dist < closest_dist: closest_dist = dist closest_vert = vert_id closest_vert_per_shell.append(closest_vert) pm.progressBar(gMainProgressBar, edit=True, status="Apply weights for each card...") pm.progressBar(gMainProgressBar, edit=True, step=0, maxValue=len(vertex_shells)) # vtx_base = str(fur_trans)+".vtx[" for i,shell in enumerate(vertex_shells): #progress if pm.progressBar(gMainProgressBar, query=True, isCancelled=True ) : return pm.progressBar(gMainProgressBar, edit=True, step=i) #get weight value of closest vertex c = closest_vert_per_shell[i] vtx = vtx_base+str(c)+"]" values = pm.skinPercent(fur_skincluster,vtx,q=1,v=1,ib=0.0001) transforms = pm.skinPercent(fur_skincluster,vtx,q=1,t=None,ib=0.0001) influences = [] for i in range(len(transforms)): influences.append((transforms[i],values[i])) #paste weight values on all other vertices in shell for v in shell: vtx = vtx_base+str(v)+"]" pm.skinPercent(fur_skincluster,vtx,tv=influences) pm.progressBar(gMainProgressBar, edit=True, endProgress=True)
def _initialize_export_progress_bar(is_on=True): """ """ pm.progressBar('pb_exportProgress', edit=True, progress=0) pm.progressBar('pb_exportProgress', edit=True, visible=is_on)
def edit(self): pm.progressBar(self.bar, edit = True, step = int(self.num)) self.num += self.num
def __init__(self): if pm.window("Baker", ex=True): pm.deleteUI("Baker") win = pm.window("Baker", wh=(620, 580), tlb=True, t="redshift baker") pm.rowLayout(w=420, nc=2, cw=((1, 200), (2, 400))) pm.columnLayout(w=200) pm.text(label="material directory", w=200) self.mat_folder = pm.textField(tx=Default.material_dir, w=200) pm.text(label="output directory", w=200) self.out_folder = pm.textField(tx=Default.output_dir, w=200) pm.text(label="material name pattern") self.pattern = pm.textField(tx=Default.name_pattern, w=200) self.size = pm.intSliderGrp(cw3=[30, 50, 110], ct3=["left", "left", "lfet"], label="size", field=True, v=Default.size, max=8192) pm.button(label="import meshes", c=multiImport, w=200) pm.button(label="check names", c=checkNames, w=200) pm.button(label="create uv", w=200, c=applyUV) pm.button(label="render settings", w=200, c=lambda *args: preferences("redshiftOptions")) pm.button(label="AO shader settings", w=200, c=lambda *args: preferences("ao_texture", "ao_material")) pm.button(label="shadow shader settings", w=200, c=lambda *args: preferences("shadow_material")) pm.button(label="remove empty png", w=200, c=self.cleanEmptyFiles) self.format = pm.optionMenu(w=200) pm.menuItem(label='obj') pm.menuItem(label='fbx') pm.menuItem(label='dae') self.default_mat = pm.checkBox(label="default material for ID", v=True) self.auto_levels = pm.checkBox(label="auto levels for shadows", v=False) self.ignore_exist = pm.checkBox(label="ignore existence", v=True) self.shadow = pm.checkBox(label="bake shadows", v=True) self.ao = pm.checkBox(label="bake ambient occlusion", v=True) pm.button(label="bake id", w=200, c=self.renderID) pm.button(label="bake mesh", w=200, c=self.renderMesh) pm.button(label="bake AO and shadow", w=200, c=self.renderAO) pm.button(label="create material", w=200, c=self.renderMaterial) pm.text(l="materials", w=200) for color in Default.materials: pm.button(label=color, w=200, c=functools.partial(applyMaterial, color)) pm.setParent(u=True) column = pm.columnLayout(w=400) self.progress = pm.progressBar(w=400) self.out_field = QTextEdit() self.out_field.setFixedSize(400, 500) self.out_field.setObjectName("baker_out") pm.control("baker_out", e=True, p=column) self.settings() win.show()
def updateProgressBar(self, percent): if self.gMainProgressBar is not None: progressValue = percent * 100 pm.progressBar(self.gMainProgressBar, edit=True, progress=progressValue)
def shrinkWrap(cls, verts, mesh, progBar='', *args, **kwargs): ''' ''' scaleFactor = 1 loc = pm.spaceLocator() pm.geometryConstraint(mesh, loc) pm.progressBar(progBar, edit=True, isInterruptable=True, maxValue = len(verts), vis=True) if verts: tmpPos = verts[0].getPosition(space='world') if len(tmpPos)==4: scaleFactor = 1/tmpPos[3] for vert in verts: if pm.progressBar(progBar, query=True, isCancelled=True): pm.progressBar(progBar, edit=True, vis=False) break else: currentVert = ((vert.split('.')[1]).lstrip('vtx[')).rstrip(']') vertPos = pm.pointPosition(vert, w=True) pm.move(loc, [vertPos[0], vertPos[1], vertPos[2] ], ws=True) locPos = pm.pointPosition(loc) pm.move(vert, [locPos[0], locPos[1], locPos[2] ], ws=True) pm.progressBar(progBar, edit=True, step=1) pm.progressBar(progBar, edit=True, vis=False) pm.progressBar(progBar, edit=True, endProgress=True) pm.delete(loc) pm.select(vert.split('.')[0], r=True) pm.delete(ch=True)
def __exit__(self, *args, **kwargs): pmc.progressBar(self.bar, edit=True, endProgress=True)
def main( new=False ) : sel = pm.ls( sl=True ) if( len( sel ) != 1 ) : pm.error( 'Please select ONE mesh transform' ) mesh = sel[0] if( mesh.type() != 'transform' ) : pm.error( 'Please select a MESH TRANSFORM' ) # meshverts = list( mesh.vtx ) # remainingverts = list( mesh.vtx ) skinclusters = pm.ls( type='skinCluster' ) # print len( remainingverts ), len( meshverts ) if( len( skinclusters ) < 2 ) : pm.error( 'The selected mesh (%s) only has one skinCluster' % mesh ) vertexweights = {} skinjoints = [] # initialise the status bar pbar = pm.language.Mel.eval( '$tmp = $gMainProgressBar' ) pm.progressBar( pbar, edit=True, beginProgress=True, isInterruptable=True, status='"Merging skinClusters..."', maxValue=len( skinclusters ) ) # iterate through skinClusters to get the weights associated with each vertex # these vertices will be associated with the pre-polyUnite'd meshes # then compare the position of each vertex in the cluster with the position of each vertex in the united mesh # if they are equivilent, store their influences and weights for later if( new ) : open( vlogloc, 'w+' ).close() for s, skincluster in enumerate( skinclusters ) : vlog = open( vlogloc, 'a' ) vlog.write( '%s : %s/%s \n' % ( str( skincluster ), s, len( skinclusters ) ) ) vlog.close() weightedInfluences = skincluster.getWeightedInfluence() for j, joint in enumerate( weightedInfluences ) : vlog = open( vlogloc, 'a' ) vlog.write( ' %s : %s/%s \n' % ( str( joint ), j, len( weightedInfluences ) ) ) vlog.close() skinjoints.append( joint ) influenceset, weights = skincluster.getPointsAffectedByInfluence( joint ) for i, vertex in enumerate( influenceset[0] ) : if( pm.progressBar( pbar, query=True, isCancelled=True ) ) : pm.progressBar( pbar, edit=True, endProgress=True ) return p1 = vertex.getPosition( 'world' ) closestPointOnMeshNode = pm.nodetypes.ClosestPointOnMesh() mesh.getShape().worldMesh >> closestPointOnMeshNode.inMesh closestPointOnMeshNode.inPosition.set( p1 ) idx = closestPointOnMeshNode.closestVertexIndex.get() pm.delete( closestPointOnMeshNode ) meshvertex = mesh.vtx[ idx ] if( not meshvertex in vertexweights.keys() ) : vertexweights[ meshvertex ] = [] vertexweights[ meshvertex ].append( [ joint, weights[i] ] ) pm.progressBar( pbar, edit=True, step=s ) vlog.close() weightsfile = open( weightsloc, 'w+' ) pickle.dump( vertexweights, weightsfile ) weightsfile.close() skinjointsfile = open( skinjointsloc, 'w+' ) pickle.dump( skinjoints, skinjointsfile ) skinjointsfile.close() # now we'll rebind the mesh and apply the weights saved from earlier if( not new ) : vertexweights = pickle.load( open( weightsloc ) ) skinjoints = pickle.load( open( skinjointsloc ) ) pm.progressBar( pbar, edit=True, beginProgress=True, isInterruptable=True, status='"Reskinning..."', maxValue=len( vertexweights ) ) pm.delete( mesh, ch=True ) pm.select( skinjoints ) pm.select( mesh, add=True ) newskin = pm.animation.skinCluster( toSelectedBones=True ) for i, vertex in enumerate( vertexweights ) : jointweights = vertexweights.get( vertex ) for jointweight in jointweights : pm.animation.skinPercent( newskin, vertex, tv=( str(jointweight[0]), float(jointweight[1]) ) ) pm.progressBar( pbar, edit=True, step=i ) pm.progressBar( pbar, edit=True, endProgress=True ) print 'Completed combining skins on %s' % mesh return True
def updateProgressbarWindow(self): #Update Progressbar pm.progressBar(self.progressControl, edit=True, step=1)
def __enter__(self): pmc.progressBar(self.bar, edit=True, beginProgress=True, isInterruptable=False, maxValue=self.count) return self
def kill(self): if not self.progress_bar: return pmc.progressBar(self.progress_bar, edit=True, endProgress=True)
def lcRetopoBasicUI(dockable=False, *args, **kwargs): """ """ ci = 0 #color index iterator windowName = 'lcRetopoBasic' shelfCommand = 'import lct.src.lcRetopoBasic.lcRetopoBasic as lcRtB\nreload(lcRtB)\nlcRtB.lcRetopoBasicUI()' icon = basePath+'lcRetopoBasic.png' winWidth = 204 winHeight = 180 mainWindow = lcWindow(windowName=windowName, width=winWidth, height=winHeight, icon=icon, shelfCommand=shelfCommand, annotation=annotation, dockable=dockable, menuBar=True) mainWindow.create() # pm.columnLayout(prefix+'_columLayout_main') pm.button(l='Setup for Retopo', bgc=colorWheel.getColorRGB(ci), w=200, h=25, annotation='Setup a high res mesh for retopology', command=lambda *args: rtb_setup_live_mesh(highresListDropdown) ) ci+=1 # pm.rowColumnLayout(nc=3, cw=([1,25], [2,150], [3,25] ) ) pm.iconTextButton(w=25, h=25, style='iconOnly', image=iconBasePath+'reloadMeshList.png', annotation='Reload the list of high res meshes', command=lambda *args: rtb_highres_list_populate(highresListDropdown) ) highresListDropdown = pm.optionMenu(prefix+'_optionMenu_highres_list', w=150, h=25, bgc=[0.5,0.5,0.5], annotation='List of high res meshes in the scene' ) highresListDropdown.changeCommand(lambda *args: rtb_choose_active(highresListDropdown) ) pm.iconTextButton(w=25, h=25, style='iconOnly', image=iconBasePath+'removeMeshFromList.png', annotation='Remove current high res mesh from the list and return it to a normal state', command=lambda *args: rtb_remove(highresListDropdown) ) pm.setParent(prefix+'_columLayout_main') # pm.rowColumnLayout(nc=4, cw=([1,50], [2,100], [3,25], [4,25] ) ) pm.iconTextStaticLabel(w=50, h=25, style='iconOnly', image=iconBasePath+'meshLayering.png', annotation='Drag slider to change mesh layering' ) pm.floatSlider(prefix+'_floatSlider_layer_mesh', step=0.01, min=0, max=1, v=0, h=25, dragCommand=lambda *args: rtb_scale_layer_mesh(highresListDropdown) ) pm.iconTextButton(w=25, h=25, style='iconOnly', image=iconBasePath+'toggleXray.png', annotation='Toggle current high res mesh X-Ray', command=lambda *args: rtb_toggle_xray(highresListDropdown) ) pm.iconTextButton(w=25, h=25, style='iconOnly', image=iconBasePath+'hideMesh.png', annotation='Hide the high-res mesh', command=lambda *args: rtb_toggle_hide(highresListDropdown) ) pm.setParent(prefix+'_columLayout_main') # pm.rowColumnLayout(nc=3, cw=([1,50], [2,100], [3,50] ) ) pm.iconTextStaticLabel(w=50, h=25, style='iconOnly', image=iconBasePath+'shaderOpacity.png', annotation='Drag slider to change shader transparency' ) pm.floatSlider(prefix+'_floatSlider_topo_trans', step=0.1, min=0, max=1, v=0.5, h=25, dragCommand=lambda *args: rtb_update_topo_transparency() ) pm.iconTextButton(w=50, h=25, style='iconOnly', image=iconBasePath+'assignShader.png', annotation='Create and/or assign a semi-transparent shader to selected low res mesh', command=lambda *args: rtb_create_retopo_shader() ) pm.setParent(prefix+'_columLayout_main') # pm.separator(style='in', h=5, hr=True) #this doesn't seem to be working right pm.rowColumnLayout(nc=2) pm.button(l='Relax', bgc=colorWheel.getColorRGB(ci), w=100, h=25, annotation='Relax selected verts and shrink-wrap them to the live mesh', command=lambda *args: rtb_relax_verts(highresListDropdown) ) ci+=1 pm.button(l='Shrink-Wrap', bgc=colorWheel.getColorRGB(ci), w=100, h=25, annotation='Shrink-wrap selected verts to the live mesh', command=lambda *args: rtb_shrink_wrap_verts(highresListDropdown) ) ci+=1 pm.setParent(prefix+'_columLayout_main') # pm.progressBar(prefix+'_progress_control', vis=False, w=202) # mainWindow.show() rtb_highres_list_populate(highresListDropdown) #vertex animation cache in viewport 2.0 must be disabled or the mesh will not update properly if pm.objExists('hardwareRenderingGlobals'): pm.PyNode('hardwareRenderingGlobals').vertexAnimationCache.set(0)
def end_progress(progress_bar): pm.progressBar(progress_bar, edit=True, endProgress=True)
def setStatus(self, status): pmc.progressBar(self.bar, edit=True, status=status)
def postRenderProcedure(self): optimizetextures.postRenderOptimizeTextures() if self.gMainProgressBar is not None: pm.progressBar(self.gMainProgressBar, edit=True, endProgress=True) self.gMainProgressBar = None
def step(self): pmc.progressBar(self.bar, edit=True, step=1)
def ui(self): ''' main ui creator ''' #TODO: only run once. use singleton instance if pm.window(self.name, q = True, ex = True): pm.deleteUI(self.name) #main window self.widgets['mainWindow'] = pm.window(self.name, title = self.name, widthHeight = (720, 400)) self.widgets['mainForm'] = pm.formLayout(parent = self.widgets['mainWindow']) #top left column self.widgets['topLColumn'] = pm.columnLayout(adjustableColumn = True, parent = self.widgets['mainForm'], h = 168) self.widgets['cameraText'] = pm.text(label = "Cameras", h = 20) self.widgets['cameraList'] = pm.iconTextScrollList(h = 105, allowMultiSelection = True, selectCommand = pm.Callback(self.updateLayers)) self.widgets['nameSep'] = pm.separator(horizontal = True, style = 'none', h = 13) self.widgets['sceneName'] = pm.textFieldGrp(label = 'Scene Name', text = self.scene.namebase, adjustableColumn = 2, columnWidth2 = [80, 0]) #top right column self.widgets['topRColumn'] = pm.columnLayout(parent = self.widgets['mainForm'], h = 168, adjustableColumn = True, rowSpacing = 1) self.widgets['outputDir'] = pm.textFieldButtonGrp(label = 'Output Path', tx = self.output, adjustableColumn = 2, columnWidth = [1, 80], buttonLabel = 'Browse...', bc = pm.Callback(self.changeOutputDestination)) self.widgets['project'] = pm.textFieldGrp(label = 'Project', adjustableColumn = 2, columnWidth = [1, 80], text = self.fileInfo.getProject()) self.widgets['department'] = pm.textFieldGrp(label = 'Department', adjustableColumn = 2, columnWidth = [1, 80], text = MusterSubmit.defaults['department']) self.widgets['pool'] = pm.optionMenuGrp(label = 'Pool', adjustableColumn = 2, columnWidth = [1, 80], cc = pm.Callback(self.savePoolOpt)) self.widgets['renderer'] = pm.optionMenuGrp(label = 'Renderer', adjustableColumn = 2, columnWidth = [1, 80], cc = pm.Callback(self.saveRendererOpt)) self.widgets['user'] = pm.optionMenuGrp(label = 'User', adjustableColumn = 2, columnWidth = [1, 80], cc = pm.Callback(self.saveUserOpt)) self.widgets['memPri'] = pm.rowLayout(parent = self.widgets['topRColumn'], numberOfColumns = 2, adjustableColumn2 = 1) self.widgets['memory'] = pm.intSliderGrp(parent = self.widgets['memPri'], label = 'Memory', columnWidth = [1,80], field = True, step = 512, value = 16384, maxValue = 65536, minValue = 512, w = 200) self.widgets['priority'] = pm.intFieldGrp(parent = self.widgets['memPri'], label = 'Priority', columnWidth = [1,50], value1 = self.priority) #top middle row self.widgets['topMRow'] = pm.rowLayout(parent = self.widgets['mainForm'], numberOfColumns = 6, adjustableColumn6 = 3) self.widgets['sep'] = pm.separator(style = "none", w = 15) self.widgets['allLayers'] = pm.checkBox(label = 'All Layers', w = 110, value = True, cc = pm.Callback(self.setAllRenderable)) self.widgets['postCopy'] = pm.checkBox(label = 'Post Copy', w = 100, value = True) self.widgets['byFrame'] = pm.intFieldGrp(label = 'By Frame', columnWidth = [1, 50], value1 = int(pm.SCENE.defaultRenderGlobals.byFrame.get())) self.widgets['padding'] = pm.intFieldGrp(label = 'Padding', columnWidth = [1, 50], value1 = int(pm.SCENE.defaultRenderGlobals.extensionPadding.get())) self.widgets['packet'] = pm.intFieldGrp(label = 'Packet', columnWidth = [1, 50], value1 = int(MusterSubmit.defaults['packet'])) #main layout self.widgets['scrollLayout'] = pm.scrollLayout(parent = self.widgets['mainForm'], childResizable = True) #bottom row self.widgets['bottomRow'] = pm.rowLayout(numberOfColumns = 3, parent = self.widgets['mainForm'], adjustableColumn = 1) self.widgets['progress'] = pm.progressBar(w = 300, progress = -1) self.widgets['paused'] = pm.checkBox(label = 'Paused', w = 60) self.widgets['Submit'] = pm.button(label = 'Submit', w = 150, c = pm.Callback(self.submit)) #form Layout self.widgets['mainForm'].attachForm(self.widgets['topLColumn'], 'top', 0) self.widgets['mainForm'].attachForm(self.widgets['topLColumn'], 'left', 0) self.widgets['mainForm'].attachNone(self.widgets['topLColumn'], 'bottom') self.widgets['mainForm'].attachPosition(self.widgets['topLColumn'], 'right', 0, 40) self.widgets['mainForm'].attachForm(self.widgets['topRColumn'], 'top', 0) self.widgets['mainForm'].attachControl(self.widgets['topRColumn'], 'left', 0, self.widgets['topLColumn']) self.widgets['mainForm'].attachNone(self.widgets['topRColumn'], 'bottom') self.widgets['mainForm'].attachForm(self.widgets['topRColumn'], 'right', 0) self.widgets['mainForm'].attachControl(self.widgets['topMRow'], 'top', 0, self.widgets['topRColumn']) self.widgets['mainForm'].attachForm(self.widgets['topMRow'], 'left', 0) self.widgets['mainForm'].attachNone(self.widgets['topMRow'], 'bottom') self.widgets['mainForm'].attachForm(self.widgets['topMRow'], 'right', 0) self.widgets['mainForm'].attachControl(self.widgets['scrollLayout'], 'top', 0, self.widgets['topMRow']) self.widgets['mainForm'].attachForm(self.widgets['scrollLayout'], 'left', 0) self.widgets['mainForm'].attachControl(self.widgets['scrollLayout'], 'bottom', 0, self.widgets['bottomRow']) self.widgets['mainForm'].attachForm(self.widgets['scrollLayout'], 'right', 0) self.widgets['mainForm'].attachNone(self.widgets['bottomRow'], 'top') self.widgets['mainForm'].attachForm(self.widgets['bottomRow'], 'left', 0) self.widgets['mainForm'].attachForm(self.widgets['bottomRow'], 'bottom', 0) self.widgets['mainForm'].attachForm(self.widgets['bottomRow'], 'right', 0) #end form layout self._populateUI() pm.scriptJob(uiDeleted = [self.widgets['mainWindow'].name(), pm.Callback(self.saveUI)]) #saves ui settings to optionVar pm.scriptJob(e = ['renderLayerChange', pm.Callback(self.updateLayers)], p = self.widgets['mainWindow'].name()) #reloads layers scroll when a layer is created or deleted #show created ui self.widgets['mainWindow'].show() self.getOptionVars()