The usd_export.py module#

Summary#

sanitize_usd_name

Convert an arbitrary string to a valid USD prim name.

unique_name

Return name or a de-duplicated variant if it already exists in existing.

raw_tess_to_usd_mesh_data

Convert raw tessellation data to USD mesh arrays.

export_design_to_usd

Export a design’s tessellation to a USD stage file.

Description#

Provides USD export utilities for PyAnsys Geometry.

Module detail#

ansys.geometry.core.plotting.usd_export.sanitize_usd_name(name: str) str#

Convert an arbitrary string to a valid USD prim name.

USD prim names must match [A-Za-z_][A-Za-z0-9_]*.

Parameters:
namestr

Input name (e.g. body or component name from the service).

Returns:
str

A valid USD prim name.

ansys.geometry.core.plotting.usd_export.unique_name(name: str, existing: set[str]) str#

Return name or a de-duplicated variant if it already exists in existing.

Parameters:
namestr

Desired prim name.

existingset[str]

Names already in use within the current USD prim scope.

Returns:
str

name if no collision, otherwise name_1, name_2, etc.

ansys.geometry.core.plotting.usd_export.raw_tess_to_usd_mesh_data(raw_tess: dict) tuple[list[tuple[float, float, float]], list[int], list[int]]#

Convert raw tessellation data to USD mesh arrays.

Parameters:
raw_tessdict

Raw tessellation as returned by Body.get_raw_tessellation(). Keys are face/edge IDs; values are dicts with "vertices" (flat float list), "faces" (VTK connectivity [3, i, j, k, ...]), and "is_edge" (bool).

Returns:
tuple

A 3-tuple of (points, face_vertex_counts, face_vertex_indices):

  • points: list of (x, y, z) float tuples.

  • face_vertex_counts: list of ints (all 3 for triangulated meshes).

  • face_vertex_indices: flat list of vertex indices.

ansys.geometry.core.plotting.usd_export.export_design_to_usd(design: ansys.geometry.core.designer.design.Design, path: pathlib.Path, tess_options: TessellationOptions | None = None) None#

Export a design’s tessellation to a USD stage file.

Parameters:
designDesign

The design to export.

pathPath

Output file path. Must end with .usda, .usdc, .usdz, or .usd.

tess_optionsTessellationOptions | None, default: None

Tessellation quality options. None uses the server default.