Python Resources

Updated on Aug 4 2024

Python In Houdini Examples

Deborah R. Fowler



Python in Houdini Example - Phyllotaxis SOP

Posted July 8  2018
Updated July 12  2018


Phyllotactic Pattern - described here

Here the example is given in a python sop node. Similar to the point wrangle node, we can create the points for the phyllotactic pattern in code. This page includes some discussion about the creation of parameters as well.
Starting with a simple example the code would look like this:

MISSING IMAGEMISSING IMAGE
We have used a for loop in python and created a point using Houdini's geo.createPoint() as well as setting the position. Going one step further, we can create user-defined parameters rather than hard-coded values.
There are two methods to do this:
MISSING GIFMISSING IMAGE
This brings up a the parameter interface window where you can drag the type of parameter from the LHS to the RHS as seen in the gif. The parameter is then referenced - for example angle parameter would be node.parm("angle").eval()
This now give you the power to create nodes with gui.

Going one step further - making it a function

MISSING
        IMAGE



Using code for parameter creation in a python SOP:

In python scripting using code is straightforward to create parameters, however there was a small problem I ran into when creating with code in a SOP. Once created, the SOP errors as the parameter is already created. I have listed two solutions below:

MISSING
        IMAGE

MISSING IMAGE

Results from using this node:

While playing with phyllotaxis in python, adding some other houdini nodes I created "Calcium"