nrusch Posted January 8, 2015 Share Posted January 8, 2015 Hey all, I've tried to do my best to dig up previous answers to this question, but so far I've been unsuccessful. What I'd like to do is set default values for some parameters on built-in node types. One good example is the 'vm_image_exr_compression' parameter on the Mantra ROP. Ideally, I would like to set these up in our site 123.py, since it's already being used for other things. I would have expected that the NodeType for the Mantra ROP would provide an interface for accomplishing this, but that doesn't seem to be the case. While I can get the ParmTemplate instances from the NodeType, only a small number are returned, and all of the sub-tabs under the Properties tab seem to be invisible to the template interface. Next, as an alternative solution, I was hoping to install some kind of an onCreate event callback for a NodeType, so that whenever a node of said type were created, I could run some code to set some of its parameter values. However, so far all I've found are the methods for installing callbacks on existing node instances... which doesn't really help me. However, this seems like the kind of thing that must be possible somehow, so I have a feeling I may be looking in the wrong places... So, all of this leaves me with a few questions: Is it possible to set parameter defaults at the NodeType level (NOT the Parm level) programmatically, say, when Houdini starts? If not, is it possible to install an onCreate callback for a NodeType, so that I can run code whenever a node that said type is created? If not, is what I'm trying to do even possible? I'd like to pull this off as concisely as possible, since my customizations live in a Mercurial repository. Thus, the preset system doesn't really feel like a great option unless I can hand-forge my own sparse preset files (that aren't > 35kb just to define 2 parameter defaults ) and force them to be applied at startup. Thanks for any insight here. Quote Link to comment Share on other sites More sharing options...
edward Posted January 8, 2015 Share Posted January 8, 2015 You can set up Node Initialization scripts so that when new nodes get created, the script runs to set the initial parameter values the way you like. Quote Link to comment Share on other sites More sharing options...
Sierra62 Posted January 8, 2015 Share Posted January 8, 2015 I would have a look at this tool to see if it close to what you are looking for. https://www.orbolt.com/asset/_heiligeslama::presetManagerSubnet Quote Link to comment Share on other sites More sharing options...
nrusch Posted January 8, 2015 Author Share Posted January 8, 2015 (edited) Thanks for the responses. The partial preset tool sounds interesting, but feels a little heavy-handed for the this type of problem, especially given how robust Houdini's Python API is in most areas. I'll certainly take a look at the GitHub repo to see if there are any tricks I can make use of though. Node initialization scripts look like they will allow me to do what I'm after... except that they don't seem to work. I have HOUDINI_PATH set to a series of directories, with the the <INSTALL>/houdini directory at the end. In one of the HOUDINI_PATH directories before the installation directory, I have created `scripts/obj/geo.py`. This script doesn't get executed when I create a Geometry node. Any idea what could be going on here? I must say I'm a little surprised there isn't a more elegant, contained way of installing creation event callbacks. Thanks Edited January 9, 2015 by nrusch Quote Link to comment Share on other sites More sharing options...
edward Posted January 9, 2015 Share Posted January 9, 2015 There's no such thing as a Geometry SOP. Do you mean Geometry OBJ ? Quote Link to comment Share on other sites More sharing options...
nrusch Posted January 9, 2015 Author Share Posted January 9, 2015 Yeah, sorry. Lots of things going on. Quote Link to comment Share on other sites More sharing options...
edward Posted January 10, 2015 Share Posted January 10, 2015 Did you try putting your directory after the default? Just taking a stab in the dark. Quote Link to comment Share on other sites More sharing options...
nrusch Posted January 10, 2015 Author Share Posted January 10, 2015 Yeah, that was one of the first things I tried. Still no dice. I guess maybe I should email support and find out if user initialization scripts are even supposed to work. The .cmd scripts in the install tree obviously work though, since that's how most of the output properties get added to things like Mantra ROPs. Quote Link to comment Share on other sites More sharing options...
edward Posted January 10, 2015 Share Posted January 10, 2015 Did you try using .cmd then? Quote Link to comment Share on other sites More sharing options...
nrusch Posted January 10, 2015 Author Share Posted January 10, 2015 Yup. Nothing. Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted January 13, 2015 Share Posted January 13, 2015 (edited) I guess maybe I should email support and find out if user initialization scripts are even supposed to work. Edward gave you an answer with a link to documentation, why do you want to email support? Must be there is something wrong with your HOUDINI_PATH, or *.py script itself. Try to put this script in $HOME/houdini13.0/scripts/obj/geo.py I must say I'm a little surprised there isn't a more elegant, contained way of installing creation event callbacks. "Elegant" is very subjective. There are other ways, but they much more complex, for example hou.ui.addEventLoopCallback(). Although, you still need 123.py or 456.py to setup this callbacks. Edited January 13, 2015 by Stalkerx777 1 Quote Link to comment Share on other sites More sharing options...
nrusch Posted January 13, 2015 Author Share Posted January 13, 2015 Edward gave you an answer with a link to documentation, why do you want to email support? Must be there is something wrong with your HOUDINI_PATH, or *.py script itself. Try to put this script in $HOME/houdini13.0/scripts/obj/geo.py I've already tried this as well, and it does nothing. I would hope that by emailing support, they would be able to tell me if the node initialization script system is actually supposed to work in this version (13.0.509), and if so, be able help me track down the issue or log it as a bug. Right now, the script is trying to print something to sys.__stdout__, as well as touch a file in /tmp. In other words, its only purpose right now is to try and confirm that it's actually running. Is there anyone that is using node initialization scripts and confirm that they do, in fact, work? "Elegant" is very subjective. There are other ways, but they much more complex, for example hou.ui.addEventLoopCallback(). Although, you still need 123.py or 456.py to setup this callbacks. There are many VFX-related packages with encapsulated event or callback systems that allow the registration of callables against various event names or callbacks. Houdini has a pretty robust Python API that has clearly had quite a bit of thought put into it, but it also contains some really strange gaping holes (for example, anything regarding Takes), and the lack of a formal callback system is another one of those. hou.ui.addEventLoopCallback would be a hacky way of trying to do what I want, and would introduce a lot of unnecessary overhead for very little gain. My callback handler would also have no information about what had changed since the last time it had run, so if I were trying to accomplish my original goal (set some parameters to alternate default values when a new node of a given type is created), it would have to query for all nodes of the desired type every time (in other words, "approximately every 50ms") and decide whether to set those parameter values. Quote Link to comment Share on other sites More sharing options...
pezetko Posted January 13, 2015 Share Posted January 13, 2015 $HOME/houdini13.0/scripts/obj/geo.pyWorks for me without any problem, with H13.0.376 and H13.0.571 Windows 7 x64.Those are lines in mine geo.py file and it got printed in Python Shell: print "hello" print kwargs['node'] Cheers Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted January 13, 2015 Share Posted January 13, 2015 Is there anyone that is using node initialization scripts and confirm that they do, in fact, work? I can. I wouldn't answer you question if i'm not sure. Have you try more recent build? and the lack of a formal callback system is another one of those..... hou.ui.addEventLoopCallback hou.Node.addEventCallback Event scripts for HDA Init scripts, mentioned before Quote Link to comment Share on other sites More sharing options...
nrusch Posted January 13, 2015 Author Share Posted January 13, 2015 OK thanks, it's good to know that they do actually work. I'll try to get a more recent build in here before emailing support. hou.ui.addEventLoopCallback hou.Node.addEventCallback Event scripts for HDA Init scripts, mentioned before Sorry, I didn't really flesh that thought out completely. A more accurate statement would have been "...the lack of a unified callback system is another one of those", and your list demonstrates that perfectly. Why is it that I can add a callback to a node instance (which does nothing for me in this case), but not to a NodeType? I'm not interested in arguing this point any further. Allowing callbacks to be registered at the NodeType level would be an improvement, period. Quote Link to comment Share on other sites More sharing options...
fathom Posted January 24, 2015 Share Posted January 24, 2015 could be the reason they don't let you adjust defaults on built-in types is that the defaults have to match the mantra defaults. SOHO ignores default values to save space (you don't want EVERY possible parm being passed along in an ifd). but if the default value is not what mantra is expecting, you can find yourself in a world of confusion. for example, if you change the default value for "allow motion blur" to be true, then SOHO would ignore that flag and never tell mantra to turn on motion blur. the only way to get SOHO to export that parm to mantra would be to turn it off, which of course would mean no motion blur in your render. so the toggle in houdini would be broken -- neither state would yield motion blur. Quote Link to comment Share on other sites More sharing options...
martinkindl83 Posted November 5, 2020 Share Posted November 5, 2020 On 1/14/2015 at 4:11 AM, pezetko said: $HOME/houdini13.0/scripts/obj/geo.py Works for me without any problem, with H13.0.376 and H13.0.571 Windows 7 x64. Those are lines in mine geo.py file and it got printed in Python Shell: print "hello" print kwargs['node'] Cheers H Peter. Does this still work in newer houdini versions? I have no problem use it for Arnold ROP (which has onCreate script that looks for those scripts), but i cant make it work for simple GEO node on OBJ level as you described. Wonder if something changed? Quote Link to comment Share on other sites More sharing options...
martinkindl83 Posted November 5, 2020 Share Posted November 5, 2020 And to answer my own question, yes it does work. Problem is that Arnold comes with their own geo.py script which was taking priority over mine. Quote Link to comment Share on other sites More sharing options...
martinkindl83 Posted November 9, 2020 Share Posted November 9, 2020 anyone would be able to help? I would like to have preset for the ar_light of example As im using arnold i already have Init scripts which came with Arnold install. I was not able to find a way how to run multiple init scripts. For obvious reasons i dont want to modify the Arnold OTLs to add onCreate presets. And hou.ui.addEventLoopCallback seems a bit overkill 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.