HDA Scripts: Reference Python File on Disk w/ Event Handler

   939   1   1
User Avatar
Member
131 posts
Joined: Sept. 2021
Offline
Hi! I have a Python file saved on disk:


When I switch the event handler to OnCreated (because I want the on-disk file to run when this node is created), it creates a new file instead of making it so my on-disk file is run when the node is created.



Is there a straightforward way to make a Python script stored on disk run when an HDA is created?

Thanks!
Anson

Attachments:
2023-08-25_11-14.png (217.1 KB)
2023-08-25_11-15.png (104.9 KB)

User Avatar
Member
22 posts
Joined: Dec. 2016
Offline
The simplest way is in the hda, in the onCreated.py like you have in your attachments above , is to simply import your script and run the method you want to run, you can pass kwargs to it if its setup to use it.

if you have a custom config folder setup in your `HOUDINI_PATH` you can setup an onCreated event for the node via:
https://www.sidefx.com/docs/houdini/hom/locations.html#startup [www.sidefx.com]

the example for : scripts/{category}/ nodename_eventtype.py

so if its a lop node called myNode, the path would be : scripts/lop/myNode_onCreated.py

however you cant have both, either the hda level or the having it in your `HOUDINI_PATH`, if you set it up as a script in the `HOUDINI_PATH` it will ignore the onCreated.py in the hda. I found that out recently

hope this helps.
kym
  • Quick Links