newton.usd.get_tetmesh#
- newton.usd.get_tetmesh(prim, *, compat_namespaces=None, _load_custom_attributes=True)[source]#
Load a tetrahedral mesh from a USD prim with the
UsdGeom.TetMeshschema.Reads vertex positions from the
pointsattribute and tetrahedral connectivity fromtetVertexIndices. If a physics material is bound to the prim (viamaterial:binding:physics) and containsyoungsModulus,poissonsRatio, ordensityattributes (canonicalphysics:namespace, withcompat_namespacesas a fallback), those values are read and converted to Lame parameters (k_mu,k_lambda) and density on the returned TetMesh. Material properties are set toNoneif not present.Custom primvars use their resolved interpolation to determine attribute frequency. Other custom arrays use length-based inference; arrays whose frequency is ambiguous or cannot be inferred emit a warning and are omitted without preventing the TetMesh from loading.
Material-attribute namespaces (deprecated default): with
compat_namespaces=None(the default) the legacy vendor namespaces (omniphysics:/physxDeformableBody:) are read off any bound material, matching the pre-canonical behavior. That default is deprecated and emits aDeprecationWarningwhen it is load-bearing: the bound material authors vendor-namespaced deformable attributes, or canonicalphysics:attributes withoutPhysicsVolumeDeformableMaterialAPI(API-applied canonical or render-only materials do not warn); a future release will default to canonicalphysics:-only. Passcompat_namespaces=()to adopt the canonical-only behavior now – moduli are then read only from a material that appliesPhysicsVolumeDeformableMaterialAPI– or pass an explicit list (e.g.newton.usd.DEFORMABLE_LEGACY_NAMESPACES) to keep reading vendor namespaces without the warning.Example
from pxr import Usd import newton import newton.usd usd_stage = Usd.Stage.Open("tetmesh.usda") tetmesh = newton.usd.get_tetmesh(usd_stage.GetPrimAtPath("/MyTetMesh")) # tetmesh.vertices -- np.ndarray, shape (N, 3) # tetmesh.tet_indices -- np.ndarray, flattened (4 per tet)
- Parameters:
prim (Usd.Prim) – The USD prim to load the tetrahedral mesh from.
compat_namespaces (Sequence[str] | None) – Vendor attribute namespaces accepted as a fallback to the canonical
physics:material attributes, lifting thePhysicsVolumeDeformableMaterialAPIgate.None(the default) selects the deprecated legacy namespaces; pass()for canonical-only.
- Returns:
A
newton.TetMeshwith vertex positions and tet connectivity.- Return type: