MFnMesh.getClosestPoint using Maya Python API 2.0

david | maya,OpenMaya,python,tutorials | Tuesday, July 9th, 2013

Yesterday I wrote about my experiences with the OpenMaya modules for python in maya, and showed some code to get the closest vertex on a mesh from the position of a locator. Today I'm going to show the same code, rewritten to use the new Maya Python API 2.0, which, according to the intro in the manual, " is a new version of the Maya Python API which provides a more Pythonic workflow and improved performance." (more...)

get closest vertex in maya using python

david | maya,OpenMaya,python,tutorials | Sunday, July 7th, 2013

Recently I was writing a python function where I needed to find the mesh vertex closest to a locator. I already knew how to get a list of vertices from my mesh, how to get their worldspace locations and how to iterate through them calculating the distance between each one and the locator to determine the closest. But the brute force approach would have been pretty slow on a dense mesh.

I'm not very familiar with the OpenMaya classes, but I was pretty sure one of them would have a method that would make this task much faster, so I began to google the problem.

Here is what I found... and what I had to do to get it to work. Advanced coders will probably find this trivial, but I'm guessing there are others like me that will find it interesting. (more...)

Powered by WordPress | Based on a theme by Roy Tanck