Jump to content

How to dynamically save and reapply any type of parm value in python


AiyaPK

Recommended Posts

I have several custom HDAs of different types, each with their own sets of parameters, some are simple string fields, some are toggles, some are menus, etc.
In these fields, the artists may opt to put in ints, floats, strings, or expressions.
I'm trying to cycle through each parameter, save the values, then reapply them again.
Expressions however are causing me some grief. By default, if I do parm.eval(), it will just resolve the value before saving it. However, I want to save and reapply the expression, not the resolved value.
I can use parm.rawValue() so that it just grabs whatever value is in the field, so even if the parameter holds say a string or a number, it should still work (toggles have a raw value of 'on' or 'off' which is a tad annoying).
Dynamically reapplying is what gets quite annoying....
parm.rawValue() gets the expression (lets say its something simple like opinputpath(".",0) )... but I need to use parm.setExpression() to properly set the parm as an expression and not just pasting the literal string of the expression, which won't behave like an expression should...
But of course parm.setExpression() can't just work on any parm... I can't use it on a toggle parm..... so I have to know ahead of time what kind of value I saved before I decide whether I use parm.setExpression() vs just a simple parm.set().
I would use parm.isShowingExpression(), but turns out that's not without its faults, because during the saving step, the parm with the expression could either be showing the expression itself (isShowingExpression() resolve to True), or the resolved value (isShowingExpression() resolves to False)....

Surely there has to be a simpler way to save and reapply parms that skips all this unnecessary logic?
I read about recipes, which saves all the parms to a file? I have not tried this, but I'm also unsure I want to be creating a file for every unique combination of data an artist has typed into the various parameters....
Am I missing some magical hom method here?...

 

Update: sorted. nvm...

Edited by AiyaPK
no longer needed
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...