Skip to content

Instantly share code, notes, and snippets.

@tin2tin
tin2tin / log.py
Created June 18, 2019 05:29 — forked from tamask/log.py
Route system output (stdout/stderr) of Blender to the app console (put in scripts/startup)
import os
import sys
import bpy
output = None
input = None
info = None
error = None
write = None
import maya.api.OpenMaya as om
import pymel.core as pm
def intersect_mesh(pos, vec, mesh_name):
selectionList = om.MSelectionList()
selectionList.add(mesh_name)
dagPath = selectionList.getDagPath(0)
fnMesh = om.MFnMesh(dagPath)
@SEVEZ
SEVEZ / getUvShells.py
Last active November 20, 2020 20:45 — forked from paulwinex/getUvShells.py
Get all UV shells from mesh object
import maya.OpenMaya as om
import maya.cmds as cmds
def getUvShelList(name):
selList = om.MSelectionList()
selList.add(name)
selListIter = om.MItSelectionList(selList, om.MFn.kMesh)
pathToShape = om.MDagPath()
selListIter.getDagPath(pathToShape)
meshNode = pathToShape.fullPathName()
@mooware
mooware / colorstreamhandler.py
Last active July 20, 2023 16:16
Colored log output for Python logging framework. Works on Windows, Linux, and probably Mac as well.
# colored stream handler for python logging framework (use the ColorStreamHandler class).
#
# based on:
# http://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output/1336640#1336640
# how to use:
# i used a dict-based logging configuration, not sure what else would work.
#
# import logging, logging.config, colorstreamhandler
#
@theodox
theodox / mayaPyManager.py
Last active January 17, 2023 09:50
Exposes the MayaPyManager class, which is used to run instances of MayaPy with explict control over paths and environment variables. A Manager can run scripts, modules, or command strings in a separate MayaPy environment; results and errors are captured and returned.
'''
Exposes the MayaPyManager class, which is used to run instances of MayaPy with explict control over paths and environment variables. A Manager can run scripts, modules, or command strings in a separate MayaPy environment; results and errors are captured and returned.
Typical uses might be:
- running unit tests
- running a copy of Maya.standalone as a headless RPC server with StandaloneRPC https://github.com/theodox/standaloneRPC
- spawning multipe copies of maya to batch process files in parallel on a multi-core machine
- do any of the above on multiple maya versions concurrently
@werediver
werediver / websse.py
Last active June 1, 2023 14:17
Simple demonstration of how to implement Server-sent events (SSE) in Python using Bottle micro web-framework. SSE require asynchronous request handling, but it's tricky with WSGI. One way to achieve that is to use gevent library as shown here.
"""
Simple demonstration of how to implement Server-sent events (SSE) in Python
using Bottle micro web-framework.
SSE require asynchronous request handling, but it's tricky with WSGI. One way
to achieve that is to use gevent library as shown here.
Usage: just start the script and open http://localhost:8080/ in your browser.
Based on: