Skip to content

Instantly share code, notes, and snippets.

View OmniZ3D's full-sized avatar

Jason Barnidge OmniZ3D

View GitHub Profile
@BigRoy
BigRoy / maya_get_visible_in_frame_range.py
Last active February 3, 2023 15:09
An optimized Maya function that returns the dag node names that are at least visible once on whole frames between requested start and end frame, this accounts for animated visibilities of the nodes and their parents.
import maya.api.OpenMaya as om2
import maya.cmds as mc
import contextlib
from colorbleed.maya.lib import iter_parents
@contextlib.contextmanager
def maintained_time():
ct = cmds.currentTime(query=True)
"""
A simple utility module for moving skinned joints.
"""
import math
import pymel.core as pmc
def reset_bind_matrix(joint):
"""
@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
@Meatplowz
Meatplowz / performFileDropAction.mel
Last active June 28, 2023 14:21
Override the Maya Drag and Drop Behavior for File Open/Import
// Randall Hess randall.hess@gmail.com
// Instructions: Copy this file over your local maya version to override the default behavior
// Maya 2022 and Higher
// Additional: You can also build and load this as a module and not overwrite the local maya file.
// Location: C:\Program Files\Autodesk\MayaXX\scripts\others\performFileDropAction.mel
global proc int
performFileDropAction (string $theFile)
@wmoten
wmoten / getproxydict.py
Last active December 3, 2023 06:22
Getting Maya Proxy Attributes
from maya import cmds, OpenMaya
from pprint import pprint
import os
def _getProxyAttributeCommands(cmdsnode):
#Takes a string of a maya object, like 'pshere1'
#checks for proxy attributes
#returns mel command to make that proxy attribute
proxyAttrCmds = []
selectionList = OpenMaya.MSelectionList()
@rondreas
rondreas / xformMirror.py
Last active June 8, 2021 21:49
Script to mirror transform similar to Maya's Joint Mirror Tool.
import pymel.core as pm
def xformMirror(transforms=[], across='YZ', behaviour=True):
""" Mirrors transform across hyperplane.
transforms -- list of Transform or string.
across -- plane which to mirror across.
behaviour -- bool
"""
@hdlx
hdlx / getClosestVertex.py
Last active September 21, 2023 08:19
Maya get closest vertex
import maya.api.OpenMaya as om
import maya.cmds as cmds
#returns the closest vertex given a mesh and a position [x,y,z] in world space.
#Uses om.MfnMesh.getClosestPoint() returned face ID and iterates through face's vertices.
def getClosestVertex(mayaMesh,pos=[0,0,0]):
mVector = om.MVector(pos)#using MVector type to represent position
selectionList = om.MSelectionList()
selectionList.add(mayaMesh)
dPath= selectionList.getDagPath(0)
@Meatplowz
Meatplowz / create_pivot_bone.py
Last active June 20, 2022 22:32
Create a joint based on the manipulator position and orientation
import maya.cmds as cmds
import pymel.core as pymel
def create_pivot_bone():
"""
Create a bone from the customPivot context
In component mode of a mesh:
Press "D" or "Insert" to go into custom pivot context
If you click on edges verts or faces the pivot will auto align
@OmniZ3D
OmniZ3D / FBX Wrapper.py
Created October 3, 2017 22:16 — forked from theodox/FBX Wrapper.py
FBXWrapper
'''
FBXWrapper
This module provides a python wrapper for every method exposed in the FBX plugin.
The arguments for the calls are the same as for the equivalent mel calls, however they can be passed with typical
python syntax, which is translated to mel-style flags and arguments under the hood. The actual flags and arguments
are documented here:
usage:
@vshotarov
vshotarov / controlShapeManagerFull.py
Last active May 21, 2023 11:50
An example control shape manager for Maya all contained in one file for demo purposes.
'''A simple example of a control shape manager in Maya contained in one file for easier access. It can be used for loading, saving, copying, etc. control shapes.
This file is used for demonstration purposes, to be followed along with in this blog post
http://bindpose.com/creating-maya-control-shape-manager
'''
import os
import json
import re