Search - User list
Full Version: Dynamic parm maxValue
Root » Technical Discussion » Dynamic parm maxValue
julien-b
Hi guys,

I'm building an interface for an OTL, and here is what I'm trying to do :

- I have a list base on a mutliparm tabs, which give me a number of entries in my list. They have their own set of parameters. All good so far.

- I have a separate integer parm, and I want to dynamically set its maxValue to the number of entries in my mutliparm list.

What would be the easiest way to get this working ?

I attached a mockup of the interface in a null node, so you can get the gist of it.

Thanks a lot,

Julien
dedeks2999
Attachment Not Found
julien-b
Hi,

Thanks for looking at it, but this is not what I'm looking for …
In your scene, the integer parm controls the number of entries in my multiparm, which is not what I'm after.
What I want to achieve is that if the multiparm has 4 entries, the integer parm (isolateLayerN) has its range from 1 to 4, if you add an entry in the multiparm, I want the range to be updated from 1 to 5 etc.

Hope this makes sense.

Thanks,

Julien
jsmack
You cannot dynamically update the range values. You can clamp the value where it is used instead. You could maybe rethink your approach. Perhaps use a radio tab based multiparm? This will give you an integer value that changes depending on which tab is current.
tamte
you can do it for spare parms, as in your example, using callback when modifying number of layers, that would change parm template of isolateLayerN parm
see example file(obviously you may need to make it more robust to avoid errors for 1-1 range etc)
layers = kwargs['parm']
node = layers.node()
ptg = node.parmTemplateGroup()
pt = ptg.find("isolateLayerN")
pt.setMinValue(1) # for 1 based multiparm
pt.setMaxValue(layers.eval())
pt.setMinIsStrict(1)
pt.setMaxIsStrict(1)
ptg.replace("isolateLayerN", pt)
node.setParmTemplateGroup(ptg)

but if you turn it into HDA you will not be able to modify template of HDA parms so you'd have to dynamically create/modify a Spare parm on top of HDA, similar process though, with the advantage of being able to define code in hdamodule instead of callback oneliner

EDIT: attached the file
julien-b
Thanks Tomas !

I believe you haven't put the file in attachment, would be great to see how you implemented the multiline script in the callback.
I indeed intend to change this into an hda, what would be the strategy here ?
Spare parameter wouldn't exist when I create a new node, right ? so I would have to create it when I create the node ?
And how would I link your code to the hda ?

Thanks again,

Julien
tamte
Sorry, seems like it didn't attach
Essentially instead of each newline separate commands with ;
I'll attach the file once I get home

And yes, for hda you'd have to create it during OnCreated callback and then simply edit the same way as here, with the difference that you can have the code in hdamodule in that case which is cleaner

But personally I'd avoid doing that as it's dangerous to have important parms as spares that are not part of hda

I'd rather add Isolate checkbox to each multiparm instance and let it's callback clear all other isilate checkboxes
tamte
here is the alternative I mentioned with isolate checkbox per instance and callback that turns others off
julien-b
Thanks Tomas,

It makes all sense, I thought about this before, but I didn't know my method would be not desirable.

Cheers,

Julien
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB