Broadcasted Refinement#

We haven’t reviewed inherits and specializes, but if you’re familiar with those arcs, you’ll know that they compose across arcs to allow downstream refinement. We call this broadcasting. So we can used inherits and specializes to refine instances of a Robot within a work cell

Exercise: Broadcasted Refinement#

In this scenario, all the boxes on a pallet were damaged. We want to label all the boxes with the “Damaged” stamp. We could add a new arc to all the affected boxes one by one, but for this example, we’re going to use a specialize arc to broadcast the change to all of the boxes on the pallet.

  1. Run in the terminal:

.\scripts\usdview.bat .\instancing_exercises\ex_sg_broadcasted_refine\Scenario.usd --camera ExCam_01

Tip

Click Camera > Select Camera > ExCam_01 if you ever lose your place in the scene or want to get back to this camera position.

  1. Click on the top left box in the Viewport.

  1. Press the “\” key to select the enclosing model.

This will select the “BoxPallet_A01” assembly.

  1. Hover your mouse over the Tree View panel and press the “F” key to frame the selected prim in the Tree View.

You should see “BoxPallet_A01_03” selected in the Tree View panel.

  1. Click the triangle to the left of the select prim in the Tree View to expand the select prim’s hierarchy.

Notice that there is a prim “_PalletBox” enclosed within the “BoxPallet_A01” asset. This is a class prim included as specialize arc target for every box on that pallet. We can author opinions in “_PalletBox” that will be applied to all boxes on that pallet.

  1. Click Window > Interpreter to open the Interpreter window.

  2. Run the following code in the Interpreter window:

1from pathlib import Path
2stage = usdviewApi.stage
3prim = stage.OverridePrim("/World/Warehouse/Rack_BoxPallet_A01_01/BoxPallet_A01_03/_PalletBox")
4stage_path = Path(stage.GetRootLayer().identifier)
5decals_path = stage_path.parent.parent / "src_assets" / "Assets" / "Utilities" / "MiscDecals" / "MiscDecals.usd"
6prim.GetReferences().AddReference(str(decals_path), "/_MixinOverrides/DamagedStamp")

Notice how all the boxes on the pallet closest to the camera now show a stamp that says, “Damaged”. In this case, we added the same reference as in the Ad-Hoc Composition Arc Addition Refinement exercise, but this could also have been direct opinions authored in the /World/Warehouse/Rack_BoxPallet_A01_01/BoxPallet_A01_03/_PalletBox of this layer. We authored one opinion that rippled changes to all the boxes.

  1. Run the following code in the Interpreter window:

1from pprint import pprint
2stats = UsdUtils.ComputeUsdStageStats(usdviewApi.stage)
3pprint(stats)

This prints a breakdown of the prim and instancing stats. Here’s a summarized comparison to the basic instancing scenario:

Scenario

Prims

Instances

Prototypes

Instancing

1711

1450

3

Broadcasted Refinement

1747

1450

4

  1. Close usdview.