assets_io

assets_io.commit_asset_position(objects)

Creates an initial world position vector each one of the surfaceShape under the given objects. This is useful a backup for possible future environment/character offsets.

Parameters:objects – maya objects
Returns:None
assets_io.curves_to_poly(curves)

Converts the given curves to one polygonal mesh combined of a poly for each curve, and makes this output polygon ready for exporting to massive hair object

Parameters:curves
Returns:
assets_io.duplicate_asset(asset)

Duplicate referenced asset as a maya instance

Parameters:asset
Returns:the resulted asset instance
assets_io.fix_deformed_tags(surfaces=True, curves=True)

When a deformer or skin bind is performed on objects a new shape is created for this object that can have ‘Deformed’ or ‘Orig’ in its name, and this new duplicated shape doesn’t have proper tags from the source shape, for that, this method will create the tags on these new shapes and give them input connections from the source mesh.

assets_io.generate_hair_xml(hair_nodes, hairXml_file, hair_type='nrHair', database_data={})

Generate hair xml file that has information about all the given hair_nodes (including the asset information each one yeti node is coming from)

Parameters:
  • hair_nodes – a list of NRHair groups or Yeti nodes of type “pgYetiMaya”
  • hairXml – the xml file path to be generated
  • hair_type – nrHair | yeti
Returns:

status

assets_io.generate_lookfile(asset_root, asset, context, img_dir, maTex_file, shdInfo_file, dst_sourceimages=None, ignore_texture=False, database_data={})

Generate maya shaders scene (maTex) and an img_dir (<dir>.img) for the used textures from the objects under the given asset root

Parameters:
  • asset_root – asset locator of the process the aniTex is being generated for
  • asset – the asset name
  • context – this can be either the aniTex context or the object context (by default, this would be the context of the given asset root)
  • img_dir – <dir_name>.img (the .img extension must be there), this is where the sourceimages will be copied
  • maTex_file – <filename>.maTex (the extension should be .maTex), this will be generated from the objects shaders
  • aniTex_info – a json description file will be generated describing the shadingEngines and objects lists {<engine>: [shape1, shap2, …etc], ….}
  • ignore_texture – if True, publishing mapped textures on shaders will be ignored (you may consider generating texture folder in additional pass using the prepare_tex_dir() in this case

which will generate files/objects symlinks in the format suitable for future textures resolve) :return: status

assets_io.generate_scene_dep_file(ast_root, dep_file, nreal_brain=None, additional_deps=None)

Write json assets dependencies .dep file for the given asset root

Parameters:
  • ast_root – asset locator
  • dep_file – dependency file path to be generated
  • nreal_brain – an instance of nreal_brain
  • additional_deps – a list of asset members dictionaries, where each dict should contain at least the keys: [‘ast’, ‘context’, ‘version’, ‘category’, ‘type’, ‘ast_sk’]
Returns:

dep filepath

assets_io.get_all_parents(obj, upto_parent)

Get all the parents of the given object up to the given upto_parent transform

Parameters:
  • obj
  • upto_parent
Returns:

list of parents

assets_io.get_asset_info(obj=None, ast_root=None, nreal_brain=None)

Returns all the information needed about the asset owning the given obj and/or ast_root locator.

Parameters:
  • obj – any object belonging to an asset (optional arg in case an ast_root is provided).
  • ast_root – asset root locator, if not provided, it will be expected based on the given obj (at least one of them should be provided).
  • nreal_brain – an instance of an initialized nreal_brain module.
Returns:

{‘ast_root’: ast_root, ‘ast’: ast, ‘category’: category, ‘context’: context, ‘version’: version, ‘current_version’: current_version, ‘latest_version’: latest_version, ‘ast_sk’: ast_sk}

assets_io.get_asset_references(ast_root)
Parameters:ast_root – asset root locator
Returns:a list dictionaries of all the database asset references under the given asset locator as {‘ast_root’: child_astRoot, ‘ref_node’: child_refNode, ‘ref_file’: ref_file, ‘any_object’: surfaceShape}

Note: ‘any_object’ key is the first surface shape found under the returned asset reference.

assets_io.get_asset_root(obj)

Get the asset root locator of the given object

Parameters:obj
Returns:
assets_io.get_child_references(root)
Parameters:root – asset root locator
Returns:list of child references nodes
assets_io.get_children_assets(ast_root, ignore_hidden=False, ignore_empty_assets=False, include_maya_transforms=False)
Parameters:
  • ast_root – asset root locator
  • ignore_hidden – hidden groups/assets will be ignored when returning the children
  • ignore_empty_assets – empty groups (or asset locators of unloaded assets) will be ignored when returning the children
  • include_maya_transforms – non-asset maya transform nodes like groups locators will be returned within the returened assets list
Returns:

a list of the children asset locators

assets_io.get_high_parent(obj, ast_root, root_stop=False)

Returns the highest parent transform object in hierarchy one level below the main asset root

assets_io.get_highest_root(obj, asset_root=None, root_context=None)

Returns the highest parent transform node below the asset root of the given root_context

example:
this will return the highest parent group of the given object where the returned transform is below ‘<objAstName>_rig_ast’ when the given root_context is ‘rig’
assets_io.get_object_reference(obj)
Parameters:obj – object of interest
Returns:the reference node owning the given object or None
assets_io.get_parent_asset_of_asset(obj)

Gets the asset locator of the parent asset that the given object is one of it’s dependency assets for example, get_parent_asset_of_asset(‘chr_rig_ast/chr_model_ast/body’) will return chr_rig_ast locator

Parameters:obj – a dependency asset locator or an object belonging to a dependency asset.
Returns:None, or the the parent asset containing the selected asset/asset_object
assets_io.get_reference_info(ast_root)
Parameters:ast_root – asset root locator
Returns:{‘ast_root’: ast_root, ‘ref_file’: ref_file, ‘ref_type’: ref_type, ‘child_assets’: child_assets, ‘nodes’: reference_nodes}

where the ‘ref_type’ key is like a snapshot type (‘maya’, ‘alembic’, ‘usd’… etc).

assets_io.get_reference_root(rfn)
Parameters:rfn – reference node
Returns:the first surface shape from the given reference node, or the asset locator if this is a maya reference
assets_io.import_asset(impFile, asset_name='', category='', context='', version='', sk='', loadReferenceDepth=None, create_locator=True, ignore_dup=False, nr_alembic=False, dynamic_process=True, database_data={}, asset_namespace=':', **kwargs)

Import the given asset file into maya.

Parameters:
  • refFile – the asset file
  • asset_name – asset name
  • category – the asset category
  • context – the task context
  • version – the current asset version
  • sk – the asset search key
  • loadReferenceDepth – maya flag ‘loadReferenceDepth’
  • create_locator – whether or not an asset locator should be created, always keep it True unless you are doing something custom.
  • ignore_dup – if an instance from the given reference exist in the scene, the reference process will be ignored.
  • nr_alembic – unused param yet! if True and the given asset is alembic, the referencing process will use nrAlembicImport() instead which will reference the asset as imported nrAlembicNode
  • dynamic_process – unused param yet! if False and nr_alembic, then the time node will be disconnected from the nrAlembic node to avoid evaluation on each frame for already static assets,

usually this is passed from processes_ctrl.dynamic attribute of the current process. :return: None

assets_io.is_valid_asset_object(obj)

Checks if the given object has proper asset information and was not been missed up for some reason like nrAlembic file change and make sure all objects are getting the proper connections and that the nrAlembic node was not missed up by file update, heirarchy change or a change in the number of properties in the original alembic file.

Returns:
assets_io.new_asset_locator(objects, name='', category='', context='', version='', sk='')

Create asset locator for the given objects.

Parameters:
  • objects – maya objects
  • name – asset locator name, this is recommended to be as <assetName>_<context>_ast
  • category – asset category
  • context – task context of the asset of interest
  • version – optional version as %03d string (without ‘v’)
  • sk – asset search key
Returns:

asset locator or None

assets_io.offset(refFile, asset_name='', category='', context='', version='', sk='', loadReferenceDepth=None, create_locator=True, ignore_dup=False, nr_alembic=False, dynamic_process=True, database_data={}, asset_namespace=':')

Reference the given asset file into maya.

Parameters:
  • refFile – the asset file
  • asset_name – asset name
  • category – the asset category
  • context – the task context
  • version – the asset file version
  • sk – the asset search key
  • loadReferenceDepth – maya flag ‘loadReferenceDepth’
  • create_locator – whether or not an asset locator should be created, always keep it True unless you are doing something custom.
  • ignore_dup – if an instance from the given reference exist in the scene, the reference process will be ignored.
  • nr_alembic – if True and the given asset is alembic, the referencing process will use nrAlembicImport() instead which will reference the asset as imported nrAlembicNode
  • dynamic_process – if False and nr_alembic, then the time node will be disconnected from the nrAlembic node to avoid evaluation on each frame for already static assets,

usually this is passed from processes_ctrl.dynamic attribute of the current process. :return: None

assets_io.reference_asset(refFile, asset_name='', category='', context='', version='', sk='', loadReferenceDepth=None, create_locator=True, ignore_dup=False, nr_alembic=False, dynamic_process=True, database_data={}, asset_namespace=':', uvs_only=False, **kwargs)

Reference the given asset file into maya.

Parameters:
  • refFile – the asset file
  • asset_name – asset name
  • category – the asset category
  • context – the task context
  • version – the asset file version
  • sk – the asset search key
  • loadReferenceDepth – maya flag ‘loadReferenceDepth’
  • create_locator – whether or not an asset locator should be created, always keep it True unless you are doing something custom.
  • ignore_dup – if an instance from the given reference exist in the scene, the reference process will be ignored.
  • nr_alembic – if True and the given asset is alembic, the referencing process will use nrAlembicImport() instead which will reference the asset as imported nrAlembicNode
  • dynamic_process – if False and nr_alembic, then the time node will be disconnected from the nrAlembic node to avoid evaluation on each frame for already static assets, usually this is passed from processes_ctrl.dynamic attribute of the current process.
  • asset_namespace – the asset will be referenced under the given namespace
Returns:

asset_locator or None if the asset was ignored

assets_io.retarget_asset(refFile, asset_name='', category='', context='', version='', sk='', loadReferenceDepth=None, create_locator=True, ignore_dup=False, nr_alembic=False, dynamic_process=True, target_processes=[], respect_subcontext=True, database_data={}, **kwargs)

Retarget the target process references by the given refFile in respect to the subcontext (by default), the subcontext is detected automatically from the given context, anyway, if the subcontext was not found, the method will be applied on any process matching with the target_process (in this case, it’s the processes that doesn’t have any subcontexts at all) Example: if the source context is “animClip/walk” and the target process is “rig”, the method will try first to retarget all references called astName_rig/walk (assuming respect_subcontext is True), if the scene doesn’t have any astName-rig with ‘walk’ subcontext, then any astName-rig will be targeted.

Parameters:
  • refFile
  • asset_name
  • category
  • context
  • version
  • sk
  • loadReferenceDepth
  • create_locator
  • ignore_dup
  • nr_alembic
  • dynamic_process
  • target_processes
  • respect_subcontext
Returns:

assets_io.set_asset_version(ast_obj, nreal_brain, version=-1, override_context='')

Retarget the asset to the given version, it will respect the referenced asset type

Parameters:
  • ast_obj – any object belonging to the asset to be reloaded from different version
  • nreal_brain – an initialized instance of nreal_brain module
  • version – the destination version the asset should reference.
  • override_context – if provided, it will override the context of which the given version will be loaded, otherwise, the current asset context will be used
Returns:

None

assets_io.update_asset_files(ast_obj, version=0, nreal_brain=None, force_versionless=True)

Update the asset files and all dependencies needed by these files for the asset owning the given asset object and force doing the symlinks for the current approved versions.

Parameters:
  • ast_obj – any object from an asset
  • version – the asset version needs to be synchronized
  • nreal_brain – an instance of NReal tactic API
Returns: