def mayaEcho(self, message): PyMELcore.inViewMessage(assistMessage=message, position='botCenter', fade=True) print("REMBRAND ECHO: {}".format(message))
def onFinish(self): """ Called when the build has completely finished. """ # record time self.endTime = time.time() self.elapsedTime = self.endTime - self.startTime errorCount = len(self.errors) # log results logMsg = "Built Rig '{0}', {1:.3f} seconds, {2} error(s)".format( self.blueprint.rigName, self.elapsedTime, errorCount) lvl = logging.WARNING if errorCount else logging.INFO self.log.log(lvl, logMsg, extra=dict( duration=self.elapsedTime, scenePath=self.blueprintFile, )) self.fileHandler.close() # show results with in view message if errorCount: pm.inViewMessage( amg='Build Finished with {0} error(s)'.format(errorCount), pos='topCenter', backColor=0xaa8336, fade=True, fadeStayTime=3000) else: pm.inViewMessage(amg='Build Finished', pos='topCenter', fade=True)
def pointToLocator(): SelectVertex = pm.ls(selection=True) if not SelectVertex: pm.inViewMessage(amg='<hl>Select One Vertex </hl>.', pos='midCenter', fade=True) else: baseName = SelectVertex[0].name().split(".")[0] base = pm.PyNode(baseName) trans = base.getParent() toParent = trans.getAllParents()[-1] Locator = pm.spaceLocator(name=toParent + '_' + 'Light' + '_' + 'Locator') Locator.useOutlinerColor.set(1) Locator.outlinerColor.set(1, 1, .5) Locator.overrideEnabled.set(1) Locator.overrideVisibility.set(1) Locator.overrideColor.set(17) pm.parent(Locator, toParent) ##Select Vertex and Locator pm.select(SelectVertex, Locator, r=True) ##Apply Constraimt Pointconstraint = pm.pointOnPolyConstraint(SelectVertex, Locator, maintainOffset=False) pm.inViewMessage(amg='<hl>ConstraintDone </hl>.', pos='midCenter', fade=True)
def main(*args): # get the top one if not cmds.ls(sl=True): cmds.select(all=True) objs = pm.ls(sl=True, references=True) if not objs: return pm.inViewMessage(smg="select object first", pos="midCenterTop", bkc=0x00FF1010, fade=True) pm.select(clear=True) for obj in objs: parent_node = pm.listRelatives(obj, children=True, fullPath=True, allParents=True) if parent_node: final = get_top(obj)[0] else: final = obj file_path = pm.referenceQuery("%s" % final, filename=True) if file_path.startswith("T:"): new_version_file = file_path.replace("T:", "m:") cmds.file(new_version_file, loadReference="%s" % final, type="mayaAscii", options="v=0") pm.inViewMessage(smg="Update Done", pos="midCenterTop", bkc=0x00FF1010, fade=True)
def TransferUvs(): if len(pm.ls(selection=True)) < 2: pm.confirmDialog(message='Select Source and Select Targets', title='Warning', button='OK') else: Selection = pm.ls(selection=True) Source = Selection[0] Selection.pop(0) for object in Selection: pm.transferAttributes(Source, object, uvs=2, sampleSpace=4, sourceUvSpace="map1", targetUvSpace="map1", searchMethod=3, colorBorders=1) pm.select(clear=True) pm.inViewMessage(msg='<hl>Transfer_DONE</hl>.', pos='midCenter', fade=True)
def YetiCheckFur(): import pymel.core as pm '''Switch Frame and %04d for check .fur in render''' PgYeti = pm.ls(type="pgYetiMaya", selection=True, dag=True) SelectTransform = pm.ls(type="transform", selection=True) Basename = SelectTransform[0].name().split(".")[0] Gettime = pm.currentTime(query=True) SetTimeFLoat = '{0:04d}'.format(int(Gettime)) for Yeti in PgYeti: CurrentParent = Yeti.getParent() GetCache = CurrentParent.cacheFileName.get() SplitName = GetCache.split(".") if len(SplitName) >= 3: if SplitName[-2].isdigit(): SplitName[-2] = '%04d' NewFormat = ".".join(SplitName) CurrentParent.cacheFileName.set(NewFormat) pm.inViewMessage(amg="<hl>AnimationFur</hl> = %s" % ('Done'), pos='midCenter', fade=True) else: SplitName[-2] = (SetTimeFLoat) NewFormat = ".".join(SplitName) CurrentParent.cacheFileName.set(NewFormat) pm.inViewMessage(amg="<hl>SetFrame</hl> = %s" % (SetTimeFLoat), pos='midCenter', fade=True)
def clear_selection(self): if self.is_layer: display_layers = self.get_selected_display_layers() if not len(display_layers): pm.inViewMessage(message="No Display Late", pos='midCenter', fade=True, fadeOutTime=1500, fontSize=12, fadeStayTime=1250) for display_layer in display_layers: display_layer.color.set(True) display_layer.overrideRGBColors.set(False) return selection = pm.ls(selection=True) for item in selection: # type: pm.PyNode if self.is_object and item.hasAttr("overrideEnabled"): # TODO: do we turn this off? # how do we know the only change was made to the color # would be really helful to add a custom attribute # item.overrideEnabled.set(True) item.overrideRGBColors.set(False) if self.is_outliner and item.hasAttr("useOutlinerColor"): item.useOutlinerColor.set(False)
def YetiDisable(): if not pm.ls(type="pgYetiMaya"): pm.inViewMessage(amg='<hl>Not Fur in Scene</hl>.', pos='midCenter', fade=True) PgYeti = pm.ls(type="pgYetiMaya") for Yeti in PgYeti: CurrentParent = Yeti.getParent() CurrentParent.visibility.set(0) pm.inViewMessage(amg='<hl>Disable_YETI_RENDER</hl>.', pos='midCenter', fade=True)
def YetiEnableSelected(): PgYeti = pm.ls(type="pgYetiMaya", selection=True, dag=True) SelectTransform = pm.ls(type="transform", selection=True) Basename = SelectTransform[0].name().split(".")[0] for Yeti in PgYeti: CurrentParent = Yeti.getParent() CurrentParent.visibility.set(1) pm.inViewMessage(amg="<hl>Enable_YETI_RENDER</hl>_%s" % (Basename), pos='midCenter', fade=True)
def show_success_message(self, text): print "SUCCESS: %s" % text pm.inViewMessage(assistMessage=text, backColor=0x0021610B, fadeStayTime=6000, f=True, position="topCenter")
def TransferShaderFromScene(): botShader = copyShader() botShader.getMaterialsFromShading() pm.inViewMessage(amg='<hl>TransferShadersDone</hl>.', pos='midCenter', fade=True)
def RenderLayerShadow(): if not pm.objExists('Shadow_RL'): rs = renderSetup.instance() # Extract Name from Transform GetName = 'Shadow' # Extract Name LigtRig SelectionLights = pm.listRelatives(type='transform') for selection in SelectionLights: if selection.endswith('LIGHTRIG'): pass # Create and append the render layer RsRenderLayer = rs.createRenderLayer(GetName + '_' + 'RL') ColectionAll = RsRenderLayer.createCollection('Env' + '_' + GetName + '_' + 'COL') ColectionLightRig = RsRenderLayer.createCollection('LightRig' + '_' + GetName + '_' + 'COL') ColectionGeoMesh = RsRenderLayer.createCollection('Characters' + '_' + GetName + '_' + 'COL') ColectionCharacter = RsRenderLayer.createCollection( 'CharacterShadows' + '_' + GetName + '_' + 'COL') EnvOverride = ColectionAll.createOverride( 'EnvOverrideShadow', OpenMaya.MTypeId(0x58000386)) #---->ShaderOverride EnvOverridePy = pm.PyNode("EnvOverrideShadow") # ShaderEnvGrp= pm.sets(name= "Env_OverrideShadow_SG", empty=True, renderable=True, noSurfaceShader=True) ShaderShadow = pm.shadingNode('RedshiftMatteShadowCatcher', name="Env_OverrideShadow_SH", asShader=True) #Connect Shader to ShadingGroup # ShaderShadow.outColor >> ShaderEnvGrp.surfaceShader #Connect Material to OverrideRL ShaderShadow.outColor >> EnvOverridePy.attrValue ##Switch Create RenderLayer rs.switchToLayer(RsRenderLayer) pm.select(clear=True) ##Build Message Done pm.inViewMessage(amg='<hl>Shadow_RL_Done!!</hl>.', pos='midCenter', fade=True) else: pm.select('LightFx_RL') pm.inViewMessage(amg='<hl>Shadow_RenderLayer_Exist!!</hl>.', pos='midCenter', fade=True)
def DisableColor(): if not pm.ls(selection=True, dag=True): pm.inViewMessage(amg='<hl>Select Group !!</hl>.', pos='midCenter', fade=True) else: selection = pm.ls(selection=True) for grp in selection: grp.useOutlinerColor.set(0) grp.outlinerColor.set(0, 0, 0) pm.inViewMessage(amg='<hl>DisableOutlinerColor</hl>.', pos='midCenter', fade=True)
def TexturureRef(): SelectObject = pm.ls(selection=True) if not SelectObject: pm.inViewMessage(amg='<hl>Noting is Selected... Select GRP.!!</hl>.', pos='midCenter', fade=True) return if len(SelectObject) >= 1: for item in SelectObject: mel.eval('CreateTextureReferenceObject {0};'.format(item.name())) pm.inViewMessage(amg='<hl>TextureReference_Done!!</hl>.', pos='midCenter', fade=True)
def GeoSubdivision0(): GeoMeshSelection = pm.ls(type="mesh", selection=True, dag=True) if GeoMeshSelection: if len(GeoMeshSelection) >= 1: for geo in GeoMeshSelection: geo.rsEnableSubdivision.set(0) geo.rsMaxTessellationSubdivs.set(0) pm.inViewMessage(amg='<hl>No Subdivision!!</hl>.', pos='midCenter', fade=True) else: pm.inViewMessage(amg='<hl>Select GEOMESH!!</hl>.', pos='midCenter', fade=True)
def frame_change(self): frame = cmds.floatFieldGrp(self.frame, q=True, value=True)[0] expression_attention = False for proxy_node in self.current_selected_arStandIn: current_expression = cmds.listConnections(proxy_node, type="expression") if not current_expression: cmds.setAttr("%s.frameNumber" % proxy_node, frame) else: expression_attention = True if expression_attention: pm.inViewMessage(smg=u"有表达式连接在frame节点!!!!!!", pos="midCenterTop", bkc=0x00FF1010, fade=True)
def CastShadowsOn(): GeoMeshSelection = pm.ls(type="mesh", selection=True, dag=True) if GeoMeshSelection: if len(GeoMeshSelection) >= 1: for geo in GeoMeshSelection: geo.rsEnableVisibilityOverrides.set(1) geo.rsShadowCaster.set(1) pm.inViewMessage(amg='<hl>CastShadows ON !!</hl>.', pos='midCenter', fade=True) else: pm.inViewMessage(amg='<hl>Select GEOMESH!!</hl>.', pos='midCenter', fade=True)
def PrimaryVisibilityOn(): EnsurePorxyVis() GeoMeshSelection = pm.ls(type="mesh", selection=True, dag=True) if GeoMeshSelection: if len(GeoMeshSelection) >= 1: for geo in GeoMeshSelection: geo.rsEnableVisibilityOverrides.set(1) geo.rsPrimaryRayVisible.set(1) pm.inViewMessage(amg='<hl>PrimaryVisibility ON !!</hl>.', pos='midCenter', fade=True) else: pm.inViewMessage(amg='<hl>Select GEOMESH!!</hl>.', pos='midCenter', fade=True)
def ui(): global _globalQtObjects if pm.selected(): renameDialog = RenameDialog(utils.ui.getMayaWindow()) for obj in reversed(_globalQtObjects): _globalQtObjects.remove(obj) obj.close() renameDialog.show() renameDialog.raise_() _globalQtObjects.append(renameDialog) else: # It would be total overkill, but I'd love to implement my own # version of this, so it showed up in the same place the rename # window would have shown up. pm.inViewMessage(message='Nothing Selected', pos='topCenter', backColor=0x00111111, fade=1, fadeInTime=200, fadeStayTime=450, fadeOutTime=200, fontSize=11)
def ChangeColor(): selection = pm.ls(selection=True) if len(selection) == 0: pm.inViewMessage(amg='<hl>Select Grp !!!!! </hl>.', pos='midCenter', fade=True) else: Value = pm.colorEditor().split(' ') ok = Value[-1] ColorValue = pm.dt.Color(float(Value[1]), float(Value[3]), float(Value[5])) for grp in selection: grp.useOutlinerColor.set(1) grp.outlinerColor.set(ColorValue) pm.inViewMessage(amg='<hl>ChangeColors</hl>.', pos='midCenter', fade=True)
def DisplayGeomesh(): activeView = pm.getPanel(wf=True) ##Disable Item if pm.modelEditor(activeView, query=True, polymeshes=True) == 1: pm.modelEditor(activeView, edit=True, polymeshes=False) pm.warning("HideGeometry") pm.inViewMessage(amg='<hl>Hide_Geometry</hl>.', pos='midCenter', fade=True) else: ##Enable Item if pm.modelEditor(activeView, query=True, polymeshes=True) == 0: pm.modelEditor(activeView, edit=True, polymeshes=True) pm.warning("ShowGeometry") pm.inViewMessage(amg='<hl>Show_Geometry</hl>.', pos='midCenter', fade=True)
def RenderLayerFx(): if not pm.objExists('Fx_RL'): rs = renderSetup.instance() # Extract Name from Transform GetName = 'Fx' # Extract Name LigtRig SelectionLights = pm.listRelatives(type='transform') for selection in SelectionLights: if selection.endswith('LIGHTRIG'): pass # Create and append the render layer RsRenderLayer = rs.createRenderLayer(GetName + '_' + 'RL') ColectionEnvironment = RsRenderLayer.createCollection('Env' + '_' + GetName + '_' + 'COL') ColectionLightRig = RsRenderLayer.createCollection('LightRig' + '_' + GetName + '_' + 'COL') ColectionGeoMesh = RsRenderLayer.createCollection('Characters' + '_' + GetName + '_' + 'COL') ColectionFx = RsRenderLayer.createCollection('Fx' + '_' + GetName + '_' + 'COL') ##Append Colection # ColectionGeoMesh.getSelector().staticSelection.add(cmds.ls(Selection, long =True)) # ColectionLightRig.getSelector().setPattern(GetName + '_' + 'LIGHTRIG*') ##Switch Create RenderLayer rs.switchToLayer(RsRenderLayer) ##Build Message Done pm.inViewMessage(amg='<hl>Fx_RL_Done!!</hl>.', pos='midCenter', fade=True) else: pm.select('Fx_RL') pm.inViewMessage(amg='<hl>Fx_RL_Exist!!</hl>.', pos='midCenter', fade=True)
def set_enabled(self, value): global move_skinned_joints_enabled move_skinned_joints_enabled = value # Disable undo while we do this, so these commands don't create their own # undo chunk, which causes redoing to clear the redo queue. This is safe # since we'll explicitly handle undo in undoIt. with maya_helpers.without_undo(): # Note that there's no query for moveJointsMode. nodes = pm.ls(type='skinCluster') for node in nodes: pm.skinCluster(node, e=True, moveJointsMode=value) if value: pm.inViewMessage(statusMessage='Move skinned joints mode active', pos='botCenter') else: pm.inViewMessage(clear='botCenter') self.undoable = True
def _set_channel_edit_target(chn, edit=True): """Set the blendshape target of a channel editable or not editable Args: chn (PyNode): Attribute channel to edit edit (bool, optional): Set ON or OFF the channel edit status """ attrs = chn.listConnections(d=True, s=False, p=True) for a in attrs: if edit: pm.sculptTarget(a.node(), e=True, t=a.index()) pm.inViewMessage(amg="{}: Edit mode is ON".format(chn.name()), pos='midCenterBot', fade=True) else: a.node().inputTarget[a.index()].sculptTargetIndex.set(-1) pm.mel.eval("updateBlendShapeEditHUD;") pm.inViewMessage(amg="{}: Edit mode is OFF".format(chn.name()), pos='midCenterBot', fade=True)
def RenderLayerClean(): ok = WarningMessage("Deseas Borrar todos los render layers.") if ok: rs = renderSetup.instance() ##Move in Defatul RenderLayer pm.editRenderLayerGlobals(crl="defaultRenderLayer") rs.clearAll() RenderLayer = pm.ls(type='renderLayer') for layer in RenderLayer: if layer != 'defaultRenderLayer': pm.delete(layer) pm.inViewMessage(amg='<hl>RenderLayers!!!!Clean</hl>.', pos='midCenter', fade=True) else: pm.inViewMessage(amg='<hl>RenderLayer_Cancel</hl>.', pos='midCenter', fade=True)
def main(*args): # get the top one cmds.select(all=True) objs = pm.ls(sl=True) if not objs: return pm.inViewMessage(smg="select object first", pos="midCenterTop", bkc=0x00FF1010, fade=True) pm.select(clear=True) for obj in objs: parent_node = pm.listRelatives(obj, children=True, fullPath=True, allParents=True) if parent_node: final = get_top(obj)[0] else: final = obj ref_jud = pm.referenceQuery("%s" % final, isNodeReferenced=True) if ref_jud: try: file_path = pm.referenceQuery("%s" % final, filename=True) print file_path current_filename = os.path.splitext(os.path.basename(file_path))[0] file_dir = os.path.join(os.path.dirname(file_path).split("maya")[0], "maya") current_version = os.path.dirname(file_path).split("/")[-2] print file_dir, current_version version_list = [folder for folder in os.listdir(file_dir) if os.path.isdir(os.path.join(file_dir, folder)) and not folder.startswith(".")] print version_list version_max = max(version_list) print version_max if not version_max == current_version: print "update" new_version_dir = os.path.join(file_dir, version_max, "rig_maya") new_version_file = os.listdir(new_version_dir)[0] print new_version_file ref_name = current_filename + "RN" ref_file = os.path.join(new_version_dir, new_version_file) print ref_name, ref_file cmds.file(ref_file, loadReference=ref_name, type="mayaAscii", options="v=0") pm.inViewMessage(smg="Update Done", pos="midCenterTop", bkc=0x00FF1010, fade=True) return except: continue
def run(default_setting=arnold): pm.mel.eval('unifiedRenderGlobalsWindow') errolist = [] for setting_dic in default_setting.values(): for parm,value in setting_dic.items(): if not value==None: try: pm.setAttr(parm,value) print parm, value, type(value) except: errolist.append((parm,value)) continue current_path = pm.mel.eval("file -q -sn") filename = os.path.basename(current_path) render_name = os.path.splitext(filename)[0] rp_code = os.path.dirname(current_path).split("/")[-1] renderdir = os.path.join(os.path.dirname(current_path)[:-len(rp_code)], "render", render_name) renderpath = os.path.join(renderdir, render_name).replace("\\", "/").replace(":", ":/") pm.mel.eval('setAttr -type "string" defaultRenderGlobals.imageFilePrefix "%s"'% renderpath) if create_aov(): print errolist pm.inViewMessage(smg="Render Setting Done\nthe error list show on the script editor" % errolist, pos="midCenter", bkc=0x00FF1010, fade=True) return pm.inViewMessage(smg="aov created",pos="midCenterTop",bkc=0x00FF1060,fade=True) else: print errolist pm.inViewMessage(smg="Render Setting Done\nthe error list show on the script editor" % errolist, pos="midCenter", bkc=0x00FF1010, fade=True) return pm.inViewMessage(smg="aov-create failed", pos="midCenterTop", bkc=0x00FF1010, fade=True)
def CreateGroupCharacters(): selobj = pm.ls(selection=True) if len(selobj) >= 1: envGrp = None if pm.objExists('Characters'): envGrp = pm.PyNode('Characters') pm.inViewMessage(amg='<hl>Group_Characters_Done!!</hl>.', pos='midCenter', fade=True) else: envGrp = pm.group(empty=True, name='Characters') envGrp.useOutlinerColor.set(1) envGrp.outlinerColor.set(1, 0, 1) pm.inViewMessage(amg='<hl>Group Created!!</hl>.', pos='midCenter', fade=True) if envGrp: for item in selobj: pm.parent(item, envGrp) else: pm.inViewMessage(amg='<hl>Select_Grps!!</hl>.', pos='midCenter', fade=True)
def GeoBakeAnimation(): SelectionList = pm.ls(selection=True) if SelectionList: if len(SelectionList) >= 1: timeStart = pm.playbackOptions(q=True, animationStartTime=True) timeEnd = pm.playbackOptions(q=True, animationEndTime=True) BakeAnimation = pm.bakeResults( SelectionList, t=(timeStart, timeEnd), sampleBy=1, simulation=True, ) pm.select(clear=True) pm.inViewMessage(amg='<hl>BakeAnimtion_Done</hl>.', pos='midCenter', fade=True) print timeStart, timeEnd else: pm.inViewMessage(amg='<hl>Select Object for Bake</hl>.', pos='midCenter', fade=True)
def RedshiftRender(): pm.setAttr("defaultRenderGlobals.currentRenderer", "redshift", type="string") SetRenderEXR() SetAnimation() DisableDefaultLight() SetHDResolution() SetUnifiedSamples() CreatePipelineAOV() RenderCameraSetings() DisableCameraShake() FurShaderTransmisionDisable() pm.inViewMessage(amg='<hl>!!!! Redshift Render !!!!</hl>.', pos='midCenter', fade=True)
def CleanShadingDelivery(): """CheckSceneMaya""" """ Clean Maya File Maya Plugins """ import pymel.core as pm Delete = pm.delete(pm.ls(type="unknown")) plugins_list = pm.unknownPlugin(q=True, l=True) if plugins_list <= 0: print 'CleanScene' else: try: for plugin in plugins_list: print '---Delete Nodes---> ', (plugin) print '' pm.unknownPlugin(plugin, r=True) except: pass try: [ pm.lockNode('TurtleDefaultBakeLayer', lock=False) for node in pm.ls() ] pm.delete('TurtleDefaultBakeLayer') except: pass pm.inViewMessage(msg='<hl>CleanScene</hl>.', pos='midCenter', fade=True)