Rigging Mentor
Stay tuned for more info...
Labels: maya, programming, python, scripting
import maya.OpenMaya as om
import maya.cmds as mc
# input curve
# input point
# output param
# output point
def jc_closestPointOnCurve(location, curveObject):
curve = curveObject
# put curve into the MObject
tempList = om.MSelectionList()
tempList.add(curve)
curveObj = om.MObject()
tempList.getDependNode(0, curveObj) # puts the 0 index of tempList's depend node into curveObj
# get the dagpath of the object
dagpath = om.MDagPath()
tempList.getDagPath(0, dagpath)
# define the curve object as type MFnNurbsCurve
curveMF = om.MFnNurbsCurve(dagpath)
# what's the input point (in world)
point = om.MPoint( location[0], location[1], location[2])
# define the parameter as a double * (pointer)
prm = om.MScriptUtil()
pointer = prm.asDoublePtr()
om.MScriptUtil.setDouble (pointer, 0.0)
# set tolerance
tolerance = .00000001
# set the object space
space = om.MSpace.kObject
# result will be the worldspace point
result = om.MPoint()
result = curveMF.closestPoint (point, pointer, 0.0, space)
position = [(result.x), (result.y), (result.z)]
curvePoint = om.MPoint ((result.x), (result.y), (result.z))
# creates a locator at the position
mc.spaceLocator (p=(position[0], position[1], position[2]))
parameter = om.MScriptUtil.getDouble (pointer)
# just return - parameter, then world space coord.
return [parameter, (result.x), (result.y), (result.z)]
Labels: maya, programming, python
I’m a little late, but Happy New Year anyway!
There’s so much to update since it’s been awhile, that I can’t remember any of it. The past month or so I’ve been mostly working on improving our rigging tools and workflows, while doing some rigging on small projects here and there. It’s crazy how fast your workflow can get once you have a chance to sit down and really think about what would make your job easier. I’ll have to make some screen captures of some of the goodies I’ve made lately to give everyone an idea of what I’m talking about.
So just this week I started to dive into Python a bit, starting with converting one of the tools I’ve written recently over from mel to python. Justin at work has been helping me out with getting the mel to python translations straight in my head, and that has helped a ton. I gotta say, already I’m impressed with python. It is really easy to get into, easy to understand, and already I see a speed improvement between the mel version of the script vs the python version.
Hopefully I’ll keep getting the free moments here and there to continue improving our rigging tools, because the more our tools improve, the faster we can work, which means the more free time we’ll have to make even cooler stuff. Already I’m noticing the effects of this, since I can now whip tasks out even faster and get back to my tool dev.
So, 2009. I think this will be the year that I can spend some time reorganizing my website (a lot of links have been broken for awhile), and definitely the year to start/finish/unveil some projects that have been cooking. And definitely the year to stick to updating my blog on a regular basis :)