Hi all,
I'm having trouble finding a way to make my HDA to run some code when I create a new instance of the tool..
I tried the onLoaded and onCreated but it seems they get ignored.
I also tried the tools/script … but it didn't work either.
I'm trying to change the asset's color in this case and I'd like to do it using python.
thanks in advance!
python script on Created
6518 6 1- VisualCortexLab
- Member
- 509 posts
- Joined: July 2005
- Offline
- graham
- Member
- 1906 posts
- Joined: Nov. 2006
- Offline
- VisualCortexLab
- Member
- 509 posts
- Joined: July 2005
- Offline
I'm using the HDA type properties->scripts->event handler page to write code into, not an external py file.
JcN
VisualCortexLab Ltd :: www.visualcortexlab.com
VisualCortexLab Ltd :: www.visualcortexlab.com
- graham
- Member
- 1906 posts
- Joined: Nov. 2006
- Offline
- VisualCortexLab
- Member
- 509 posts
- Joined: July 2005
- Offline
yep, houdini creates such sections when I select any of those..
and yeah sorry.. correct names are “OnLoaded” or “OnCreated” .. and set to python.
it seems I've found the problem.
in fact the code is working.. but its coloring “its parent” ..
if I run the following code:
node = hou.pwd()
color = hou.Color()
color.setRGB((0.4,0.2,0.6))
node.setColor(color)
in a SOP hda->OnCreated script, the containing OBJ will get such color.
isn't hou.pwd() supposed to be the SOPhda itself?
thanks!
and yeah sorry.. correct names are “OnLoaded” or “OnCreated” .. and set to python.
it seems I've found the problem.
in fact the code is working.. but its coloring “its parent” ..
if I run the following code:
node = hou.pwd()
color = hou.Color()
color.setRGB((0.4,0.2,0.6))
node.setColor(color)
in a SOP hda->OnCreated script, the containing OBJ will get such color.
isn't hou.pwd() supposed to be the SOPhda itself?
thanks!
JcN
VisualCortexLab Ltd :: www.visualcortexlab.com
VisualCortexLab Ltd :: www.visualcortexlab.com
- graham
- Member
- 1906 posts
- Joined: Nov. 2006
- Offline
- VisualCortexLab
- Member
- 509 posts
- Joined: July 2005
- Offline
graham
No. The parent has to create the node as a child, so pwd() will return it. You get the newly created node using kwargs
node = kwargs
node.setColor(hou.Color((1,0,0)))
ahh that's it! thanks a lot! exactly what I needed
I remember reading about that kwargs but I guess I need to investigate further more on that one.
thanks!
JcN
VisualCortexLab Ltd :: www.visualcortexlab.com
VisualCortexLab Ltd :: www.visualcortexlab.com
-
- Quick Links