Last active
March 5, 2021 12:38
-
-
Save hdlx/271eff183ab5400828a155a55b1692dc to your computer and use it in GitHub Desktop.
Maya get curve normal
This file contains hidden or 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 | |
#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) | |
res=mCurve.closestPoint(om.MPoint(om.MVector(pos)),space=om.MSpace.kWorld) | |
point=om.MVector(res[0]) | |
param=res[1] | |
n=mCurve.normal(param,space=om.MSpace.kWorld) | |
t=mCurve.tangent(param,space=om.MSpace.kWorld) | |
li=[n,t,point] | |
return li |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment