grafikzeug Posted December 9, 2019 Share Posted December 9, 2019 Hey folks, I have a simple subnet that I use to reduce the poly-count of incoming geometry. I have exposed some parameters and added the ordered menu "Level of Detail". I want to be able to use this dropdown menu as a list of presets to fill in the three values into the fields below. I then want to be able to adjust the values via the sliders. I'm sure there is a straightforward solution to this that I do not see. Thanks a bunch for your help, Felix Quote Link to comment Share on other sites More sharing options...
grafikzeug Posted December 9, 2019 Author Share Posted December 9, 2019 Here's what I've tried. Not very successful ... DropdownToChangeValues.hipnc Quote Link to comment Share on other sites More sharing options...
Drughi Posted December 10, 2019 Share Posted December 10, 2019 You will need a python script for this to work. Do you want to make a hda or keep it a subnet? Quote Link to comment Share on other sites More sharing options...
Drughi Posted December 10, 2019 Share Posted December 10, 2019 (edited) If you want to keep it a subnet. This is the way to go. DropdownToChangeValues_fix.hipnc In the sliders working geo Edited December 10, 2019 by Drughi 1 Quote Link to comment Share on other sites More sharing options...
grafikzeug Posted December 10, 2019 Author Share Posted December 10, 2019 (edited) Hej Johannes, vielen lieben Dank für deine Hilfe. Subset is fine. Your .hip does exactly what I need and gives me the opportunity to inspect how you did it. Out of curiosity: why is it that the hda "forgets" the python code? Much appreciated! Best, Felix Edited December 10, 2019 by grafikzeug Quote Link to comment Share on other sites More sharing options...
anim Posted December 10, 2019 Share Posted December 10, 2019 I'd suggest creating an HDA as then you can have the script self contained and easily update the code for all the instances if you decide to do so (to for example update list of presets, or even read presets from external file , etc...) parameter callback script: hou.phm().loadPreset(kwargs) HDA module: def loadPreset(kwargs): presets = [{ "voxelsize": 0.04, "voxeloffset": 1, "percentage": 50 }, { "voxelsize": 0.05, "voxeloffset": 1, "percentage": 30 }, { "voxelsize": 0.06, "voxeloffset": 1, "percentage": 10 } ] node = kwargs['node'] parm = kwargs['parm'] i = parm.eval() node.setParms(presets[i]) DropdownToChangeValues_hda.hipnc 1 4 Quote Link to comment Share on other sites More sharing options...
Drughi Posted December 10, 2019 Share Posted December 10, 2019 34 minutes ago, anim said: def loadPreset(kwargs): presets = [{ "voxelsize": 0.04, "voxeloffset": 1, "percentage": 50 }, { "voxelsize": 0.05, "voxeloffset": 1, "percentage": 30 }, { "voxelsize": 0.06, "voxeloffset": 1, "percentage": 10 } ] node = kwargs['node'] parm = kwargs['parm'] i = parm.eval() node.setParms(presets[i]) Ah, your right better to use a dictionary. 48 minutes ago, grafikzeug said: Out of curiosity: why is it that the hda "forgets" the python code? probably you need to add the script to the "code" paramterer defaults. But Tomas is right - better embed the code to a hda. The way I did it (this code parameter) is more of a hack to be able not to use a hda. Quote Link to comment Share on other sites More sharing options...
grafikzeug Posted December 10, 2019 Author Share Posted December 10, 2019 (edited) Hey there! Thank you Tomas, that looks very clean and direct though it sent my head spinning a lot, too. It's perfectly useable for me, even without knowing anything about callback functions and global dictonaries. I can basically just skip everything I don't understand for now and adjust the values as needed, so thanks a lot for your time! This will make my work much easier and save me lots of tedious repititions. Cheers! Edited December 10, 2019 by grafikzeug 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.