About Me

Sunday, April 3, 2011

Maya Bug: pointOnPolyConstraint

I was playing over the weekend and found a bug in the pointOnPolyConstraint code that ships with Maya2011, it doesn't support namespaces. Just to clarify, if you select a component, then a transform and use the 'constrain>point on poly' menuItem it'll fail on source objects with namespaces. The bug is in the Python code that assembles the command prior to passing it to the mel scope. Reading through this you have to query why the hell they build up the commands like this, built it in python, then pass a string back to mel to then run and eval on the string?? Why the hell not just run it from the python scope?

Anyway, the problem file is this one:

C:\Program Files\Autodesk\Maya 2011 Subscription Advantage Pack\Python\lib\site-packages\maya\app\general\pointOnPolyConstraint.py

Around line 18 there's a .split() to get the node name back, unfortunately in the constraint node that gets generated it doesn't support the nodes namespace in the attributes that get generated and the command fails. Easy to fix, open the file up and replace the following:

name = strings[0].split( '.' )[0]
#replace with the following
name = strings[0].split( '.' )[0].split(':')[-1]

Fixes it. Another one to log with support. Not yet tried it on Maya 2012 but I suspect the same will be the case