Skip to content

Instantly share code, notes, and snippets.

@danbradham
danbradham / hotkeys.py
Last active November 22, 2022 08:06
Autodesk Maya hotkeys with Python
from __future__ import print_function
from collections import namedtuple
from maya import cmds
import pymel.core as pmc
from maya.utils import executeDeferred
from functools import wraps
KeySequence = namedtuple('KeySequence', 'ctrl shift alt key full')
@danbradham
danbradham / npapi.py
Last active March 9, 2016 20:30
Maya nParticle API
import functools
import maya.cmds as cmds
import maya.mel as mel
connect_dynamic = functools.partial(cmds.connectDynamic, delete=False)
disconnect_dynamic = functools.partial(cmds.connectDynamic, delete=True)
def chunk(fn):

While this started as a quick gist, I ended up developing it far enough to give it it's own repository and documentation.

Visit Shout's Repo!

@danbradham
danbradham / deploy.bat
Last active August 29, 2015 14:05
Deploy a package from a github repo, to a local or remote location.
@echo off
SET GIT_REPOS=\path\to\git_repos
SET REMOTE_ROOT=\\remote\deploy\location
SET LOCAL_ROOT=%USERPROFILE%\Documents\maya\2015-x64\scripts
if "%1"=="-h" ( GOTO :help_msg )
if "%1"=="--help" ( GOTO :help_msg )
if "%1"=="-l" ( GOTO :list_packs )
if "%1"=="--list" ( GOTO :list_packs )
@danbradham
danbradham / ftools.rst
Last active January 7, 2016 17:19
File/Folder Sequence Tools

This gist was improved and incorporated in a set of shell scripts called cgutils.

Visit the repo!

@danbradham
danbradham / mvp.rst
Last active January 7, 2016 17:12
MVP - Maya Viewport API

This gist turned into a full python packge!

Visit the repo!

@danbradham
danbradham / pythonmanager.py
Last active October 15, 2019 19:11
Python Manager
# -*- coding: utf-8 -*-
#! /usr/bin/env python
'''
Python Manager
==============
GUI tool for managing modules and packages based on reimport: Full featured reload for Python.
'''
import os
@danbradham
danbradham / templateformatters.py
Last active August 29, 2015 14:15
String formatters for converting standard pythong string templates to regex and glob patterns.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
template formatters
===================
``string.Formatter``s for converting standard pythong string templates to regex
and glob patterns. ``RegexFormatter`` formats to a regex pattern with named
groups perfect for use with ``re.search``. ``GlobFormatter`` formats to a glob
pattern that can be used with ``glob.glob``, ``fnmatch.fnmatch`` and
``fnmatch.filter``. ``format_regex`` and ``format_glob`` are instances of
@danbradham
danbradham / toolshed.py
Last active August 29, 2015 14:15
An arm rigging marathon.
'''
toolshed
========
Rigging tools for Autodesk Maya.
'''
from maya import cmds, OpenMaya
import maya.api.OpenMaya as mapi
import traceback
@danbradham
danbradham / stopwatch.py
Created February 16, 2015 13:48
Context manager for timing code execution.
import time
import sys
from contextlib import contextmanager
@contextmanager
def stopwatch(label, width=20):
'''
A context manager that prints out the execution time of the nested code.
'''