API Reference¶
Package¶
Version helpers for the Axe USD plugin.
Core¶
Custom exceptions for USD export operations.
- exception axe_usd.core.exceptions.AxeUSDError(message, details=None)[source]¶
Bases:
ExceptionBase exception for all axe_usd errors.
- Parameters:
message (str)
details (Mapping[str, Any] | None)
- Return type:
None
- message¶
Human-readable error message.
- details¶
Optional dictionary of additional error context.
- exception axe_usd.core.exceptions.ConfigurationError(message, details=None)[source]¶
Bases:
AxeUSDErrorRaised when configuration is invalid.
- Parameters:
message (str)
details (Mapping[str, Any] | None)
- Return type:
None
- exception axe_usd.core.exceptions.FileSystemError(message, details=None)[source]¶
Bases:
AxeUSDErrorRaised when file system operations fail.
- Parameters:
message (str)
details (Mapping[str, Any] | None)
- Return type:
None
- exception axe_usd.core.exceptions.GeometryExportError(message, details=None)[source]¶
Bases:
AxeUSDErrorRaised when geometry export fails.
- Parameters:
message (str)
details (Mapping[str, Any] | None)
- Return type:
None
- exception axe_usd.core.exceptions.MaterialAssignmentError(message, details=None)[source]¶
Bases:
AxeUSDErrorRaised when material assignment to meshes fails.
- Parameters:
message (str)
details (Mapping[str, Any] | None)
- Return type:
None
- exception axe_usd.core.exceptions.MaterialExportError(message, details=None)[source]¶
Bases:
AxeUSDErrorRaised when material export operations fail.
- Parameters:
message (str)
details (Mapping[str, Any] | None)
- Return type:
None
- exception axe_usd.core.exceptions.TextureParsingError(message, details=None)[source]¶
Bases:
AxeUSDErrorRaised when texture slot parsing fails.
- Parameters:
message (str)
details (Mapping[str, Any] | None)
- Return type:
None
- exception axe_usd.core.exceptions.USDStageError(message, details=None)[source]¶
Bases:
AxeUSDErrorRaised when USD stage operations fail.
- Parameters:
message (str)
details (Mapping[str, Any] | None)
- Return type:
None
- exception axe_usd.core.exceptions.ValidationError(message, details=None)[source]¶
Bases:
AxeUSDErrorRaised when input validation fails.
- Parameters:
message (str)
details (Mapping[str, Any] | None)
- Return type:
None
- class axe_usd.core.exporter.ExportWriter(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol for exporters that write USD publish outputs.
- export(materials, settings, geo_file, paths)[source]¶
Export USD layers for the given materials.
- Parameters:
materials (Iterable[MaterialBundle]) – Material bundles to export.
settings (ExportSettings) – Export settings that drive output content.
geo_file (Path | None) – Optional geometry USD file to reference.
paths (PublishPaths) – Precomputed publish paths to write to.
- Return type:
None
- axe_usd.core.exporter.export_publish(materials, settings, geo_file, writer)[source]¶
Build publish paths and delegate export to the writer.
- Parameters:
materials (Iterable[MaterialBundle]) – Material bundles to export.
settings (ExportSettings) – Export settings including output location.
geo_file (Path | None) – Optional geometry USD file to reference.
writer (ExportWriter) – Export writer implementation.
- Returns:
The resolved publish paths used for export.
- Return type:
File system helpers with validation and consistent error wrapping.
- class axe_usd.core.filesystem.DefaultFileSystem[source]¶
Bases:
objectDefault file system implementation with validation.
- ensure_directory(path)[source]¶
Create directory if it doesn’t exist.
- Parameters:
path (Path)
- Return type:
Path
- class axe_usd.core.models.ExportSettings(usdpreview, arnold, materialx, openpbr, primitive_path, publish_directory, save_geometry, texture_format_overrides=None, arnold_displacement_mode='bump')[source]¶
Bases:
objectConfiguration for a USD export run.
- Parameters:
usdpreview (bool)
arnold (bool)
materialx (bool)
openpbr (bool)
primitive_path (str)
publish_directory (Path)
save_geometry (bool)
texture_format_overrides (Dict[str, str] | None)
arnold_displacement_mode (str)
- usdpreview¶
Whether to emit UsdPreviewSurface materials.
- Type:
bool
- arnold¶
Whether to emit Arnold materials.
- Type:
bool
- materialx¶
Whether to emit MaterialX standard surface materials.
- Type:
bool
- openpbr¶
Whether to emit MaterialX OpenPBR materials.
- Type:
bool
- primitive_path¶
Root prim path for published assets.
- Type:
str
- publish_directory¶
Output directory for USD layers.
- Type:
pathlib.Path
- save_geometry¶
Whether to export mesh geometry.
- Type:
bool
- texture_format_overrides¶
Optional per-renderer texture format overrides.
- Type:
Dict[str, str] | None
- arnold_displacement_mode¶
Whether to use bump or true displacement for Arnold height maps.
- Type:
str
- arnold_displacement_mode: str = 'bump'¶
- class axe_usd.core.models.MaterialBundle(name, textures, mesh_names=(), udim_slots=())[source]¶
Bases:
objectMaterial name with resolved texture slot paths.
- Parameters:
name (str)
textures (Dict[str, str])
mesh_names (Tuple[str, ...])
udim_slots (Tuple[str, ...])
- name¶
Material identifier.
- Type:
str
- textures¶
Mapping of slot name to texture path.
- Type:
Dict[str, str]
- mesh_names¶
Optional mesh names assigned to this material/texture set.
- Type:
Tuple[str, …]
- udim_slots¶
Optional texture slots that use UDIM token paths.
- Type:
Tuple[str, …]
- mesh_names: Tuple[str, ...] = ()¶
- udim_slots: Tuple[str, ...] = ()¶
- class axe_usd.core.models.PublishPaths(root_dir, geometry_path)[source]¶
Bases:
objectResolved file system paths for USD publishing.
- Parameters:
root_dir (Path)
geometry_path (Path)
- root_dir¶
Root publish directory.
- Type:
pathlib.Path
- geometry_path¶
Path to the geometry layer file (geo.usdc).
- Type:
pathlib.Path
- axe_usd.core.publish_paths.build_publish_paths(publish_directory, asset_name='')[source]¶
Build publish paths for an export directory.
- Parameters:
publish_directory (Path) – Target directory or main layer file path.
asset_name (str) – Optional asset name to subfolder geometry.
- Returns:
Container of resolved publish paths.
- Return type:
Texture slot name resolution from file paths.
- axe_usd.core.texture_keys.slot_from_path(path)[source]¶
Resolve a texture slot name from a file path.
- Parameters:
path (str) – Texture file path to inspect.
- Returns:
The normalized slot name if matched.
- Return type:
Optional[str]
- axe_usd.core.texture_parser.parse_textures(textures_dict, mesh_name_map=None)[source]¶
Parse texture exports into material bundles.
- Parameters:
textures_dict (Mapping[str | Tuple[str, ...], Sequence[str]]) – Mapping of texture set keys to file paths.
mesh_name_map (Mapping[str, Sequence[str]] | None) – Optional mapping of texture set name to mesh names.
- Returns:
Bundles with normalized texture slots.
- Return type:
List[MaterialBundle]
- Raises:
TextureParsingError – If textures_dict is None or not a mapping.
USD¶
Component-builder USD asset file structure.
- class axe_usd.usd.asset_files.AssetFilePaths(root_dir, asset_file, payload_file, geo_file, mtl_file, textures_dir)[source]¶
Bases:
objectComponent-builder USD asset file paths.
- Structure:
- /AssetName/
AssetName.usd # Main entry point (payloads payload.usdc) payload.usdc # References mtl.usdc and geo.usdc geo.usdc # Geometry layer mtl.usdc # Material layer /textures/ # Texture maps (handled by DCC plugin)
- Parameters:
root_dir (Path)
asset_file (Path)
payload_file (Path)
geo_file (Path)
mtl_file (Path)
textures_dir (Path)
- asset_file: Path¶
- geo_file: Path¶
- mtl_file: Path¶
- payload_file: Path¶
- root_dir: Path¶
- textures_dir: Path¶
- axe_usd.usd.asset_files.create_asset_file_structure(output_dir, asset_name)[source]¶
Create component-builder file structure.
- Parameters:
output_dir (Path) – Parent directory to create asset folder in.
asset_name (str) – Name of the asset (e.g., “MyProp”).
- Returns:
Paths to all asset files.
- Return type:
Example
>>> paths = create_asset_file_structure(Path("./output"), "Hero") >>> # Creates: ./output/Hero/Hero.usd, payload.usdc, etc.
- axe_usd.usd.asset_files.create_asset_usd_file(paths, asset_name)[source]¶
Create the main Asset.usd file.
Creates: - /__class__/AssetName (class prim) - /AssetName (root Xform, Kind=component, assetInfo, inherits) - Payloads payload.usdc into /AssetName
- Parameters:
paths (AssetFilePaths) – Asset file paths.
asset_name (str) – Name of the asset.
- Returns:
The created main asset stage.
- Return type:
Usd.Stage
- axe_usd.usd.asset_files.create_geo_usd_file(paths, asset_name)[source]¶
Create geo.usdc geometry layer scaffold.
- Parameters:
paths (AssetFilePaths) – Asset file paths.
asset_name (str) – Name of the asset.
- Returns:
The created geometry stage.
- Return type:
Usd.Stage
- axe_usd.usd.asset_files.create_mtl_usd_file(paths, asset_name)[source]¶
Create mtl.usdc for the material layer.
- Parameters:
paths (AssetFilePaths) – Asset file paths.
asset_name (str) – Name of the asset.
- Returns:
The created material stage.
- Return type:
Usd.Stage
- axe_usd.usd.asset_files.create_payload_usd_file(paths, asset_name)[source]¶
Create payload.usdc that references mtl.usdc and geo.usdc.
- Parameters:
paths (AssetFilePaths) – Asset file paths.
asset_name (str) – Name of the asset.
- Returns:
The created payload stage.
- Return type:
Usd.Stage
USD asset structure utilities.
- axe_usd.usd.asset_structure.initialize_component_asset(stage, asset_name, asset_identifier=None)[source]¶
Initialize a Component asset structure.
Creates the following structure: - /__class__/<asset_name>: Class prim for inheritance - /<asset_name>: Root Xform with Kind=component, assetInfo, inheritance - Sets stage defaultPrim metadata
- Parameters:
stage (pxr.Usd.Stage) – USD stage to initialize.
asset_name (str) – Name of the asset (e.g., “hero_prop”).
asset_identifier (str | None) – Optional asset identifier (defaults to “./<asset_name>.usd”).
- Returns:
The root asset prim.
- Return type:
Usd.Prim
Example
>>> stage = Usd.Stage.CreateInMemory() >>> root = initialize_component_asset(stage, "MyAsset") >>> print(root.GetPath()) /MyAsset
Material builder package exports.
- class axe_usd.usd.material_builders.ArnoldBuilder(context)[source]¶
Bases:
object- Parameters:
context (MaterialBuildContext)
- class axe_usd.usd.material_builders.MaterialBuildContext(stage: pxr.Usd.Stage, material_dict: Dict[str, axe_usd.usd.types.MaterialTextureInfoWithMeshes], is_transmissive: bool, texture_format_overrides: axe_usd.usd.material_model.TextureFormatOverrides, logger: logging.Logger, arnold_displacement_mode: str = 'bump')[source]¶
Bases:
object- Parameters:
stage (pxr.Usd.Stage)
material_dict (Dict[str, MaterialTextureInfoWithMeshes])
is_transmissive (bool)
texture_format_overrides (TextureFormatOverrides)
logger (Logger)
arnold_displacement_mode (str)
- arnold_displacement_mode: str = 'bump'¶
- is_transmissive: bool¶
- logger: Logger¶
- material_dict: Dict[str, MaterialTextureInfoWithMeshes]¶
- stage: pxr.Usd.Stage¶
- texture_format_overrides: TextureFormatOverrides¶
- class axe_usd.usd.material_builders.MtlxBuilder(context)[source]¶
Bases:
_MtlxLikeBuilder- Parameters:
context (MaterialBuildContext)
- input_map: Dict[str, str] = {'basecolor': 'base_color', 'displacement': 'displacement', 'emission': 'emission_color', 'metalness': 'metalness', 'normal': 'normal', 'opacity': 'opacity', 'roughness': 'specular_roughness'}¶
- renderer_name = 'mtlx'¶
- texture_prefix = 'mtlx'¶
- class axe_usd.usd.material_builders.OpenPbrBuilder(context)[source]¶
Bases:
_MtlxLikeBuilder- Parameters:
context (MaterialBuildContext)
- emission_intensity_input = 'emission_luminance'¶
- image_signatures = {'basecolor': 'color3', 'displacement': 'float', 'emission': 'color3', 'metalness': 'float', 'normal': 'vector3', 'opacity': 'float', 'roughness': 'float'}¶
- input_map: Dict[str, str] = {'basecolor': 'base_color', 'displacement': 'displacement', 'emission': 'emission_color', 'metalness': 'base_metalness', 'normal': 'geometry_normal', 'opacity': 'geometry_opacity', 'roughness': 'specular_roughness'}¶
- renderer_name = 'openpbr'¶
- texture_prefix = 'openpbr'¶
- class axe_usd.usd.material_builders.UsdPreviewBuilder(context)[source]¶
Bases:
object- Parameters:
context (MaterialBuildContext)
Shared data helpers for USD material processing.
- class axe_usd.usd.material_model.TextureFormatOverrides(overrides: Dict[str, str])[source]¶
Bases:
object- Parameters:
overrides (Dict[str, str])
- classmethod from_mapping(texture_format_overrides)[source]¶
- Parameters:
texture_format_overrides (Mapping[str, str] | None)
- Return type:
- overrides: Dict[str, str]¶
- axe_usd.usd.material_model.apply_texture_format_override(path, override)[source]¶
- Parameters:
path (str)
override (str | None)
- Return type:
str
- axe_usd.usd.material_model.is_transmissive_material(material_name, tokens=None)[source]¶
- Parameters:
material_name (str)
tokens (tuple[str, ...] | None)
- Return type:
bool
- axe_usd.usd.material_model.normalize_asset_path(path)[source]¶
- Parameters:
path (str)
- Return type:
str
- axe_usd.usd.material_model.normalize_material_dict(material_dict, logger=None, slot_aliases={'height': 'displacement'})[source]¶
- Parameters:
material_dict (Dict[str, MaterialTextureInfoWithMeshes])
logger (Logger | None)
slot_aliases (Mapping[str, str])
- Return type:
Dict[str, MaterialTextureInfoWithMeshes]
- axe_usd.usd.material_model.normalize_slot_name(slot, slot_aliases={'height': 'displacement'})[source]¶
- Parameters:
slot (str)
slot_aliases (Mapping[str, str])
- Return type:
str
USD material processing utilities.
Copyright Ahmed Hindy. Please mention the author if you found any part of this code useful.
- class axe_usd.usd.material_processor.USDShaderCreate(stage, material_name, material_dict, mesh_names=None, parent_primpath='/Asset/material', create_usd_preview=False, create_arnold=False, create_mtlx=False, create_openpbr=False, arnold_displacement_mode='bump', texture_format_overrides=None)[source]¶
Bases:
objectCreate USD material prims and shader networks.
- Parameters:
stage (pxr.Usd.Stage)
material_name (str)
material_dict (Dict[str, MaterialTextureInfoWithMeshes])
mesh_names (Sequence[str] | None)
parent_primpath (str)
create_usd_preview (bool)
create_arnold (bool)
create_mtlx (bool)
create_openpbr (bool)
arnold_displacement_mode (str)
texture_format_overrides (Mapping[str, str] | None)
- stage¶
USD stage to author into.
- material_name¶
Name of the material to create.
- material_dict¶
Mapping of texture slots to file paths.
- parent_primpath¶
Parent prim path to place materials under.
- create_usd_preview¶
Whether to create UsdPreviewSurface materials.
- create_arnold¶
Whether to create Arnold materials.
- create_mtlx¶
Whether to create MaterialX materials.
- create_openpbr¶
Whether to create MaterialX OpenPBR materials.
- texture_format_overrides¶
Optional per-renderer texture format overrides (usd_preview, arnold, mtlx, openpbr).
- is_transmissive¶
Whether the material is treated as transmissive.
- axe_usd.usd.material_processor.create_shaded_asset_publish(material_dict_list, stage=None, geo_file=None, parent_path='/Asset', layer_save_path=None, create_usd_preview=True, create_arnold=False, create_mtlx=True, create_openpbr=False, arnold_displacement_mode='bump', texture_format_overrides=None)[source]¶
Create a component-builder USD asset with materials and optional geometry.
Creates structure: - Files: AssetName.usd, payload.usdc, geo.usdc, mtl.usdc, /textures/ - Prims: /__class__/Asset, /Asset (Kind=component)
- Parameters:
material_dict_list (List[Dict[str, MaterialTextureInfoWithMeshes]]) – Material texture dictionaries to publish.
stage (pxr.Usd.Stage | None) – Ignored (legacy argument, kept for signature compatibility).
geo_file (str | None) – Optional geometry USD file to reference (source).
parent_path (str) – Root prim path for the published asset (e.g., “/Asset”).
layer_save_path (str | None) – Output directory.
create_usd_preview (bool) – Whether to create UsdPreviewSurface materials.
create_arnold (bool) – Whether to create Arnold materials.
create_mtlx (bool) – Whether to create MaterialX materials.
create_openpbr (bool) – Whether to create MaterialX OpenPBR materials.
arnold_displacement_mode (str) – Whether to use bump or true displacement for Arnold height maps.
texture_format_overrides (Mapping[str, str] | None) – Optional per-renderer texture format overrides.
- Return type:
None
Configurable naming conventions for USD materials and meshes.
- class axe_usd.usd.naming.NamingConvention(strip_prefixes=<factory>, strip_suffixes=<factory>)[source]¶
Bases:
objectMaterial and mesh naming conventions.
This class defines how material names should be cleaned by removing DCC-specific prefixes and suffixes before matching with mesh names.
- Parameters:
strip_prefixes (Sequence[str])
strip_suffixes (Sequence[str])
- strip_prefixes¶
List of prefixes to remove from material names.
- Type:
Sequence[str]
- strip_suffixes¶
List of suffixes to remove from material names.
- Type:
Sequence[str]
Examples
>>> convention = NamingConvention() >>> convention.clean_material_name("mat_Body_ShaderSG") 'Body'
>>> custom = NamingConvention( ... strip_prefixes=["custom_"], ... strip_suffixes=["_MAT"] ... ) >>> custom.clean_material_name("custom_Body_MAT") 'Body'
- clean_material_name(raw_name)[source]¶
Clean a material name by removing configured prefixes/suffixes.
Suffixes are removed first (since they’re at the end), then prefixes. This order matters when both prefix and suffix are present.
- Parameters:
raw_name (str) – Raw material name from USD prim.
- Returns:
Cleaned material name.
- Return type:
str
Examples
>>> convention = NamingConvention() >>> convention.clean_material_name("Body") 'Body' >>> convention.clean_material_name("mat_Body") 'Body' >>> convention.clean_material_name("Body_ShaderSG") 'Body' >>> convention.clean_material_name("mat_Body_collect") 'Body'
- axe_usd.usd.naming.clean_material_name(raw_name, convention=None)[source]¶
Clean a material name using the provided or default convention.
This is a convenience function that uses DEFAULT_NAMING if no convention is provided.
- Parameters:
raw_name (str) – Raw material name from USD prim.
convention (NamingConvention | None) – Optional naming convention (uses DEFAULT_NAMING if None).
- Returns:
Cleaned material name.
- Return type:
str
Examples
>>> clean_material_name("mat_Body_ShaderSG") 'Body' >>> custom = NamingConvention(strip_prefixes=["my_"]) >>> clean_material_name("my_Body", custom) 'Body'
- class axe_usd.usd.pxr_writer.PxrUsdWriter[source]¶
Bases:
objectWrite USD layers using the Pixar USD Python API.
- export(materials, settings, geo_file, paths)[source]¶
Export materials and optional geometry to USD layers.
- Parameters:
materials (Iterable[MaterialBundle]) – Material bundles to export.
settings (ExportSettings) – Export settings to honor.
geo_file (Path | None) – Optional geometry USD file to payload.
paths (PublishPaths) – Publish path container.
- Return type:
None
- class axe_usd.usd.types.MaterialTextureInfo[source]¶
Bases:
TypedDictTexture metadata for a material slot.
- mat_name¶
Material identifier.
- Type:
str
- path¶
File path to the texture.
- Type:
str
- class axe_usd.usd.types.MaterialTextureInfoWithMeshes[source]¶
Bases:
dictOptional mesh name assignments for a material slot.
- mesh_names: List[str]¶
USD utility helpers.
Copyright Ahmed Hindy. Please mention the author if you found any part of this code useful.
- axe_usd.usd.utils.collect_prims_of_type(parent_prim, prim_type, contains_str=None, recursive=False)[source]¶
Collect prims of a given type under a parent prim.
- Parameters:
parent_prim (pxr.Usd.Prim) – Parent primitive to search under.
prim_type (type) – USD prim type to match.
contains_str (str | None) – Optional name substring filter.
recursive (bool) – Whether to traverse descendants recursively.
- Returns:
Success flag and list of matching prims.
- Return type:
Tuple[bool, List[Usd.Prim]]
Substance Painter¶
Qt compatibility layer for Substance Painter.
Supports PySide2 (SP < 10.1.0) and PySide6 (SP >= 10.1.0).
Substance Painter plugin for exporting USD assets.
Copyright Ahmed Hindy. Please mention the author if you found any part of this code useful.
- class axe_usd.dcc.substance_painter.substance_plugin.ExportContext(*args, **kwargs)[source]¶
Bases:
ProtocolSubstance Painter export context interface.
- textures: Mapping[Tuple[str, str], Sequence[str]]¶
- class axe_usd.dcc.substance_painter.substance_plugin.MeshExporter(settings, skip_postprocess=False)[source]¶
Bases:
objectExports mesh geometry to USD if requested.
- Parameters:
settings (ExportSettings)
skip_postprocess (bool)
- axe_usd.dcc.substance_painter.substance_plugin.close_plugin()[source]¶
Remove all widgets that have been added to the UI.
- Return type:
None
- axe_usd.dcc.substance_painter.substance_plugin.on_post_export(context)[source]¶
Handle the texture export completion event.
- Parameters:
context (ExportContext) – Substance Painter export context.
- Return type:
None
- axe_usd.dcc.substance_painter.substance_plugin.register_callbacks()[source]¶
Register the post-export callback.
- Return type:
None
- axe_usd.dcc.substance_painter.substance_plugin.start_plugin()[source]¶
Create the export UI and register callbacks.
- Return type:
None
Substance Painter USD export UI.
- class axe_usd.dcc.substance_painter.ui.USDExporterView(*args, **kwargs)[source]¶
Bases:
QDialogUI widget for USD export settings.
- class axe_usd.dcc.substance_painter.ui.USDSettings(usdpreview, arnold, materialx, save_geometry, openpbr, arnold_displacement_mode, usdpreview_resolution, texture_format_overrides, log_level)[source]¶
Bases:
objectUSD export options container.
- Parameters:
usdpreview (bool)
arnold (bool)
materialx (bool)
save_geometry (bool)
openpbr (bool)
arnold_displacement_mode (str)
usdpreview_resolution (int)
texture_format_overrides (Dict[str, str])
log_level (str)
- usdpreview¶
Include UsdPreviewSurface shader.
- Type:
bool
- arnold¶
Include Arnold standard_surface shader.
- Type:
bool
- materialx¶
Include MaterialX standard_surface shader.
- Type:
bool
- openpbr¶
Include MaterialX OpenPBR shader.
- Type:
bool
- arnold_displacement_mode¶
Arnold height handling (“bump” or “displacement”).
- Type:
str
- save_geometry¶
Whether to export mesh geometry.
- Type:
bool
- usdpreview_resolution¶
Size of USD Preview textures (pixels).
- Type:
int
- texture_format_overrides¶
Optional per-renderer overrides.
- Type:
Dict[str, str]
- log_level¶
Logging verbosity.
- Type:
str
- arnold_displacement_mode: str¶
USD fixups for Substance Painter exports.
- axe_usd.dcc.substance_painter.usd_scene_fixup.fix_sp_mesh_stage(stage, target_root)[source]¶
Normalize a Substance Painter mesh stage for component layout.
Removes material scope under the detected root prim.
Moves all prims under the detected root prim to the target root prim.
- Parameters:
stage (pxr.Usd.Stage) – The opened USD stage to modify.
target_root (str) – Target root prim path (e.g. “/Asset”).
- Returns:
True if changes were applied.
- Return type:
bool