usdex.core#
usdex.core provides higher-level convenience functions top of lower-level OpenUSD concepts, so developers can quickly adopt OpenUSD best practices when mapping their native data sources to OpenUSD-legible data models.
Functions:
|
Verify the expected usdex modules are being loaded at runtime. |
Verify the expected usdex modules are being loaded at runtime. |
|
|
Decorator used to deprecate public functions |
Test whether the |
|
Activates the |
|
Deactivates the |
|
|
Set the |
Get the current |
|
|
Get the |
|
Set the |
Get the current |
|
|
Check if the |
|
Set metadata on the |
|
Get metadata from the |
|
Save the given |
|
Export the given |
|
Create and configure a Usd.Stage so that the defining metadata is explicitly authored. |
|
Overloaded function. |
|
Save the given |
|
Overloaded function. |
Get the Asset token. |
|
Get the token for the Contents layer. |
|
Get the token for the Geometry layer and scope. |
|
Get the token for the Library layer. |
|
Get the token for the Materials layer and scope. |
|
Get the token for the Payload directory. |
|
Get the token for the Physics layer and scope. |
|
Get the token for the Textures directory. |
|
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Create a relative layer within a |
|
Create a specific Content Layer and add it as a sublayer to the stage's edit target. |
|
Create a Library Layer from which the Content Layers can reference prims. |
|
Add an Asset Interface to a stage, which payloads a source stage's contents. |
|
Produce a valid prim name from the input name |
|
Take a vector of the preferred names and return a matching vector of valid and unique names. |
|
Take a prim and a preferred name. |
|
Take a prim and a vector of the preferred names. |
|
Produce a valid property name using the Bootstring algorithm. |
|
Take a vector of the preferred names and return a matching vector of valid and unique names. |
|
Return this prim's display name (metadata). |
|
Sets this prim's display name (metadata) |
|
Clears this prim's display name (metadata) in the current EditTarget (only) |
|
Block this prim's display name (metadata) |
Calculate the effective display name of this prim |
|
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Determines if a UsdPrim has a |
|
Get the "correct" light attribute for a light that could have any combination of authored old and new UsdLux schema attributes |
|
Overloaded function. |
|
Overloaded function. |
|
Create a |
|
Authors a direct binding to the given material on this prim. |
|
Get the effective surface Shader of a Material for the universal render context. |
|
Overloaded function. |
|
Adds a diffuse texture to a preview material |
|
Adds a normals texture to a preview material |
|
Adds an ORM (occlusion, roughness, metallic) texture to a preview material |
Adds a single channel roughness texture to a preview material |
|
Adds a single channel metallic texture to a preview material |
|
|
Adds a single channel opacity texture to a preview material |
|
Adds |
|
Removes any |
|
Get the str matching a given ColorSpace |
|
Translate an sRGB color value to linear color space |
|
Translate a linear color value to sRGB color space |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Aligns an existing joint with the specified position, rotation, and axis. |
|
Overloaded function. |
|
Adds physical material parameters to an existing Material. |
|
Binds a physics material to a given rigid body or collision geometry. |
Classes:
Controls the diagnostics that will be emitted when the |
|
Control the output stream to which diagnostics are logged. |
|
The NameCache class provides a mechanism for generating unique and valid names for UsdPrims and their UsdProperties. |
|
|
|
Enumerates the rotation order of the 3-angle Euler rotation. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Texture color space (encoding) types |
|
Specifies a position and rotation in the coordinate system specified by |
- usdex.core.version() str #
Verify the expected usdex modules are being loaded at runtime.
- Returns:
A human-readable version string for the usdex modules.
- usdex.core.buildVersion() str #
Verify the expected usdex modules are being loaded at runtime.
- Returns:
A human-readable build version string for the usdex modules.
- usdex.core.deprecated(version: str, message: str)#
Decorator used to deprecate public functions
Example:
@deprecated("0.5", "Use `baz` instead") def foo(bar: str) -> str: return baz(bar)
- Parameters:
version – The major.minor version in which the function was first deprecated
message – A user facing message about the deprecation, ideally with a suggested alternative function. Do not include the version in this message, it will be prefixed automatically.
- class usdex.core.DiagnosticsLevel#
Controls the diagnostics that will be emitted when the
Delegate
is active.Members:
eFatal : Only
Tf.Fatal
are emitted.eError : Emit
Tf.Error
andTf.Fatal
, but suppressTf.Warn
andTf.Status
diagnostics.eWarning : Emit
Tf.Warn
,Tf.Error
, andTf.Fatal
, but suppressTf.Status
diagnostics.eStatus : All diagnostics are emitted.
Attributes:
- property name#
- class usdex.core.DiagnosticsOutputStream#
Control the output stream to which diagnostics are logged.
Members:
eNone : All diagnostics are suppressed.
eStdout : All diagnostics print to the
stdout
stream.eStderr : All diagnostics print to the
stderr
stream.Attributes:
- property name#
- usdex.core.isDiagnosticsDelegateActive() bool #
Test whether the
Delegate
is currently active.When active, the
Delegate
replaces the defaultTfDiagnosticMgr
printing with a more customized result. SeeactivateDiagnosticsDelegate()
for more details.- Returns:
Whether the Delegate is active
- usdex.core.activateDiagnosticsDelegate() None #
Activates the
Delegate
to specializeTfDiagnostics
handling.The
Tf
module from OpenUSD provides various diagnostic logging abilities, including the ability to override the default message handler (which prints tostderr
) with one or more custom handlers.This function can be used to activate a specialized
TfDiagnosticMgr::Delegate
provided by OpenUSD Exchange. The primary advantages of thisDelegate
are:Diagnostics can be filtered by
DiagnosticsLevel
.Diagnostics can be redirected to
stdout
,stderr
, or muted entirely usingDiagnosticsOutputStream
.The message formatting is friendlier to end-users.
Note
Use of this
Delegate
is entirely optional and it is not activated by default when loading this module. To active it, client code must explicitly callactivateDiagnosticsDelegate()
. This is to allow clients to opt-in and to prevent double printing for clients that already have their ownTfDiagnosticMgr::Delegate
implementation.
- usdex.core.deactivateDiagnosticsDelegate() None #
Deactivates the
Delegate
to restore defaultTfDiagnostics
handling.When deactivated, the default
TfDiagnosticMgr
printing is restored, unless some otherDelegate
is still active.
- usdex.core.setDiagnosticsLevel( ) None #
Set the
DiagnosticsLevel
for theDelegate
to filterTfDiagnostics
by severity.This can be called at any time, but the filtering will only take affect after calling
activateDiagnosticsDelegate()
.- Parameters:
value – The highest severity
DiagnosticsLevel
that should be emitted.
- usdex.core.getDiagnosticsLevel() usdex.core._usdex_core.DiagnosticsLevel #
Get the current
DiagnosticsLevel
for theDelegate
.This can be called at any time, but the filtering will only take affect after calling
activateDiagnosticsDelegate()
.- Returns:
The current
DiagnosticsLevel
for theDelegate
.
- usdex.core.getDiagnosticLevel(
- code: pxr.Tf.DiagnosticType,
Get the
DiagnosticsLevel
for a givenTfDiagnosticType
.- Parameters:
code – The
TfDiagnosticType
to get theDiagnosticsLevel
for.- Returns:
The
DiagnosticsLevel
for theTfDiagnosticType
.
- usdex.core.setDiagnosticsOutputStream( ) None #
Set the
DiagnosticsOutputStream
for theDelegate
to redirectTf.Diagnostics
to different streams.This can be called at any time, but will only take affect after calling
activateDiagnosticsDelegate()
.- Parameters:
value – The stream to which all diagnostics should be emitted.
- usdex.core.getDiagnosticsOutputStream() usdex.core._usdex_core.DiagnosticsOutputStream #
Get the current
DiagnosticsOutputStream
for theDelegate
.This can be called at any time, but will only take affect after calling
activateDiagnosticsDelegate()
.- Returns:
The current
DiagnosticsOutputStream
for theDelegate
.
- usdex.core.hasLayerAuthoringMetadata(layer: pxr.Sdf.Layer) bool #
Check if the
Sdf.Layer
has metadata indicating the provenance of the data.Note
This metadata is strictly informational, it is not advisable to drive runtime behavior from this metadata. In the future, the “creator” key may change, or a more formal specification for data provenance may emerge.
Checks the CustomLayerData for a “creator” key.
- Parameters:
layer – The layer to check
- Returns:
A bool indicating if the metadata exists
- usdex.core.setLayerAuthoringMetadata(layer: pxr.Sdf.Layer, value: str) None #
Set metadata on the
Sdf.Layer
indicating the provenance of the data.It is desirable to capture data provenance information into the metadata of SdfLayers, in order to keep track of what tools & versions were used throughout content creation pipelines, and to capture notes from the content author. While OpenUSD does not currently have a formal specification for this authoring metadata, some conventions have emerged throughout the OpenUSD Ecosystem.
The most common convention for tool tracking is to include a “creator” string in the
Sdf.Layer.customLayerData
. Similarly, notes from the content author should be captured viaSdf.Layer.SetComment
. While these are trivial usingSdf.Layer
public methods, they are also easy to forget, and difficult to discover.This function assists authoring applications in settings authoring metadata, so that each application can produce consistant provenance information. The metadata should only add information which can be used to track the data back to its origin. It should not be used to store sensitive information about the content, nor about the end user (i.e. do not use it to store Personal Identifier Information).
Example
layer = Sdf.Layer.CreateAnonymous() authoring_metadata = "My Content Editor® 2024 SP 2, USD Exporter Plugin v1.1.23.11" usdex.core.exportLayer(layer, file_name, authoring_metadata, user_comment);
Note
This metadata is strictly informational, it is not advisable to drive runtime behavior from this metadata. In the future, the “creator” key may change, or a more formal specification for data provenance may emerge.
- Parameters:
layer – The layer to modify
value – The provenance information for this layer
- usdex.core.getLayerAuthoringMetadata(layer: pxr.Sdf.Layer) str #
Get metadata from the
Sdf.Layer
indicating the provenance of the data.Note
This metadata is strictly informational, it is not advisable to drive runtime behavior from this metadata. In the future, the “creator” key may change, or a more formal specification for data provenance may emerge.
This function retrieves the provenance information from the “creator” key of the CustomLayerData.
- Parameters:
layer – The layer to read from
- Returns:
The provenance information for this layer, or an empty string if none exists
- usdex.core.saveLayer(
- layer: pxr.Sdf.Layer,
- authoringMetadata: str | None = None,
- comment: str | None = None,
Save the given
Sdf.Layer
with an optional commentNote
This does not impact sublayers or any stages that this layer may be contributing to. See
setLayerAuthoringMetadata
for details. This is to preserve authoring metadata on referenced layers that came from other applications.- Parameters:
layer – The stage to be saved.
authoringMetadata – The provenance information from the host application. See
setLayerAuthoringMetadata
for details.comment –
The comment will be authored in the layer as the
Sdf.Layer
comment.- Returns:
A bool indicating if the save was successful.
- usdex.core.exportLayer(
- layer: pxr.Sdf.Layer,
- identifier: str,
- authoringMetadata: str,
- comment: str | None = None,
- fileFormatArgs: Dict[str, str] = {},
Export the given
Sdf.Layer
to an identifier with an optional comment.Note
This does not impact sublayers or any stages that this layer may be contributing to. See
setLayerAuthoringMetadata
for details. This is to preserve authoring metadata on referenced layers that came from other applications.- Parameters:
layer – The layer to be exported.
identifier – The identifier to be used for the new layer.
authoringMetadata – The provenance information from the host application. See
setLayerAuthoringMetadata
for details. If the “creator” key already exists, it will not be overwritten & this data will be ignored.comment – The comment will be authored in the layer as the
Sdf.Layer
comment.fileFormatArgs – Additional file format-specific arguments to be supplied during layer export.
- Returns:
A bool indicating if the export was successful.
- usdex.core.createStage(
- identifier: str,
- defaultPrimName: str,
- upAxis: str,
- linearUnits: float,
- authoringMetadata: str,
- fileFormatArgs: dict | None = None,
- massUnits: float | None = None,
Create and configure a Usd.Stage so that the defining metadata is explicitly authored.
See configureStage for more details.
Note
The extension of the identifier must be associated with a file format that supports editing.
- Parameters:
identifier – The identifier to be used for the root layer of this stage.
defaultPrimName – Name of the root prim root prim.
upAxis – The up axis for all the geometry contained in the stage.
linearUnits – The meters per unit for all linear measurements in the stage.
authoringMetadata – The provenance information from the host application. See setLayerAuthoringMetadata for details.
fileFormatArgs – Additional file format-specific arguments to be supplied during Stage creation.
massUnits – The kilograms per unit for all mass measurements in the stage. If not provided, the default value will be used.
- Returns:
The newly created stage or None
- usdex.core.configureStage(*args, **kwargs)#
Overloaded function.
configureStage(stage: pxr.Usd.Stage, defaultPrimName: str, upAxis: str, linearUnits: float, massUnits: float, authoringMetadata: Optional[str] = None) -> bool
Configure a stage so that the defining metadata is explicitly authored.
The default prim will be used as the target of a Reference or Payload to this layer when no explicit prim path is specified. A root prim with the given
defaultPrimName
will be defined on the stage. If a new prim is defined then the type name will be set toScope
.The stage metrics of Up Axis, Linear Units and Mass Units will be authored.
The root layer will be annotated with authoring metadata, unless previously annotated. This is to preserve authoring metadata on referenced layers that came from other applications. See
setLayerAuthoringMetadata
for more details.- Args:
stage: The stage to be configured. defaultPrimName: Name of the default root prim. upAxis: The up axis for all the geometry contained in the stage. linearUnits: The meters per unit for all linear measurements in the stage. massUnits: The kilograms per unit for all mass measurements in the stage. authoringMetadata: The provenance information from the host application. See
setLayerAuthoringMetadata
for details.- Returns:
A bool indicating if the metadata was successfully authored.
configureStage(stage: pxr.Usd.Stage, defaultPrimName: str, upAxis: str, linearUnits: float, authoringMetadata: Optional[str] = None) -> bool
Configure a stage so that the defining metadata is explicitly authored.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Args:
stage: The stage to be configured. defaultPrimName: Name of the default root prim. upAxis: The up axis for all the geometry contained in the stage. linearUnits: The meters per unit for all linear measurements in the stage. authoringMetadata: The provenance information from the host application. See
setLayerAuthoringMetadata
for details.- Returns:
A bool indicating if the metadata was successfully authored.
- usdex.core.saveStage(
- stage: pxr.Usd.Stage,
- authoringMetadata: str | None = None,
- comment: str | None = None,
Save the given
Usd.Stage
with metadata applied to all dirty layers.Save all dirty layers and sublayers contributing to this stage.
All dirty layers will be annotated with authoring metadata, unless previously annotated. This is to preserve authoring metadata on referenced layers that came from other applications.
The comment will be authored in all layers as the SdfLayer comment.
- Parameters:
stage – The stage to be saved.
authoringMetadata – The provenance information from the host application. See
setLayerAuthoringMetadata
for details. If the “creator” key already exists on a given layer, it will not be overwritten & this data will be ignored.comment – The comment will be authored in all dirty layers as the
Sdf.Layer
comment.
- usdex.core.isEditablePrimLocation(*args, **kwargs)#
Overloaded function.
isEditablePrimLocation(stage: pxr.Usd.Stage, path: pxr.Sdf.Path) -> tuple
Validate that prim opinions could be authored at this path on the stage
This validates that the
stage
andpath
are valid, and that the path is absolute. If a prim already exists at the given path it must not be an instance proxy.If the location is invalid and
reason
is non-null, an error message describing the validation error will be set.- Parameters:
stage - The stage to consider.
path - The absolute to consider.
- Returns:
Tuple[bool, str] with a bool indicating if the location is valid, and the string is a non-empty reason if the location is invalid.
isEditablePrimLocation(prim: pxr.Usd.Prim, name: str) -> tuple
Validate that prim opinions could be authored for a child prim with the given name
This validates that the
prim
is valid, and that thename
is a valid identifier. If a prim already exists at the given path it must not be an instance proxy.If the location is invalid and
reason
is non-null, an error message describing the validation error will be set.- Parameters:
parent - The UsdPrim which would be the parent of the proposed location.
name - The name which would be used for the UsdPrim at the proposed location.
- Returns:
Tuple[bool, str] with a bool indicating if the location is valid, and the string is a non-empty reason if the location is invalid.
isEditablePrimLocation(prim: pxr.Usd.Prim) -> tuple
Validate that prim opinions could be authored for the prim
This validates that the
prim
is valid and not be an instance proxy.If the location is invalid and
reason
is non-null, an error message describing the validation error will be set.- Parameters:
prim - The UsdPrim to consider.
- Returns:
Tuple[bool, str] with a bool indicating if the location is valid, and the string is a non-empty reason if the location is invalid.
- usdex.core.getAssetToken() str #
Get the Asset token.
- Returns:
The Asset token.
- usdex.core.getContentsToken() str #
Get the token for the Contents layer.
- Returns:
The token for the Contents layer.
- usdex.core.getGeometryToken() str #
Get the token for the Geometry layer and scope.
- Returns:
The token for the Geometry layer and scope.
- usdex.core.getLibraryToken() str #
Get the token for the Library layer.
- Returns:
The token for the Library layer.
- usdex.core.getMaterialsToken() str #
Get the token for the Materials layer and scope.
- Returns:
The token for the Materials layer and scope.
- usdex.core.getPayloadToken() str #
Get the token for the Payload directory.
- Returns:
The token for the Payload directory.
- usdex.core.getPhysicsToken() str #
Get the token for the Physics layer and scope.
- Returns:
The token for the Physics layer and scope.
- usdex.core.getTexturesToken() str #
Get the token for the Textures directory.
- Returns:
The token for the Textures directory.
- usdex.core.definePayload(*args, **kwargs)#
Overloaded function.
definePayload(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, source: pxr.Usd.Prim) -> pxr.Usd.Prim
Define a payload to a prim.
This creates a payload prim that targets a prim in another layer (external payload) or the same layer (internal payload).
The payload’s assetPath will be set to the relative identifier between the stage’s edit target and the source’s stage if it’s an external payload with a valid relative path.
- For more information, see:
- Parameters:
stage - The stage on which to define the payload
path - The absolute prim path at which to define the payload
source - The payload to add
- Returns:
The newly created payload prim. Returns an invalid prim on error.
definePayload(parent: pxr.Usd.Prim, source: pxr.Usd.Prim, name: Optional[str] = None) -> pxr.Usd.Prim
Define a payload to a prim as a child of the
parent
primThis is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - The parent prim to add the payload to
source - The payload to add
name - The name of the payload. If not provided, uses the source prim’s name
- Returns:
The newly created payload prim. Returns an invalid prim on error.
- usdex.core.defineReference(*args, **kwargs)#
Overloaded function.
defineReference(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, source: pxr.Usd.Prim) -> pxr.Usd.Prim
Define a reference to a prim.
This creates a reference prim that targets a prim in another layer (external reference) or the same layer (internal reference).
The reference’s assetPath will be set to the relative identifier between the stage’s edit target and the source’s stage if it’s an external reference with a valid relative path.
- For more information, see:
- Parameters:
stage - The stage on which to define the reference
path - The absolute prim path at which to define the reference
source - The prim to reference
- Returns:
The newly created reference prim. Returns an invalid prim on error.
defineReference(parent: pxr.Usd.Prim, source: pxr.Usd.Prim, name: Optional[str] = None) -> pxr.Usd.Prim
Define a reference to a prim as a child of the
parent
primThis is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - The parent prim to add the reference to
source - The prim to reference
name - The name of the reference. If not provided, uses the source prim’s name
- Returns:
The newly created reference prim. Returns an invalid prim on error.
- usdex.core.defineScope(*args, **kwargs)#
Overloaded function.
defineScope(stage: pxr.Usd.Stage, path: pxr.Sdf.Path) -> pxr.UsdGeom.Scope
Defines a scope on the stage.
A scope is a simple grouping primitive that is useful for organizing prims in a scene.
- Parameters:
stage - The stage on which to define the scope
path - The absolute prim path at which to define the scope
- Returns:
A
UsdGeom.Scope
schema wrapping the definedUsd.Prim
. Returns an invalid schema on error.
defineScope(parent: pxr.Usd.Prim, name: str) -> pxr.UsdGeom.Scope
Defines a scope on the stage.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the scope
name - Name of the scope
- Returns:
A
UsdGeom.Scope
schema wrapping the definedUsd.Prim
. Returns an invalid schema on error.
defineScope(prim: pxr.Usd.Prim) -> pxr.UsdGeom.Scope
Defines a scope from an existing prim.
This converts an existing prim to a Scope type.
- Parameters:
prim - The existing prim to convert to a scope
- Returns:
A
UsdGeom.Scope
schema wrapping the definedUsd.Prim
. Returns an invalid schema on error.
- usdex.core.createAssetPayload(
- stage: Stage,
- format: str = 'usda',
- fileFormatArgs: dict | None = None,
Create a relative layer within a
getPayloadToken()
subdirectory to hold the content of an asset.This layer represents the root layer of the Payload that the Asset Interface targets.
This entry point layer will subLayer the different Content Layers (e.g., Geometry, Materials, etc.) added via
usdex.core.addAssetContent
.Note
This function does not create an actual Payload, it is only creating a relative layer that should eventually be the target of a Payload (via
usdex.core.addAssetInterface
).- Parameters:
stage – The stage’s edit target identifier will dictate where the relative payload layer will be created.
format – The file format extension (default: “usda”).
fileFormatArgs – Additional file format-specific arguments to be supplied during stage creation.
- Returns:
The newly created relative payload layer opened as a new stage. Returns an invalid stage on error.
- usdex.core.addAssetContent(
- stage: Stage,
- name: str,
- format: str = 'usda',
- fileFormatArgs: dict | None = None,
- prependLayer: bool = True,
- createScope: bool = True,
Create a specific Content Layer and add it as a sublayer to the stage’s edit target.
Any Prim data can be authored in the Content Layer, there are no specific restrictions or requirements.
However, it is recommended to use a unique Content Layer for each domain (Geometry, Materials, Physics, etc.) and to ensure only domain-specific opinions are authored in that Content Layer. This provides a clear separation of concerns and allows for easier reuse of assets across domains as each layer can be enabled/disabled (muted) independently.
- Parameters:
stage – The stage’s edit target will determine where the Content Layer is created and will have its subLayers updated with the new content
name – The name of the Content Layer (e.g., “Geometry”, “Materials”, “Physics”)
format – The file format extension (default: “usda”).
fileFormatArgs – Additional file format-specific arguments to be supplied during stage creation.
prependLayer – Whether to prepend (or append) the layer to the sublayer stack (default: True).
createScope – Whether to create a scope in the content stage (default: True).
- Returns:
The newly created Content Layer opened as a new stage. Returns an invalid stage on error.
- usdex.core.addAssetLibrary(
- stage: Stage,
- name: str,
- format: str = 'usdc',
- fileFormatArgs: dict | None = None,
Create a Library Layer from which the Content Layers can reference prims.
This layer will contain a library of meshes, materials, prototypes for instances, or anything else that can be referenced by the Content Layers. It is not intended to be used as a standalone layer. The default prim will have a
class
specifier.- Parameters:
stage – The stage’s edit target identifier will dictate where the Library Layer will be created.
name – The name of the library (e.g., “Geometry”, “Materials”).
format – The file format extension (default: “usdc”).
fileFormatArgs – Additional file format-specific arguments to be supplied during stage creation.
- Returns:
The newly created relative layer opened as a new stage. It will be named “<name>Library.<format>”
- usdex.core.addAssetInterface(stage: pxr.Usd.Stage, source: pxr.Usd.Stage) bool #
Add an Asset Interface to a stage, which payloads a source stage’s contents.
This function creates a payload to the source stage’s contents as the default prim on the stage.
It (re)configures the stage with the source stage’s metadata, payloads the defaultPrim from the source stage, and annotates the Asset Interface with USD model metadata including component kind, asset name, and extents hint.
- Parameters:
stage – The stage’s edit target will become the Asset Interface
source – The stage that the Asset Interface will target as a Payload
- Returns:
True if the Asset Interface was added successfully, false otherwise.
- usdex.core.getValidPrimName(name: str) str #
Produce a valid prim name from the input name
- Parameters:
name – The input name
- Returns:
A string that is considered valid for use as a prim name.
- usdex.core.getValidPrimNames(
- names: List[str],
- reservedNames: list(str) = [],
Take a vector of the preferred names and return a matching vector of valid and unique names.
- Parameters:
names – A vector of preferred prim names.
reservedNames – A vector of reserved prim names. Names in the vector will not be included in the returns.
- Returns:
A vector of valid and unique names.
- usdex.core.getValidChildName(prim: pxr.Usd.Prim, name: str) str #
Take a prim and a preferred name. Return a valid and unique name as the child name of the given prim.
- Parameters:
prim – The USD prim where the given prim name should live under.
names – A preferred prim name.
- Returns:
A valid and unique name.
- usdex.core.getValidChildNames(prim: pxr.Usd.Prim, names: List[str])#
Take a prim and a vector of the preferred names. Return a matching vector of valid and unique names as the child names of the given prim.
- Parameters:
prim – The USD prim where the given prim names should live under.
names – A vector of preferred prim names.
- Returns:
A vector of valid and unique names.
- class usdex.core.NameCache#
The NameCache class provides a mechanism for generating unique and valid names for UsdPrims and their UsdProperties.
The class ensures that generated names are valid according to OpenUSD name requirements and are unique within the context of sibling Prim and Property names.
The cache provides a performant alternative to repeated queries by caching generated names and managing reserved names for Prims and Properties.
Because reserved names are held in the cache, collisions can be avoided in cases where the Prim or Property has not been authored in the Stage. Names can be requested individually or in bulk, supporting a range of authoring patterns. Cache entries are based on prim path and are not unique between stages or layers.
The name cache can be used in several authoring contexts, by providing a particular parent type: - SdfPath: Useful when generating names before authoring anything in USD. - UsdPrim: Useful when authoring in a UsdStage. - SdfPrimSpec: Useful when authoring in an SdfLayer
When a cache entry is first created it will be populated with existing names depending on the scope of the supplied parent. - Given an SdfPath no names will be reserved - Given a UsdPrim it’s existing child Prim and Property names (after composition) will be reserved - Given an SdfPrimSpec it’s existing child Prim and Property names (before composition) will be reserved
The parent must be stable to be useable as a cache key. - An SdfPath must be an absolute prim path containing no variant selections. - A UsdPrim must be valid. - An SdfPrimSpec must not be NULL or dormant.
The pseudo root cannot have properties, therefore it is not useable as a parent for property related functions.
Warning
This class does not automatically invalidate cached values based on changes to the prims from which values were cached. Additionally, a separate instance of this class should be used per-thread, calling methods from multiple threads is not safe.
Methods:
clear
(*args, **kwargs)Overloaded function.
clearPrimNames
(*args, **kwargs)Overloaded function.
clearPropertyNames
(*args, **kwargs)Overloaded function.
getPrimName
(*args, **kwargs)Overloaded function.
getPrimNames
(*args, **kwargs)Overloaded function.
getPropertyName
(*args, **kwargs)Overloaded function.
getPropertyNames
(*args, **kwargs)Overloaded function.
update
(*args, **kwargs)Overloaded function.
updatePrimNames
(*args, **kwargs)Overloaded function.
updatePropertyNames
(*args, **kwargs)Overloaded function.
- clear(*args, **kwargs)#
Overloaded function.
clear(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path) -> None
Clear the reserved prim and property names for a prim.
- Args:
parent: The parent prim path
clear(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Clear the reserved prim and property names for a prim.
- Args:
parent: The parent prim
clear(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Clear the reserved prim and property names for a prim.
- Args:
parent: The parent prim spec
- clearPrimNames(*args, **kwargs)#
Overloaded function.
clearPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path) -> None
Clear the reserved child names for a prim.
- Args:
parent: The parent prim path
clearPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Clear the reserved child names for a prim.
- Args:
parent: The parent prim path
clearPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Clear the reserved child names for a prim.
- Args:
parent: The parent prim path
- clearPropertyNames(*args, **kwargs)#
Overloaded function.
clearPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path) -> None
Clear the reserved property names for a prim.
- Args:
parent: The parent prim path
clearPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Clear the reserved property names for a prim.
- Args:
parent: The parent prim
clearPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Clear the reserved property names for a prim.
- Args:
parent: The parent prim spec
- getPrimName(*args, **kwargs)#
Overloaded function.
getPrimName(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path, name: str) -> str
Make a name valid and unique for use as the name of a child of the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim path name: Preferred name
- Returns:
Valid and unique name token
getPrimName(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim, name: str) -> str
Make a name valid and unique for use as the name of a child of the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim name: Preferred name
- Returns:
Valid and unique name token
getPrimName(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec, name: str) -> str
Make a name valid and unique for use as the name of a child of the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim spec name: Preferred name
- Returns:
Valid and unique name token
- getPrimNames(*args, **kwargs)#
Overloaded function.
getPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of a children of the given prim.
- Args:
parent: The parent prim path names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
getPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of a children of the given prim.
- Args:
parent: The parent prim names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
getPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of a children of the given prim.
- Args:
parent: The parent prim spec names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
- getPropertyName(*args, **kwargs)#
Overloaded function.
getPropertyName(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path, name: str) -> str
Make a name valid and unique for use as the name of a property on the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim path name: Preferred name
- Returns:
Valid and unique name token
getPropertyName(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim, name: str) -> str
Make a name valid and unique for use as the name of a property on the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim name: Preferred name
- Returns:
Valid and unique name token
getPropertyName(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec, name: str) -> str
Make a name valid and unique for use as the name of a property on the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim spec name: Preferred name
- Returns:
Valid and unique name token
- getPropertyNames(*args, **kwargs)#
Overloaded function.
getPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of properties on the given prim.
- Args:
parent: The parent prim path names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
getPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of properties on the given prim.
- Args:
parent: The parent prim names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
getPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of properties on the given prim.
- Args:
parent: The parent prim spec names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
- update(*args, **kwargs)#
Overloaded function.
update(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Update the reserved child and property names for a prim to include existing children and properties.
- Args:
parent: The parent prim
update(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Update the reserved child and property names for a prim to include existing children and properties.
- Args:
parent: The parent prim spec
- updatePrimNames(*args, **kwargs)#
Overloaded function.
updatePrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Update the reserved child names for a prim to include existing children.
- Args:
parent: The parent prim
updatePrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Update the reserved child names for a prim to include existing children.
- Args:
parent: The parent prim spec
- updatePropertyNames(*args, **kwargs)#
Overloaded function.
updatePropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Update the reserved property names for a prim to include existing properties.
- Args:
parent: The parent prim
updatePropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Update the reserved property names for a prim to include existing properties.
- Args:
parent: The parent prim spec
- class usdex.core.ValidChildNameCache(**kwargs)#
- usdex.core.getValidPropertyName(name: str) str #
Produce a valid property name using the Bootstring algorithm.
- Parameters:
name – The input name
- Returns:
A string that is considered valid for use as a property name.
- usdex.core.getValidPropertyNames(
- names: List[str],
- reservedNames: list(str) = [],
Take a vector of the preferred names and return a matching vector of valid and unique names.
- Parameters:
names – A vector of preferred property names.
reservedNames – A vector of reserved prim names. Names in the vector will not be included in the return.
- Returns:
A vector of valid and unique names.
- usdex.core.getDisplayName(prim: pxr.Usd.Prim) str #
Return this prim’s display name (metadata).
- Parameters:
prim – The prim to get the display name from
- Returns:
Authored value, or an empty string if no display name has been set.
- usdex.core.setDisplayName(prim: pxr.Usd.Prim, name: str) bool #
Sets this prim’s display name (metadata)
DisplayName is meant to be a descriptive label, not necessarily an alternate identifier; therefore there is no restriction on which characters can appear in it
- Parameters:
prim – The prim to set the display name for
name – The value to set
- Returns:
True on success, otherwise false
- usdex.core.clearDisplayName(prim: pxr.Usd.Prim) bool #
Clears this prim’s display name (metadata) in the current EditTarget (only)
- Parameters:
prim – The prim to clear the display name for
- Returns:
True on success, otherwise false
- usdex.core.blockDisplayName(prim: pxr.Usd.Prim) bool #
Block this prim’s display name (metadata)
The fallback value will be explicitly authored to cause the value to resolve as if there were no authored value opinions in weaker layers
- Parameters:
prim – The prim to block the display name for
- Returns:
True on success, otherwise false
- usdex.core.computeEffectiveDisplayName(prim: pxr.Usd.Prim) str #
Calculate the effective display name of this prim
If the display name is un-authored or empty then the prim’s name is returned
- Parameters:
prim – The prim to compute the display name for
- Returns:
The effective display name
- usdex.core.defineXform(*args, **kwargs)#
Overloaded function.
defineXform(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, transform: Optional[pxr.Gf.Transform] = None) -> pxr.UsdGeom.Xform
Defines an xform on the stage.
- Parameters:
stage - The stage on which to define the xform
path - The absolute prim path at which to define the xform
transform - Optional local transform to set
- Returns:
UsdGeom.Xform schema wrapping the defined Usd.Prim. Returns an invalid schema on error.
defineXform(parent: pxr.Usd.Prim, name: str, transform: Optional[pxr.Gf.Transform] = None) -> pxr.UsdGeom.Xform
Defines an xform on the stage.
- Parameters:
parent - Prim below which to define the xform
name - Name of the xform
transform - Optional local transform to set
- Returns:
UsdGeom.Xform schema wrapping the defined Usd.Prim. Returns an invalid schema on error.
defineXform(prim: pxr.Usd.Prim, transform: Optional[pxr.Gf.Transform] = None) -> pxr.UsdGeom.Xform
Defines an xform from an existing prim.
This converts an existing prim to an Xform type, preserving any existing transform data.
- Parameters:
prim - The existing prim to convert to an xform
transform - Optional local transform to set
- Returns:
UsdGeom.Xform schema wrapping the converted Usd.Prim.
- class usdex.core.RotationOrder#
Enumerates the rotation order of the 3-angle Euler rotation.
Members:
eXyz
eXzy
eYxz
eYzx
eZxy
eZyx
Attributes:
- property name#
- usdex.core.getLocalTransform(*args, **kwargs)#
Overloaded function.
getLocalTransform(prim: pxr.Usd.Prim, time: pxr.Usd.TimeCode = nan) -> pxr.Gf.Transform
Get the local transform of a prim at a given time.
- Args:
prim: The prim to get local transform from. time: Time at which to query the value.
- Returns:
Transform value as a transform.
getLocalTransform(xformable: pxr.UsdGeom.Xformable, time: pxr.Usd.TimeCode = nan) -> pxr.Gf.Transform
Get the local transform of an xformable at a given time.
- Args:
xformable: The xformable to get local transform from. time: Time at which to query the value.
- Returns:
Transform value as a transform.
- usdex.core.getLocalTransformMatrix(*args, **kwargs)#
Overloaded function.
getLocalTransformMatrix(prim: pxr.Usd.Prim, time: pxr.Usd.TimeCode = nan) -> pxr.Gf.Matrix4d
Get the local transform of a prim at a given time in the form of a 4x4 matrix.
- Args:
prim: The prim to get local transform from. time: Time at which to query the value.
- Returns:
Transform value as a 4x4 matrix.
getLocalTransformMatrix(xformable: pxr.UsdGeom.Xformable, time: pxr.Usd.TimeCode = nan) -> pxr.Gf.Matrix4d
Get the local transform of an xformable at a given time in the form of a 4x4 matrix.
- Args:
xformable: The xformable to get local transform from. time: Time at which to query the value.
- Returns:
Transform value as a 4x4 matrix.
- usdex.core.getLocalTransformComponents(*args, **kwargs)#
Overloaded function.
getLocalTransformComponents(prim: pxr.Usd.Prim, time: pxr.Usd.TimeCode = nan) -> tuple
Get the local transform of a prim at a given time in the form of common transform components.
- Args:
prim: The prim to get local transform from. time: Time at which to query the value.
- Returns:
Transform value as a tuple of translation, pivot, rotation, rotation order, scale.
getLocalTransformComponents(xformable: pxr.UsdGeom.Xformable, time: pxr.Usd.TimeCode = nan) -> tuple
Get the local transform of an xformable at a given time in the form of common transform components.
- Args:
xformable: The xformable to get local transform from. time: Time at which to query the value.
- Returns:
Transform value as a tuple of translation, pivot, rotation, rotation order, scale.
- usdex.core.getLocalTransformComponentsQuat(*args, **kwargs)#
Overloaded function.
getLocalTransformComponentsQuat(prim: pxr.Usd.Prim, time: pxr.Usd.TimeCode = nan) -> tuple
Get the local transform of a prim at a given time in the form of common transform components with quaternion orientation.
- Args:
prim: The prim to get local transform from. time: Time at which to query the value.
- Returns:
Transform value as a tuple of translation, pivot, orientation (quaternion), scale.
getLocalTransformComponentsQuat(xformable: pxr.UsdGeom.Xformable, time: pxr.Usd.TimeCode = nan) -> tuple
Get the local transform of an xformable at a given time in the form of common transform components with quaternion orientation.
- Args:
xformable: The xformable to get local transform from. time: Time at which to query the value.
- Returns:
Transform value as a tuple of translation, pivot, orientation (quaternion), scale.
- usdex.core.setLocalTransform(*args, **kwargs)#
Overloaded function.
setLocalTransform(prim: pxr.Usd.Prim, transform: pxr.Gf.Transform, time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of a prim.
- Parameters:
prim - The prim to set local transform on.
transform - The transform value to set.
time - Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
setLocalTransform(prim: pxr.Usd.Prim, matrix: pxr.Gf.Matrix4d, time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of a prim from a 4x4 matrix.
- Parameters:
prim - The prim to set local transform on.
matrix - The matrix value to set.
time - Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
setLocalTransform(prim: pxr.Usd.Prim, translation: pxr.Gf.Vec3d, pivot: pxr.Gf.Vec3d, rotation: pxr.Gf.Vec3f, rotationOrder: usdex.core._usdex_core.RotationOrder, scale: pxr.Gf.Vec3f, time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of a prim from common transform components.
- Parameters:
prim - The prim to set local transform on.
translation - The translation value to set.
pivot - The pivot position value to set.
rotation - The rotation value to set in degrees.
rotationOrder - The rotation order of the rotation value.
scale - The scale value to set.
time - Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
setLocalTransform(prim: pxr.Usd.Prim, translation: pxr.Gf.Vec3d, orientation: pxr.Gf.Quatf, scale: pxr.Gf.Vec3f = Gf.Vec3f(1.0, 1.0, 1.0), time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of a prim from common transform components using a quaternion for orientation.
- Parameters:
prim - The prim to set local transform on.
translation - The translation value to set.
orientation - The orientation value to set as a quaternion.
scale - The scale value to set - defaults to (1.0, 1.0, 1.0).
time - Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
setLocalTransform(xformable: pxr.UsdGeom.Xformable, transform: pxr.Gf.Transform, time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of an xformable.
- Args:
xformable: The xformable to set local transform on. transform: The transform value to set. time: Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
setLocalTransform(xformable: pxr.UsdGeom.Xformable, matrix: pxr.Gf.Matrix4d, time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of an xformable from a 4x4 matrix.
- Args:
xformable: The xformable to set local transform on. matrix: The matrix value to set. time: Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
setLocalTransform(xformable: pxr.UsdGeom.Xformable, translation: pxr.Gf.Vec3d, pivot: pxr.Gf.Vec3d, rotation: pxr.Gf.Vec3f, rotationOrder: usdex.core._usdex_core.RotationOrder, scale: pxr.Gf.Vec3f, time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of an xformable from common transform components.
- Args:
xformable: The xformable to set local transform on. translation: The translation value to set. pivot: The pivot position value to set. rotation: The rotation value to set in degrees. rotationOrder: The rotation order of the rotation value. scale: The scale value to set. time: Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
setLocalTransform(xformable: pxr.UsdGeom.Xformable, translation: pxr.Gf.Vec3d, orientation: pxr.Gf.Quatf, scale: pxr.Gf.Vec3f = Gf.Vec3f(1.0, 1.0, 1.0), time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of an xformable from common transform components using a quaternion for orientation.
- Args:
xformable: The xformable to set local transform on. translation: The translation value to set. orientation: The orientation value to set as a quaternion. scale: The scale value to set - defaults to (1.0, 1.0, 1.0). time: Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
- usdex.core.definePointCloud(*args, **kwargs)#
Overloaded function.
definePointCloud(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, points: pxr.Vt.Vec3fArray, ids: Optional[pxr.Vt.Int64Array] = None, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.Points
Defines a
UsdGeom.Points
prim on the stage.Attribute values will be validated and in the case of invalid data the Points will not be defined. An invalid
UsdGeom.Points
object will be returned in this case.Values will be authored for all attributes required to completely describe the Points, even if weaker matching opinions already exist.
Point Count
Points
Extent
The “extent” of the Points will be computed and authored based on the
points
andwidths
provided.The following common primvars can optionally be authored at the same time using a
PrimvarData
to specify interpolation, data, and optionally indices or elementSize.Ids
Widths
Normals
Display Color
Display Opacity
For both widths and normals, if they are provided, they are authored as
primvars:widths
andprimvars:normals
, so that indexing is possible and to ensure that the value takes precedence in cases where both the non-primvar and primvar attributes are authored.- Parameters:
stage The stage on which to define the points.
path The absolute prim path at which to define the points.
points Vertex/CV positions for the points described in local space.
ids Values for the id specification for the points.
widths Values for the width specification for the points.
normals Values for the normals primvar for the points. Only Vertex normals are considered valid.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.Points
schema wrapping the definedUsd.Prim
definePointCloud(parent: pxr.Usd.Prim, name: str, points: pxr.Vt.Vec3fArray, ids: Optional[pxr.Vt.Int64Array] = None, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.Points
Defines a
UsdGeom.Points
prim on the stage.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent Prim below which to define the points.
name Name of the points prim.
points Vertex/CV positions for the points described in local space.
ids Values for the id specification for the points.
widths Values for the width specification for the points.
normals Values for the normals primvar for the points. Only Vertex normals are considered valid.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.Points
schema wrapping the definedUsd.Prim
definePointCloud(prim: pxr.Usd.Prim, points: pxr.Vt.Vec3fArray, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.Points
Defines a point cloud using the
UsdGeom.Points
schema.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Args:
prim: Prim to define the point cloud on. The prim’s type will be set to
UsdGeom.Points
. points: Positions of the points. widths: Values for the width specification for the points. normals: Values for the normals primvar for the points. displayColor: Values to be authored for the display color primvar. displayOpacity: Values to be authored for the display opacity primvar.- Returns:
UsdGeom.Points
schema wrapping the definedUsd.Prim
- usdex.core.definePolyMesh(*args, **kwargs)#
Overloaded function.
definePolyMesh(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, faceVertexCounts: pxr.Vt.IntArray, faceVertexIndices: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, uvs: Optional[usdex.core._usdex_core.Vec2fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.Mesh
Defines a basic polygon mesh on the stage.
All interrelated attribute values will be authored, even if weaker matching opinions already exist.
The following common primvars can optionally be authored at the same time.
Normals
Primary UV Set
Display Color
Display Opacity
- Parameters:
stage - The stage on which to define the mesh
path - The absolute prim path at which to define the mesh
faceVertexCounts - The number of vertices in each face of the mesh
faceVertexIndices - Indices of the positions from the
points
to use for each face vertexpoints - Vertex positions for the mesh described points in local space
normals - Values to be authored for the normals primvar
uvs - Values to be authored for the uv primvar
displayColor - Value to be authored for the display color primvar
displayOpacity - Value to be authored for the display opacity primvar
- Returns:
UsdGeom.Mesh
schema wrapping the definedUsd.Prim
.
definePolyMesh(parent: pxr.Usd.Prim, name: str, faceVertexCounts: pxr.Vt.IntArray, faceVertexIndices: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, uvs: Optional[usdex.core._usdex_core.Vec2fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.Mesh
Defines a basic polygon mesh on the stage.
All interrelated attribute values will be authored, even if weaker matching opinions already exist.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the mesh
name - Name of the mesh
faceVertexCounts - The number of vertices in each face of the mesh
faceVertexIndices - Indices of the positions from the
points
to use for each face vertexpoints - Vertex positions for the mesh described points in local space
normals - Values to be authored for the normals primvar
uvs - Values to be authored for the uv primvar
displayColor - Value to be authored for the display color primvar
displayOpacity - Value to be authored for the display opacity primvar
- Returns:
UsdGeom.Mesh
schema wrapping the definedUsd.Prim
.
definePolyMesh(prim: pxr.Usd.Prim, faceVertexCounts: pxr.Vt.IntArray, faceVertexIndices: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, uvs: Optional[usdex.core._usdex_core.Vec2fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.Mesh
Defines a basic polygon mesh on the stage.
All interrelated attribute values will be authored, even if weaker matching opinions already exist.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim - Existing prim to convert to a mesh
faceVertexCounts - The number of vertices in each face of the mesh
faceVertexIndices - Indices of the positions from the
points
to use for each face vertexpoints - Vertex positions for the mesh described points in local space
normals - Values to be authored for the normals primvar
uvs - Values to be authored for the uv primvar
displayColor - Value to be authored for the display color primvar
displayOpacity - Value to be authored for the display opacity primvar
- Returns:
UsdGeom.Mesh
schema wrapping the definedUsd.Prim
.
- usdex.core.defineLinearBasisCurves(*args, **kwargs)#
Overloaded function.
defineLinearBasisCurves(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, curveVertexCounts: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, wrap: str = ‘nonperiodic’, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.BasisCurves
Defines a batched Linear
UsdGeom.BasisCurves
prim on the stage.Attribute values will be validated and in the case of invalid data the Curves will not be defined. An invalid
UsdGeom.BasisCurves
object will be returned in this case.Values will be authored for all attributes required to completely describe the Curves, even if weaker matching opinions already exist.
Curve Vertex Counts
Points
Type
Wrap
Extent
The “extent” of the Curves will be computed and authored based on the
points
andwidths
provided.The following common primvars can optionally be authored at the same time using a
PrimvarData
to specify interpolation, data, and optionally indices or elementSize.Widths
Normals
Display Color
Display Opacity
For both widths and normals, if they are provided, they are authored as
primvars:widths
andprimvars:normals
, so that indexing is possible and to ensure that the value takes precedence in cases where both the non-primvar and primvar attributes are authored.- Parameters:
stage The stage on which to define the curves.
path The absolute prim path at which to define the curves.
curveVertexCounts The number of vertices in each independent curve. The length of this array determines the number of curves.
points Vertex/CV positions for the curves described in local space.
- wrap Determines how the start and end points of the curve behave. Accepted values for linear curves are
UsdGeom.Tokens.nonperiodic
andUsdGeom.Tokens.periodic
.
widths Values for the width specification for the curves.
normals Values for the normals primvar for the curves. If authored, the curves are considered oriented ribbons rather than tubes.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.BasisCurves
schema wrapping the definedUsd.Prim
defineLinearBasisCurves(parent: pxr.Usd.Prim, name: str, curveVertexCounts: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, wrap: str = ‘nonperiodic’, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.BasisCurves
Defines a batched Linear
UsdGeom.BasisCurves
prim on the stage.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent Prim below which to define the curves
name Name of the curves
curveVertexCounts The number of vertices in each independent curve. The length of this array determines the number of curves.
points Vertex/CV positions for the curves described in local space.
- wrap Determines how the start and end points of the curve behave. Accepted values for linear curves are
UsdGeom.Tokens.nonperiodic
andUsdGeom.Tokens.periodic
.
widths Values for the width specification for the curves.
normals Values for the normals primvar for the curves. If authored, the curves are considered oriented ribbons rather than tubes.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.BasisCurves
schema wrapping the definedUsd.Prim
defineLinearBasisCurves(prim: pxr.Usd.Prim, curveVertexCounts: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, wrap: str = ‘nonperiodic’, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.BasisCurves
Defines a batched Linear
UsdGeom.BasisCurves
prim on the stage.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim The stage on which to define the curves.
name The absolute prim path at which to define the curves.
curveVertexCounts The number of vertices in each independent curve. The length of this array determines the number of curves.
points Vertex/CV positions for the curves described in local space.
- wrap Determines how the start and end points of the curve behave. Accepted values for linear curves are
UsdGeom.Tokens.nonperiodic
andUsdGeom.Tokens.periodic
.
widths Values for the width specification for the curves.
normals Values for the normals primvar for the curves. If authored, the curves are considered oriented ribbons rather than tubes.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.BasisCurves
schema wrapping the definedUsd.Prim
- usdex.core.defineCubicBasisCurves(*args, **kwargs)#
Overloaded function.
defineCubicBasisCurves(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, curveVertexCounts: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, basis: str = ‘bezier’, wrap: str = ‘nonperiodic’, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.BasisCurves
Defines a batched Cubic
UsdGeom.BasisCurves
prim on the stage.Attribute values will be validated and in the case of invalid data the Curves will not be defined. An invalid
UsdGeom.BasisCurves
object will be returned in this case.Values will be authored for all attributes required to completely describe the Curves, even if weaker matching opinions already exist.
Curve Vertex Counts
Points
Type
Basis
Wrap
Extent
The “extent” of the Curves will be computed and authored based on the
points
andwidths
provided.The following common primvars can optionally be authored at the same time using a
PrimvarData
to specify interpolation, data, and optionally indices or elementSize.Widths
Normals
Display Color
Display Opacity
For both widths and normals, if they are provided, they are authored as
primvars:widths
andprimvars:normals
, so that indexing is possible and to ensure that the value takes precedence in cases where both the non-primvar and primvar attributes are authored.- Parameters:
stage The stage on which to define the curves.
path The absolute prim path at which to define the curves.
curveVertexCounts The number of vertices in each independent curve. The length of this array determines the number of curves.
points Vertex/CV positions for the curves described in local space.
- basis The basis specifies the vstep and matrix used for cubic interpolation. Accepted values for cubic curves are
UsdGeom.Tokens.bezier
,UsdGeom.Tokens.bspline
, orUsdGeom.Tokens.catmullRom
.
- wrap Determines how the start and end points of the curve behave. Accepted values are
UsdGeom.Tokens.nonperiodic
, UsdGeom.Tokens.periodic
, andUsdGeom.Tokens.pinned
(bspline and catmullRom only).
- wrap Determines how the start and end points of the curve behave. Accepted values are
widths Values for the width specification for the curves.
normals Values for the normals primvar for the curves. If authored, the curves are considered oriented ribbons rather than tubes.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.BasisCurves
schema wrapping the definedUsd.Prim
defineCubicBasisCurves(parent: pxr.Usd.Prim, name: str, curveVertexCounts: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, basis: str = ‘bezier’, wrap: str = ‘nonperiodic’, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.BasisCurves
Defines a batched Cubic
UsdGeom.BasisCurves
prim on the stage.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent Prim below which to define the curves
name Name of the curves
curveVertexCounts The number of vertices in each independent curve. The length of this array determines the number of curves.
points Vertex/CV positions for the curves described in local space.
- basis The basis specifies the vstep and matrix used for cubic interpolation. Accepted values for cubic curves are
UsdGeom.Tokens.bezier
,UsdGeom.Tokens.bspline
,UsdGeom.Tokens.catmullRom
.
- wrap Determines how the start and end points of the curve behave. Accepted values are
UsdGeom.Tokens.nonperiodic
, UsdGeom.Tokens.periodic
, andUsdGeom.Tokens.pinned
(bspline and catmullRom only).
- wrap Determines how the start and end points of the curve behave. Accepted values are
widths Values for the width specification for the curves.
normals Values for the normals primvar for the curves. If authored, the curves are considered oriented ribbons rather than tubes.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.BasisCurves
schema wrapping the definedUsd.Prim
defineCubicBasisCurves(prim: pxr.Usd.Prim, curveVertexCounts: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, basis: str = ‘bezier’, wrap: str = ‘nonperiodic’, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.BasisCurves
Defines a batched Cubic
UsdGeom.BasisCurves
prim on the stage.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim The stage on which to define the curves.
name The absolute prim path at which to define the curves.
curveVertexCounts The number of vertices in each independent curve. The length of this array determines the number of curves.
points Vertex/CV positions for the curves described in local space.
- basis The basis specifies the vstep and matrix used for cubic interpolation. Accepted values for cubic curves are
UsdGeom.Tokens.bezier
,UsdGeom.Tokens.bspline
, orUsdGeom.Tokens.catmullRom
.
- wrap Determines how the start and end points of the curve behave. Accepted values are
UsdGeom.Tokens.nonperiodic
, UsdGeom.Tokens.periodic
, andUsdGeom.Tokens.pinned
(bspline and catmullRom only).
- wrap Determines how the start and end points of the curve behave. Accepted values are
widths Values for the width specification for the curves.
normals Values for the normals primvar for the curves. If authored, the curves are considered oriented ribbons rather than tubes.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.BasisCurves
schema wrapping the definedUsd.Prim
- usdex.core.defineCamera(*args, **kwargs)#
Overloaded function.
defineCamera(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, cameraData: pxr.Gf.Camera) -> pxr.UsdGeom.Camera
Defines a basic 3d camera on the stage.
Note that
Gf.Camera
is a simplified form of 3d camera data that does not account for time-sampled data, shutter window, stereo role, or exposure. If you need to author those properties, do so after defining theUsdGeom.Camera
.An invalid UsdGeomCamera will be returned if camera attributes could not be authored successfully.
- Parameters:
stage - The stage on which to define the camera
path - The absolute prim path at which to define the camera
cameraData - The camera data to set, including the world space transform matrix
- Returns:
A
UsdGeom.Camera
schema wrapping the definedUsd.Prim
.
defineCamera(parent: pxr.Usd.Prim, name: str, cameraData: pxr.Gf.Camera) -> pxr.UsdGeom.Camera
Defines a basic 3d camera on the stage.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the camera
name - Name of the camera
cameraData - The camera data to set, including the world space transform matrix
- Returns:
A
UsdGeom.Camera
schema wrapping the definedUsd.Prim
.
defineCamera(prim: pxr.Usd.Prim, cameraData: pxr.Gf.Camera) -> pxr.UsdGeom.Camera
Defines a basic 3d camera from an existing prim.
This converts an existing prim to a Camera type, preserving any existing transform data.
- Parameters:
prim - The existing prim to convert to a camera
cameraData - The camera data to set, including the world space transform matrix
- Returns:
A
UsdGeom.Camera
schema wrapping the convertedUsd.Prim
.
- class usdex.core.FloatPrimvarData#
PrimvarData
that holdsVt.FloatArray
values (e.g widths or scale factors).This is a read-only class to manage all
UsdGeom.Primvar
data as a single object without risk of detaching (copying) arrays.UsdGeom.Primvars
are often used when authoringUsdGeom.PointBased
prims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvar
data can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Array
detach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvar
data handling.All of the USD authoring “define” functions in this library accept optional
PrimvarData
to define e.g normals, display colors, etc.Methods:
effectiveSize
(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize
(self)The element size.
getPrimvarData
(primvar[, time])Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.hasIndices
(self)Whether this is indexed or non-indexed
PrimvarData
index
(self)Update the values and indices of this
PrimvarData
object to avoid duplicate values.indices
(self)Access to the indices array.
interpolation
(self)The geometric interpolation.
isIdentical
(self, other)Check that all data between two
PrimvarData
objects is identical.isValid
(self)Whether the data is valid or invalid.
setPrimvar
(self, primvar[, time])Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.values
(self)Access to the values array.
- effectiveSize( ) int #
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int #
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvar
data to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()
for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()
to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData
.
- hasIndices( ) bool #
Whether this is indexed or non-indexed
PrimvarData
- Returns:
Whether this is indexed or non-indexed
PrimvarData
.
- index( ) bool #
Update the values and indices of this
PrimvarData
object to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray #
Access to the indices array.
This method throws a runtime error if the
PrimvarData
is not indexed. For exception-free access, checkhasIndices()
before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()
to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str #
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()
orUsdGeom.Primvar.IsValidInterpolation()
to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool #
Check that all data between two
PrimvarData
objects is identical.This differs from the equality operator in that it ensures the
Vt.Array
values and indices have not detached.- Parameters:
other – The other
PrimvarData
.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool #
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarData
itself & the requirements ofUsdGeom.Prim
. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBased
prim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation()
.The values are not empty. Note that individual values may be invalid (e.g
NaN
values on aVt.FloatArray
) but this will not be considered a failure, as some workflows allow forNaN
to indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.FloatPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarData
members.To copy data from one
UsdGeom.Primvar
to another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)
to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)
to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvar
was completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.FloatArray #
Access to the values array.
Bear in mind the values may need to be accessed via
indices()
or using anelementSize()
stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.IntPrimvarData#
PrimvarData
that holdsVt.IntArray
values (e.g simple switch values or booleans consumable by shaders).This is a read-only class to manage all
UsdGeom.Primvar
data as a single object without risk of detaching (copying) arrays.UsdGeom.Primvars
are often used when authoringUsdGeom.PointBased
prims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvar
data can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Array
detach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvar
data handling.All of the USD authoring “define” functions in this library accept optional
PrimvarData
to define e.g normals, display colors, etc.Methods:
effectiveSize
(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize
(self)The element size.
getPrimvarData
(primvar[, time])Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.hasIndices
(self)Whether this is indexed or non-indexed
PrimvarData
index
(self)Update the values and indices of this
PrimvarData
object to avoid duplicate values.indices
(self)Access to the indices array.
interpolation
(self)The geometric interpolation.
isIdentical
(self, other)Check that all data between two
PrimvarData
objects is identical.isValid
(self)Whether the data is valid or invalid.
setPrimvar
(self, primvar[, time])Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.values
(self)Access to the values array.
- effectiveSize( ) int #
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int #
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvar
data to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()
for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()
to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData
.
- hasIndices( ) bool #
Whether this is indexed or non-indexed
PrimvarData
- Returns:
Whether this is indexed or non-indexed
PrimvarData
.
- index( ) bool #
Update the values and indices of this
PrimvarData
object to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray #
Access to the indices array.
This method throws a runtime error if the
PrimvarData
is not indexed. For exception-free access, checkhasIndices()
before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()
to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str #
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()
orUsdGeom.Primvar.IsValidInterpolation()
to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool #
Check that all data between two
PrimvarData
objects is identical.This differs from the equality operator in that it ensures the
Vt.Array
values and indices have not detached.- Parameters:
other – The other
PrimvarData
.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool #
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarData
itself & the requirements ofUsdGeom.Prim
. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBased
prim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation()
.The values are not empty. Note that individual values may be invalid (e.g
NaN
values on aVt.FloatArray
) but this will not be considered a failure, as some workflows allow forNaN
to indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.IntPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarData
members.To copy data from one
UsdGeom.Primvar
to another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)
to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)
to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvar
was completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.IntArray #
Access to the values array.
Bear in mind the values may need to be accessed via
indices()
or using anelementSize()
stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.Int64PrimvarData#
PrimvarData
that holdsVt.Int64Array
values (e.g ids that might be very large).This is a read-only class to manage all
UsdGeom.Primvar
data as a single object without risk of detaching (copying) arrays.UsdGeom.Primvars
are often used when authoringUsdGeom.PointBased
prims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvar
data can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Array
detach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvar
data handling.All of the USD authoring “define” functions in this library accept optional
PrimvarData
to define e.g normals, display colors, etc.Methods:
effectiveSize
(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize
(self)The element size.
getPrimvarData
(primvar[, time])Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.hasIndices
(self)Whether this is indexed or non-indexed
PrimvarData
index
(self)Update the values and indices of this
PrimvarData
object to avoid duplicate values.indices
(self)Access to the indices array.
interpolation
(self)The geometric interpolation.
isIdentical
(self, other)Check that all data between two
PrimvarData
objects is identical.isValid
(self)Whether the data is valid or invalid.
setPrimvar
(self, primvar[, time])Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.values
(self)Access to the values array.
- effectiveSize( ) int #
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int #
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvar
data to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()
for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()
to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData
.
- hasIndices( ) bool #
Whether this is indexed or non-indexed
PrimvarData
- Returns:
Whether this is indexed or non-indexed
PrimvarData
.
- index( ) bool #
Update the values and indices of this
PrimvarData
object to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray #
Access to the indices array.
This method throws a runtime error if the
PrimvarData
is not indexed. For exception-free access, checkhasIndices()
before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()
to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str #
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()
orUsdGeom.Primvar.IsValidInterpolation()
to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool #
Check that all data between two
PrimvarData
objects is identical.This differs from the equality operator in that it ensures the
Vt.Array
values and indices have not detached.- Parameters:
other – The other
PrimvarData
.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool #
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarData
itself & the requirements ofUsdGeom.Prim
. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBased
prim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation()
.The values are not empty. Note that individual values may be invalid (e.g
NaN
values on aVt.FloatArray
) but this will not be considered a failure, as some workflows allow forNaN
to indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.Int64PrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarData
members.To copy data from one
UsdGeom.Primvar
to another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)
to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)
to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvar
was completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.Int64Array #
Access to the values array.
Bear in mind the values may need to be accessed via
indices()
or using anelementSize()
stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.Vec3fPrimvarData#
PrimvarData
that holdsVt.Vec3fArray
values (e.g normals, colors, or other vectors).This is a read-only class to manage all
UsdGeom.Primvar
data as a single object without risk of detaching (copying) arrays.UsdGeom.Primvars
are often used when authoringUsdGeom.PointBased
prims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvar
data can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Array
detach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvar
data handling.All of the USD authoring “define” functions in this library accept optional
PrimvarData
to define e.g normals, display colors, etc.Methods:
effectiveSize
(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize
(self)The element size.
getPrimvarData
(primvar[, time])Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.hasIndices
(self)Whether this is indexed or non-indexed
PrimvarData
index
(self)Update the values and indices of this
PrimvarData
object to avoid duplicate values.indices
(self)Access to the indices array.
interpolation
(self)The geometric interpolation.
isIdentical
(self, other)Check that all data between two
PrimvarData
objects is identical.isValid
(self)Whether the data is valid or invalid.
setPrimvar
(self, primvar[, time])Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.values
(self)Access to the values array.
- effectiveSize( ) int #
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int #
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvar
data to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()
for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()
to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData
.
- hasIndices( ) bool #
Whether this is indexed or non-indexed
PrimvarData
- Returns:
Whether this is indexed or non-indexed
PrimvarData
.
- index( ) bool #
Update the values and indices of this
PrimvarData
object to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray #
Access to the indices array.
This method throws a runtime error if the
PrimvarData
is not indexed. For exception-free access, checkhasIndices()
before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()
to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str #
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()
orUsdGeom.Primvar.IsValidInterpolation()
to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool #
Check that all data between two
PrimvarData
objects is identical.This differs from the equality operator in that it ensures the
Vt.Array
values and indices have not detached.- Parameters:
other – The other
PrimvarData
.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool #
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarData
itself & the requirements ofUsdGeom.Prim
. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBased
prim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation()
.The values are not empty. Note that individual values may be invalid (e.g
NaN
values on aVt.FloatArray
) but this will not be considered a failure, as some workflows allow forNaN
to indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.Vec3fPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarData
members.To copy data from one
UsdGeom.Primvar
to another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)
to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)
to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvar
was completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.Vec3fArray #
Access to the values array.
Bear in mind the values may need to be accessed via
indices()
or using anelementSize()
stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.Vec2fPrimvarData#
PrimvarData
that holdsVt.Vec2fArray
values (e.g texture coordinates).This is a read-only class to manage all
UsdGeom.Primvar
data as a single object without risk of detaching (copying) arrays.UsdGeom.Primvars
are often used when authoringUsdGeom.PointBased
prims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvar
data can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Array
detach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvar
data handling.All of the USD authoring “define” functions in this library accept optional
PrimvarData
to define e.g normals, display colors, etc.Methods:
effectiveSize
(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize
(self)The element size.
getPrimvarData
(primvar[, time])Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.hasIndices
(self)Whether this is indexed or non-indexed
PrimvarData
index
(self)Update the values and indices of this
PrimvarData
object to avoid duplicate values.indices
(self)Access to the indices array.
interpolation
(self)The geometric interpolation.
isIdentical
(self, other)Check that all data between two
PrimvarData
objects is identical.isValid
(self)Whether the data is valid or invalid.
setPrimvar
(self, primvar[, time])Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.values
(self)Access to the values array.
- effectiveSize( ) int #
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int #
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvar
data to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()
for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()
to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData
.
- hasIndices( ) bool #
Whether this is indexed or non-indexed
PrimvarData
- Returns:
Whether this is indexed or non-indexed
PrimvarData
.
- index( ) bool #
Update the values and indices of this
PrimvarData
object to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray #
Access to the indices array.
This method throws a runtime error if the
PrimvarData
is not indexed. For exception-free access, checkhasIndices()
before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()
to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str #
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()
orUsdGeom.Primvar.IsValidInterpolation()
to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool #
Check that all data between two
PrimvarData
objects is identical.This differs from the equality operator in that it ensures the
Vt.Array
values and indices have not detached.- Parameters:
other – The other
PrimvarData
.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool #
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarData
itself & the requirements ofUsdGeom.Prim
. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBased
prim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation()
.The values are not empty. Note that individual values may be invalid (e.g
NaN
values on aVt.FloatArray
) but this will not be considered a failure, as some workflows allow forNaN
to indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.Vec2fPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarData
members.To copy data from one
UsdGeom.Primvar
to another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)
to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)
to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvar
was completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.Vec2fArray #
Access to the values array.
Bear in mind the values may need to be accessed via
indices()
or using anelementSize()
stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.StringPrimvarData#
PrimvarData
that holdsVt.StringArray
values (e.g human readable descriptors).This is a read-only class to manage all
UsdGeom.Primvar
data as a single object without risk of detaching (copying) arrays.UsdGeom.Primvars
are often used when authoringUsdGeom.PointBased
prims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvar
data can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Array
detach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvar
data handling.All of the USD authoring “define” functions in this library accept optional
PrimvarData
to define e.g normals, display colors, etc.Methods:
effectiveSize
(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize
(self)The element size.
getPrimvarData
(primvar[, time])Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.hasIndices
(self)Whether this is indexed or non-indexed
PrimvarData
index
(self)Update the values and indices of this
PrimvarData
object to avoid duplicate values.indices
(self)Access to the indices array.
interpolation
(self)The geometric interpolation.
isIdentical
(self, other)Check that all data between two
PrimvarData
objects is identical.isValid
(self)Whether the data is valid or invalid.
setPrimvar
(self, primvar[, time])Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.values
(self)Access to the values array.
- effectiveSize( ) int #
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int #
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvar
data to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()
for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()
to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData
.
- hasIndices( ) bool #
Whether this is indexed or non-indexed
PrimvarData
- Returns:
Whether this is indexed or non-indexed
PrimvarData
.
- index( ) bool #
Update the values and indices of this
PrimvarData
object to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray #
Access to the indices array.
This method throws a runtime error if the
PrimvarData
is not indexed. For exception-free access, checkhasIndices()
before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()
to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str #
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()
orUsdGeom.Primvar.IsValidInterpolation()
to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool #
Check that all data between two
PrimvarData
objects is identical.This differs from the equality operator in that it ensures the
Vt.Array
values and indices have not detached.- Parameters:
other – The other
PrimvarData
.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool #
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarData
itself & the requirements ofUsdGeom.Prim
. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBased
prim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation()
.The values are not empty. Note that individual values may be invalid (e.g
NaN
values on aVt.FloatArray
) but this will not be considered a failure, as some workflows allow forNaN
to indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.StringPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarData
members.To copy data from one
UsdGeom.Primvar
to another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)
to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)
to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvar
was completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.StringArray #
Access to the values array.
Bear in mind the values may need to be accessed via
indices()
or using anelementSize()
stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.TokenPrimvarData#
PrimvarData
that holdsVt.TokenArray
values (e.g more efficient human readable descriptors).This is a more efficient format than raw strings if you have many repeated values across different prims.
Note
TfToken
lifetime lasts the entire process. Too many tokens in memory may consume resources somewhat unexpectedly.This is a read-only class to manage all
UsdGeom.Primvar
data as a single object without risk of detaching (copying) arrays.UsdGeom.Primvars
are often used when authoringUsdGeom.PointBased
prims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvar
data can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Array
detach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvar
data handling.All of the USD authoring “define” functions in this library accept optional
PrimvarData
to define e.g normals, display colors, etc.Methods:
effectiveSize
(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize
(self)The element size.
getPrimvarData
(primvar[, time])Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.hasIndices
(self)Whether this is indexed or non-indexed
PrimvarData
index
(self)Update the values and indices of this
PrimvarData
object to avoid duplicate values.indices
(self)Access to the indices array.
interpolation
(self)The geometric interpolation.
isIdentical
(self, other)Check that all data between two
PrimvarData
objects is identical.isValid
(self)Whether the data is valid or invalid.
setPrimvar
(self, primvar[, time])Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.values
(self)Access to the values array.
- effectiveSize( ) int #
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int #
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvar
data to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()
for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarData
from aUsdGeom.Primvar
that has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()
to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData
.
- hasIndices( ) bool #
Whether this is indexed or non-indexed
PrimvarData
- Returns:
Whether this is indexed or non-indexed
PrimvarData
.
- index( ) bool #
Update the values and indices of this
PrimvarData
object to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray #
Access to the indices array.
This method throws a runtime error if the
PrimvarData
is not indexed. For exception-free access, checkhasIndices()
before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()
to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str #
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()
orUsdGeom.Primvar.IsValidInterpolation()
to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool #
Check that all data between two
PrimvarData
objects is identical.This differs from the equality operator in that it ensures the
Vt.Array
values and indices have not detached.- Parameters:
other – The other
PrimvarData
.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool #
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarData
itself & the requirements ofUsdGeom.Prim
. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBased
prim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation()
.The values are not empty. Note that individual values may be invalid (e.g
NaN
values on aVt.FloatArray
) but this will not be considered a failure, as some workflows allow forNaN
to indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.TokenPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvar
from aPrimvarData
that has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarData
members.To copy data from one
UsdGeom.Primvar
to another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)
to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)
to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar
.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvar
was completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.TokenArray #
Access to the values array.
Bear in mind the values may need to be accessed via
indices()
or using anelementSize()
stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- usdex.core.isLight(prim: pxr.Usd.Prim) bool #
Determines if a UsdPrim has a
UsdLux.LightAPI
schema applied- Parameters:
prim – The prim to check for an applied
UsdLux.LightAPI
schema- Returns:
True if the prim has a
UsdLux.LightAPI
schema applied
- usdex.core.getLightAttr(defaultAttr: pxr.Usd.Attribute) pxr.Usd.Attribute #
Get the “correct” light attribute for a light that could have any combination of authored old and new UsdLux schema attributes
The new attribute names have “inputs:” prepended to the names to make them connectable.
Light has only “intensity” authored: return “intensity” attribute
Light has only “inputs:intensity” authored: return “inputs:intensity” attribute
Light has both “inputs:intensity” and “intensity” authored: return “inputs:intensity”
- Parameters:
defaultAttr – The attribute to read from the light schema: eg.
UsdLux.RectLight.GetHeightAttr()
- Returns:
The attribute from which the light value should be read
- usdex.core.defineDomeLight(*args, **kwargs)#
Overloaded function.
defineDomeLight(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, intensity: float = 1.0, texturePath: Optional[str] = None, textureFormat: str = ‘automatic’) -> pxr.UsdLux.DomeLight
Creates a dome light with an optional texture.
A dome light represents light emitted inward from a distant external environment, such as a sky or IBL light probe.
Texture Format values:
automatic
- Tries to determine the layout from the file itself.latlong
- Latitude as X, longitude as Y.mirroredBall
- An image of the environment reflected in a sphere, using an implicitly orthogonal projection.angular
- Similar to mirroredBall but the radial dimension is mapped linearly to the angle, for better sampling at the edges.cubeMapVerticalCross
- Set to “automatic” by default.
Note:
The DomeLight schema requires the dome’s top pole to be aligned with the world’s +Y axis. In USD 23.11 a new UsdLuxDomeLight_1 schema was added which gives control over the pole axis. However, it is not widely supported yet, so we still prefer to author the original DomeLight schema and expect consuming application and renderers to account for the +Y pole axis.
- Parameters:
stage - The stage in which the light should be authored
path - The path which the light prim should be written to
intensity - The intensity value of the dome light
texturePath - The path to the texture file to use on the dome light.
textureFormat - How the texture should be mapped on the dome light.
- Returns:
The dome light if created successfully.
defineDomeLight(parent: pxr.Usd.Prim, name: str, intensity: float = 1.0, texturePath: Optional[str] = None, textureFormat: str = ‘automatic’) -> pxr.UsdLux.DomeLight
Creates a dome light with an optional texture.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the light
name - Name of the light
intensity - The intensity value of the dome light
texturePath - The path to the texture file to use on the dome light.
textureFormat - How the texture should be mapped on the dome light.
- Returns:
The dome light if created successfully.
defineDomeLight(prim: pxr.Usd.Prim, intensity: float = 1.0, texturePath: Optional[str] = None, textureFormat: str = ‘automatic’) -> pxr.UsdLux.DomeLight
Creates a dome light with an optional texture.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Args:
prim: Prim to define the dome light on. The prim’s type will be set to
UsdLux.DomeLight
. intensity: The intensity value of the dome light texturePath: The path to the texture file to use on the dome light. textureFormat: How the texture should be mapped on the dome light.- Returns:
The light if created successfully.
- usdex.core.defineRectLight(*args, **kwargs)#
Overloaded function.
defineRectLight(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, width: float, height: float, intensity: float = 1.0, texturePath: Optional[str] = None) -> pxr.UsdLux.RectLight
Creates a rectangular (rect) light with an optional texture.
A rect light represents light emitted from one side of a rectangle.
- Parameters:
stage - The stage in which the light should be authored
path - The path which the light prim should be written to
width - The width of the rectangular light, in the local X axis.
height - The height of the rectangular light, in the local Y axis.
intensity - The intensity value of the rectangular light
texturePath - Optional - The path to the texture file to use on the rectangular light.
- Returns:
The rect light if created successfully.
defineRectLight(parent: pxr.Usd.Prim, name: str, width: float, height: float, intensity: float = 1.0, texturePath: Optional[str] = None) -> pxr.UsdLux.RectLight
Creates a rectangular (rect) light with an optional texture.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the light
name - Name of the light
width - The width of the rectangular light, in the local X axis.
height - The height of the rectangular light, in the local Y axis.
intensity - The intensity value of the rectangular light
texturePath - Optional - The path to the texture file to use on the rectangular light.
- Returns:
The rect light if created successfully.
defineRectLight(prim: pxr.Usd.Prim, width: float, height: float, intensity: float = 1.0, texturePath: Optional[str] = None) -> pxr.UsdLux.RectLight
Creates a rectangular (rect) light with an optional texture.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Args:
prim: Prim to define the rectangular light on. The prim’s type will be set to
UsdLux.RectLight
. width: The width of the rectangular light, in the local X axis. height: The height of the rectangular light, in the local Y axis. intensity: The intensity value of the rectangular light. texturePath: The path to the texture file to use on the rectangular light.- Returns:
The light if created successfully.
- usdex.core.createMaterial(
- parent: pxr.Usd.Prim,
- name: str,
Create a
UsdShade.Material
as the child of the Prim parent- Parameters:
parent – Parent prim of the material
name – Name of the material to be created
- Returns:
The newly created
UsdShade.Material
. Returns an invalid material object on error.
- usdex.core.bindMaterial(
- prim: pxr.Usd.Prim,
- material: pxr.UsdShade.Material,
Authors a direct binding to the given material on this prim.
Validates both the prim and the material, applies the
UsdShade.MaterialBindingAPI
to the target prim, and binds the material to the target prim.Note
The material is bound with the default “all purpose” used for both full and preview rendering, and with the default “fallback strength” meaning descendant prims can override with a different material. If alternate behavior is desired, use the
UsdShade.MaterialBindingAPI
directly.- Parameters:
prim – The prim that the material will affect
material – The material to bind to the prim
- Returns:
Whether the material was successfully bound to the target prim.
- usdex.core.computeEffectivePreviewSurfaceShader(
- material: pxr.UsdShade.Material,
Get the effective surface Shader of a Material for the universal render context.
- Parameters:
material – The Material to consider
- Returns:
The connected Shader. Returns an invalid shader object on error.
- usdex.core.definePreviewMaterial(*args, **kwargs)#
Overloaded function.
definePreviewMaterial(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, color: pxr.Gf.Vec3f, opacity: float = 1.0, roughness: float = 0.5, metallic: float = 0.0) -> pxr.UsdShade.Material
Defines a PBR
UsdShade.Material
driven by aUsdPreviewSurface
shader network for the universal render context.The input parameters reflect a subset of the UsdPreviewSurface specification commonly used when authoring materials using the metallic/metalness workflow (as opposed to the specular workflow). Many other inputs are available and can be authored after calling this function (including switching to the specular workflow).
- Parameters:
stage - The stage on which to define the Material
path - The absolute prim path at which to define the Material
color - The diffuse color of the Material
opacity - The Opacity Amount to set, 0.0-1.0 range where 1.0 = opaque and 0.0 = invisible
roughness - The Roughness Amount to set, 0.0-1.0 range where 1.0 = flat and 0.0 = glossy
metallic - The Metallic Amount to set, 0.0-1.0 range where 1.0 = max metallic and 0.0 = no metallic
- Returns:
The newly defined
UsdShade.Material
. Returns an Invalid prim on error
definePreviewMaterial(parent: pxr.Usd.Prim, name: str, color: pxr.Gf.Vec3f, opacity: float = 1.0, roughness: float = 0.5, metallic: float = 0.0) -> pxr.UsdShade.Material
Defines a PBR
UsdShade.Material
driven by aUsdPreviewSurface
shader network for the universal render context.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the Material
name - Name of the Material
color - The diffuse color of the Material
opacity - The Opacity Amount to set, 0.0-1.0 range where 1.0 = opaque and 0.0 = invisible
roughness - The Roughness Amount to set, 0.0-1.0 range where 1.0 = flat and 0.0 = glossy
metallic - The Metallic Amount to set, 0.0-1.0 range where 1.0 = max metallic and 0.0 = no metallic
- Returns:
The newly defined
UsdShade.Material
. Returns an Invalid prim on error
definePreviewMaterial(prim: pxr.Usd.Prim, color: pxr.Gf.Vec3f, opacity: float = 1.0, roughness: float = 0.5, metallic: float = 0.0) -> pxr.UsdShade.Material
Defines a PBR
UsdShade.Material
driven by aUsdPreviewSurface
shader network for the universal render context.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Args:
prim: Prim to define the material on. The prim’s type will be set to
UsdShade.Material
. color: The diffuse color of the Material opacity: The Opacity Amount to set, 0.0-1.0 range where 1.0 = opaque and 0.0 = invisible roughness: The Roughness Amount to set, 0.0-1.0 range where 1.0 = flat and 0.0 = glossy metallic: The Metallic Amount to set, 0.0-1.0 range where 1.0 = max metallic and 0.0 = no metallic- Returns:
The newly defined
UsdShade.Material
. Returns an Invalid object on error.
- usdex.core.addDiffuseTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds a diffuse texture to a preview material
It is expected that the material was created by
definePreviewMaterial()
The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st
).- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPath
for the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addNormalTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds a normals texture to a preview material
It is expected that the material was created by
definePreviewMaterial()
The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st
).The UsdPreviewSurface specification requires the texture reader to provide data that is properly scaled and ready to be consumed as a tangent space normal. Textures stored in 8-bit file formats require scale and bias adjustment to transform the normals into tangent space.
This module cannot read the provided
texturePath
to inspect the channel data (the file may not resolve locally, or even exist yet). To account for this, it performs the scale and bias adjustment when the texturePath extension matches a list of known 8-bit formats:["bmp", "tga", "jpg", "jpeg", "png", "tif"]
. Similarly, it assumes that the raw normals data was written into the file, regardless of any file format specific color space metadata. If either of these assumptions is incorrect for your source data, you will need to adjust thescale
,bias
, andsourceColorSpace
settings after calling this function.- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPath
for the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addOrmTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds an ORM (occlusion, roughness, metallic) texture to a preview material
An ORM texture is a normal 3-channel image asset, where the R channel represents occlusion, the G channel represents roughness, and the B channel represents metallic/metallness.
It is expected that the material was created by
definePreviewMaterial()
The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st
).- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPath
for the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addRoughnessTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds a single channel roughness texture to a preview material
It is expected that the material was created by
definePreviewMaterial()
The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st
).- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPath
for the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addMetallicTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds a single channel metallic texture to a preview material
It is expected that the material was created by
definePreviewMaterial()
The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st
).- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPath
for the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addOpacityTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds a single channel opacity texture to a preview material
It is expected that the material was created by
definePreviewMaterial()
The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st
).- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPath
for the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addPreviewMaterialInterface(material: pxr.UsdShade.Material) bool #
Adds
UsdShade.Inputs
to the material prim to create an “interface” to the underlying Preview Shader network.All non-default-value
UsdShade.Inputs
on the effective surface shader for the universal render context will be “promoted” to theUsdShade.Material
as newUsdShade.Inputs
. They will be connected to the original source inputs on the shaders, to drive those values, and they will be authored with a value matching what had been set on the shader inputs at the time this function was called.Additionally,
UsdUVTexture.file
inputs on connected shaders will be promoted to the material, following the same logic as direct surface inputs.Note
It is preferable to author all initial shader attributes (including textures) before calling
addPreviewMaterialInterface()
.Warning
This function will fail if there is any other render context driving the material surface. It is only suitable for use on Preview Shader networks, such as the network generated by
definePreviewMaterial()
and its associatedadd*Texture
functions. If you require multiple contexts, you should instead construct a Material Interface directly, or with targetted end-user interaction.- Parameters:
material – The material prim
- Returns:
Whether or not the Material inputs were added successfully
- usdex.core.removeMaterialInterface(
- material: pxr.UsdShade.Material,
- bakeValues: bool = True,
Removes any
UsdShade.Inputs
found on the material prim.All
UsdShade.Inputs
on theUsdShade.Material
will be disconnected from any underlying shader inputs, then removed from the material. The current values may be optionally “baked down” onto the shader inputs in order to retain the current material behavior, or may be discarded in order to revert to a default appearance based on the shader definitions.Note
While
addPreviewMaterialInterface
is specific to Preview Material shader networks,removeMaterialInterface
affects all render contexts and will remove allUsdShade.Inputs
returned viaUsdShade.Material.GetInterfaceInputs()
, baking down the values onto all consumer shaders, regardless of render context.- Parameters:
material – The material prim
bakeValues – Whether or not the current Material inputs values are set on the underlying Shader inputs
- Returns:
Whether or not the Material inputs were removed successfully
- class usdex.core.ColorSpace#
Texture color space (encoding) types
Members:
eAuto : Check for gamma or metadata in the texture itself
eRaw : Use linear sampling (typically used for Normal, Roughness, Metallic, Opacity textures, or when using high dynamic range file formats like EXR)
eSrgb : Use sRGB sampling (typically used for Diffuse textures when using PNG files)
Attributes:
- property name#
- usdex.core.getColorSpaceToken(value: usdex.core._usdex_core.ColorSpace) str #
Get the str matching a given ColorSpace
The string representation is typically used when setting shader inputs, such as
inputs:sourceColorSpace
onUsdUVTexture
.- Parameters:
value – The
ColorSpace
- Returns:
The str for the given
ColorSpace
value
- usdex.core.sRgbToLinear(color: pxr.Gf.Vec3f) pxr.Gf.Vec3f #
Translate an sRGB color value to linear color space
Many 3D modeling applications define colors in sRGB (0-1) color space. Many others use a linear color space that aligns with how light and color behave in the natural world. When authoring
UsdShade.Shader
color input data, including external texture assets, you may need to translate between color spaces.Note
Color is a complex topic in 3D rendering and providing utilities covering the full breadth of color science is beyond the scope of this module. See this [MathWorks article](https://www.mathworks.com/help/images/understanding-color-spaces-and-color-space-conversion.html) for a relatively brief introduction. If you need more specific color handling please use a dedicated color science library like [OpenColorIO](https://opencolorio.org).
- Parameters:
color – sRGB representation of a color to be translated to linear color space
- Returns:
The translated color in linear color space
- usdex.core.linearToSrgb(color: pxr.Gf.Vec3f) pxr.Gf.Vec3f #
Translate a linear color value to sRGB color space
Many 3D modeling applications define colors in sRGB (0-1) color space. Many others use a linear color space that aligns with how light and color behave in the natural world. When authoring
UsdShade.Shader
color input data, including external texture assets, you may need to translate between color spaces.Note
Color is a complex topic in 3D rendering and providing utilities covering the full breadth of color science is beyond the scope of this module. See this [MathWorks article](https://www.mathworks.com/help/images/understanding-color-spaces-and-color-space-conversion.html) for a relatively brief introduction. If you need more specific color handling please use a dedicated color science library like [OpenColorIO](https://opencolorio.org).
- Parameters:
color – linear representation of a color to be translated to sRGB color space
- Returns:
The translated color in sRGB color space
- class usdex.core.JointFrame#
Specifies a position and rotation in the coordinate system specified by
space
Note
The
position
andorientation
are stored as doubles to avoid precision loss when aligning the joint to each body. This differs from theUsdPhysics.Joint
schema, which stores them as floats. The final authored values on thePhysicsJoint
prim will be cast down to floats to align with the schema.Classes:
Coordinate systems in which a joint can be defined
Attributes:
The orientation of the joint
The position of the joint
The space in which the joint is defined
- class Space#
Coordinate systems in which a joint can be defined
Members:
Body0 : The joint is defined in the local space of
body0
Body1 : The joint is defined in the local space of
body1
World : The joint is defined in world space
Attributes:
- property name#
- property orientation#
The orientation of the joint
- property position#
The position of the joint
- property space#
The space in which the joint is defined
- usdex.core.definePhysicsFixedJoint(*args, **kwargs)#
Overloaded function.
definePhysicsFixedJoint(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame) -> pxr.UsdPhysics.FixedJoint
Creates a fixed joint connecting two rigid bodies.
A fixed joint connects two prims making them effectively welded together. For maximal coordinate (free-body) solvers it is important to fully constrain the two bodies. For reduced coordinate solvers this is may seem redundant, but it is important for consistency & cross-solver portability.
Using the coordinate system specified by the
jointFrame
, the local position and rotation corresponding tobody0
andbody1
of the joint are automatically calculated.- Parameters:
stage - The stage on which to define the joint
path - The absolute prim path at which to define the joint
body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
- Returns:
UsdPhysics.FixedJoint
schema wrapping the definedUsd.Prim
.
definePhysicsFixedJoint(parent: pxr.Usd.Prim, name: str, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame) -> pxr.UsdPhysics.FixedJoint
Creates a fixed joint connecting two rigid bodies.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the physics joint
name - Name of the physics joint
body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
- Returns:
UsdPhysics.FixedJoint
schema wrapping the definedUsd.Prim
.
definePhysicsFixedJoint(prim: pxr.Usd.Prim, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame) -> pxr.UsdPhysics.FixedJoint
Creates a fixed joint connecting two rigid bodies.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim - Prim to define the joint. The prim’s type will be set to
UsdPhysics.FixedJoint
.body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
- Returns:
UsdPhysics.FixedJoint
schema wrapping the definedUsd.Prim
.
- usdex.core.definePhysicsRevoluteJoint(*args, **kwargs)#
Overloaded function.
definePhysicsRevoluteJoint(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame, axis: pxr.Gf.Vec3f, lowerLimit: Optional[float] = None, upperLimit: Optional[float] = None) -> pxr.UsdPhysics.RevoluteJoint
Creates a revolute joint, which acts as a hinge around a single axis, connecting two rigid bodies.
Using the coordinate system specified by the
jointFrame
, the local position and rotation corresponding tobody0
andbody1
of the joint are automatically calculated.The
axis
specifies the primary axis for rotation, based on the local joint orientation relative to each body.To rotate around the X-axis, specify (1, 0, 0). To rotate in the opposite direction, specify (-1, 0, 0).
To rotate around the Y-axis, specify (0, 1, 0). To rotate in the opposite direction, specify (0, -1, 0).
To rotate around the Z-axis, specify (0, 0, 1). To rotate in the opposite direction, specify (0, 0, -1).
Any other direction will be aligned to X-axis via a local rotation for both bodies.
- Parameters:
stage - The stage on which to define the joint
path - The absolute prim path at which to define the joint
body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
axis - The axis of rotation
lowerLimit - The lower limit of the joint (degrees).
upperLimit - The upper limit of the joint (degrees).
- Returns:
UsdPhysics.RevoluteJoint
schema wrapping the definedUsd.Prim
.
definePhysicsRevoluteJoint(parent: pxr.Usd.Prim, name: str, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame, axis: pxr.Gf.Vec3f, lowerLimit: Optional[float] = None, upperLimit: Optional[float] = None) -> pxr.UsdPhysics.RevoluteJoint
Creates a revolute joint, which acts as a hinge around a single axis, connecting two rigid bodies.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the physics joint
name - Name of the physics joint
body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
axis - The axis of rotation
lowerLimit - The lower limit of the joint (degrees).
upperLimit - The upper limit of the joint (degrees).
- Returns:
UsdPhysics.RevoluteJoint
schema wrapping the definedUsd.Prim
.
definePhysicsRevoluteJoint(prim: pxr.Usd.Prim, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame, axis: pxr.Gf.Vec3f, lowerLimit: Optional[float] = None, upperLimit: Optional[float] = None) -> pxr.UsdPhysics.RevoluteJoint
Creates a revolute joint, which acts as a hinge around a single axis, connecting two rigid bodies.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim - Prim to define the joint. The prim’s type will be set to
UsdPhysics.RevoluteJoint
.body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
axis - The axis of rotation
lowerLimit - The lower limit of the joint (degrees).
upperLimit - The upper limit of the joint (degrees).
- Returns:
UsdPhysics.RevoluteJoint
schema wrapping the definedUsd.Prim
.
- usdex.core.definePhysicsPrismaticJoint(*args, **kwargs)#
Overloaded function.
definePhysicsPrismaticJoint(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame, axis: pxr.Gf.Vec3f, lowerLimit: Optional[float] = None, upperLimit: Optional[float] = None) -> pxr.UsdPhysics.PrismaticJoint
Creates a prismatic joint, which acts as a slider along a single axis, connecting two rigid bodies.
Using the coordinate system specified by the
jointFrame
, the local position and rotation corresponding tobody0
andbody1
of the joint are automatically calculated.The
axis
specifies the primary axis for rotation, based on the local joint orientation relative to each body.To slide along the X-axis, specify (1, 0, 0). To slide in the opposite direction, specify (-1, 0, 0).
To slide along the Y-axis, specify (0, 1, 0). To slide in the opposite direction, specify (0, -1, 0).
To slide along the Z-axis, specify (0, 0, 1). To slide in the opposite direction, specify (0, 0, -1).
Any other direction will be aligned to X-axis via a local rotation for both bodies.
The
lowerLimit
andupperLimit
are specified as distance along theaxis
in [linear units of the stage](https://openusd.org/release/api/group___usd_geom_linear_units__group.html).- Parameters:
stage - The stage on which to define the joint
path - The absolute prim path at which to define the joint
body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
axis - The axis of the joint.
lowerLimit - The lower limit of the joint (distance).
upperLimit - The upper limit of the joint (distance).
- Returns:
UsdPhysics.PrismaticJoint
schema wrapping the definedUsd.Prim
.
definePhysicsPrismaticJoint(parent: pxr.Usd.Prim, name: str, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame, axis: pxr.Gf.Vec3f, lowerLimit: Optional[float] = None, upperLimit: Optional[float] = None) -> pxr.UsdPhysics.PrismaticJoint
Creates a prismatic joint, which acts as a slider along a single axis, connecting two rigid bodies.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the physics joint
name - Name of the physics joint
body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
axis - The axis of the joint.
lowerLimit - The lower limit of the joint (distance).
upperLimit - The upper limit of the joint (distance).
- Returns:
UsdPhysics.PrismaticJoint
schema wrapping the definedUsd.Prim
.
definePhysicsPrismaticJoint(prim: pxr.Usd.Prim, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame, axis: pxr.Gf.Vec3f, lowerLimit: Optional[float] = None, upperLimit: Optional[float] = None) -> pxr.UsdPhysics.PrismaticJoint
Creates a prismatic joint, which acts as a slider along a single axis, connecting two rigid bodies.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim - Prim to define the joint. The prim’s type will be set to
UsdPhysics.PrismaticJoint
.body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
axis - The axis of the joint.
lowerLimit - The lower limit of the joint (distance).
upperLimit - The upper limit of the joint (distance).
- Returns:
UsdPhysics.PrismaticJoint
schema wrapping the definedUsd.Prim
.
- usdex.core.definePhysicsSphericalJoint(*args, **kwargs)#
Overloaded function.
definePhysicsSphericalJoint(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame, axis: pxr.Gf.Vec3f, coneAngle0Limit: Optional[float] = None, coneAngle1Limit: Optional[float] = None) -> pxr.UsdPhysics.SphericalJoint
Creates a spherical joint, which acts as a ball and socket joint, connecting two rigid bodies.
Using the coordinate system specified by the
jointFrame
, the local position and rotation corresponding tobody0
andbody1
of the joint are automatically calculated.The
axis
specifies the primary axis for rotation, based on the local joint orientation relative to each body.To rotate around the X-axis, specify (1, 0, 0). To rotate in the opposite direction, specify (-1, 0, 0).
To rotate around the Y-axis, specify (0, 1, 0). To rotate in the opposite direction, specify (0, -1, 0).
To rotate around the Z-axis, specify (0, 0, 1). To rotate in the opposite direction, specify (0, 0, -1).
Any other direction will be aligned to X-axis via a local rotation for both bodies.
For SphericalJoint, the axis specified here is used as the center, and the horizontal and vertical cone angles are limited by
coneAngle0Limit
andconeAngle1Limit
.- Parameters:
stage - The stage on which to define the joint
path - The absolute prim path at which to define the joint
body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
axis - The axis of the joint.
coneAngle0Limit - The lower limit of the cone angle (degrees).
coneAngle1Limit - The upper limit of the cone angle (degrees).
- Returns:
UsdPhysics.SphericalJoint
schema wrapping the definedUsd.Prim
.
definePhysicsSphericalJoint(parent: pxr.Usd.Prim, name: str, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame, axis: pxr.Gf.Vec3f, coneAngle0Limit: Optional[float] = None, coneAngle1Limit: Optional[float] = None) -> pxr.UsdPhysics.SphericalJoint
Creates a spherical joint, which acts as a ball and socket joint, connecting two rigid bodies.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the physics joint
name - Name of the physics joint
body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
axis - The axis of the joint.
coneAngle0Limit - The lower limit of the cone angle (degrees).
coneAngle1Limit - The upper limit of the cone angle (degrees).
- Returns:
UsdPhysics.SphericalJoint
schema wrapping the definedUsd.Prim
.
definePhysicsSphericalJoint(prim: pxr.Usd.Prim, body0: pxr.Usd.Prim, body1: pxr.Usd.Prim, frame: usdex.core._usdex_core.JointFrame, axis: pxr.Gf.Vec3f, coneAngle0Limit: Optional[float] = None, coneAngle1Limit: Optional[float] = None) -> pxr.UsdPhysics.SphericalJoint
Creates a spherical joint, which acts as a ball and socket joint, connecting two rigid bodies.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim - Prim to define the joint. The prim’s type will be set to
UsdPhysics.SphericalJoint
.body0 - The first body of the joint
body1 - The second body of the joint
frame - The position and rotation of the joint in the specified coordinate system.
axis - The axis of the joint.
coneAngle0Limit - The lower limit of the cone angle (degrees).
coneAngle1Limit - The upper limit of the cone angle (degrees).
- Returns:
UsdPhysics.SphericalJoint
schema wrapping the definedUsd.Prim
.
- usdex.core.alignPhysicsJoint(
- joint: pxr.UsdPhysics.Joint,
- frame: usdex.core._usdex_core.JointFrame,
- axis: pxr.Gf.Vec3f,
Aligns an existing joint with the specified position, rotation, and axis.
The Joint’s local position & orientation relative to each Body will be authored to align to the specified position, orientation, and axis.
The
axis
specifies the primary axis for rotation or translation, based on the local joint orientation relative to each body.To rotate or translate about about the X-axis, specify (1, 0, 0). To operate in the opposite direction, specify (-1, 0, 0).
To rotate or translate about about the Y-axis, specify (0, 1, 0). To operate in the opposite direction, specify (0, -1, 0).
To rotate or translate about about the Z-axis, specify (0, 0, 1). To operate in the opposite direction, specify (0, 0, -1).
Any other direction will be aligned to X-axis via a local rotation or translation for both bodies.
- Parameters:
align (- joint - The joint to)
system. (- frame - Specifies the position and rotation of the joint in the specified coordinate)
joint. (- axis - The axis of the)
- usdex.core.definePhysicsMaterial(*args, **kwargs)#
Overloaded function.
definePhysicsMaterial(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, dynamicFriction: float, staticFriction: Optional[float] = None, restitution: Optional[float] = None, density: Optional[float] = None) -> pxr.UsdShade.Material
Creates a Physics Material.
When
UsdPhysics.MaterialAPI
is applied on aUsdShade.Material
it specifies various physical properties which should be used during simulation of the bound geometry.See [UsdPhysicsMaterialAPI](https://openusd.org/release/api/class_usd_physics_material_a_p_i.html) for details.
- Parameters:
stage - The stage on which to define the material
path - The absolute prim path at which to define the material
dynamicFriction - The dynamic friction of the material
staticFriction - The static friction of the material
restitution - The restitution of the material
density - The density of the material
- Returns:
UsdShade.Material
schema wrapping the definedUsd.Prim
.
definePhysicsMaterial(parent: pxr.Usd.Prim, name: str, dynamicFriction: float, staticFriction: Optional[float] = None, restitution: Optional[float] = None, density: Optional[float] = None) -> pxr.UsdShade.Material
Creates a Physics Material.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the physics material
name - Name of the physics material
dynamicFriction - The dynamic friction of the material
staticFriction - The static friction of the material
restitution - The restitution of the material
density - The density of the material
- Returns:
UsdShade.Material
schema wrapping the definedUsd.Prim
.
definePhysicsMaterial(prim: pxr.Usd.Prim, dynamicFriction: float, staticFriction: Optional[float] = None, restitution: Optional[float] = None, density: Optional[float] = None) -> pxr.UsdShade.Material
Creates a Physics Material.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim - Prim to define the material. The prim’s type will be set to
UsdShade.Material
.dynamicFriction - The dynamic friction of the material
staticFriction - The static friction of the material
restitution - The restitution of the material
density - The density of the material
- Returns:
UsdShade.Material
schema wrapping the definedUsd.Prim
.
- usdex.core.addPhysicsToMaterial(
- material: pxr.UsdShade.Material,
- dynamicFriction: float,
- staticFriction: float | None = None,
- restitution: float | None = None,
- density: float | None = None,
Adds physical material parameters to an existing Material.
Used to apply
UsdPhysics.MaterialAPI
and related properties to an existingUsdShade.Material
(e.g. a visual material).@note When mixing visual and physical materials, be sure use both
usdex.core.bindMaterial
andusdex.core.bindPhysicsMaterial
on the target geometry, to ensure the material is used in both rendering and simulation contexts.- Parameters:
to (- material - The material to add the physics material parameters)
material (- density - The density of the)
material
material
material
- Returns:
True
if the physics material parameters were successfully added to the material,False
otherwise.
- usdex.core.bindPhysicsMaterial(
- prim: pxr.Usd.Prim,
- material: pxr.UsdShade.Material,
Binds a physics material to a given rigid body or collision geometry.
Validates both the prim and the material, applies the
UsdShade.MaterialBindingAPI
to the target prim, and binds the material to the target prim with the “physics” purpose.Note
The material is bound with the “physics” purpose, and with the default “fallback strength”, meaning descendant prims can override with a different material. If alternate behavior is desired, use the
UsdShade.MaterialBindingAPI
directly.Note
We cannot bind materials to prims across different instance boundaries. This function returns an error if
prim
andmaterial
are not placed in an editable location.- Returns:
True
if the material was successfully bound to the target prim,False
otherwise.