How to know the name the instance of the asset that OnCreated() is associated with?

   2470   4   1
User Avatar
Member
40 posts
Joined: Feb. 2016
Offline
Hi,

When I create a digital asset, I go to Scripts->OnCreated() method and write some python script to change some parameters in the newly created digital asset, HOWEVER, I don't know the name of the asset, hence I don't know the path to any node inside the digital asset? When I type hou.pwd(), I get “obj”…

Thanks,

Attachments:
onCreated.png (673.0 KB)
onCreated.hip (44.0 KB)

User Avatar
Member
1909 posts
Joined: Nov. 2006
Offline
You want to use the information stored inside the kwargs dictionary that is available in the OnCreated script. It will contain relevant information such as a hou.Node representing the actual node that was created.

Using hou.pwd() in any Script section is generally a bad idea since they are basically scripts/modules that have no guarantee of being run in an instance of the node like you expect.
Edited by graham - April 12, 2017 10:06:54
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
40 posts
Joined: Feb. 2016
Offline
Thanks Just another question, I could not find in the documentation the entire content of kwargs dictionary, I found some keys like ‘node’, ‘parm’, ‘old_name’ but I got these names after watching an online tutorial

My question: does the content of kwargs change with context? Is there is a central place to know its content in each context? I know ‘kwargs’ is a python thing but I totally new to python…

Thanks,
User Avatar
Member
1909 posts
Joined: Nov. 2006
Offline
They definitely vary depending upon the context. There's a list here:

http://www.sidefx.com/docs/houdini/hom/locations#python_event_handlers [sidefx.com]
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
40 posts
Joined: Feb. 2016
Offline
Thaaaaaaanks
  • Quick Links