Last active
May 7, 2019 00:01
-
-
Save raganmd/ee258ae5ebdfdb07c23e3a139824f061 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dict_to_storage(target_op, storage_dict_key, preset_name, dict_to_store): | |
''' | |
A reusable method for capturing parameters on a single page of a COMP | |
Args | |
--------------- | |
target_op (TouchDesigner COMP): | |
> a ToughDesigner COMP that has custom parameters you would like to convert | |
> into a python dictionary. | |
storage_dict_key (str): | |
> the string name of the storage dictionary you'd like to add | |
> your preset / cue to. | |
preset_name (str): | |
> a name for the preset / cue. | |
dict_to_store (dict): | |
> a python dictionary to put into storage. | |
Returns | |
--------------- | |
None | |
''' | |
# grab the dictionary from storage | |
all_presets = target_op.fetch(storage_dict_key) | |
# create a new entry | |
all_presets[preset_name] = dict_to_store | |
# put dictionary back into storage | |
target_op.store(storage_dict_key, all_presets) | |
# example use | |
target_op = op('base_example') | |
storage_dict_key = 'presets' | |
preset_name = 'look001' | |
dict_to_store = {"preset_values": { | |
'Blacklevel' : 0.0, | |
'Contrast' : 1.0, | |
'Opacity' : 1.0 | |
} | |
} | |
dict_to_storage(target_op, storage_dict_key, preset_name, dict_to_store) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment