Skip to content

Instantly share code, notes, and snippets.

@tokejepsen
tokejepsen / mct.py
Created March 31, 2016 10:27
Maya: Closest Transform
import pymel.core as pm
def ctr_dist(objA, objB):
Ax, Ay, Az = objA.getRotatePivot(space="world")
Bx, By, Bz = objB.getRotatePivot(space="world")
return ((Ax-Bx)**2 + (Ay-By)**2 + (Az-Bz)**2 )**0.5
def get_closest_node(src, nodes):
@tokejepsen
tokejepsen / gist:3446862668187d1e5550
Last active February 11, 2016 14:43
Nuke: Maya Fit Resolution Gate Vertical
Input this expression into the window scale u and v:
(root.format.w/root.format.h)/(haperture/vaperture)
Example:
set cut_paste_input [stack 0]
version 9.0 v7
push $cut_paste_input
Camera2 {
@tokejepsen
tokejepsen / mut.py
Created February 1, 2016 14:11
Maya: Unfreeze Transform
import pymel.core
for node in pymel.core.ls(selection=True):
grp1 = pymel.core.group(empty=True)
grp2 = pymel.core.group(empty=True)
pymel.core.delete(pymel.core.parentConstraint(node, grp1))
pymel.core.delete(pymel.core.parentConstraint(node, grp2))
pymel.core.parent(node, grp1)
@tokejepsen
tokejepsen / mrrr.py
Created January 8, 2016 17:09
mixamo rig reference replacement
import os
import pymel.core
def replaceReference():
basicFilter = "*.mb"
f = pymel.core.fileDialog2(fileFilter=basicFilter, dialogStyle=1, fileMode=1)
if not f:
@tokejepsen
tokejepsen / mia.py
Created December 17, 2015 10:12
Mixamo Import Animation
import traceback
import pymel.core
import maya.mel
def importAnim():
sel = pymel.core.ls(selection=True)
@tokejepsen
tokejepsen / matte_renderlayers.py
Last active December 8, 2015 11:05
Maya: Matte from Materials
"""
Select the geometry to make the renderlayers from.
Will find all the materials (lambert), make a renderlayer per material only showing that material.
"""
import traceback
import pymel.core
selection = pymel.core.ls(selection=True)
@tokejepsen
tokejepsen / batch_edit.py
Last active April 23, 2020 22:16
Nuke: Batch Edit Tool
import os
import difflib
import nuke
import nukescripts
class KnobsPanel(nukescripts.PythonPanel):
def __init__(self, knobs):
nukescripts.PythonPanel.__init__(self, 'KnobsPanel')
@tokejepsen
tokejepsen / select_alembic.py
Created November 11, 2015 11:32
Nuke: select alembic item by name
import nuke
items = ['polySurfaceShape15']
node = nuke.selectedNode()
scene_view = node['scene_view']
scene_view.setSelectedItems([])
selection = []
for item in scene_view.getAllItems():
for split in item.split('/'):
@tokejepsen
tokejepsen / mht.py
Last active July 11, 2016 08:25
Maya: Highlight Tool
import pymel
import traceback
def place_highlight(cam, obj):
""" Creates a highlight rig for placing highlights on an object
"""
parent_loc = pymel.core.spaceLocator()
up_vector = pymel.core.spaceLocator()
aim_loc = pymel.core.spaceLocator()
@tokejepsen
tokejepsen / matte_tool.py
Last active October 12, 2015 08:42
Maya: Matte Tool
import sys
import maya.cmds as cmds
import pymel
import pymel.core
from PySide import QtGui
class Example(QtGui.QWidget):