Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / msaor.py
Last active April 14, 2016 08:59
Maya: Set Attribute On Renderlayer
import pymel.core
drg = pymel.core.PyNode('defaultRenderGlobals')
# dict of attributes and values to set.
# needs to include node name as well.
# Note that time values are divided by the framerate, ei. 10 frame / 25 frame/sec = 0.4 sec
attrs = {'defaultRenderGlobals.startFrame': 0.4}
# iterate over the selected renderlayers.
@tokejepsen
tokejepsen / mgaor.py
Last active May 18, 2022 02:22
Maya: Get Attribute On Renderlayer
import pymel.core
drg = pymel.core.PyNode('defaultRenderGlobals')
# iterate over the selected renderlayers.
# can select renderlayers through the outliner with "Display" > "DAG Objects Only"
data = {}
render_cams = []
for layer in pymel.core.ls(selection=True, type='renderLayer'):
@tokejepsen
tokejepsen / mptt.py
Last active May 4, 2016 14:19
Maya: Pointcache to Transforms
"""
This script will try to convert a point cache to transform animation.
Create a set called "driven" with the transforms to get animated,
and create a set called "driver" with the single pointcache.
Tolerance is for how far the sample points should be from each other.
"""
import re
import os
@tokejepsen
tokejepsen / at.py
Created May 6, 2016 11:31
alembic testing
import os
import pymel.core as pm
pm.loadPlugin('AbcExport.mll', quiet=True)
pm.loadPlugin('AbcImport.mll', quiet=True)
root = r'L:\ethel_and_ernest_0001\sequences\q060\q060c005\fx\cache'
driven = pm.PyNode('driven').members()
re_sim = []
@tokejepsen
tokejepsen / ncp.txt
Last active July 8, 2016 14:17
Nuke: Card Placer
set cut_paste_input [stack 0]
version 9.0 v7
Camera2 {
inputs 0
translate {{curve x1 -32.95905358 -32.95814868 -32.95544124 -32.95094221 -32.9446625 -32.93661304 -32.92680475 -32.91524855 -32.90195538 -32.88693616 -32.87020179 -32.85176322 -32.83163137 -32.80981718 -32.78633153 -32.76118537 -32.73438966 -32.70595525 -32.67589311 -32.6442142 -32.61092936 -32.57604955 -32.53958576 -32.5015488 -32.46194971 -32.42079923 -32.37810854 -32.33388843 -32.2881497 -32.24090353 -32.19216073 -32.14193206 -32.09022874 -32.03706156 -31.98244127 -31.92637912 -31.86888588 -31.8099723 -31.74964964 -31.68792865 -31.62482009 -31.56033524 -31.49448484 -31.42727962 -31.3587309 -31.28884939 -31.21764584 -31.14513156 -31.07131706 -30.99621392 -30.91983219 -30.84218322 -30.7632784 -30.68312774 -30.60174263 -30.51913445 -30.43531319 -30.35029024 -30.26407702 -30.17668347 -30.08812101 -29.99840107 -29.90753356 -29.8155299 -29.72240157 -29.62815841 -29.53281188 -29.43637346 -29.33885297 -29.24026189 -29.14061171 -29.03991222 -28.93817
@tokejepsen
tokejepsen / nrc.py
Last active July 8, 2016 15:38
Nuke: related code
# limited random scaling
import nuke
import random
min_scale = 800
max_scale = 1600
for node in nuke.selectedNodes("Card2"):
scale = random.uniform(min_scale, max_scale)
node['uniform_scale'].setValue(scale)