Skip to content

Instantly share code, notes, and snippets.

@skttSnippet
skttSnippet / calculate_pole_vector.py
Created October 17, 2020 19:19 — forked from chris-lesage/calculate_pole_vector.py
Autodesk Maya script to calculate pole vector position based on 3 input objects
import pymel.core as pm
'''
An Autodesk Maya PyMEL script that calculates a pole vector position
based on 3 input PyNode objects. example: leg, knee, ankle bones.
Chris Lesage chris@rigmarolestudio.com
'''
def calculate_pole_vector(p1, p2, p3, poleDistance=1):
"""
@skttSnippet
skttSnippet / example_usage.py
Created October 17, 2020 19:19 — forked from chris-lesage/example_usage.py
A script to pin an object to a NurbsSurface in Autodesk Maya
import pymel.core as pm
'''
Here are some examples of how to use the pin_to_surface.py script.
'''
# make a nurbsPlane
oNurbs = pm.nurbsPlane(n='nurbsPlane1')
# You can specify the nurbsSurface by string, PyNode transform or PyNode shape.
# this is an example script how ngSkinTools can be automated
# to configure left-right influence mapping
# this example assumes that the scene has a skinned pPlane1
# which has ngSkinTools info already initialized. if not,
# see http://www.ngskintools.com/documentation/api/mll-interface.html
# for tips to how to do that programatically
# for this we use "manual mapping overrides" feature:
# the same where you can correct automatic associations by hand,
# only this time we choose to 'bake' the whole mapping using the
@skttSnippet
skttSnippet / ngSkinTools_import_without_ui.py
Created October 11, 2020 00:11 — forked from viktorasm/ngSkinTools_import_without_ui.py
Example of JSON import into ngSkinTools by skipping UI settings screen.
from ngSkinTools.importExport import JsonImporter
from ngSkinTools.influenceMapping import InfluenceMapping
from ngSkinTools.mllInterface import MllInterface
from ngSkinTools.ui.events import LayerEvents
from ngSkinTools.ui.layerDataModel import LayerDataModel
def ngSkinToolsImport(fileName, targetMesh):
'''
loads a JSON file (previously exported with ngSkinTools exporter) and loads data onto provided mesh.
@skttSnippet
skttSnippet / ngSkinTools_diagnostics.py
Created October 11, 2020 00:10 — forked from viktorasm/ngSkinTools_diagnostics.py
A little utility to run inside Maya's script editor (Python tab!) to troubleshoot ngSkinTools installation issues.
print "-------------------------------------------"
import sys
import os
from maya import cmds
print "Environment info:"
print "Maya version:", cmds.about(installedVersion=True)
print "Maya API version:", cmds.about(apiVersion=True)
print cmds.about(operatingSystem=True), cmds.about(operatingSystemVersion=True)
@skttSnippet
skttSnippet / test.py
Created October 11, 2020 00:10 — forked from viktorasm/test.py
A bug in Autodesk Maya API
"""
This is a test for Autodesk Maya to demonstrate that when skin cluster inputs are not transform nodes,
Maya simply crashes using MFnSkinCluster.setWeights() API call.
1. Run this script a few times to demonstrate that everything works as expected: you have a simple skinned mesh,
and you set weights for single joint, single vertex.
2. set "enable_bug_and_crash_maya" to True and rerun script - might need few reruns of the script.
Eventually, maya crashes.
"""
@skttSnippet
skttSnippet / benchmark.py
Created October 11, 2020 00:09 — forked from viktorasm/benchmark.py
Python equality test for old vs new objects
import cProfile
import pstats
from random import random
class SampleObject:
def __init__(self):
self.sample_data = random()
class SampleObjectNew(object):