Jump to content
Sign in to follow this  
pelos

how.pwd() on created otl

Recommended Posts

i am doing an otl and i want to get its path when i put down the node to grab some parms.

the idea is once its been drop in the network editor, will read if there is a camera node, if there is one, put that camera in the otl path parm.

in the script tab i am doing a "on created"

i am doing print hou.pwd() but once i TAB select the otl and drop it, it print "obj" and not the actual node.

if i put a spare parm button that print hou.pwd() it does print the node correctly.

is there something special on created that i need to know? or a diferent type of code?

Thanks guys.

Share this post


Link to post
Share on other sites

hou.pwd() will return the location in which the new node will be a child of. In the OnCreated handler you can get the new node using the kwargs dictionary :

node = kwargs["node"]

Share this post


Link to post
Share on other sites

using kwargs[] is preferred way to get this kind of data and you should use it every time it is available to avoid problems in the future, especially in nested digital asset where pwd() will not always be what you think is should

Share this post


Link to post
Share on other sites

here is some read on that subject

http://www.sidefx.com/docs/houdini12.1/hom/assetscripts#parameter_callback_scripts

and even though they say, "Using hou.pwd, or hou.node('.'), is also a valid way to access the PythonModule section, since Houdini changes the current node to the HDA instance when it invokes a parameter callback." I had problems in the past when calling hou.pwd() from within the callback function for nested assets. When nested asset had button with such callback script and that button was linked to parent asset button, the hou.pwd() returned parent asset rather than nested asset, since parent asset was still current, not sure if this is the case nowadays since from that point I tend to use kwargs dictionary

Share this post


Link to post
Share on other sites
Posted (edited)

UPDATE. kwargs['node'] is actually accepted inside a onLoaded event handler. I don't know why it was not working when I tried it the first time..
However it's not mentioned in the documentation of Hou17.

-------

What's the reason for the 'node' key not being accepted in a onLoaded event handler script?
http://www.sidefx.com/docs/houdini/hom/locations.html#node_event_kwargs

I need to know what is the instance of the digital asset in the onLoaded script.
If do something like hou.pwd() it would return "/"

Edited by Andr1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×