Table of contents
module flair_style_presets
API module exposing functions related to shader style presets within Flair. The shader style presets are directly applied onto the flairGlobals node, changing engine settings and post-processing shaders. This module is directly used by the Style Presets UI.
Presets are individually stored as .json files and contain attributes of objects and their values.
Examples:
Instance the style presets library and load a style
1
2
3
4
5
6
7
import flair_style_presets
style_preset_lib = flair_style_presets.StylePresetLibrary()
# load a style with all options enabled
options = { "worldScale": False, "quality": True, "canvases": True, "attributes": True }
style_preset_lib.load("wc_ingres", options)
function set_style_attrs
1
set_style_attrs(globals_data, options=None)
Set the style attributes in the globals node according to options.
Options are:
- worldScale - set world scale attribute
- quality - set quality attributes i.e., TAA, TAA samples, render scale
- canvases - set all attributes with canvas in their name
- attributes - set all remaining attributes
You can get the shader style attributes with the get_maya_attrs() function from the import/export API. You could use the respective set_maya_attrs() function too, but you won’t be able to set options and will also set global attributes like _sequenceDir and _sequenceName that might not be desired.
Args:
globals_data(dict): Dictionary of style data within the flairGlobals nodeoptions(dict): Dictionary of options to set (default:{ "worldScale": True, "quality": True, "canvases": True, "attributes": True })
class StylePresetLibrary
Preset library class to save and load style presets within Flair.
This class inherits from the Python dict object, extending its functionality.
Example:
Load library and print available presets
1
2
3
4
5
6
# load preset library
style_preset_lib = flair_style_presets.StylePresetLibrary()
# print available presets
preset_names = style_preset_lib.keys()
print(preset_names)
method StylePresetLibrary.delete
1
delete(name)
Deletes the preset from the library.
Args:
name(unicode): Name of the preset to delete
method StylePresetLibrary.find
1
find()
Finds all available style presets and populates the library class. Style presets are searched on disk in the following locations:
- Specified presets folder in environment variable
FLAIR_PRESETS_PATH(FLAIR_PRESETS_PATH/styles) - User presets folder (
AppDocuments/Flair/presets/styles) - Installation presets folder
method StylePresetLibrary.load
1
load(name, options)
Load the shader style preset with the specified options onto the flairGlobals node.
Options are:
- worldScale - sets world scale attribute
- quality - sets quality attributes i.e., TAA, TAA samples, render scale
- canvases - sets all attributes with canvas in their name
- attributes - sets all remaining attributes
Options are a requirement for this method and can be defined as follows:
options = { "worldScale": False, "quality": True, "canvases": True, "attributes": True }
Args:
name(unicode): name of style presetoptions(dict): options to load the shader style with
method StylePresetLibrary.rename_preset
1
rename_preset(name, new_name)
Rename an existing preset.
Args:
name(unicode): name of the preset to renamenew_name(unicode): new name of the preset
method StylePresetLibrary.save
1
save(name, obj)
Save the shader style attributes of the flairGlobals node into a preset with the specified name. The preset is saved on disk in the first location that is writable among the following:
- Specified presets folder in environment variable
FLAIR_PRESETS_PATH(FLAIR_PRESETS_PATH/styles) - User presets folder (
AppDocuments/Flair/presets/styles) - Installation presets folder
Args:
name(unicode): name of the style presetobj(list, unicode): name of the globals node to create preset from e.g.,"flairGlobals"