Pages

Friday, 17 December 2010

Blender/Houdini python API

I have just looked into Blender scripting API, which is all done in python, being curious... This is how Maya python API should look like, or similar. Just looking in the way how it`s all object oriented, easy getting information about the scene as we first get the scene object and then use scene object methods, and so on.. below is one simple example:

from Blender import Curve, Object, Scene
cu = Curve.New() # create new curve data
scn = Scene.GetCurrent() # get current scene
ob = scn.objects.new(cu) # make a new curve from the curve data

http://www.blender.org/documentation/249PythonDoc/

Then I thought I would look at Houdini as well, because it also uses python. And here is one example from it. Making a geometry object (not actual mesh) to create a poly cube and subdivide it:

>>> # Build a simple sop network.
>>> hou.hipFile.clear()
>>> geo = hou.node('/obj').createNode('geo')
>>> box = geo.createNode('box')
>>> subd = geo.createNode('subdivide')
>>> subd.parm('iterations').set(3)
>>> subd.setFirstInput(box)



Something for Autodesk to think about :) Especially because python is taking over and considerable time is spent by studios to build their script libraries for Maya. A proper implementation would help and make lot of code writing not needed. OpenSource codes like PyMel or MRV can help, but it`s only wrappers which add another layer (not supported by Autodesk) on top of main architecture made from MEL-to-python commands and SWIG binded C++ API. Also using this python Maya API in scripts doesn`t support undo.
After "first look" comparing, Blender and Houdini scripting API seems a lot better.

No comments: