Skip to content

Instantly share code, notes, and snippets.

View bohdon's full-sized avatar

Bohdon Sayre bohdon

View GitHub Profile
@bohdon
bohdon / viewLayerAnim
Created June 15, 2011 00:20
cocos view layer animation
id seq = [CCSequence actions:[CCMoveTo actionWithDuration:0.0 position:ccp(249, 180)],
[CCMoveTo actionWithDuration:27.29 position:ccp(753, 180)],
[CCMoveTo actionWithDuration:1.5 position:ccp(774, 180)],
[CCMoveTo actionWithDuration:0.63 position:ccp(779, 180)],
[CCMoveTo actionWithDuration:0.71 position:ccp(783, 180)],
[CCMoveTo actionWithDuration:3.33 position:ccp(780, 180)],
[CCMoveTo actionWithDuration:1.46 position:ccp(778, 147)],
[CCMoveTo actionWithDuration:18.04 position:ccp(762, -876)],
[CCMoveTo actionWithDuration:1.63 position:ccp(761, -925)],
[CCMoveTo actionWithDuration:1.38 position:ccp(760, -940)],
@bohdon
bohdon / spaceSwitch.py
Created July 18, 2011 18:39
maya space switch transformation matrix
def switchDriver(node, index):
spaceA = node.getParent()
spaceB = getDriver(index)
deltaMatrix = getSpaceSwitch(spaceA, spaceB)
# change driver
node.driver.set(index)
node.translateSpace.set(deltaMatrix.getTranslation('world'))
newRot = deltaMatrix.getRotation()
newRot.setDisplayUnit('degrees')
node.rotateSpace.set(dt.Vector(newRot[0], newRot[1], newRot[2]))
@bohdon
bohdon / miStringOpts.py
Created August 31, 2011 17:18
setting mental ray string options
opts = SCENE.miDefaultOptions
key = 'ambient occlusion'
for item in opts.stringOptions:
if item.attr('name').get() == key:
item.value.set('true')
@bohdon
bohdon / hideNclothSolverDisplay.py
Created March 12, 2012 03:17
hide all ncloth solver displays
from pymel.core import *
for x in ls(type='nCloth'):
x.solverDisplay.set(0)
@bohdon
bohdon / badPymelNodes.py
Created April 11, 2012 19:54
bad node finder for pymel
from pymel.core import *
for x in cmds.ls(r=True, l=True):
try:
PyNode(x)
except Exception as e:
print('bad node {0}: {1}'.format(x, e))
@bohdon
bohdon / getPublishStruct.py
Created June 6, 2012 19:54
proarch and publish struct
import production
from mbotutils import proarchutils
from mbotutils import hourglassutils
proj = hourglassutils.getProject('diggs-game')
arch = proarchutils.getProjectArch(proj)
arch['assetType'].name = 'character'
arch['asset'].name = 'pig1'
arch['assetStep'].name = 'rig'
@bohdon
bohdon / assemblyFBXExport.py
Created January 14, 2013 15:24
exporting snippet
import os
from pymel.core import *
import exportUtils
reload(exportUtils)
# get rig/publish directory relative to mod/work
d = os.path.dirname
outDir = os.path.join(d(d(d(sceneName()))), 'rig/publish')
exportUtils.exportAssemblies(outDir, resetPositions=True)
@bohdon
bohdon / clusterCombinedGeometry.py
Last active December 19, 2015 15:58
cluster geometry shell by geo
import butterfly
from butterfly.attrs import LinkerAttr as A
def combineAndCluster(geo):
# combine the geometry
newGeo = pm.duplicate(geo)
combinedMesh = pm.polyUnite(newGeo, ch=False)[0]
# cluster the combined mesh
transforms = []
@bohdon
bohdon / getUnlinkedLights.py
Created October 30, 2013 20:43
find unlinked lights
import pymel.core as pm
def getUnlinkedLights():
linker = pm.selected()[0]
lonely = []
for i in range(linker.link.numElements()):
ln = linker.link[i]
lights = ln.light.inputs()
objects = ln.object.inputs()
if len(lights) and not len(objects):
@bohdon
bohdon / maya_show_file_in_explorer.py
Created February 11, 2019 21:40
Maya - Show File in Explorer
import pymel.core as pm
import subprocess
sceneName = pm.sceneName()
if sceneName:
sceneName = str(sceneName.parent).replace('/', '\\')
subprocess.call(['explorer.exe', sceneName])