Jump to content

Is it possible to set a parameter value when a certain menu item is ch


Recommended Posts

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 :)

Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by magneto
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by magneto
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...