Skip to content

Instantly share code, notes, and snippets.

@OmniZ3D
OmniZ3D / changeMoBuTxtrs.py
Created August 24, 2012 20:12
Example for changing / repathing texture files in MotionBuilder via python
from pyfbsdk import *
for v in FBSystem().Scene.VideoClips:
print v.Filename
v.Filename = r'C:\someDir\txtrFile.tga'
@dgovil
dgovil / dgCameraDisplayFilter.py
Created April 11, 2014 18:59
Snippet to go through all the cameras, turn off joints and IK handles, and only show curves in the default cameras
import maya.cmds as mc
panels = mc.getPanel(typ='modelPanel')
for pan in panels:
cam = mc.modelPanel(pan, q=1, camera=1)
startup = mc.camera(cam, q=1, sc=1)
mc.modelEditor(pan, e=1, joints=0, nurbsCurves=startup, ikHandles=0)
@jirihnidek
jirihnidek / b3d_prop_callbacks.py
Created March 19, 2015 11:27
Blender property and callbacks
"""
Example of callbacks used for Blender integer property
"""
import bpy
# Some global values
values = {}
default_value = -1
@EricTRocks
EricTRocks / UpdateJointBindPose.py
Created July 21, 2016 00:24
Updates selected Maya joint's bind pose Credit to Ryan Porter (yantor3d)
# Credit to Ryan Porter (yantor3d)
from maya import cmds
for jnt in cmds.ls(sl=True, type="joint"):
matrixPlugs = cmds.listConnections(jnt + ".worldMatrix", type="skinCluster", p=True) or []
for mp in matrixPlugs:
bindPreMatrixPlug = mp.replace('matrix', 'bindPreMatrix')
if cmds.listConnections(bindPreMatrixPlug, s=True, d=False):
@cyaoeu
cyaoeu / fbx_batchexport_anims.py
Created August 29, 2017 17:57
Blender script: batch export anims
import bpy
path = bpy.path.abspath('//') #path of .blend
objname = bpy.context.active_object.name #select rig
singleanim = True
if singleanim == True:
action = bpy.context.active_object.animation_data.action
from pyfbsdk import FBSystem, FBNamespaceAction, FBPlugModificationFlag
def DeleteNameSpace(namespace):
FBSystem().Scene.NamespaceDeleteContent(namespace, FBPlugModificationFlag.kFBPlugAllContent, True)
def AddNamespace(components, namespace):
for comp in components:
comp.ProcessObjectNamespace(FBNamespaceAction.kFBConcatNamespace, namespace)
def SafeDeleteList(components):
@defTechAndrew
defTechAndrew / fbx_animation_editing.py
Created April 1, 2019 22:01
Here are some useful calls I've developed for editing FBX animation files using the Python FBX SDK.
import FbxCommon
def fbx_trim_keys(scene, start, end, take_buffer=10):
"""
Uses the FBX SDK to remove unnecessary keys.
:param scene: FBX SDK scene class that hold data to edit
:param int start: start frame of animation keys to keep
:param int end: end frame of animation keys to keep
@chris-lesage
chris-lesage / removeUnusedInfluences.py
Last active July 18, 2024 05:05
Snippet to removeUnusedInfluences in Autodesk Maya using Python.
import maya.cmds as cmds
'''
# EXAMPLE USAGES:
# Removes all unused influences from skinCluster1
remove_unused_influences('skinCluster1')
# Removes the two specified joints from Body_SkinCluster,
but only if they are not currently weighted to anything.
remove_unused_influences('Body_SkinCluster', ['leg_L0_5_jnt', 'leg_R0_5_jnt'])
@chris-lesage
chris-lesage / build_slerp_ramp.py
Last active September 19, 2023 03:26
Fake a multi-output lerp/slerp ramp in Autodesk Maya using remapValue nodes. Useful for twisting or interpolating objects and attributes.
import pymel.core as pm
"""
Take a collection of attributes and interpolate them along a curve.
It uses a master remapValue that drives multiple remapValues
to simulate the effect of a multi-out curve node.
References to "twist", because it was originally written for twisting ribbon IK
But it can interpolate any custom attributes you wish
Written by Chris Lesage, June 2019
@zewt
zewt / gist:73bd5f83927f3ccf20c32cf0440120a4
Created August 19, 2020 06:14
Reset bind position to joint position
# Public domain
from pymel import core as pm
import re
def resetJointOnCluster(joint, skinClusterPreMatrixPlug):
inverseMatrix = joint.attr('worldInverseMatrix').get()
curMatrix = skinClusterPreMatrixPlug.get()
if curMatrix is not None:
different = any(abs(a-b) > 0.00001 for a, b in zip(inverseMatrix, curMatrix))