Jump to content
Sign in to follow this  
konstantin magnus

Plus button for dynamically adding parameters

Recommended Posts

I am currently creating a little HDRI studio inside COP land. The user should be enabled to freely add "light sources" (aka spots and rectangles on the image canvas).


How can I integrate a plus button in my parameter field? How can I duplicate parameters with it? Here is a mockup:



Instead of adding more and more nodes, I would like to fill up arrays holding all spot positions, light intensities etc.


Share this post

Link to post
Share on other sites


I think I would probably do it in Python, using PyQt, to have all the "dynamic" funcionnalities you want (adding fields etc.), and then create a script that takes all this info and creates the VOP COP node with all the proper children nodes and parameters within it

Share this post

Link to post
Share on other sites

Radical approach! ; )

I was rather expecting hints at parameter menu scripts, but rewriting the whole thing is of course another option.

Edited by konstantin magnus

Share this post

Link to post
Share on other sites

you can do it comfortably in vex since you can get parameter values using ch*("path/to/parm")

however COP VEX context is older and I don't see a way to define Evaluation node path like in Attrib VOP so you'll probably have to use absolute paths and for that you can use opfullpath('.')

the code will look something like this (careful, I added print just to test, don't use print on large images):

string op = opfullpath(".");
int lights = chi(op + "/lights");
for(int i=0; i<lights; i++){
    string si = itoa(i);
    vector spot_pos = chv(op + "/spot_pos" + si);
    float spot_size = chf(op + "/spot_size" + si);
    float spot_int = chf(op + "/spot_int" + si);
    vector spot_color = chv(op + "/spot_color" + si);
    printf("\nLight%d: pos: %g | size: %f | int: %f | color: %g ", i, spot_pos, spot_size, spot_int, spot_color);



  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this