Quickly store all parameters in expression mode to values in constant mode?

On a custom component, I want to be able to quickly convert all the values of the parameters in expression mode to values in constant mode. Basically, store the blue numbers to gray numbers. If I switch from expression to constant, it reverts to the value previously set in constant mode. I’ve been memorizing / copy-pasting the expression number into the constant value one-by-one as of now and wondering if there’s a better way.

Thank you for any advice. Ideally there would be native feature such as “store all expression values as constant”, but perhaps this is something I can script myself.

Hello,
You can iterate through all custom parameters with a python script, then evaluate them and set .val, something like this:

cPars = op('base1').customPars
for p in cPars:
	eVal = p.eval()
	p.val = eVal:

setting par.val will also put it into constant mode automatically, retaining the expression that was in expression mode if you were to go back to it, which you could do like this for all custom parameters on an op:


cPars = op('base1').customPars
for p in cPars:
	p.mode = ParMode.EXPRESSION

Hope that helps.

Cheers
P

2 Likes

This is the solution. Thank you kindly for the thorough reply and educating me on this useful python expression. I just want to add that the first bit of code only worked for me after removing the second colon, reading like so: