https://docs.python.org/2.7/library/logging.html https://docs.python.org/2.7/library/logging.config.html https://docs.python.org/2.7/whatsnew/2.7.html#pep-391-dictionary-based-configuration-for-logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
log = logging.getLogger() | |
handler = logging.StreamHandler() | |
formatter = logging.Formatter('%(levelname)s: %(message)s') | |
handler.setFormatter(formatter) | |
log.addHandler(handler) | |
log.setLevel(logging.INFO) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
from PyQt5 import QtWidgets | |
class QtModalOperator(bpy.types.Operator): | |
"""A base class for Operators that run a Qt interface.""" | |
def modal(self, context, event): | |
if self._app: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
import maya.OpenMaya as OpenMaya | |
import math | |
# Find if object located within camera frustum | |
# Usage: | |
# from obj_in_frust import in_frustum | |
# in_frustum('camera1', 'pCube1') | |
class Plane(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Convert camel-case to snake-case in python. | |
e.g.: CamelCase -> snake_case | |
Relevant StackOverflow question: http://stackoverflow.com/a/1176023/293064 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
def getAttributes(object): | |
attributes = cmds.listAttr(object) | |
for attribute in attributes: | |
try: | |
print attribute + ' = ' + str(cmds.getAttr(object + '.' + attribute)) | |
except: | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymel.core as pm | |
import sgtk | |
engine = sgtk.platform.current_engine() | |
pearlmaya = sgtk.platform.framework.load_framework(engine, engine.get_env(), 'tk-framework-pearl-maya_v0.x.x') | |
mayasession = pearlmaya.import_module('mayasession') | |
ctxWork = mayasession.MayaAssetWork() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.app.renderSetup.model.override as override | |
import maya.app.renderSetup.model.selector as selector | |
import maya.app.renderSetup.model.collection as collection | |
import maya.app.renderSetup.model.renderLayer as renderLayer | |
import maya.app.renderSetup.model.renderSetup as renderSetup | |
import maya.cmds as cmds | |
rs = renderSetup.instance() | |
defaultRenderLayer = rs.getDefaultRenderLayer() |
NewerOlder