magneto Posted August 6, 2012 Share Posted August 6, 2012 Hi, I am not sure if this is possible, but I want to set an integer parameter to a calculated value from the UI, when a certain menu item is picked. So let's say the user picked "poly" from the Primitive Type menu, I want to set an integer field to ch("sx") for instance. Is this doable? Thanks Quote Link to comment Share on other sites More sharing options...
anim Posted August 6, 2012 Share Posted August 6, 2012 sure you can use parameter callback script to set that directly or usually if it's from your asset you can call some function from HDA Python module which will do something when that parameter is changed 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted August 6, 2012 Author Share Posted August 6, 2012 (edited) Thanks anim. I looked around but is there any example you know of? Edited August 6, 2012 by magneto Quote Link to comment Share on other sites More sharing options...
anim Posted August 6, 2012 Share Posted August 6, 2012 this may be helpful for you http://www.sidefx.com/docs/houdini12.0/hom/assetscripts as an example I don't remember a particular one, but with a little search here and on sidefx for "callback" you should get plenty of interesting posts or maybe if you specify more what you want I cam make the example 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted August 6, 2012 Author Share Posted August 6, 2012 Thanks anim, will check it out now. Basically I want to set a value of a numeric parameter, let's say when you select Primitive Type "poly", I want to set the height to 5. That sort of thing. But after that the user is free to adjust that parameter himself, so it's not locked but just set to an initial value for a particular option. Quote Link to comment Share on other sites More sharing options...
anim Posted August 6, 2012 Share Posted August 6, 2012 here is simple example simple_callback.hip 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted August 6, 2012 Author Share Posted August 6, 2012 (edited) Thanks anim, very useful example. I never used callbacks before so this is very helpful. EDIT: Although I tried to create it from scratch but getting this error: def __getattr__(*args): return _hou.HDAModule___getattr__(*args) AttributeError: 'module' object has no attribute 'setHeight' I am using setHeight like you both for the function name, and the callback function call in the parameter. Edited August 6, 2012 by magneto Quote Link to comment Share on other sites More sharing options...
anim Posted August 6, 2012 Share Posted August 6, 2012 it tells you that setHeight() function does not exist you need to define that function in your asset setHeight() is function I created in Scripts tab of the Asset, by creating Python Module and filled it with definition so you need to define your function there if you want to call it, or of course you can call any function declared anywhere else Quote Link to comment Share on other sites More sharing options...
magneto Posted August 6, 2012 Author Share Posted August 6, 2012 (edited) Yeah I saw that in your hip file, and added a function, but that's how I got the error. Let me see if I can create a simple test case. EDIT: I think I found the problem. It's because of namespaces. Does this change how the callback function should be used? hou.phm().setHeight(kwargs) Will be something else? Edited August 6, 2012 by magneto Quote Link to comment Share on other sites More sharing options...
anim Posted August 7, 2012 Share Posted August 7, 2012 it shouldn't be namespaces since hou.phm() should point to current nodes python module but you can try: kwargs['node'].hdaModule().setHeight(kwargs) or post your file so we can check it Quote Link to comment Share on other sites More sharing options...
magneto Posted August 7, 2012 Author Share Posted August 7, 2012 Thanks anim, you are right. Namespacing doesn't do it. I am not able to reproduce it. I will see if I can make something Quote Link to comment Share on other sites More sharing options...
magneto Posted August 7, 2012 Author Share Posted August 7, 2012 I found the problem, it was due to some error in the script, which Houdini showed an error message for not being able to find the function because it was failed to be defined. It might be because of maybe I sent the errors to the console and it only printed the last error or I missed it. But it works now. Thanks anim 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.