Jump to content

How to code Python the "correct" way in Houdini


sant0s81

Recommended Posts

Hey,

I am trying to find out, what the most elegant way to write Python in Houdini would be.

At the moment I always create an HDA and add a Python Modul.

Than there is the option, to save the code as a .py file.

And of course there is the Python SOP.

And what I see often, a DIY Python SOP (like creating a string with multiple lines and Python as language on a geometry).

But when does it make sense, to use what techniqe and what are the benefits?

Sry if that sound stupid, but in every tutorial there is another way.

Thanks,
sant0s :)

Edited by sant0s81
Link to comment
Share on other sites

10 hours ago, sant0s81 said:

But when does it make sense, to use what techniqe and what are the benefits?

10 hours ago, sant0s81 said:

I always create an HDA and add a Python Modul.

proper way if you need a node that needs some python, so you may want some internal module, of course you can always use external modules from python folder of your package or other scanned directories

if you don't need node or HDA, just something that execures the script, then you can create a Tool and either add it to shelf or just let it be called from Tab menu, same deal, you can use your external modules

 

10 hours ago, sant0s81 said:

And of course there is the Python SOP.

only for runtime stuff when you want python to be executed every time sop is dirtied and cooked, usually to modify geometry, but should not be used for business outside of modifying the current geo (like creating nodes, setting ui parameter values, etc...)

10 hours ago, sant0s81 said:

a DIY Python SOP (like creating a string with multiple lines and Python as language on a geometry).

quick way to prototype some code for testing without needing to have HDA and code in HDA module  and don't want to mess with tools, so quick and dirty self contained stuff, does not replace Python SOP though as it's not runtime, can modify geo stored in Data Parms though (as any method can)

also hip file session module can be used for prototyping and testing, just note that that is executed every time the scene is open

there is also Script SOP (and some specific DOP nodes), for executing certain stuff during cooking of that node

Edited by anim
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...