Skip to content

Instantly share code, notes, and snippets.

View RootsAndIvy.py
#F. Hiba, C. Mendes, B. Lefebvre, P. Hubert
import maya.api.OpenMaya as om
import maya.cmds as cmds
from math import radians, degrees, sin, cos
from random import gauss, random, uniform, shuffle
from copy import copy
#4 utilities function related to transformations
#give the quaternion corresponding to the rottion from vector 1 to vector 2
@hdlx
hdlx / getCurveNormal.py
Last active Aug 23, 2019
Maya get curve normal
View getCurveNormal.py
import maya.api.OpenMaya as om
import maya.cmds as cmds
#Returns normal, tangent, at a given point on a curve, given the curve and a position in space.
#result as a list of openmaya MVector()
def getCurveNormal(mayaCurve, pos=[0,0,0]):
selectionList = om.MSelectionList()
selectionList.add(mayaCurve)
dPath= selectionList.getDagPath(0)
mCurve=om.MFnNurbsCurve (dPath)
@hdlx
hdlx / getClosestVertex.py
Last active Aug 23, 2019
Maya get closest vertex
View getClosestVertex.py
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)
You can’t perform that action at this time.