unreal.UsdConversionContext

class unreal.UsdConversionContext(outer=None, name='None')

Bases: unreal.Object

Wraps the UnrealToUsd component conversion functions from the USDUtilities module so that they can be used by scripting languages.

This is an instanceable object instead of just static functions so that the USDStage to use for the conversions can be provided and cached between function calls, which is helpful because we’re forced to provide at most prim and layer file paths (as opposed to direct pxr::UsdPrim objects).

We can’t provide the pxr::UsdPrim object directly because USD types can’t be part of C++ function signatures that are automatically exposed to scripting languages. Lucikly we can use UsdUtils’ stage cache to make sure that C++ and e.g. Python are still referencing the same USD Stage in memory, so that we can e.g. use these functions to convert data within stages created via Python.

C++ Source:

  • Plugin: USDImporter

  • Module: USDExporter

  • File: USDConversionBlueprintContext.h

cleanup() None

Discards the currently opened stage. This is critical when using this class via scripting: The C++ destructor will not be called when the python object runs out of scope, so we would otherwise keep a strong reference to the stage

convert_cine_camera_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool

Convert Cine Camera Component

Parameters
Return type

bool

convert_directional_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool

Convert Directional Light Component

Parameters
Return type

bool

convert_hism_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool

Convert Hism Component

Parameters
Return type

bool

convert_instanced_foliage_actor(actor, prim_path, instances_level=None, time_code=340282346638528859811704183484516925440.000000) bool

Convert Instanced Foliage Actor

Parameters
Return type

bool

convert_landscape_proxy_actor_material(actor, prim_path, properties_to_bake, default_texture_size, textures_dir, time_code=340282346638528859811704183484516925440.000000) bool

Convert Landscape Proxy Actor Material

Parameters
Return type

bool

convert_landscape_proxy_actor_mesh(actor, prim_path, lowest_lod, highest_lod, time_code=340282346638528859811704183484516925440.000000) bool

Convert Landscape Proxy Actor Mesh

Parameters
  • actor (LandscapeProxy) –

  • prim_path (str) –

  • lowest_lod (int32) –

  • highest_lod (int32) –

  • time_code (float) –

Return type

bool

convert_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool

Note: We use FLT_MAX on these functions because Usd.TimeCode.Default().GetValue() is actually a nan, and nan arguments are automatically sanitized to 0.0f. We manually convert the FLT_MAX value into Usd.TimeCode.Default().GetValue() within the functions though, so if you want the Default timecode just omit the argument We are also forced to copypaste the FLT_MAX value (3.402823466e+38F) in here as the default arguments are parsed before the preprocessor replaces the defines

Parameters
Return type

bool

convert_mesh_component(component, prim_path) bool

Convert Mesh Component

Parameters
Return type

bool

convert_point_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool

Convert Point Light Component

Parameters
Return type

bool

convert_rect_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool

Convert Rect Light Component

Parameters
Return type

bool

convert_scene_component(component, prim_path) bool

Convert Scene Component

Parameters
Return type

bool

convert_sky_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool

Convert Sky Light Component

Parameters
Return type

bool

convert_spot_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool

Convert Spot Light Component

Parameters
Return type

bool

get_edit_target() FilePath

Gets the filepath of the current edit target layer of our internal stage

Return type

FilePath

get_stage_root_layer() FilePath

Gets the file path of the root layer of our current stage

Return type

FilePath

remove_unreal_surface_output(prim_path, layer_to_author_in) bool

Clears any opinions for the ‘unreal’ render context surface output of MaterialPrim within LayerToAuthorIn. If LayerToAuthorIn is empty it will clear opinions from all layers of the stage’s layer stack.

Parameters
  • prim_path (str) – Path to the prim pxr::UsdShadeMaterial schema to update the ‘unreal’ surface output of (e.g. “/Root/MyCube/Red”)

  • layer_to_author_in (FilePath) – Layer to clear the opinions in. Can be the empty string to clear opinions from all layers in the layer stack

Returns

Whether we successfully cleared the opinions or not

Return type

bool

replace_unreal_materials_with_baked(layer_to_author_in, baked_materials, is_asset_layer, use_payload, remove_unreal_materials) None

Traverses the context’s stage and authors material binding attributes for all unrealMaterials that were baked into USD material assets.

Parameters
  • layer_to_author_in (FilePath) – File path to the layer where the material binding opinions are authored

  • baked_materials (Map(str, str)) – Maps from material path names to file paths where they were baked Example: { “/Game/MyMaterials/Red.Red”: “C:/MyFolder/Red.usda” }

  • is_asset_layer (bool) – True when we’re exporting a single mesh/animation asset. False when we’re exporting a level. Dictates minor behaviors when authoring the material binding relationships, e.g. whether we author them inside variants or not

  • use_payload (bool) – Should be True if the Stage was exported using payload files to store the actual Mesh prims. Also dictates minor behaviors when authoring the material binding relationships.

  • remove_unreal_materials (bool) – Whether to remove the unrealMaterial attributes after replacing them with material bindings. Important because the unrealMaterial attributes will be used as a higher priority when determining material assignments on import

set_edit_target(edit_target_layer_path) None

Sets the current edit target of our internal stage. When calling the conversion functions, prims and attributes will be authored on this edit target only

Parameters

edit_target_layer_path (FilePath) –

set_stage_root_layer(stage_root_layer_path) None

Opens or creates a USD stage using StageRootLayerPath as root layer, creating the root layer if needed. All future conversions will fetch prims and get/set USD data to/from this stage. Note: You must remember to call Cleanup() when done, or else this object will permanently hold a reference to the opened stage!

Parameters

stage_root_layer_path (FilePath) –