Jump to content

Use Ordered Menu to Change Parameters in Tool


grafikzeug

Recommended Posts

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

 

happrentice_2019-12-09_22-34-12_SXk.png

Link to comment
Share on other sites

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

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

  • Like 1
  • Thanks 4
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by grafikzeug
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...