sanostol Posted March 31, 2012 Share Posted March 31, 2012 (edited) I'm working on a asset that needs to be updated if the user adds a node inside it, but there is only a python function for this if the input has changed. is there another way to do this? another strang thing is that hou.pwd().children() gives me the child nodes, hou.pwd().parent() gives me NONE any ideas? Martin Edited March 31, 2012 by sanostol Quote Link to comment Share on other sites More sharing options...
symek Posted March 31, 2012 Share Posted March 31, 2012 (edited) Hi Martin, As to the first question, you could register an event callback with: hou.Node.addEventCallback(), so you can react on ChildCreated event among many others. Second issue sounds suspicious, is it a Obj HDA or SOP? From which place do you evaluate hou.pwd().parent()? It should work imho. Edited March 31, 2012 by SYmek Quote Link to comment Share on other sites More sharing options...
sanostol Posted April 1, 2012 Author Share Posted April 1, 2012 (edited) Hi SYmek, Hi Martin, As to the first question, you could register an event callback with: hou.Node.addEventCallback(), so you can react on ChildCreated event among many others. great I will try it, sounds very powerfull Second issue sounds suspicious, is it a Obj HDA or SOP? From which place do you evaluate hou.pwd().parent()? It should work imho. it is a subnetype for outputdrivers. mh, strange and I evaluate it as script in the hda module, like this hou.pwd().parent() thanks Martin Edited April 1, 2012 by sanostol Quote Link to comment Share on other sites More sharing options...
sanostol Posted April 1, 2012 Author Share Posted April 1, 2012 (edited) the eventCallback is very cool, but it does not show up anywhere, right? how can one inspect all types of events on a object? and they don't get saved to the assets or in the scene so I have to create them by a script everytme the asset is loaded I guess but for now it does it's job Edited April 1, 2012 by sanostol Quote Link to comment Share on other sites More sharing options...
symek Posted April 1, 2012 Share Posted April 1, 2012 Yes, I think you have to create event callbacks in On Created script. They are grouped as hou.nodeEventType.* As to hou.pwd().parent() it works in ROP subnet hdaModule in 12.0.581 here, which is strange as I thought it won't. There used to be a limitation for hou.pwd() only for parameters calls. Must had changed at some point... Quote Link to comment Share on other sites More sharing options...
sanostol Posted April 1, 2012 Author Share Posted April 1, 2012 (edited) As to hou.pwd().parent() it works in ROP subnet hdaModule in 12.0.581 here, which is strange as I thought it won't. There used to be a limitation for hou.pwd() only for parameters calls. Must had changed at some point... very strange, hou.pwd().parent() gives me a None on 12.0.581 , but anyway it would have been a workaround, the event method is much better thanks again for this Martin Edited April 1, 2012 by sanostol Quote Link to comment Share on other sites More sharing options...
rdg Posted April 1, 2012 Share Posted April 1, 2012 very strange, hou.pwd().parent() gives me a None on 12.0.581 Did you check what hou.pwd() in your case actually refers to? In many cases hou.pwd() is hou.node('/obj') or some other top level node. kwargs['node'] might be the one your looking for. But this is just a wild guess Quote Link to comment Share on other sites More sharing options...
symek Posted April 1, 2012 Share Posted April 1, 2012 Did you check what hou.pwd() in your case actually refers to? In many cases hou.pwd() is hou.node('/obj') or some other top level node. kwargs['node'] might be the one your looking for. But this is just a wild guess Georg has good intuitions (and wild!), but the parent of /rop/subnet is /rop and the parent of /rop is "/" which is also a node, and finally third parent in raw is None. Martin, did you look for a grand-grand-grand parent (because knowing our history, I'm telling you, he/she was Polish ). Quote Link to comment Share on other sites More sharing options...
graham Posted April 1, 2012 Share Posted April 1, 2012 (edited) I'm inclined to agree with Georg in that it something to do with how the code is called and what exactly you are doing. I should point out that using hou.pwd() inside a PythonModule is always a bad idea. Since the module is not tied to any particular instance of the node, you can get irregularities based on how things are called. If you could post an example file I'm sure it would be readily apparent what is going on. Edited April 1, 2012 by graham Quote Link to comment Share on other sites More sharing options...
graham Posted April 1, 2012 Share Posted April 1, 2012 (edited) Now that I have a moment, here's a bit more information/examples about how the current working director is set and what hou.pwd() will return in various instances. Normally, unless you change it, it tends to stay at the root node '/'. When evaluating event handlers such as OnInputChanged and OnNameChanged it will not change. In this case, it will generally be '/'. When running an OnCreated script, the cwd will point to the parent of where the node is created. For example, when creating a Geometry object under '/obj', hou.pwd() will return /obj. Inside of parameters or parameter callbacks, it will be changed to the node that parameters belong to. Since the majority of PythonModule use is usually for parameter callbacks, it's a fair bet that hou.pwd() inside a PythonModule will resolve to an instance of the node type the module belongs to. This also applies to the Pre/Post Render/Frame script parameters on ROP nodes. Inside of the PythonCook (Code tab) of a Python operator the cwd will resolve to the instance of the operator that is cooking. hou.pwd() in the PythonModule when invoked from thsi method will resolve to the operator instance. Node event callbacks will resolve to the cwd, not the node that has somehow changed. Edited April 1, 2012 by graham Quote Link to comment Share on other sites More sharing options...
sanostol Posted April 6, 2012 Author Share Posted April 6, 2012 I did a new run on this. the events give me dictionary object containing the node and the type of it. by picking up the node I can do .parent() without problem. maybe my problem was to try pwd from a event, a thing I think I forgot to mention Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.