2018-10-09

prPyMath.py making-of

A custom Maya node that can be found here:
https://github.com/parzival-roethlein/prmaya
Direct file link:
https://github.com/parzival-roethlein/prmaya/blob/master/prmaya/plugins/prPyMath.py

Origin
I wanted to create a node for some trigonometry functions, so I don't have to pollute the node graph with expressions. But after noticing that the functions I needed are all part of the Python math module I decided to just wrap the whole module, to make the node more useful.
There are only a few repeating argument in the whole module and all functions return one or two numbers. Which means there are also few Maya attributes needed to cover all cases.

Usability
A math node with that many operations is not typical for Maya.
When comparing such general purpose math nodes it might be better to just use a Python expression node like this one: http://around-the-corner.typepad.com/adn/2012/08/a-mathematical-dg-node.html

Code
It was the first time I used the Maya Python API 2.0 for an MPxNode. But in this simple case it did not make a big difference. For the Attribute Editor buttons "Create element", "Delete element" I had to look into querying the node in the Attribute Editor context for the first time. Currently it is a workaround with a hidden textfield. I guess a global MEL variable might be the proper way to handle that?!


No comments:

Post a Comment