@hunt.casey
Take a look at this example to get jumpstarted:
save_vals_example.toe (5.87 KB)
An execute DAT is used to save your knob values to a table when you save your project, and then to set those values to your knobs when you start-up your project. The exciting stuff happens in a the module “text_set_recall”.
[code]# here we declare some variables for reuse in both of our functions
knobs will be a list of operators that are containers that
have “knob” anywhere in their name
knobs = parent().findChildren(type=containerCOMP, name=“knob”)
this just cleans up our references for the table DAT that
holds our values
val_DAT = op(‘table_knob_vals’)
def Store_knob_vals():
# the job of this function will be to store the values of the knobs
# inside of a table DAT.
# first we need to clear out old results from our table, but
# we want to make sure we keep our header row
val_DAT.clear(keepFirstRow=True)
# next we loop through each knob and find the values for u and v
# these radial knobs are harder to get a value out of, but I think
# this should do the trick.
# our last step in this loop is to add our values to our table DAT
for each_knob in knobs:
slider1 = each_knob.op('slider1')
row_data = [slider1.path, slider1.panel.u, slider1.panel.v, slider1.op('out1')['v1']]
val_DAT.appendRow(row_data)
return
def Set_knob_vals():
# the job of this function will be to make sure our knobs are correctly
# set up when the project starts
# here we loop through each row of our table (excluding the first row)
# for each target we set the u an v values to make sure that our
# settings are faithfully restored.
for each_row in range(val_DAT.numRows)[1:]:
target = op(val_DAT[each_row, 'path'])
target.panel.u = val_DAT[each_row, 'u']
target.panel.v = val_DAT[each_row, 'v']
return[/code]
Two helper functions are used to save your knob values, and then set them.
Gotchas - this assumes that the word “knob” is in the name of the container COMP. This approach only works with the TUIK knobs, and would need to be adjusted if you wanted to use it for sliders or other kinds of UI pieces.
Hope this helps you get started.