This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Functions for generating spline weights. | |
Usage: | |
This modules functions each take curve parameters and output control point weights. The weights are generated using | |
a modified version of de Boor's algorithm. These weights can be used to create a weighted sum to find a point or | |
tangent on a spline. | |
While these functions are written for usage in Autodesk Maya, they don't actually have any Maya-specific libraries. | |
Additionally none of these functions actually care about the data type of provided control points. This way these |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""When using maya.cmds.listRelatives with allDescendents=True it will only return the first instanced child. | |
Below are some example functions that correctly return all instanced children where they are "somewhat" optimized to rapidly return a result as opposed to slow recursive queries. | |
""" | |
import maya.api.OpenMaya as om | |
from maya import cmds | |
import time | |
import re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Snap multiple objects by vertex index to target vertex. | |
1. Select all objects you want to snap | |
2. Add the target vertex to your selection. | |
3. Run script | |
Make sure each object has the same topological order because | |
this just simply snaps the same vertex number of each object | |
to the selected target vertex. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.api.OpenMaya as om | |
import maya.cmds | |
import time | |
def is_normal_reversed(poly, mesh): | |
""" | |
Check the normal faces in or out of the model by doing a simple ray cast and | |
count results. Evens face out, odds face in. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.OpenMaya as OpenMaya | |
import pymel.core as pm | |
import maya.OpenMayaAnim as OpenMayaAnim | |
import maya.cmds as cmds | |
import maya.mel as mel | |
class checkMaxSkinInfluences(object): | |
''' This script takes a mesh with a skinCluster and checks it for N skin weights. | |
If it has more than N, it selects the verts, so you can edit them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fit(self): | |
self.centroids, self.std_list = kmeans(self.X, self.k, max_iters=1000) | |
if not self.std_from_clusters: | |
dMax = np.max([get_distance(c1, c2) for c1 in self.centroids for c2 in self.centroids]) | |
self.std_list = np.repeat(dMax / np.sqrt(2 * self.k), self.k) | |
RBF_X = self.rbf_list(self.X, self.centroids, self.std_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RBF: | |
def __init__(self, X, y, tX, ty, num_of_classes, | |
k, std_from_clusters=True): | |
self.X = X | |
self.y = y | |
self.tX = tX | |
self.ty = ty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def get_distance(x1, x2): | |
sum = 0 | |
for i in range(len(x1)): | |
sum += (x1[i] - x2[i]) ** 2 | |
return np.sqrt(sum) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.api.OpenMaya as om | |
import maya.cmds as cmds | |
TRANSFORM_NODETYPES = ["transform", "joint"] | |
def has_non_default_locked_attributes(node): | |
locked_attributes = [] | |
for attribute in ["translate", "rotate", "scale", "jointOrient"]: | |
default_value = 1 if attribute == "scale" else 0 | |
for axis in "XYZ": |
NewerOlder