Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add python type annotations #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ See [USD's build documentation](https://github.com/PixarAnimationStudios/USD#3-r
### Python
Python modules can always run using `python name_of_module.py`

To automatically run all of the python examples:

```bash
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
pytest
```

## Sections
Here are links of a recommended viewing order for every project in this repository.
Expand Down
16 changes: 8 additions & 8 deletions concepts/mesh_with_materials/python/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@
ASSETS_DIRECTORY = os.path.dirname(os.path.realpath(__file__))


def attach_billboard(stage, root, name="card"):
def attach_billboard(stage: Usd.Stage, root: UsdGeom.Xform, name="card") -> UsdGeom.Mesh:
billboard = UsdGeom.Mesh.Define(stage, str(root.GetPath()) + "/" + name)
billboard.CreatePointsAttr(
[(-430, -145, 0), (430, -145, 0), (430, 145, 0), (-430, 145, 0)]
)
billboard.CreateFaceVertexCountsAttr([4])
billboard.CreateFaceVertexIndicesAttr([0, 1, 2, 3])
billboard.CreateExtentAttr([(-430, -145, 0), (430, 145, 0)])
texCoords = billboard.CreatePrimvar(
texCoords = UsdGeom.PrimvarsAPI(billboard).CreatePrimvar(
"st", Sdf.ValueTypeNames.TexCoord2fArray, UsdGeom.Tokens.varying
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new API change. tested and working.

texCoords.Set([(0, 0), (1, 0), (1, 1), (0, 1)])
return billboard


def attach_surface_shader(stage, material, path):
def attach_surface_shader(stage: Usd.Stage, material: UsdShade.Material, path: str) -> UsdShade.Shader:
shader = UsdShade.Shader.Define(stage, path)
shader.CreateIdAttr("UsdPreviewSurface")
shader.CreateInput("roughness", Sdf.ValueTypeNames.Float).Set(0.4)
shader.CreateInput("metallic", Sdf.ValueTypeNames.Float).Set(0.0)

material.CreateSurfaceOutput().ConnectToSource(shader, "surface")
material.CreateSurfaceOutput().ConnectToSource(shader.CreateInput("surface", Sdf.ValueTypeNames.Color3f))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this should be CreateInput or CreateOutput. Also not sure if the type is correct.


return shader


def attach_texture(
stage, shader, material_path, reader_name="stReader", shader_name="diffuseTexture"
):
stage: Usd.Stage, shader: UsdShade.Shader, material_path, reader_name="stReader", shader_name="diffuseTexture"
) -> UsdShade.Shader:
reader = UsdShade.Shader.Define(stage, material_path + "/" + reader_name)
reader.CreateIdAttr("UsdPrimvarReader_float2")

Expand All @@ -57,11 +57,11 @@ def attach_texture(
os.path.join(ASSETS_DIRECTORY, "USDLogoLrg.png")
)
diffuseTextureSampler.CreateInput("st", Sdf.ValueTypeNames.Float2).ConnectToSource(
reader, "result"
reader.CreateInput("result", Sdf.ValueTypeNames.Float2)
)
diffuseTextureSampler.CreateOutput("rgb", Sdf.ValueTypeNames.Float3)
shader.CreateInput("diffuseColor", Sdf.ValueTypeNames.Color3f).ConnectToSource(
diffuseTextureSampler, "rgb"
diffuseTextureSampler.CreateInput("rgb", Sdf.ValueTypeNames.Color3f)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some more guesses on input vs output and type. The examples all run correctly, just not sure if they're doing the right thing.

)

return reader
Expand Down
2 changes: 1 addition & 1 deletion concepts/reference_into_prim/python/reference_into_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def Xform "Bar" (
)

with tempfile.NamedTemporaryFile(suffix=".usda", delete=False) as handler:
handler.write(code)
handler.write(code.encode())

stage = Usd.Stage.Open(handler.name)

Expand Down
4 changes: 2 additions & 2 deletions concepts/variant_set_in_stronger_layer/python/variant_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pxr import Usd, UsdGeom


def create_basic_stage():
def create_basic_stage() -> Usd.Stage:
stage = Usd.Stage.CreateInMemory()
sphere = UsdGeom.Sphere.Define(stage, "/SomeSphere")

Expand All @@ -42,7 +42,7 @@ def create_basic_stage():
return stage


def create_override_stage(identifier):
def create_override_stage(identifier: str) -> Usd.Stage:
stage = Usd.Stage.CreateInMemory()
stage.GetPrimAtPath("/SomeSphere")
root = stage.GetRootLayer()
Expand Down
6 changes: 3 additions & 3 deletions concepts/variant_set_production_shot/python/shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pxr import Usd, UsdGeom


def create_asset():
def create_asset() -> Usd.Stage:
"""Create some asset to add into a sequence of shots."""
stage = Usd.Stage.CreateInMemory()
stage.GetRootLayer().documentation = (
Expand All @@ -36,7 +36,7 @@ def create_asset():
return stage


def create_sequence(asset):
def create_sequence(asset: str) -> Usd.Stage:
"""Create a collection that shots will include and add some character to it."""
stage = Usd.Stage.CreateInMemory()
root = stage.GetRootLayer()
Expand All @@ -59,7 +59,7 @@ def create_sequence(asset):
return stage


def create_shot(sequence):
def create_shot(sequence: str) -> Usd.Stage:
"""Get the settings from some `sequence` and modify its assets."""
stage = Usd.Stage.CreateInMemory()
stage.GetRootLayer().subLayerPaths.append(sequence)
Expand Down
6 changes: 6 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pytest


@pytest.fixture(autouse=True)
def change_test_dir(request, monkeypatch):
monkeypatch.chdir(request.fspath.dirname)
8 changes: 4 additions & 4 deletions features/notice_send/python/notice_send_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class Sender(object):

"""

def __init__(self, stage):
def __init__(self, stage: Usd.Stage):
"""Store some stage so that it can be retrieved, later."""
super(Sender, self).__init__()

self._stage = stage

def get_stage(self):
def get_stage(self) -> Usd.Stage:
"""`pxr.Usd.Stage`: The stored object that was added to this instance."""
return self._stage

Expand All @@ -38,7 +38,7 @@ class Callback(object):

"""

def __init__(self, registered_type, notice, sender):
def __init__(self, registered_type: type[Tf.Notice], notice: Tf.Notice, sender: Sender):
"""Keep track of the given information."""
super(Callback, self).__init__()

Expand All @@ -47,7 +47,7 @@ def __init__(self, registered_type, notice, sender):
self.notice = notice
self.sender = sender

def callback(self, notice, sender):
def callback(self, notice: Tf.Notice, sender: Sender):
"""Print out the notice / sender that triggered this notice.

In many cases you'd want `notice` and `sender` to be whatever
Expand Down
8 changes: 4 additions & 4 deletions features/notice_send/python/notice_send_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

# IMPORT THIRD-PARTY LIBRARIES
from pxr import Tf

from typing import Any


def main():
"""Run the main execution of the current script."""
def handle_notice(notice, sender):
print("Handling notice")
def handle_notice(notice: Tf.Notice, sender: Any):
print("Handling notice", type(notice), sender)

listener = Tf.Notice.RegisterGlobally("TfNotice", handle_notice)
listener = Tf.Notice.RegisterGlobally(Tf.Notice, handle_notice)
Tf.Notice().SendGlobally() # This will print the contents in `handle_notice`
del listener # You can also run `listener.Revoke()`
Tf.Notice().SendGlobally() # This won't print anything
Expand Down
12 changes: 6 additions & 6 deletions features/notices/python/notice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# -*- coding: utf-8 -*-

# IMPORT FUTURE LIBRARIES
from __future__ import print_function
from __future__ import print_function, annotations

# IMPORT THIRD-PARTY LIBRARIES
from pxr import Tf, Usd


def update(notice, sender):
def update(notice: Usd.Notice.ObjectsChanged, sender: Usd.Stage):
"""Print example data that you can get from the callback."""
print("The triggered sender", notice.GetStage())
print("Resynced paths", notice.GetResyncedPaths())
Expand Down Expand Up @@ -38,7 +38,7 @@ def main():
# You must assign `Register` to a variable (even if you don't run
# `del` on it later) or the callback goes out of scope and does nothing.
#
updated = Tf.Notice.Register(Usd.Notice.ObjectsChanged, update, stage)
updated: Tf.Notice.Listener = Tf.Notice.Register(Usd.Notice.ObjectsChanged, update, stage)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically speaking, the use of annotations on variable assignments like this isn't necessary for mypy to work correctly, because the types-usd stubs provide the output type of the method. I've included them in some places because they act as a kind of assertion: if the output type of the method as defined by the stubs disagrees with the annotated type, then mypy will generate an error.

stage.DefinePrim("/SomeSphere")
stage.GetPrimAtPath("/SomeSphere").SetMetadata("comment", "")

Expand All @@ -54,13 +54,13 @@ def main():
# `Usd.Notice.StageContentsChanged`
# `Usd.Notice.StageEditTargetChanged`
#
contents = Tf.Notice.RegisterGlobally(
contents: Tf.Notice.Listener = Tf.Notice.RegisterGlobally(
Usd.Notice.StageContentsChanged, stage_changed
)

objects = Tf.Notice.RegisterGlobally(Usd.Notice.ObjectsChanged, objects_changed)
objects: Tf.Notice.Listener = Tf.Notice.RegisterGlobally(Usd.Notice.ObjectsChanged, objects_changed)

targets = Tf.Notice.RegisterGlobally(
targets: Tf.Notice.Listener = Tf.Notice.RegisterGlobally(
Usd.Notice.StageEditTargetChanged, target_changed
)

Expand Down
17 changes: 9 additions & 8 deletions features/value_caching/python/value_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# IMPORT STANDARD LIBRARIES
import functools
import time
from typing import Iterable

# IMPORT THIRD-PARTY LIBRARIES
from pxr import Usd, UsdGeom
Expand All @@ -30,7 +31,7 @@ def timeit(function, repeats):
return result


def _create_basic_scene():
def _create_basic_scene() -> Usd.Stage:
stage = Usd.Stage.CreateInMemory()
sphere = UsdGeom.Sphere.Define(stage, "/Some/Prim")
sphere.GetRadiusAttr().Set(10.0)
Expand All @@ -43,7 +44,7 @@ def _create_basic_scene():
return another


def _create_basic_scene_with_more_values():
def _create_basic_scene_with_more_values() -> Usd.Stage:
stage = _create_basic_scene()
override = UsdGeom.Sphere(stage.OverridePrim("/Some/Prim"))

Expand All @@ -53,7 +54,7 @@ def _create_basic_scene_with_more_values():
return stage


def _get_time_samples(attributes):
def _get_time_samples(attributes: Iterable[Usd.Attribute]):
for attribute in attributes:
attribute.GetTimeSamples()

Expand All @@ -79,22 +80,22 @@ def main():
timeit(radius.GetTimeSamples, REPEATS)

function = functools.partial(query.GetUnionedTimeSamples, [query])
function.__name__ = "GetUnionedTimeSamples"
function.__name__ = "GetUnionedTimeSamples" # type: ignore
print("Testing GetTimeSamples(), using a union")
timeit(function, REPEATS)
print()

visibility = sphere.GetVisibilityAttr()

function = functools.partial(_get_time_samples, (radius, visibility))
function.__name__ = "_get_time_samples - with radius and visibility"
function.__name__ = "_get_time_samples - with radius and visibility" # type: ignore
print("Testing GetTimeSamples() for multiple attributes, normally")
timeit(function, REPEATS)

function = functools.partial(
query.GetUnionedTimeSamples, [query, Usd.AttributeQuery(visibility)]
)
function.__name__ = "GetUnionedTimeSamples - with radius and visibility"
function.__name__ = "GetUnionedTimeSamples - with radius and visibility" # type: ignore
print("Testing GetTimeSamples() for multiple attributes, using a union")
timeit(function, REPEATS)
print()
Expand All @@ -106,14 +107,14 @@ def main():
visibility = sphere.GetVisibilityAttr()
query = Usd.AttributeQuery(radius)
function = functools.partial(_get_time_samples, (radius, visibility))
function.__name__ = "_get_time_samples - with radius and visibility"
function.__name__ = "_get_time_samples - with radius and visibility" # type: ignore
print("Testing GetTimeSamples() for multiple attributes, normally")
timeit(function, REPEATS)

function = functools.partial(
query.GetUnionedTimeSamples, [query, Usd.AttributeQuery(visibility)]
)
function.__name__ = "GetUnionedTimeSamples - with radius and visibility"
function.__name__ = "GetUnionedTimeSamples - with radius and visibility" # type: ignore
print("Testing GetTimeSamples() for multiple attributes, using a union")
timeit(function, REPEATS)

Expand Down
8 changes: 7 additions & 1 deletion features/value_clips/cpp/template_and_explicit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include <pxr/usd/usd/clipsAPI.h>
#include <pxr/usd/sdf/types.h>
#include <pxr/usd/usd/stage.h>

#include <pxr/base/vt/array.h>
#include <pxr/base/gf/vec2d.h>

int main() {
auto stage = pxr::UsdStage::CreateInMemory();
Expand All @@ -30,6 +31,11 @@ int main() {
model.SetClipTemplateStride(1, template_set_name);
model.SetClipPrimPath("/Template", template_set_name);

pxr::VtArray<pxr::SdfAssetPath> assetPaths;
model.GetClipAssetPaths(&assetPaths, non_template_set_name);
pxr::VtVec2dArray active;
model.GetClipActive(&active);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the new C++ code that I added to match the new python behavior, but I was not able to test it.

chad $ USD_INSTALL_ROOT=~/dev/USD/.build-23.05-py39-stock cmake ..

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
USD_BOOST_PYTHON
    linked by target "run_it" in directory /Users/chad/dev/USD-Cookbook/features/value_clips/cpp/template_and_explicit
USD_SDF
    linked by target "run_it" in directory /Users/chad/dev/USD-Cookbook/features/value_clips/cpp/template_and_explicit
USD_TF
    linked by target "run_it" in directory /Users/chad/dev/USD-Cookbook/features/value_clips/cpp/template_and_explicit
USD_USD
    linked by target "run_it" in directory /Users/chad/dev/USD-Cookbook/features/value_clips/cpp/template_and_explicit
USD_USDGEOM
    linked by target "run_it" in directory /Users/chad/dev/USD-Cookbook/features/value_clips/cpp/template_and_explicit
USD_VT
    linked by target "run_it" in directory /Users/chad/dev/USD-Cookbook/features/value_clips/cpp/template_and_explicit

My build uses the standard USD build script, and the contents of $USD_INSTALL_ROOT/lib seem correct for MacOS:

drwxr-xr-x   6 chad  staff      192 Jun  7 08:59 OpenSubdiv.framework
drwxr-xr-x   6 chad  staff      192 Jun  7 08:59 OpenSubdiv_static.framework
drwxr-xr-x  10 chad  staff      320 Jun  7 08:59 cmake
-rwxr-xr-x   1 chad  staff   936072 Jun  7 08:56 libMaterialXCore.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       29 Jun  7 08:56 libMaterialXCore.1.dylib -> libMaterialXCore.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       24 Jun  7 08:56 libMaterialXCore.dylib -> libMaterialXCore.1.dylib
-rwxr-xr-x   1 chad  staff   363008 Jun  7 08:56 libMaterialXFormat.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       31 Jun  7 08:56 libMaterialXFormat.1.dylib -> libMaterialXFormat.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       26 Jun  7 08:56 libMaterialXFormat.dylib -> libMaterialXFormat.1.dylib
-rwxr-xr-x   1 chad  staff   420608 Jun  7 08:56 libMaterialXGenGlsl.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       32 Jun  7 08:56 libMaterialXGenGlsl.1.dylib -> libMaterialXGenGlsl.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       27 Jun  7 08:56 libMaterialXGenGlsl.dylib -> libMaterialXGenGlsl.1.dylib
-rwxr-xr-x   1 chad  staff   287032 Jun  7 08:56 libMaterialXGenMdl.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       31 Jun  7 08:56 libMaterialXGenMdl.1.dylib -> libMaterialXGenMdl.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       26 Jun  7 08:56 libMaterialXGenMdl.dylib -> libMaterialXGenMdl.1.dylib
-rwxr-xr-x   1 chad  staff   240736 Jun  7 08:56 libMaterialXGenOsl.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       31 Jun  7 08:56 libMaterialXGenOsl.1.dylib -> libMaterialXGenOsl.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       26 Jun  7 08:56 libMaterialXGenOsl.dylib -> libMaterialXGenOsl.1.dylib
-rwxr-xr-x   1 chad  staff   841984 Jun  7 08:56 libMaterialXGenShader.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       34 Jun  7 08:56 libMaterialXGenShader.1.dylib -> libMaterialXGenShader.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       29 Jun  7 08:56 libMaterialXGenShader.dylib -> libMaterialXGenShader.1.dylib
-rwxr-xr-x   1 chad  staff   672616 Jun  7 08:56 libMaterialXRender.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       31 Jun  7 08:56 libMaterialXRender.1.dylib -> libMaterialXRender.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       26 Jun  7 08:56 libMaterialXRender.dylib -> libMaterialXRender.1.dylib
-rwxr-xr-x   1 chad  staff  1275728 Jun  7 08:56 libMaterialXRenderGlsl.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       35 Jun  7 08:56 libMaterialXRenderGlsl.1.dylib -> libMaterialXRenderGlsl.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       30 Jun  7 08:56 libMaterialXRenderGlsl.dylib -> libMaterialXRenderGlsl.1.dylib
-rwxr-xr-x   1 chad  staff    55272 Jun  7 08:56 libMaterialXRenderHw.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       33 Jun  7 08:56 libMaterialXRenderHw.1.dylib -> libMaterialXRenderHw.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       28 Jun  7 08:56 libMaterialXRenderHw.dylib -> libMaterialXRenderHw.1.dylib
-rwxr-xr-x   1 chad  staff   108560 Jun  7 08:56 libMaterialXRenderOsl.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       34 Jun  7 08:56 libMaterialXRenderOsl.1.dylib -> libMaterialXRenderOsl.1.38.4.dylib
lrwxr-xr-x   1 chad  staff       29 Jun  7 08:56 libMaterialXRenderOsl.dylib -> libMaterialXRenderOsl.1.dylib
-rwxr-xr-x   1 chad  staff    85024 Jun  7 08:19 libboost_atomic.dylib
-rwxr-xr-x   1 chad  staff   295120 Jun  7 08:20 libboost_python39.dylib
-rwxr-xr-x   1 chad  staff   350856 Jun  7 08:20 libboost_regex.dylib
-rwxr-xr-x   1 chad  staff  1048032 Jun  7 08:59 libosdCPU.3.5.0.dylib
-rw-r--r--   1 chad  staff  1463216 Jun  7 08:59 libosdCPU.a
lrwxr-xr-x   1 chad  staff       21 Jun  7 08:59 libosdCPU.dylib -> libosdCPU.3.5.0.dylib
-rwxr-xr-x   1 chad  staff   995464 Jun  7 08:59 libosdGPU.3.5.0.dylib
-rw-r--r--   1 chad  staff  1328072 Jun  7 08:59 libosdGPU.a
lrwxr-xr-x   1 chad  staff       21 Jun  7 08:59 libosdGPU.dylib -> libosdGPU.3.5.0.dylib
-rwxr-xr-x   1 chad  staff   261480 Jun  7 08:21 libtbb.dylib
-rwxr-xr-x   1 chad  staff   704200 Jun  7 08:21 libtbb_debug.dylib
-rwxr-xr-x   1 chad  staff   113664 Jun  7 08:21 libtbbmalloc.dylib
-rwxr-xr-x   1 chad  staff   223568 Jun  7 08:21 libtbbmalloc_debug.dylib
-rwxr-xr-x   1 chad  staff    54024 Jun  7 08:21 libtbbmalloc_proxy.dylib
-rwxr-xr-x   1 chad  staff    54576 Jun  7 08:21 libtbbmalloc_proxy_debug.dylib
-rwxr-xr-x   1 chad  staff   365584 Jun  7 09:25 libusd_ar.dylib
-rwxr-xr-x   1 chad  staff   267464 Jun  7 09:25 libusd_arch.dylib
-rwxr-xr-x   1 chad  staff    77104 Jun  7 09:25 libusd_cameraUtil.dylib
-rwxr-xr-x   1 chad  staff   639608 Jun  7 09:25 libusd_garch.dylib
-rwxr-xr-x   1 chad  staff    95256 Jun  7 09:25 libusd_geomUtil.dylib
-rwxr-xr-x   1 chad  staff   690056 Jun  7 09:25 libusd_gf.dylib
-rwxr-xr-x   1 chad  staff   364568 Jun  7 09:25 libusd_glf.dylib
-rwxr-xr-x   1 chad  staff  6038576 Jun  7 09:25 libusd_hd.dylib
-rwxr-xr-x   1 chad  staff   275896 Jun  7 09:25 libusd_hdGp.dylib
-rwxr-xr-x   1 chad  staff   175712 Jun  7 09:25 libusd_hdMtlx.dylib
-rwxr-xr-x   1 chad  staff  4312152 Jun  7 09:25 libusd_hdSt.dylib
-rwxr-xr-x   1 chad  staff    61568 Jun  7 09:25 libusd_hdar.dylib
-rwxr-xr-x   1 chad  staff  1653440 Jun  7 09:25 libusd_hdsi.dylib
-rwxr-xr-x   1 chad  staff  1917632 Jun  7 09:25 libusd_hdx.dylib
-rwxr-xr-x   1 chad  staff    87208 Jun  7 09:25 libusd_hf.dylib
-rwxr-xr-x   1 chad  staff   181952 Jun  7 09:25 libusd_hgi.dylib
-rwxr-xr-x   1 chad  staff   494072 Jun  7 09:25 libusd_hgiGL.dylib
-rwxr-xr-x   1 chad  staff   101144 Jun  7 09:25 libusd_hgiInterop.dylib
-rwxr-xr-x   1 chad  staff   429008 Jun  7 09:25 libusd_hgiMetal.dylib
-rwxr-xr-x   1 chad  staff   562664 Jun  7 09:25 libusd_hio.dylib
-rwxr-xr-x   1 chad  staff   165792 Jun  7 09:25 libusd_js.dylib
-rwxr-xr-x   1 chad  staff   101312 Jun  7 09:25 libusd_kind.dylib
-rwxr-xr-x   1 chad  staff   298040 Jun  7 09:25 libusd_ndr.dylib
-rwxr-xr-x   1 chad  staff  1549280 Jun  7 09:25 libusd_pcp.dylib
-rwxr-xr-x   1 chad  staff   374952 Jun  7 09:25 libusd_plug.dylib
-rwxr-xr-x   1 chad  staff   146920 Jun  7 09:25 libusd_pxOsd.dylib
-rwxr-xr-x   1 chad  staff  6214120 Jun  7 09:25 libusd_sdf.dylib
-rwxr-xr-x   1 chad  staff   320480 Jun  7 09:25 libusd_sdr.dylib
-rwxr-xr-x   1 chad  staff  1249112 Jun  7 09:25 libusd_tf.dylib
-rwxr-xr-x   1 chad  staff   424496 Jun  7 09:25 libusd_trace.dylib
-rwxr-xr-x   1 chad  staff  9673488 Jun  7 09:25 libusd_usd.dylib
-rwxr-xr-x   1 chad  staff   199776 Jun  7 09:25 libusd_usdAppUtils.dylib
-rwxr-xr-x   1 chad  staff   163624 Jun  7 09:25 libusd_usdBakeMtlx.dylib
-rwxr-xr-x   1 chad  staff  1815040 Jun  7 09:25 libusd_usdGeom.dylib
-rwxr-xr-x   1 chad  staff   161648 Jun  7 09:25 libusd_usdHydra.dylib
-rwxr-xr-x   1 chad  staff  5737712 Jun  7 09:25 libusd_usdImaging.dylib
-rwxr-xr-x   1 chad  staff   311224 Jun  7 09:25 libusd_usdImagingGL.dylib
-rwxr-xr-x   1 chad  staff   520400 Jun  7 09:25 libusd_usdLux.dylib
-rwxr-xr-x   1 chad  staff   170776 Jun  7 09:25 libusd_usdMedia.dylib
-rwxr-xr-x   1 chad  staff   834568 Jun  7 09:25 libusd_usdMtlx.dylib
-rwxr-xr-x   1 chad  staff   433208 Jun  7 09:25 libusd_usdPhysics.dylib
-rwxr-xr-x   1 chad  staff   106016 Jun  7 09:25 libusd_usdProc.dylib
-rwxr-xr-x   1 chad  staff   211496 Jun  7 09:25 libusd_usdProcImaging.dylib
-rwxr-xr-x   1 chad  staff   234208 Jun  7 09:25 libusd_usdRender.dylib
-rwxr-xr-x   1 chad  staff   235128 Jun  7 09:25 libusd_usdRi.dylib
-rwxr-xr-x   1 chad  staff   150728 Jun  7 09:25 libusd_usdRiImaging.dylib
-rwxr-xr-x   1 chad  staff   846784 Jun  7 09:25 libusd_usdShade.dylib
-rwxr-xr-x   1 chad  staff  1811600 Jun  7 09:25 libusd_usdSkel.dylib
-rwxr-xr-x   1 chad  staff   628880 Jun  7 09:25 libusd_usdSkelImaging.dylib
-rwxr-xr-x   1 chad  staff   137208 Jun  7 09:25 libusd_usdUI.dylib
-rwxr-xr-x   1 chad  staff  1213208 Jun  7 09:25 libusd_usdUtils.dylib
-rwxr-xr-x   1 chad  staff   166544 Jun  7 09:25 libusd_usdVol.dylib
-rwxr-xr-x   1 chad  staff   212304 Jun  7 09:25 libusd_usdVolImaging.dylib
-rwxr-xr-x   1 chad  staff   149248 Jun  7 09:25 libusd_usdviewq.dylib
-rwxr-xr-x   1 chad  staff  2923528 Jun  7 09:25 libusd_vt.dylib
-rwxr-xr-x   1 chad  staff    81224 Jun  7 09:25 libusd_work.dylib
-rwxr-xr-x   1 chad  staff   121704 Jun  7 08:17 libz.1.2.11.dylib

I think there's just a minor adjustment that needs to be made to the CMakeLists.txt.


prim.GetReferences().AddReference(
"./ref.usda",
pxr::SdfPath{"/Ref"}
Expand Down
6 changes: 3 additions & 3 deletions features/value_clips/python/explicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"""Use the Value Clip API's explicit syntax to author Value Clips."""

# IMPORT THIRD-PARTY LIBRARIES
from pxr import Sdf, Usd
from pxr import Sdf, Usd, Vt


def main():
"""Run the main execution of this module."""
stage = Usd.Stage.CreateInMemory()
stage: Usd.Stage = Usd.Stage.CreateInMemory()
stage.SetStartTimeCode(0)
stage.SetEndTimeCode(12)

prim = stage.DefinePrim("/Prim")
prim: Usd.Prim = stage.DefinePrim("/Prim")
model = Usd.ClipsAPI(prim)
model.SetClipActive([(0, 0), (2, 1)])
model.SetClipAssetPaths(
Expand Down
13 changes: 10 additions & 3 deletions features/value_clips/python/template_and_explicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
# -*- coding: utf-8 -*-

"""Use the Value Clip API's template syntax to author Value Clips."""
from __future__ import annotations

# IMPORT THIRD-PARTY LIBRARIES
from pxr import Sdf, Usd
from pxr import Sdf, Usd, Vt


def main():
"""Run the main execution of this module."""
stage = Usd.Stage.CreateInMemory()
stage: Usd.Stage = Usd.Stage.CreateInMemory()
stage.SetStartTimeCode(0)
stage.SetEndTimeCode(2)

prim = stage.DefinePrim("/Set")
prim: Usd.Prim = stage.DefinePrim("/Set")
non_template_set_name = "non_template_clips"
model = Usd.ClipsAPI(prim)
model.SetClipActive([(0.0, 0)], non_template_set_name)
Expand All @@ -29,6 +30,12 @@ def main():
model.SetClipTemplateStride(1, template_set_name)
model.SetClipPrimPath("/Template", template_set_name)

paths: list[Sdf.AssetPath] = model.GetClipAssetPaths(non_template_set_name)
assert paths == [Sdf.AssetPath("./non_template_clip.usda")]

active: Vt.Vec2dArray = model.GetClipActive()
assert isinstance(active, Vt.Vec2dArray)

prim.GetReferences().AddReference(assetPath="./set.usda", primPath="/Set")

print(stage.GetRootLayer().ExportToString())
Expand Down
10 changes: 10 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[mypy]
check_untyped_defs=true
python_version=3.11
files=concepts/*/python,features/*/python

[mypy-pxr.*]
ignore_errors=true

[mypy-PySide6.*]
ignore_missing_imports = True
Loading