Table of contents
  1. module flair_import_export
    1. Global Variables
    2. function import_stylization
    3. function export_stylization
    4. function get_maya_attrs
    5. function set_maya_attrs
    6. function get_material_attrs
    7. function set_materials
    8. function get_proxies
    9. function set_proxies
    10. function get_vertex_data
    11. function set_vertex_data
    12. function custom_import
    13. function auto_import_style

module flair_import_export

API module exposing functions related to the import and export of the Flair style.

Flair stylizations are exported as .style files, which contains data stored as text-based python dictionaries.

Examples:

Export only the Flair globals into a style file:

1
2
import flair_import_export
flair_import_export.export_stylization(export_path="PATH/TO/SAVE/ONTO.style", materials=False, vfx=False, proxies=False)

Global Variables

  • cjson
  • maya_useNewAPI

function import_stylization

1
2
3
4
5
6
7
8
9
10
11
12
import_stylization(
    import_path,
    selected=False,
    namespace_changes=None,
    maya_attrs=True,
    materials=True,
    vfx=True,
    proxies=True,
    auto_import=False,
    prefix='',
    quiet=False
)

Imports the stylization from a .style file into the scene.

Args:

  • import_path (unicode): Path to import stylization from
  • selected (bool): If import should only happen to selected objects (default: entire scene)
  • namespace_changes (dict): Dictionary with name changes (default: no changes)
  • maya_attrs (bool): If the maya attributes need to be imported (default: True)
  • materials (bool): If the materials need to be imported (default: True)
  • vfx (bool): If the vertexFX need to be imported (default: True)
  • proxies (bool): If proxies need to be imported (default: True)
  • auto_import (bool): If this function is called from auto-importing the style (default: False)
  • prefix (unicode): Prefix in case objects are in an additional hierarchy/group (default: no prefixes)
  • quiet (bool): If no success prompt should be display at the end (default: False)

function export_stylization

1
2
3
4
5
6
7
8
9
export_stylization(
    export_path,
    selected=False,
    maya_attrs=True,
    materials=True,
    vfx=True,
    proxies=True,
    quiet=False
)

Exports the stylization of the scene into a .style file.

Args:

  • export_path (unicode): Path to save .style file onto
  • selected (bool): If export should only happen from selected objects (default: entire scene)
  • maya_attrs (bool): If the style needs to be exported (default: True)
  • materials (bool): If the materials need to be exported (default: True)
  • vfx (bool): If the vertex data needs to be exported e.g., vertexFX, baked data (default: True)
  • proxies (bool): If proxies need to be exported (default: True)
  • quiet (bool): If no success prompt should be display at the end (default: False)

function get_maya_attrs

1
get_maya_attrs()

Get the attributes from the Flair globals node.

Data is returned as a Python dictionary i.e., { "attributeName" : value, ... }.

Returns:

  • (dict): Style attributes and their values

function set_maya_attrs

1
set_maya_attrs(maya_attrs)

Set the attributes in the Flair globals node.

Args:

  • maya_attrs (dict): dictionary with Flair global attributes and their values i.e., { "attributeName" : value, ... }

function get_material_attrs

1
get_material_attrs(shapes=None)

From the specified shapes/components, get their materials, material attributes/textures/type and their values.

Additionally, shapes assigned to the materials are stored within the meshes key.

Data is returned as a Python dictionary e.g.,:

1
2
3
4
5
6
7
8
9
10
11
12
13
{'flairMat': {'attributes': {'albedo': [(0.0, 0.0, 0.0)],
                             'alphaMask': 0.0,
                             ... },
               'meshes': ['|pSphere1'],
               'textures': {'albedo': {'attrs': {'alphaGain': 1.0,
                                                 'alphaIsLuminance': False,
                                                 ... },
                                       'name': 'file1',
                                       ... }
                            'alphaMask':  0.0,
                            ... },
               'type': 'flairShader' },
 ... }

Args:

  • shapes (list, unicode): Shapes to extract material data from (default: selected shapes/components)

Returns:

  • (dict): All material data from shapes/components

function set_materials

1
set_materials(objects=None, materials=None)

Set material data onto objects.

Args:

  • objects (list): List of objects to assign to (default, all shapes/components defined within the meshes key)
  • materials (dict): Dictionary of material data (Formatted as with get_material_attrs())

function get_proxies

1
get_proxies(materials)

Get proxies from material data.

Args:

  • materials (dict): Dictionary of material data

Returns:

  • (list): List of proxy meshes

function set_proxies

1
set_proxies(materials, style_path)

Set proxies in the scene, if available.

Proxy meshes are exported with the suffix _proxies.fbx alongside the .style file. So, if this file is found alongside the style_path, the geometry will be imported and proxy materials assigned to it.

Args:

  • materials (dict): Dictionary with material data
  • style_path (unicode): Path of the .style file

function get_vertex_data

1
get_vertex_data(shapes, data_type='VertexFX')

From the specified shapes, get their vertex data i.e., VertexFX or baked positions.

Data is returned as a Python dictionary e.g.,:

1
2
3
4
5
{'|pSphere1': {'controlSetA': {0: [0.0, 0.0, 0.0025098039768636227, 0.0],
                               1: [0.0, 0.0, 0.0025098039768636227, 0.0],
                               ... },
                ... },
... }

Args:

  • shapes (unicode, list): Shapes to get vertex control values from
  • data_type (unicode): Type of data i.e., “VertexFX”, “baked” (default: “VertexFX)

Returns:

  • (dict): Vertex data for all specified shapes

function set_vertex_data

1
set_vertex_data(objects, vertex_data, data_type='VertexFX')

Set vertex data onto shapes, be it VertexFX or baked positions.

Args:

  • objects (unicode, list): Objects to set vertex data onto
  • vertex_data (dict): Dictionary containing the vertex data (Formatted as with get_vertex_data())
  • data_type (unicode): Type of data i.e., “VertexFX”, “baked” (default: “VertexFX)

function custom_import

1
custom_import()

Custom import function that can be customized within the _custom_import_export.py module to have any kind of predefined options, namespace changes and even prefixes applied. Refer to _custom_import_export_example.py for an example on how this can be customized.

Usually run when right-clicking on the im/ex shelf button and selecting Custom import.


function auto_import_style

1
auto_import_style()

Custom auto-import function that can be customized within the _custom_import_export.py module to automatically browse the style of assets in the scene and apply them with predetermined values. Refer to _custom_import_export_example.py for an example on how this can be customized.

Usually run when right-clicking on the im/ex shelf button and selecting Custom auto-import.