I'm trying to change some String parameters in my UI based on the scene and variables, once, when the HDA is created.
Basically, these are editable fields, but with default values changed based on the scene.
Since these are supposed to be user-editable fields, I'm trying to avoid putting the Python code within the default field in the Parameter Editor itself, but instead automatically modify them from one of the Python Script Modules on creation.
But if I try to access the HDA UI params via the Python module OnCreate, I get NoneType errors. I assume because the OnCreate script triggers before the UI is initialized. I wonder if there's another way of doing this, or just not possible?
I tried OnLoaded, which doesn't seem to trigger at all on node creation, and I couldn't really find any more in-depth description of the different Event Handlers.
In short, can I set() or eval() the HDA UI parameters from the Python Module or Event Handlers, once, automatically when the HDA is created?
Python access HDA UI parm onCreate
580 4 2- Tronotrond
- Member
- 53 posts
- Joined: 7月 2017
- Offline
- AlexNardini1
- Member
- 46 posts
- Joined: 4月 2008
- Offline
Hello,
The case you are referring to is: preFirstCreate,
where the tool isn't created yet but you can use it to set some stuff.
The onCreate module should actually work, I am using it with success.
I usually create the python definitions inside the pythonModule and call them from the onCreate module like so:
The case you are referring to is: preFirstCreate,
where the tool isn't created yet but you can use it to set some stuff.
The onCreate module should actually work, I am using it with success.
I usually create the python definitions inside the pythonModule and call them from the onCreate module like so:
kwargs["node"].hdaModule().yourScriptName(...)
- Trono
- Member
- 4 posts
- Joined: 3月 2013
- Offline
AlexNardini1
Hello,
The case you are referring to is: preFirstCreate,
where the tool isn't created yet but you can use it to set some stuff.
The onCreate module should actually work, I am using it with success.
I usually create the python definitions inside the pythonModule and call them from the onCreate module like so:kwargs["node"].hdaModule().yourScriptName(...)
Interesting, I've done exactly that and I get "AttributeError: 'NoneType' object has no attribute 'set'"
Perhaps it's the way I call the node within the HoudiniModule function?
def TestFunction(): node = hou.pwd() ident = 'test' node.parm('identifier').set(ident)
But I can call the same function from a button press etc. without errors.
Edited by Trono - 2024年9月26日 17:03:48
- AlexNardini1
- Member
- 46 posts
- Joined: 4月 2008
- Offline
- Tronotrond
- Member
- 53 posts
- Joined: 7月 2017
- Offline
-
- Quick Links