usd_chunks.chunk_stage
USD I/O for chunks: layer management, stage synchronization and chunk serialization.
ChunkStageSync
⚓︎
Singleton that keeps a Chunk prim on the stage for every chunk in the scene.
It authors a Chunk prim whenever a Python chunk is added to the scene, then wires each inputs: attribute to the matching param via connect_usd_attr. That keeps the stage live, so any USD tool can save and capture the current param state.
clear_attr_connections
⚓︎
Clear a chunk prim attr's connections in every layer that holds one.
A connection may have been authored while a different Edit Target was active (or before any Edit Target chunk ran at all); clearing only the current edit layer would silently no-op, leaving that original opinion composed in as a stale, seemingly-undeletable connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attr
|
Attribute
|
The attribute to clear. |
required |
Source code in usd_chunks/chunk_stage.py
discarding_stage
⚓︎
Delete chunks inside this block without touching the stage they are on.
Deleting a chunk removes its prim, re-heals the exec chain around it and reconciles Edit Targets across the scene -- right for a chunk deleted from a stage that lives on, and wasted work, once per chunk, for a stage that is about to be thrown away whole. File > Open already tears down that way (_reloading); this is the same for any caller that owns the stage it is discarding, such as a script's Scene closing.
Source code in usd_chunks/chunk_stage.py
drop_vanished
⚓︎
Delete the chunks whose prims left the stage (see _prune_vanished).
Queued to run after the change that removed them has been handed round. A host's undo calls it as soon as the restore returns, so the graph it rebuilds next has no chunk without a prim; calling it again, or with nothing queued, does nothing. A prim that came back meanwhile (a redo before the queue ran) keeps its chunk.
Source code in usd_chunks/chunk_stage.py
initialize
⚓︎
Start syncing a stage and scene: listen for chunk and stage changes and load its chunks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage to author chunk prims on. |
required |
scene
|
SceneSender
|
The scene whose chunks are synced. |
required |
Source code in usd_chunks/chunk_stage.py
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | |
record_sources
⚓︎
Note where each chunk's prim composes from, for _adopt_resynced_inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
Iterable[ChunkBase]
|
The chunks to note. |
required |
only_new
|
bool
|
Skip the chunks already noted. |
False
|
Source code in usd_chunks/chunk_stage.py
reload_chunks
⚓︎
Reload Chunks: read the chunk modules again and rebuild the graph from the stage.
The stage already holds every chunk's prim, params and wires, so the chunks are dropped and loaded back from it, as File > Open does, with each module's file read afresh. Rebuilding chunks from their modules instead put every param back to its default and lost the wires.
The chunks' layers go before the layer manager starts over: it would otherwise forget them, and each reload left them in the stack. discarding_stage keeps taking them off from rescanning the stage, which found the chunks' prims and built them again mid-teardown.
Source code in usd_chunks/chunk_stage.py
reload_for_stage
⚓︎
Reinitialize for a newly opened stage (File > Open).
Safe to call from a deferred context (e.g. QTimer.singleShot) once the stage has fully settled.
Compares stage object identity, not the root layer's identifier string -- re-exporting to the same path and reloading (a common iteration workflow) gives a genuinely new Usd.Stage with the same file path, so comparing identifiers would wrongly skip the reset here, leaving the previous file's chunk objects (and their now-orphaned bookkeeping/positions) still registered and silently re-wrapped alongside the freshly loaded content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The new stage, or None when the host has dropped its stage. |
required |
Source code in usd_chunks/chunk_stage.py
ParamClear
⚓︎
Bases: NamedTuple
What clear_param did, for the UI to tell the user.
Attributes:
| Name | Type | Description |
|---|
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
ForwardRef('Sdf.Layer | None')
|
|
None
|
others
|
ForwardRef('tuple[Sdf.Layer, ...]')
|
|
()
|
default_can_win
|
ForwardRef('bool')
|
|
False
|
branch_place
⚓︎
Where chunk cooks among chunks no wire orders: as a View cooks them, a Merge's last input first.
A Merge's slots are on the stage, not in the DAG, so the cook queue cannot see them (chunk_cook.break_ties_with). Without this, two branches of a Merge cooked in the order they were made, and a Transform made before the Cube it moves found nothing to move once the scene was opened again. Every graph is walked once per shape of the graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk to place. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Its place; lower cooks first. |
Source code in usd_chunks/chunk_stage.py
can_clear_param
⚓︎
Whether clear_param has anything to clear, or to say about who still sets param.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
ChunkCommon
|
The param or vector. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when any layer holds a value, wire or expression for param, or, for a param |
bool
|
without an attr of its own, when its value is not its default. |
Source code in usd_chunks/chunk_stage.py
chunk_matches_search
⚓︎
Whether chunk's name and/or type (per scope) fuzzy-matches query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
query
|
str
|
The search text; an empty query always matches. |
required |
scope
|
str
|
"both", "name" or "type". |
'both'
|
typos
|
bool
|
False to match a substring only. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True on a match. |
Source code in usd_chunks/chunk_stage.py
chunk_prim_edit_context
⚓︎
An edit context for authoring on chunk's prim: ports, connections, new child chunks.
Targets the layer chunk's bookkeeping belongs in, not the layer its cooked output goes to, so what is authored inside it is saved with the scene.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase | None
|
The chunk whose prim is authored on. |
None
|
Returns:
| Type | Description |
|---|---|
EditContext
|
The edit context. |
Source code in usd_chunks/chunk_stage.py
clear_attr_connections
⚓︎
Remove attr's connections from every layer that has one, not just the edit target.
clear_param
⚓︎
Clear param in the layer its edits go to now, as if it had never been edited there.
Its value, wire and expression text go from that one layer (param_storage_layer). Other layers that set it are left alone: the param takes their value, and they are returned so the UI can say so. With nothing left anywhere, the param lets go of its storage attr, so the next edit makes a new one, as on a new chunk.
A param whose attr cannot go (see _own_storage_attr) is set to its default, which is written into the shared attr. A field that brings its vector back to its default then clears the vector.
A wire the graph drew into the param goes too (see _wire_attrs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
ChunkCommon
|
The param or vector to clear. |
required |
Returns:
| Type | Description |
|---|---|
ParamClear
|
Where it was cleared, and which layers still set it. |
Source code in usd_chunks/chunk_stage.py
commit_order_from_stage
⚓︎
Order chunks for commit by what the stage says they read, not by DAG depth.
chunk_scheduler.commit_order sorts on DagNode depth, which only sees edges someone created with add_dependency. That covers exec wiring (load_chunks mirrors inputs:chunk into add_dependency) but NOT a param port: drag-to-connect authors an @Node.param@ expression, whose live link is a NoticeConnection rather than a DAG edge, so two chunks joined only by a param wire both sit at depth 0 and commit in arbitrary order.
The stage has both kinds of wire, and is already the authority the rest of the wiring code trusts (see exec_dependencies), so order from it instead.
A cycle can't be topologically ordered and must not drop anyone: the first chunk still waiting is emitted and the sort continues, so the result always contains every input chunk exactly once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
list[ChunkBase]
|
The chunks to order |
required |
stage
|
Stage | None
|
The stage holding their chunk prims; None falls back to the depth-based ordering |
required |
Returns:
| Type | Description |
|---|---|
list[ChunkBase]
|
list[core.ChunkBase]: The chunks, every chunk preceded by everything it reads from |
Source code in usd_chunks/chunk_stage.py
connect_exec
⚓︎
Author a plain outputs:chunk -> inputs:chunk exec connection between two chunk prims.
For a caller that creates chunks directly (a chunk module wiring its own children, a test, a CLI) rather than via the node graph's drag-to-connect: view-driven execution (recook_for_view) mutes any chunk not reachable from its context's active view, so a programmatically created chunk that's never wired into the exec chain gets hidden the first time its context recooks, even though it authored real content. Mirrors the exec-only path of ChunkGraphView._author_connection; does not handle typed param connections.
Deliberately does NOT also trigger a recook the way _author_connection does for a live drag-to-connect: figuring out which view (if any) is safe to recook through from inside a headless caller, without touching mute/block state anywhere it doesn't have full information about, risks muting unrelated scene content, or the chunk just wired itself. Simpler and safer to author the connection correctly here and let the caller's own next real recook (a view switch, another wire, diving into the context) pick it up.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage to author on. |
required |
scene
|
SceneSender
|
The scene the chunks live in. |
required |
src_prim_path
|
str
|
Prim path of the upstream chunk. |
required |
dst_prim_path
|
str
|
Prim path of the downstream chunk. |
required |
input_name
|
str
|
The exec slot on dst -- a merge's inputs:chunkN rather than the plain inputs:chunk, so rewiring something into the slot it came out of does not replace whatever branch is already in slot 0. |
_EXEC_INPUT
|
append
|
bool
|
Add src to the slot's existing wires instead of replacing them, for a slot that several wires stack on. |
False
|
Returns:
| Type | Description |
|---|---|
Attribute | None
|
The authored inputs:chunk attribute, or None if either prim couldn't be resolved. |
Source code in usd_chunks/chunk_stage.py
5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 | |
copy_selected_chunks
⚓︎
Store prim paths of selected non-view chunks for later paste.
Source code in usd_chunks/chunk_stage.py
creating_at
⚓︎
Create chunks at pos (USD space) for the duration of the block.
The module globals are how a caller passes a position and a loft preference down into _define_prim, which is several frames below and has no argument for either. Doing that save/assign/restore by hand in every caller would mean one try/finally per call site, each an opportunity to forget the restore and leave every later chunk landing at someone else's mouse position.
Nesting works: the previous values come back rather than being cleared, so grouping (which creates a group, then materializes chunks inside it) does not lose the outer position when the inner block ends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
tuple[float, float] | None
|
The node position new chunks get, in USD coordinates, or None for the default. |
required |
loft
|
bool | None
|
Whether new chunks are lofted to their group's Params page; None leaves it unchanged. |
None
|
Yields:
| Type | Description |
|---|---|
|
None, with the position and loft preference in effect. |
Source code in usd_chunks/chunk_stage.py
delete_attr_specs
⚓︎
Remove attr_name from prim in every layer that has it, not just the edit target.
Source code in usd_chunks/chunk_stage.py
exec_dependencies
⚓︎
The chunks feeding this one's exec slots, read from the live stage.
The public way for a chunk module to ask "what is immediately upstream of me on the exec chain". chunk.get_dependencies() is not that question: the Python DAG also mirrors param wires, which mean a value flows rather than that one chunk precedes another.
The stage is the authority here, not the DAG: the node graph's drag-to-connect authors the USD connection directly and never calls add_dependency(). _author_prim relies on this, or export would chain chunks in scene.get_chunks() order instead of their real exec order. Every slot is read -- a merge's branches past the first are real inputs, and reconcile_dag_dependencies would otherwise remove edges it cannot see.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk to read the exec inputs of |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
The upstream chunks, one per connected exec slot |
Source code in usd_chunks/chunk_stage.py
exec_downstream
⚓︎
Every chunk start's exec output reaches, following exec wires forward.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
ChunkBase
|
The chunk to start from. |
required |
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
Returns:
| Type | Description |
|---|---|
set[ChunkBase]
|
The downstream chunks. start itself is excluded, even when a cycle leads back to it. |
Source code in usd_chunks/chunk_stage.py
exec_input_connections
⚓︎
Every exec connection target on prim, strongest branch first.
exec_input_slots_for_prim
⚓︎
How many positional exec input ports a chunk prim has.
1 for almost everything -- one inputs:chunk that several wires may stack on. Above 1 the slots mean different things and each gets its own port, which is what a Stage Expression Switch needs: slot 0 is the normal path and slot 1 the matched one, which is not a property a merge ordering can express.
A dynamic-slot chunk (has_dynamic_exec_inputs_prim) answers 1 here and is handled by that predicate instead: its slots grow with what is wired in, so a fixed count is the wrong question for it.
Takes the prim: the node graph builds ports from the stage and may have no chunk object. Read off the registry's discovery-time config rather than by importing the module: the config is parsed when chunks are found, so this costs a dict lookup and never triggers a module load while a scene is being built.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prim
|
Prim
|
The chunk prim. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The slot count, at least 1. |
Source code in usd_chunks/chunk_stage.py
exec_output_path
⚓︎
Return the outputs:chunk attribute path an exec connection to chunk must point at.
A ChunkGroup is its own prim root, so its exec output lives on the group prim itself (/Tab1/Group.outputs:chunk) -- NOT under the root it provides for its children, which is what _resolve_chunk_root returns and would give the nonexistent /Tab1/Group/Group.outputs:chunk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The upstream chunk being connected from |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The absolute outputs:chunk attribute path |
Source code in usd_chunks/chunk_stage.py
exec_tails
⚓︎
Non-view chunks in context whose exec output nothing takes: the ends of the chains.
Wiring a view to a tail makes the view cook that tail's whole upstream chain. Used to auto-wire a default view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
context
|
ChunkBase | None
|
The context, or None for the top level. |
None
|
Returns:
| Type | Description |
|---|---|
list[ChunkBase]
|
The tail chunks. |
Source code in usd_chunks/chunk_stage.py
exec_upstream
⚓︎
chunk and everything upstream of it, following exec wires only.
Not view_cook_list, which follows param wires and lofts as well and answers "what has to cook for this view". This answers "which chunks make up this branch": suppressing a branch has to suppress the whole of it, not merely the chunk plugged into the slot -- the rest would carry on authoring into the composed stage.
Guarded against revisiting: a diamond (two branches sharing a source) would otherwise walk the shared part once per path, and a cycle would not terminate at all.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk to start from. |
required |
seen
|
set | None
|
Chunks already visited; filled in and returned. |
None
|
Returns:
| Type | Description |
|---|---|
set
|
The chunks in the branch, |
Source code in usd_chunks/chunk_stage.py
export_chunks
⚓︎
Export the current chunk graph as one clean, portable USD layer.
Copies each chunk's already-composed, already-correctly-wired prim spec straight across from the live stage -- connections (inputs:chunk exec wiring, expression refs), values, node positions, everything, exactly as currently authored -- rather than re-deriving them from Python object state. The Python DAG (chunk.get_dependencies()) is empty for a graph wired live in the node graph, which authors the USD-level inputs:chunk connection directly and never calls add_dependency(), so re-deriving would chain chunks in iteration order instead of their real exec order.
UsdUtils.FlattenLayerStack resolves the live composition first -- chunk-prim bookkeeping can be split across several layers (chunk_utils.get_bookkeeping_layer, since it follows Edit Target) -- giving each prim/attr its correct final composed state to copy from, regardless of which layer(s) it's actually scattered across.
Only chunk prims themselves are copied -- reopening regenerates everything a chunk drives by re-running load_chunks' cook pass, not by replaying a content snapshot. Content that isn't reproduced by re-execution (an RBD Solver's bake) or that never went through a chunk at all does not round-trip through this.
The stage's up-axis and units are stamped onto the file as well. Sdf.CopySpec copies prim specs and nothing else, and those two are not prim data: they are stage metadata, resolved only from a stage's own root/session layer and never composed up from anything underneath. Without an opinion of its own the exported file falls back to USD's global default: a Z-up, centimetre scene would reopen Y-up in metres, with every chunk-authored prim lying on its side at a hundredth of its size.
Chunks that arrive by composition -- a sequence network sublayered into this file, or
referenced in under a chunkgroup -- are not this file's to write out. Only the layers
the chunk system owns are flattened (_owned_stage), so what gets copied for such a
chunk is the sparse over this scene put on it, and a chunk with no local opinion at
all is skipped rather than copied from a spec that does not exist locally. The root
layer's foreign sublayers are carried onto the file so the sequence stays composed
underneath those overs on reopen. This is what lets a shot tweak a sequence's network
and save without inlining it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scene
|
SceneSender
|
The scene to export. |
required |
path
|
str | Path
|
The file to write. |
required |
relative_paths
|
bool | None
|
Write the files the chunks read relative to path's folder where they sit under it, as USD search paths, so the network and its inputs move together (asset_paths). None: as the network's Stage Settings say, on if none. |
None
|
Source code in usd_chunks/chunk_stage.py
8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 | |
export_network
⚓︎
Write one group's network to its own file, the way export_chunks writes a scene's.
The group goes at /chunks/
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scene
|
SceneSender
|
The scene. |
required |
group
|
ChunkBase
|
The chunkgroup to export. |
required |
path
|
str | Path
|
The file to write. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The group's prim path in the file -- what a host references. |
Raises:
| Type | Description |
|---|---|
ValueError
|
There is no stage, or the group has nothing to export. |
Source code in usd_chunks/chunk_stage.py
find_group_active_view
⚓︎
The View a group's saved slot names, else its lowest-slot View (inert ones last).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
ChunkBase
|
The group. |
required |
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
Returns:
| Type | Description |
|---|---|
ChunkBase | None
|
The view chunk, or None if the group has no inner view. |
Source code in usd_chunks/chunk_stage.py
find_output_chunk
⚓︎
The Output of context's graph, or None if it has none.
A group's Output is its own, never the parent graph's (prim-path membership). For the top level (context None) the shallowest Output wins, so a group's inner Output is never taken for the file's.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
context
|
ChunkBase | None
|
The graph to look in, or None for the top level. |
required |
Returns:
| Type | Description |
|---|---|
ChunkBase | None
|
The Output chunk, or None. |
Source code in usd_chunks/chunk_stage.py
find_view_chunk_for_slot
⚓︎
The view chunk assigned to slot, or None.
Each graph (tab or group) has its own slots, so a tab view and a group view can both be slot 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot
|
int
|
The view slot. |
required |
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
context
|
ChunkBase | None
|
The graph to look in; None looks everywhere. |
None
|
Returns:
| Type | Description |
|---|---|
ChunkBase | None
|
The view chunk, or None. |
Source code in usd_chunks/chunk_stage.py
flatten_without_chunks
⚓︎
Flatten the stage to a layer carrying the result but none of the recipe.
A Chunk prim left in a delivered file is not inert: open it anywhere usd_chunks is installed and the network reloads and re-cooks, overriding the very geometry the file was exported to carry. Stripping them is what makes the output plain USD that anyone can open with nothing installed.
FlattenLayerStack rather than Stage.Export, because it keeps references as references where Export inlines the referenced asset outright -- which stops mattering only while a network builds all its own geometry.
Shallowest path first, so removing a parent Chunk takes its children with it and the later lookup for those children simply finds nothing.
The stage's up-axis and units are stamped on as well (stamp_stage_metadata): flattening carries them only when the root layer itself authors them, which a new scene never has. The prims a Prune Prim pruned are left out (pruned_paths).
Source code in usd_chunks/chunk_stage.py
fuzzy_matches
⚓︎
Whether term matches candidate, tolerating small typos.
An exact case-insensitive substring always matches (the common case: the user typed the name or type correctly, or a meaningful fragment of it); otherwise difflib's typo-tolerant ratio decides.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
term
|
str
|
What the user typed; blank matches everything. |
required |
candidate
|
str
|
The text to match against. |
required |
threshold
|
float
|
The minimum similarity ratio for a non-substring match. |
0.6
|
typos
|
bool
|
False to match a substring only. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True on a match. |
Source code in usd_chunks/chunk_stage.py
gate_to_branches
⚓︎
Let the branches at live reach the stage and suppress every other input's.
The one implementation behind both gating chunks -- the Switch, picking a branch by index, and the Stage Expression Switch, picking it by what a variable says. They differ only in how that set is chosen, so the muting lives here once.
Suppression is a block plus a layer mute, never the DISABLED state, which belongs to the user: a chunk reaching in to set and clear it on chunks it does not own means every flip risks undoing theirs. A branch contributes because its layers are in the stage, not because it is wired, so cutting the connection instead would leave its prims composed exactly as before and gate nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
ChunkBase
|
The gating chunk. |
required |
live
|
set[int]
|
Indices into the gate's exec dependencies (exec_dependencies) whose branches stay live. |
required |
Returns:
| Type | Description |
|---|---|
tuple[set, set]
|
tuple[set, set]: the chunks kept live, and the chunks muted |
Source code in usd_chunks/chunk_stage.py
4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 | |
get_chunk_prim
⚓︎
Chunk's prim on the live stage, or None if the session has none for it yet.
Source code in usd_chunks/chunk_stage.py
get_search_query
⚓︎
The context's persisted Params-page search query.
An absent attribute means empty, as if nothing was ever typed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
ChunkBase
|
The context. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The query, "" if none. |
Source code in usd_chunks/chunk_stage.py
get_search_scope
⚓︎
The context's persisted search scope: one of "both", "name", "type".
An absent attribute, or an unrecognized stored value, means "both" (search name and type).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
ChunkBase
|
The context. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The scope. |
Source code in usd_chunks/chunk_stage.py
get_upstream_stage
⚓︎
A throwaway stage of every chunk layer except chunk itself and its real downstream.
The raw root layer is included too. It is for a read that must never be influenced by a downstream chunk's edit to the same prim -- e.g. Scatter reading a mesh a Transform wired after it also targets.
Unlike exec_with_hidden_view, this never mutates the real stage, mutes any real layer, or executes anything -- it's a pure composition of already-existing layers into a scratch root, discarded once the caller is done reading. That makes it safe to call unconditionally from inside a chunk's own execute() (reactive param changes included), which is where it's actually needed: a plain param edit never goes through recook_for_view at all, so nothing else protects that path. Chunks are included by "not downstream of me", not "reachable upstream of me" -- a mesh from an unwired sibling chunk (e.g. a Mesh chunk the user picked by path, never wired into the exec chain) still resolves correctly; only genuine downstream chunks are excluded.
Included layers keep their REAL relative strength order (read off the actual graph layers' subLayerPaths), not scene.get_chunks()'s iteration order. Two included chunks can both touch the same prim without conflicting with each other (e.g. whatever created a mesh, and a Transform rotating it, both authoring xformOp:transform on the same prim) -- the real order already correctly resolves that via the existing sort-key/view-driven ranking, and rebuilding it from scratch here would silently pick a different, wrong winner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The live stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
chunk
|
ChunkBase
|
The chunk doing the read. |
required |
Inside a masked cook (skip_cook) the scratch stage is masked the same way, and what the chunk looks up on it is watched like the cook stage itself: it is where such a chunk does its reading.
Returns:
| Type | Description |
|---|---|
Stage
|
The scratch stage. |
Source code in usd_chunks/chunk_stage.py
5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 | |
get_view_exec_sources
⚓︎
Return the chunks wired into view_chunk's inputs:chunk.
Source code in usd_chunks/chunk_stage.py
graph_driver
⚓︎
What a graph cooks by: a View, an Output (standing for all its Outputs), or its chain's end.
Shown (deliver False): the View its saved slot names, else its Output, else its lowest-slot View (a file from before Outputs). Handed to its parent graph (deliver True): its Output, else its active View, else the end of its chain; one wired to nothing doesn't count, since it would cook nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
context
|
ChunkBase | None
|
The graph. |
required |
deliver
|
bool
|
What the graph hands on, as its parent's recook cooks a group, not what it shows. |
False
|
Returns:
| Type | Description |
|---|---|
tuple[ChunkBase | None, bool]
|
(the driver or None, True when it is the chain's end standing in for a View). |
Source code in usd_chunks/chunk_stage.py
graph_outputs
⚓︎
Every Output of a graph, weakest layer first.
A shot sublayering its departments composes each department's Output into one graph. Delivering the graph cooks all of them, weakest first: implied edges (implied_sources) usually chain them already, but a stronger layer can wire a weaker chunk after its own and cut that chain, and the weaker department still delivers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
context
|
ChunkBase | None
|
The graph, or None for the top level (the shallowest Outputs). |
required |
Returns:
| Type | Description |
|---|---|
list[ChunkBase]
|
The Outputs, weakest layer first; empty when the graph has none. |
Source code in usd_chunks/chunk_stage.py
has_collapsible_body
⚓︎
Whether a chunk's node has a body of params to fold away.
Not a View or Output, nor a Merge or Dot (no body), nor a group (its double-click is its dive).
Source code in usd_chunks/chunk_stage.py
has_dynamic_exec_inputs_prim
⚓︎
Whether a chunk prim's exec input slots grow with what is wired in.
Such a chunk gets one numbered port (inputs:chunk, inputs:chunk1, ...) per branch wired in -- Merge and Switch, and whatever else declares config.dynamic_exec_inputs. See exec_input_slots_for_prim for the other kind, where the count is fixed and positional.
Takes the prim: the node graph builds ports from the stage and may have no chunk object. See exec_input_slots_for_prim for why this reads the registry's discovery-time config rather than importing the module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prim
|
Prim
|
The chunk prim. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for a dynamic-slot chunk's prim. |
Source code in usd_chunks/chunk_stage.py
heal_exec_chain_on_delete
⚓︎
Rewire around a node about to be deleted so its exec chain survives.
For A -> X -> B, deleting X must leave A -> B (each successor B's inputs:chunk is repointed to X's predecessor A; cleared if X had none). Call while X's prim still exists -- its inputs:chunk predecessor is only readable before removal. Exec only (inputs/outputs:chunk); data/typed connections to X are left to drop with the prim.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage to author on. |
required |
deleted_path
|
str
|
Prim path of the node being deleted. |
required |
Source code in usd_chunks/chunk_stage.py
5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 | |
hold_asset_layers
⚓︎
Open the files a chunk brings in and keep them open on it, until it brings in others.
network_target opens a file to ask whether it holds a network, and lets it go; the arc the chunk then authors opened it all over again -- every asset read twice on each cook, half a second of the bathroom scene's five-second open. Held here, the question and the arc share one read. The layers go when the chunk's files change, or with it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
The Reference, Payload or Sublayer chunk. |
required | |
paths
|
Iterable[str]
|
The files it brings in. |
required |
Source code in usd_chunks/chunk_stage.py
host_network
⚓︎
Make chunk the host of the network at prim_path in asset_path. See host_networks.
Source code in usd_chunks/chunk_stage.py
host_networks
⚓︎
Make chunk the host of these networks, each an (asset path, prim path) pair.
Authors the arcs on chunk's own prim -- in its bookkeeping layer, since an arc is structure that must survive a cook and a save, not content -- and gives the chunk the flags a group has, so the composed-in children nest under it and cook as its subnet (recook_for_view recurses into a group's inner view). The children are then loaded straight away: the arc write lands while a cook has notices suppressed, and the rescan that would otherwise pick them up waits for the next unsuppressed stage change, which may be a while.
Several targets compose together under the one prim, first strongest -- the order a Sublayer chunk's list has, and what stacking those files as sublayers would do to their chunk prims too: a chunk both networks name is one chunk with the stronger file's opinions on top.
Idempotent: re-hosting the same targets rewrites the same arcs and loads nothing new.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The hosting chunk. |
required |
targets
|
list[tuple[str, str]]
|
(asset path, prim path) pairs, strongest first. An empty list unhosts. |
required |
arc
|
str
|
"reference" or "payload": the kind the hosting chunk stands for. A payload host's network unloads with the stage's other payloads, and its arc on the prim is what a reader sees, so a Payload chunk must not quietly become a reference. |
'reference'
|
namespace
|
str
|
The scene root the network's prim paths resolve under; "" means the paths as written, which is the sequence-into-shot case. A network's chunks author absolute paths -- /Clock_01 -- so two hosts of the same room would fight over the same prims; with a namespace each host's chunks resolve their prim-path params under its root (ChunkParamBase.network_namespace), and /Clock_01 in the file is /bedroom/Clock_01 in the scene. The file and the params' stored text are untouched. |
''
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in usd_chunks/chunk_stage.py
3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 | |
implied_sources
⚓︎
The chunks a chunk is fed by because of composition, not a wire.
A chunk with no exec input starts where everything weaker than it ends:
- A shot sublayers its departments, each a chain ending in its Output, and nothing is wired between them. A first chunk in lighting.usda starts where layout.usda's chain ends, as if wired to what feeds layout's Output -- the nearest weaker layer beside it (its sibling Outputs) that brings one.
- A network composed in by an arc (a reference, payload, inherit or variant authored in the chunk's own layer or a weaker one) cooks before it too, so a shot's chain can read the referenced house it builds on.
These edges are derived from composition on every read and never authored -- the same reading gives the cook order (view_cook_list), live change propagation (_wired_dependencies) and the load, and nothing is written to any file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prim
|
Prim
|
A chunk prim. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Prim paths of the chunks feeding those Outputs; empty for a chunk with an exec |
list[str]
|
input, a terminal chunk, a chunk composed in by an arc itself, or one with nothing |
list[str]
|
weaker to follow. |
Source code in usd_chunks/chunk_stage.py
3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 | |
initialize
⚓︎
Start the layer manager and stage sync for a stage and scene, and follow stage replacement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
Source code in usd_chunks/chunk_stage.py
input_consumers
⚓︎
The chunks with a typed input wired to this one's prim, in scene order.
The reverse of a param wire: USD keeps a connection only on the consumer's side, so this is read from an index of the scene's stage, kept until a wire changes. Exec inputs are not counted -- they say what cooks after what, not what feeds what.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk being read from |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
The consuming chunks, without chunk itself |
Source code in usd_chunks/chunk_stage.py
is_chunk_lofted
⚓︎
Whether chunk is lofted to its group, so its panel shows on the group's Params page.
An authored chunk:lofted (or, from an older file, chunk:pinned) always wins.
Otherwise -- no authored value, which can mean the prim itself doesn't exist yet -- it
falls back in order:
- Views and Outputs are wiring, never panels: not lofted.
- _loft_new_chunks, when a create/paste flow is deciding it right now. Set before the create notice is sent, so it is right whichever PARAM_ADDED listener runs first.
- Absent means not lofted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the chunk is lofted. |
Source code in usd_chunks/chunk_stage.py
is_chunkgroup
⚓︎
Whether chunk is a chunkgroup proper -- the chunkgroup chunk type.
A chunkgroup is defined in USD and is a subnet you navigate into; a chunk is defined in
python, and one that owns children (AMDMaterialXLibrary creating reference and
bind_material) is reusing them as an implementation detail, not exposing a subnet to
edit. Both carry GroupFlags.CONTEXT, so CONTEXT alone cannot tell them apart.
Navigation, and the UI that advertises it, keys on this. Containment and cooking key on is_group_chunk, so a chunk-in-chunk keeps hiding its children and running their code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for a chunkgroup. |
Source code in usd_chunks/chunk_stage.py
is_edit_target_chunk
⚓︎
Return True if chunk is an Edit Target chunk (chunks/usd/edit_target.py).
is_group_chunk
⚓︎
Whether chunk owns child chunks: a CONTEXT chunk with a module.
This is about containment: whose children are hidden until entered, cook as a unit, and share a layer. It is true of a chunkgroup, and equally true of a chunk-in-chunk like AMDMaterialXLibrary, whose children are an implementation detail. For the narrower "is this a subnet the user may navigate into", see is_chunkgroup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for a chunk that contains others. |
Source code in usd_chunks/chunk_stage.py
is_localisable
⚓︎
Whether localise_network has anything to do for this chunk.
That is a network host, or a chunkgroup that references its network from a file (publish_network's result).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if it can be localised. |
Source code in usd_chunks/chunk_stage.py
is_merge_chunk
⚓︎
Whether chunk is specifically a Merge chunk (chunks/core/merge.py).
Narrower than has_dynamic_exec_inputs_prim: Merge's slot order also decides composition strength ("first input wins"), which is a Merge-only meaning that a dynamic-slot chunk with no such ranking (a Switch) does not share.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for a Merge chunk. |
Source code in usd_chunks/chunk_stage.py
is_merge_prim
⚓︎
is_merge_chunk for a bare prim, when there is no live chunk object to ask.
Used where only the stage is at hand (slot compaction, cook ordering).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prim
|
Prim
|
The chunk prim. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for a Merge chunk's prim. |
Source code in usd_chunks/chunk_stage.py
is_network_host
⚓︎
Whether chunk brings a chunk network in by reference and hosts it as a subnet.
A Reference chunk pointed at a file whose target prim is a chunkgroup does not put that prim into the scene; it puts the reference arc on its OWN chunk prim (host_network), so the group's chunks compose in as its children and the node is the group -- dive in, and the network is there, as if it had been expanded in place. The chunk carries CONTEXT while it hosts (so containment and cooking treat it as a group, see is_group_chunk) and the arc on its prim is what tells it apart from a chunk that builds its own children (AMD MaterialX Library), which is CONTEXT too.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for a chunk hosting a network. |
Source code in usd_chunks/chunk_stage.py
is_node_in_context
⚓︎
Whether chunk is a NODE in context's graph: its prim is a direct child of the context's root.
That matches how the graph rebuild picks nodes, and separates 'group as a node' from 'group as a container': a group is a node in its PARENT graph (its prim's parent is the parent root), and the group's inner chunks are nodes in the group's graph. get_context() would conflate the two, since it returns self for a context chunk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
context
|
ChunkBase | None
|
The context, or None for the top level (always True). |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if chunk is a node of that graph. |
Source code in usd_chunks/chunk_stage.py
is_output_chunk
⚓︎
Return True if chunk is a graph's Output: what the graph delivers and cooks to.
is_subnet
⚓︎
Whether chunk is a graph the user may dive into.
That is a chunkgroup, or a chunk hosting a referenced network (is_network_host). This is what navigation keys on; is_group_chunk (containment and cooking) is wider and includes chunks whose children are an implementation detail.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for a subnet. |
Source code in usd_chunks/chunk_stage.py
is_terminal_chunk
⚓︎
Return True for a chain-ending marker (a view or an Output), which has no content.
Read from the module's config, so any terminal chunk is never taken for a chain's tail, cooked, pinned or copied.
Source code in usd_chunks/chunk_stage.py
is_transient_param
⚓︎
Whether param is session state that is never recorded (ParamFlags.TRANSIENT).
A vector is transient when all of its components are: its own flags are group flags.
Source code in usd_chunks/chunk_stage.py
is_view_chunk
⚓︎
layer_label
⚓︎
A layer as a user knows it: the chunk whose cook layer it is, or its file name.
A chunk's procedural layer is named anon:
:Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
Layer
|
The layer. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The chunk's name, or the layer's display name (its identifier when it has none). |
Source code in usd_chunks/chunk_stage.py
layer_stack_ids
⚓︎
Identifiers of every layer FlattenLayerStack takes in: the stage's stack and the chunk layers in it, not what its references bring in.
Source code in usd_chunks/chunk_stage.py
load_chunks
⚓︎
Turn Chunk prims into chunks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage to read. |
required |
scene
|
SceneSender
|
The scene to add the chunks to. |
required |
loaded_prim_paths
|
set[str] | None
|
Prim paths already loaded, skipped and updated. |
None
|
prims
|
Generator | None
|
Narrows which prims are considered -- see ChunkStageSync._scan_for_new_chunks, which derives it from what USD reported changed. None considers the whole stage, which is what a file being opened wants. |
None
|
Source code in usd_chunks/chunk_stage.py
localise_network
⚓︎
Turn a hosted network into a plain chunkgroup of this file.
The inverse of publish_network, and what "Allow Editing of Contents" means here. The composed subtree under the host prim -- the file's chunks with the shot's overrides on top -- is flattened and authored as local defs in the host's bookkeeping layer, the arc is dropped, and the host prim becomes a chunkgroup. The live objects are then rebuilt from the prims, since the host was a Reference (or Sublayer, Payload) chunk and its replacement is a chunkgroup; the same load path a reopened file takes, so the result is what saving and reopening would have given.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
ChunkBase
|
The hosting chunk. |
required |
Returns:
| Type | Description |
|---|---|
ChunkBase | None
|
The new chunkgroup, or None if there was nothing to localise. |
Source code in usd_chunks/chunk_stage.py
9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 | |
loft_param_to_context
⚓︎
Loft a param up to the context prim's public interface.
Creates inputs:{owner}_{param.name} on the context prim, connects the inner
storage attribute to it, and re-binds the Python param to track the context
attribute -- so reads and writes flow through the context prim interface.
The name is settled here, once, and then belongs to the group. It is deliberately not re-derived from the owning chunk later: the interface is what the CLI addresses by name, what expressions reference and what saved files record, so renaming an inner chunk must not silently change the group's published interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
ChunkParamBase
|
The param to loft. |
required |
context
|
ChunkBase
|
The group to publish it on. |
required |
Source code in usd_chunks/chunk_stage.py
9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 | |
lofted_copy
⚓︎
The param on context that param is lofted to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
ChunkParamBase
|
The inner param. |
required |
context
|
ChunkBase
|
The group it may be lofted to. |
required |
Returns:
| Type | Description |
|---|---|
ChunkParamBase | None
|
The lofted param on context, or None when param is not lofted there. |
Source code in usd_chunks/chunk_stage.py
match_lofted_params
⚓︎
Bring each group's lofted params back in line with its attributes in USD.
An undo or redo of Loft up or Unloft changes only USD. A lofted param whose attribute is gone is dropped, and one whose attribute came back is made again, so the Params page shows what the stage has.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage. |
required |
contexts
|
Iterable[ChunkBase]
|
The groups to check. |
required |
Source code in usd_chunks/chunk_stage.py
nested_cook_keys
⚓︎
A sort key per chunk (by id) that orders a nested network upstream-first.
The key is the chunk's ancestor chain, outermost first, each level standing for how far down its own siblings' wiring that ancestor sits (its longest path from a sibling with no input, read from the stage's wires as in commit_order_from_stage). Siblings wired to nothing tie, and a tie goes to the shorter chain, so a chunk still comes before what is nested deeper beside it -- the outermost-first order load_chunks always cooked in.
What a plain depth sort missed is two groups wired one after the other: the downstream group's inner chunks are shallower than the upstream group's deepest ones, so they cooked first, against a stage without what the upstream group makes, and nothing cooked them again.
A wire from inside another group counts against the sibling holding its source. A cycle is broken rather than dropped: whatever is left takes the level after the last.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
Iterable[ChunkBase]
|
The chunks to key; ancestors outside this set end the chain. |
required |
stage
|
Stage
|
The stage holding their chunk prims. |
required |
from_dag
|
bool
|
Read the wires from the chunks' DAG dependencies, not the stage. A load reads the stage, which is what the file says; a script sorting after every chunk it makes reads the DAG, which agrees and costs a small fraction of the time. |
False
|
Returns:
| Type | Description |
|---|---|
dict[int, tuple]
|
id(chunk) -> key tuple. |
Source code in usd_chunks/chunk_stage.py
7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 | |
network_target
⚓︎
The prim path of the chunkgroup a referenced file offers, or None for scene content.
Resolved the way the Reference chunk resolves its target: the explicit import path, else the layer's defaultPrim, else its single root prim. A target is a network when it composes to a Chunk of type chunkgroup -- the shape export_chunks writes. That shape puts the group under a /chunks scope, so a target that is the scope itself stands for the first chunkgroup in it: pointing a Reference at a saved network file, with no import path, hosts the network it holds.
Composed, not read off the one layer's specs: a file may hold its network only through its own sublayers (a sequence file that stacks a layout file and a lighting file), and hosting composes the whole of it in anyway. Opened with a population mask of just the candidate paths, so asking a heavy asset file whether it is a network costs its chunk prims, not its geometry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_path
|
str
|
The referenced file. |
required |
import_path
|
str
|
The prim path the reference targets, or "" for the file's default. |
''
|
Returns:
| Type | Description |
|---|---|
str | None
|
The chunkgroup's prim path in the file, or None. |
Source code in usd_chunks/chunk_stage.py
3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 | |
normalize_merge_slots
⚓︎
Keep a dynamic-slot chunk's connected exec inputs in slots 0..N-1 with no gaps.
Applies to Merge, Switch and any other dynamic-slot chunk. Clearing a middle slot compacts the rest up, so slot order (which is what decides whose Merge opinion wins, or which branch a Switch's index N means) always matches the port order the user sees on the node, rather than drifting into a question about invisible attribute names.
Judged on the CONNECTED slots alone -- an exec attribute that exists but connects nothing
is deliberately left in place. It has to be: this runs synchronously from the stage
notice that CreateAttribute itself fires, so an authoring path which creates the
attribute and then connects it (_author_connection does exactly that, and so does the
numbered-slot branch of _on_dependency_added) would otherwise have the attribute deleted
underneath it between the two statements, and would go on to call SetConnections on an
invalid handle. The cost is that clearing the LAST slot can leave a connectionless
inputs:chunkN behind; it is inert -- it carries no connection, _build_ports counts
connections rather than attributes, and the next compaction sweeps it -- so it is
preferable to breaking the authoring paths.
No-ops for anything without dynamic exec inputs, and for one already in shape, so it is safe to call on every exec-input change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage to author on. |
required |
prim
|
Prim
|
The chunk prim. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if any slot was rewritten |
Source code in usd_chunks/chunk_stage.py
5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 | |
order_layers_like_the_views
⚓︎
Rank chunk layers as each graph's recook for its view will, without cooking anything.
A load first sorts by wiring depth (sort_chunk_layers), which mixes a Merge's branches by length. A graph's recook for its active View, or its Output when none is active, keeps each branch together with the Merge's first input strongest. Ranked the same way here, a script opening the network gets the graph's result, and the graph's first recook moves nothing -- so every chunk can still skip its next cook. Inner graphs first, as a recook ranks a group's chunks in the group's own cook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
The stage. |
required | |
scene
|
The scene. |
required | |
lm
|
ChunkLayerManager
|
The layer manager. |
required |
Source code in usd_chunks/chunk_stage.py
owning_group
⚓︎
The group chunk sits in: the one it is lofted to.
Not get_context() for a group, which answers the group itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
Returns:
| Type | Description |
|---|---|
ChunkBase | None
|
The group, or None for the outermost one. |
Source code in usd_chunks/chunk_stage.py
param_held_by
⚓︎
The layer whose opinion on this param is stronger than where the param writes, or None.
The other side of param_override_source. There the param's own value sits over one composed in; here something sits over the param's own: an Override Chunk Prim's layer, or a department layer stronger than the one this chunk's prim is written in. An edit to the param still lands, in its home (chunk_utils.get_attr_home_layer), but the value composed -- and so the one the param shows and cooks with -- is the stronger one's. Without saying so the field just springs back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
ChunkParamBase
|
The param, or a vector part (its vector's attribute is the one asked about). |
required |
Returns:
| Type | Description |
|---|---|
Layer | None
|
The stronger layer, or None. |
Source code in usd_chunks/chunk_stage.py
param_locked_by
⚓︎
The locked layer an edit of param would land in, or None when it can be edited.
Where an edit goes is the same answer ChunkParamBase.data_changed acts on (chunk_utils.param_storage_layer): with the stage's edit target on a read-only department file, a layout chunk's param is locked; set it to a layer you can edit and the same edit is an override there.
Source code in usd_chunks/chunk_stage.py
param_override_source
⚓︎
The composed-in layer whose opinion this param's value overrides, or None.
A param on a chunk that arrived by composition (a hosted network, a sublayered sequence) shows the file's value until the shot writes its own; then the storage attr has an opinion in an owned layer sitting over one from a foreign layer or across an arc. That weaker opinion's layer is the answer -- what a UI names in "overrides seq.usda" and what revert_param_override puts back. A local opinion with nothing composed in beneath it is not an override, just a value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
ChunkParamBase
|
The param. |
required |
Returns:
| Type | Description |
|---|---|
Layer | None
|
The overridden layer, or None. |
Source code in usd_chunks/chunk_stage.py
param_sdf_type
⚓︎
The type a param's chunk-prim attribute is created with, or None if it has none.
From the value, or from the default while the value is a @Node.param@ expression -- the expression text is not the param's type, and a Slider wired to another chunk must still get a number attribute, or the first plain number typed into it after the wire is gone cannot be written.
Source code in usd_chunks/chunk_stage.py
params_are_bound
⚓︎
Whether any of this chunk's params still drives a real prim attribute.
For a chunk that builds its params from the prim it authors -- a Light, a Camera, anything on show_attribute -- this is the difference between a cook that landed and one that only looked like it did. Cooking against a muted layer composes no prim, so show_attribute binds nothing; a chunk that caches "already cooked this type at this path" would then never rebuild the binding, and every value it holds drives nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if some param has a driven attribute path. |
Source code in usd_chunks/chunk_stage.py
paste_chunks
⚓︎
Create duplicates of clipboard chunks, copying their input attribute values.
Source code in usd_chunks/chunk_stage.py
pruned_paths
⚓︎
The prims Prune Prim pruned that an export holding own_layer_ids can leave out.
A pruned prim is deactivated and flagged (PRUNED_KEY). One defined only in the layers
given -- what the export writes, and the chunk layers it bakes into them -- can go
from the written files altogether. One that also gets a def from somewhere else (a
referenced asset) is left: dropping its inactive over would bring it back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
The stage the export writes from. |
required | |
own_layer_ids
|
Identifiers of the layers whose content the export writes. |
required |
Returns:
| Type | Description |
|---|---|
list[Path]
|
The paths, shallowest first. |
Source code in usd_chunks/chunk_stage.py
publish_edit_target
⚓︎
Record the layer an Edit Target chunk targets, then re-home everything downstream to it.
The record is the _EDIT_TARGET_MARKER attr on the chunk's prim, read by nearest_upstream_edit_layer. This is the single entry point the Edit Target chunk's execute() calls, which keeps the marker format and the downstream migration owned by core, not the script.
The marker is updated in place at its existing home (get_attr_home_layer) so re-pointing the Edit Target repeatedly never leaves a stale stronger opinion shadowing the new one -- same discipline as set_chunk_lofted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The Edit Target chunk. |
required |
stage
|
Stage
|
The stage. |
required |
layer
|
Layer | None
|
The layer it targets, or None for none. |
required |
Source code in usd_chunks/chunk_stage.py
publish_network
⚓︎
Write group's network to path and make group the host of that file.
The inverse of localise_network. After the write, the group prim references the file and its children's local specs are dropped from every owned layer, so the same chunks now compose in from the file and anything the shot does to them from here on is an override. The chunk objects are untouched: their prims still exist, composed rather than authored. The group prim's own bookkeeping (position, active view) stays local -- it is this graph's node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
ChunkBase
|
The chunkgroup to publish. |
required |
path
|
str | Path
|
The file to write. |
required |
Source code in usd_chunks/chunk_stage.py
push_chunk_values
⚓︎
Re-author every value chunk's params drive, e.g. a Light's inputs.
Needed after a chunk's layer comes back from being muted: USD refuses to author into a muted layer, so a value restored on load (or edited) while the chunk was gated off never landed, and the light would come back at its schema default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage to author on. |
required |
chunk
|
ChunkBase
|
The chunk whose driven values to write. |
required |
Source code in usd_chunks/chunk_stage.py
reached_by_graph_driver
⚓︎
Whether what drives chunk's graph reaches it, so that it is one the graph cooks.
The driver is graph_driver's. A graph with neither a view nor an Output is not view-driven at all (a script building one, a headless run), and everything in it cooks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if chunk is in its graph's cook set, or its graph is not view-driven. |
Source code in usd_chunks/chunk_stage.py
reconcile_dag_dependencies
⚓︎
Make chunk's Python DAG dependencies match its live inputs:chunk connections.
The stage is the authority for chunk-level exec wiring: the node-graph UI's drag-to-connect authors inputs:chunk directly and never calls add_dependency(), so without this the Python DAG holds no edge at all for an interactively built graph and INPUT_CHANGED never fires between two chunks the user visibly wired together.
Adding the edge here also dirties the dependent, so an edge change propagates downstream exactly like a param change does.
Only chunk-level dependencies are touched. Param-level dependencies (added via the c_param.add_dependency(a_param) API) have no inputs:chunk counterpart and are left alone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk whose inputs:chunk connections changed |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if any dependency was added or removed |
Source code in usd_chunks/chunk_stage.py
reconcile_edit_targets
⚓︎
Move every chunk's bookkeeping to the Edit Target resolved for its exec-chain position.
For each regular (non-CONTEXT) chunk whose effective edit layer (_reconcile_destination) no longer matches where its bookkeeping prim lives, move the prim spec there and re-execute it so ChunkLayerManager.get_chunk_layer re-nests the chunk's driven content under the new target too (its graph layer reparents -- see chunk_registry.get_chunk_layer). A chunk already homed correctly moves nothing and is NOT re-executed, so on the common paths (creation authors bookkeeping into the right layer up front via _new_chunk_bookkeeping_layer) this is a cheap no-op and never oscillates. It does real work only when a target actually changes -- which is exactly when publish_edit_target gates its call on the marker having changed.
Idempotent, so safe after any structural change (attach/detach/delete of an exec wire, or an Edit Target changing its layer). CONTEXT chunks (Tab containers, groups) are structural scaffolding pinned to the session layer, not content, so they are left alone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
roots
|
list[ChunkBase] | None
|
Narrows the pass to those chunks and everything downstream of them. A change at one place in the graph can only move the target of chunks at or below it, so a caller that knows where the change happened (wiring an edge, an Edit Target picking a new layer) can say so and skip the rest. None visits the whole scene, which is what a load or a delete -- where the change is not localised to one chunk -- still wants. This matters because the pass is O(chunks) and every wire fires one: on a graph of any size, visiting the whole scene per edge would make building it quadratic. |
None
|
cook
|
bool
|
False migrates without re-running anything, for the one caller that is about to cook the whole graph anyway: loading. There the re-run is not just redundant but quadratic -- each migration would cascade a solve over everything downstream of it, once per chunk. |
True
|
protect_root_layer
|
bool
|
Never delete specs from the stage's root layer while migrating, so opening a file cannot empty the file's own layer. |
False
|
Source code in usd_chunks/chunk_stage.py
5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 | |
recook_focus
⚓︎
Establish the GLOBAL stage for the tab/graph the user is looking at.
The stage is shared by every context, but only the focused one should drive it. Root (context is None) is already a full global establish -- recook_for_view(None) touches every chunk and recurses into all groups. But a GROUP focus only manages its own children, so the parent tab's active view (and sibling groups) would stay unmuted and bleed through ("switch tabs, still see the previous view"). So when focusing a group, first mute + block everything OUTSIDE the group's subtree, then recook inside it -- leaving only the group's inner active view driving the stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
context
|
ChunkBase | None
|
The focused context, or None for the top level. |
required |
view_chunk
|
ChunkBase | None
|
The focused context's active view, or None. |
required |
Source code in usd_chunks/chunk_stage.py
6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 | |
recook_for_view
⚓︎
recook_for_view(stage, scene, context, view_chunk, _synthetic_tail=False, _force=False, _hidden=False)
Apply view-driven execution for one context.
With a view_chunk: reveal only its upstream tree (roots-first); every other non-view chunk in the context is blocked + muted (dormant, hidden). With view_chunk=None (no active view) the context cooks to its Output: a view is for looking, the Output is what the graph delivers. With neither, block + mute everything -- nothing cooks.
Blocking a chunk both hides its result (its layer is muted) and stops it reacting to param changes (see ChunkBase.value_changed) -- so being outside the active view's tree means "does not execute", live.
Of the revealed tree, only the chunks that are stale (chunk_cook.is_cook_stale) cook. Muting keeps a layer's content, so a chunk that already cooked on its current inputs comes back with that result, and running it again would redo the same work -- for an import that parses a mesh file, on every view switch and every wire. A chunk that cooks reaches everything downstream of it through the DAG while those are still muted, which marks them stale in turn, so a change upstream still recooks the whole chain below it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
context
|
ChunkBase | None
|
The context to recook, or None for the top level. |
required |
view_chunk
|
ChunkBase | None
|
The active view, or None for none. |
required |
_synthetic_tail
|
bool
|
True when view_chunk is a stand-in exec tail rather than a real view chunk (see the is_group_chunk branch). Real view chunks are markers excluded from their own cook_list by view_cook_list, but a synthetic tail is real content that must cook too, so it's appended back in rather than excluded. |
False
|
_force
|
bool
|
Cook every revealed chunk, stale or not. Set for the inside of a group that is itself stale: a change reached the group, and its inner chunks read what it brings in. |
False
|
_hidden
|
bool
|
The context is outside its parent's cook set, so it cooks nothing at all, Output or not. |
False
|
A chunk whose cook fails does not stop the pass halfway, with the chunks below it still muted: nothing below it cooks (chunk_cook.cook_pass), the rest of the pass runs and shows their last results, and the first error is raised once it is done. While a chunk waits on a long job (chunk_cook.hold) the recook waits too, and runs after it; inside a change_block, once the block has ended and cooked.
Source code in usd_chunks/chunk_stage.py
remove_prim_specs
⚓︎
Remove the prim specs at paths from layer, with what is under them, in place.
Source code in usd_chunks/chunk_stage.py
rename_context_prim_path
⚓︎
Move all chunk prims in context to a new root using Sdf.CopySpec, then remove the old specs.
Source code in usd_chunks/chunk_stage.py
9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 | |
restore_edit_target_selections
⚓︎
After a load, re-apply each Edit Target chunk's stored selection.
A chunk.Menu rejects a value not in its menu_items, and on load the stored selection ("shot") is restored before the anon layer it names is recreated by the upstream Create Layer chunk -- so the Menu silently drops it and keeps the default ("Session Layer"). By the time the whole graph has loaded, every Layer chunk has run, so the layers (and therefore the menu items) exist; re-applying the stored value here restores the selection. The resulting value change re-publishes the marker and reconciles downstream via the normal path.
Runs strictly post-load -- NOT from the refresh callback mid-load -- so a chain of Edit Targets settles deterministically. Applied UPSTREAM-FIRST: re-applying a downstream Edit Target before an upstream one leaves the upstream still on its (rejected) default while the downstream's execute/reconcile cascade runs, which corrupts the upstream's selection. Ordering by how many Edit Targets sit upstream keeps each chain settling from its root out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The loaded stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
saved
|
dict[str, str] | None
|
The pre-load snapshot from snapshot_edit_target_selections, and the only trustworthy source for these values: the Menu's rejection does not merely drop the value in memory, it writes the default back to USD, so a selection whose layer didn't exist yet at the moment its chunk was rebuilt is already gone from the stage by the time this runs. None falls back to reading the stage, which still covers any selection that happened to survive load. |
None
|
Source code in usd_chunks/chunk_stage.py
6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 | |
revert_param_override
⚓︎
Drop the shot's opinion on this param so the composed-in value shows through again.
Every owned-layer spec for the storage attr goes (an override can have been written under more than one edit target over its life); the param is then set to what now composes, which the write path sees as already authored and leaves alone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
ChunkParamBase
|
The param to revert. |
required |
Source code in usd_chunks/chunk_stage.py
save_scene
⚓︎
Save the scene: the same file export_chunks writes, under the name the Save Scene menu uses.
Only chunk prims are written. Reopening regenerates everything a chunk is responsible for by re-running it, so content that is not reproduced by re-execution needs an explicit re-run after reload -- a bake, the same as Houdini's File Cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scene
|
SceneSender
|
The scene to save. |
required |
chunkgroup_path
|
str | Path
|
Where the chunk graph is written -- the file to reopen. |
required |
Source code in usd_chunks/chunk_stage.py
saved_layer
⚓︎
The in-memory layer export_chunks writes to path, built and not written.
The chunk prims, their asset paths fitted to path's folder, and the stage's up-axis and units stamped. Building it changes nothing on the stage or in any of its layers, so autosave writes a quick save from it without the side effects of a save (laying out scripted nodes, reloading the file's cached layer, storing the open cache).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scene
|
SceneSender
|
The scene, which must have a stage. |
required |
path
|
str | Path
|
The file the layer is meant for. |
required |
relative_paths
|
bool | None
|
As for export_chunks. |
None
|
Source code in usd_chunks/chunk_stage.py
sdf_type_for_param
⚓︎
The USD type an attribute backing this param should have, or None if unmappable.
Typed from the param's DEFAULT rather than whatever it currently holds. A live value can be an unresolved expression string, or something that arrived over a wire, and an attribute's type is fixed for good once it is created -- so typing from the value in hand risks pinning a float param to String and failing every numeric write afterwards. The default is the one value that always reflects what the param actually is.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
The param. |
required |
Returns:
| Type | Description |
|---|---|
ValueTypeName | None
|
The Sdf value type name, or None. |
Source code in usd_chunks/chunk_stage.py
search_chunks
⚓︎
The chunks a search finds: the ones whose text holds query, else the ones a typo away.
Typos only count when nothing holds the text, so "Mesh1" finds Mesh1 and not Mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
list
|
The chunks to search. |
required |
query
|
str
|
The search text; an empty query matches every chunk. |
required |
scope
|
str
|
"both", "name" or "type". |
'both'
|
Returns:
| Type | Description |
|---|---|
list
|
The matching chunks, in their order. |
Source code in usd_chunks/chunk_stage.py
set_chunk_lofted
⚓︎
Loft chunk to its group's Params page, or take it back down.
Written as chunk:lofted on the chunk prim, as chunk-prim bookkeeping: an existing
spec is updated where it lives (chunk_utils.get_attr_home_layer), else it goes to
chunk_utils.get_bookkeeping_layer, so toggling never leaves an older, stronger opinion
in one layer shadowing a newer one in another. An older file's chunk:pinned is
replaced by it. Then chunk_lofted_hook is told.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The chunk. |
required |
lofted
|
bool
|
The new state. |
required |
Source code in usd_chunks/chunk_stage.py
set_chunks_muted
⚓︎
Block and unblock many chunks, changing the stage's mute state ONCE.
Every stage.MuteLayer / UnmuteLayer is a composition change, and composition changes
are reported to everything watching the stage as a resync of / -- the whole stage,
re-read. One per chunk would make a single shot change in a shot-gated graph cost
several full-stage resyncs, and far more on the first switch, each one telling Hydra
that every prim it holds may have changed.
A live viewport is where that lands: the renderer repopulates again and again for one logical change, and the prim browser walks a stage that is being recomposed underneath it -- a renderer can even miss content entirely until it is switched away and back, which is simply a repopulate done once, cleanly.
MuteAndUnmuteLayers does both lists in one operation, so the stage recomposes once and watchers get one resync however many branches the gate moved.
Blocking is the engine's own lever, deliberately not the DISABLED state: DISABLED belongs to the user, who sets it by hand and expects it to stay. ChunkLayerManager guards the two against each other, so a blocked layer is never un-muted by the disable path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage whose layer mute state changes. |
required |
to_mute
|
Chunks to block and mute. |
required | |
to_unmute
|
Chunks to unblock and unmute. |
required |
Returns:
| Type | Description |
|---|---|
tuple[set, set]
|
tuple[set, set]: the chunks actually muted, and those actually un-muted |
Source code in usd_chunks/chunk_stage.py
4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 | |
set_param_default_in
⚓︎
Write param's default into layer, over the value, wire or expression others set.
For after clear_param, when other layers still set the param: an opinion in layer hides theirs without touching them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
ChunkCommon
|
The param or vector. |
required |
layer
|
Layer
|
The layer it was cleared in (ParamClear.layer). |
required |
Source code in usd_chunks/chunk_stage.py
set_search_query
⚓︎
Persist context's Params-page search query as filter:searchQuery on its own prim.
Defines the prim on demand: a plain tab context's own prim is never authored by _define_prim (it is added with send_added=False, so PARAM_ADDED never fires for it), and only exists as an implicit ancestor once a child chunk is added under it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
ChunkBase
|
The context. |
required |
query
|
str
|
The search text. |
required |
Source code in usd_chunks/chunk_stage.py
set_search_scope
⚓︎
Persist context's search scope as filter:searchScope on its own prim.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
ChunkBase
|
The context. |
required |
scope
|
str
|
"both", "name" or "type"; anything else is stored as "both". |
required |
Source code in usd_chunks/chunk_stage.py
snapshot_edit_target_selections
⚓︎
Every Edit Target prim's stored selection, read straight off the stage before loading.
Must be called BEFORE load_chunks -- restore_edit_target_selections needs it.
Loading is itself destructive to these values. When a chunk.Menu is handed a value that isn't (yet) one of its menu_items, edit_target.py's refresh handler resets it to the default, and that reset is a param write, so it lands back in USD -- overwriting the saved selection with "Session Layer". Mid-load that happens routinely: an Edit Target pointing at "A" is rebuilt before the upstream Layer chunk has recreated layer A, so "A" isn't a menu item yet and the selection is destroyed on the way in.
Reading afterwards therefore can't recover it, however carefully -- by then USD holds "Session Layer" and the real answer exists only in the file on disk. This runs first, while the stage still has exactly what was saved, and needs no chunks to exist yet since it reads raw attrs off prims.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage about to be loaded. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
{prim path: selection}. |
Source code in usd_chunks/chunk_stage.py
sort_chunk_layers
⚓︎
Order chunk layers by their place in the wiring, for a graph with no View to do it.
Each chunk layer is placed when it is made, before it is wired, so placement alone leaves creation order and an upstream chunk's opinions win. A View re-sorts on every recook; this does the same for a load, or a script still building.
Ranked by nested_cook_keys, the order a load cooks in: a chunk wired after a chunkgroup sorts past every chunk inside it, however deep. By chain depth (layer_sort_key) it tied with the group's last chunk -- the DAG does not nest a group inside the one that holds it -- and which won came down to the order the layers were made, one way on a fresh build and the other after a reopen. The graph layers are ordered within their targets too, as a View's recook does: a nested group's chunks sit in one of their own.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lm
|
ChunkLayerManager
|
The layer manager. |
required |
chunks
|
Iterable[ChunkBase]
|
The chunks whose layers to sort. |
required |
keys
|
dict | None
|
Their nested_cook_keys, when the caller has them (a load reads them once from the stage). Otherwise read here, from the DAG: this runs after every chunk a script makes, and reading every chunk prim's wires each time was quadratic. |
None
|
Source code in usd_chunks/chunk_stage.py
stamp_stage_metadata
⚓︎
Stamp the stage's up-axis and units onto the in-memory layer before it is written.
Read with the same UsdGeom API the live stage answers with, so the file carries the
opinion from its first byte rather than being reopened and patched afterwards. Written
straight onto the layer's pseudo-root: opening a stage over dst to set them composed
the whole layer, which for an exported scene is everything in it.
Shared by every writer -- save, export_network, scene.export and the Export USD chunk -- since a file without them falls back to USD's global default whatever the scene was.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dst
|
Layer
|
The layer to stamp. |
required |
stage
|
Stage
|
The stage to read them from. |
required |
keep_own
|
bool
|
Keep a value dst already holds. For a sublayer: the stage never reads its values, so the stage's say nothing about what it was given (a Stage Settings chunk behind an Edit Target writes them there for its export). |
False
|
Source code in usd_chunks/chunk_stage.py
start_collapsed
⚓︎
Collapse new chunks before they are added, so their nodes start as a header.
A graph that branches stacks its nodes under each other, and full bodies make that stack tall: a node shows its header, exec ports and wired ports until it is opened. Set before the add, so the prim is written collapsed and the node is built that way rather than drawn open and then shut. Views, Outputs and groups are left as they are: the first two have no body, and a group's double-click is its dive. USD_CHUNKS_START_COLLAPSED=0 starts every node open instead. It is read on each call, so a script can flip it mid-session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
The chunks about to be added. |
required |
Source code in usd_chunks/chunk_stage.py
strip_chunks
⚓︎
Remove the Chunk prims from layer, in place, and everything that pointed at them.
Shared by scene.export() and the Export USD chunk, so both write the same plain USD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
The layer to clean. |
required | |
only_paths
|
Strip just these chunk prim paths and leave every other chunk in place. None strips every Chunk prim in the layer. |
None
|
Source code in usd_chunks/chunk_stage.py
8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 | |
strongest_output
⚓︎
The Output of a graph from its strongest layer, or None when it has none.
Source code in usd_chunks/chunk_stage.py
suggest_location_from_file
⚓︎
Fill a Reference or Payload chunk's primpath_location from its file_path.
Called when file_path changes: the location becomes /
Only a location that still follows the file is replaced: an empty one, or the one this
last suggested. One typed in, set by a script or loaded from a saved network is a
choice, and a new file does not move it -- usdchunks run net.usda
Reference.file_path=other.usd (and every run of a batch) swaps the asset, not where
the network put it. A glob names no one file, so it suggests nothing either.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
The param that changed (file_path, or another param of the chunk). |
required |
Source code in usd_chunks/chunk_stage.py
unhost_network
⚓︎
Drop a hosted network: clear the arc from chunk's prim and the group flags from the chunk.
The composed-in children disappear with the arc and the stage-change path tears their chunk objects down, the same as any prim vanishing from the stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
ChunkBase
|
The hosting chunk. |
required |
Source code in usd_chunks/chunk_stage.py
unloft_param
⚓︎
Remove a lofted param from its group. The inner param keeps its current value.
A copy lofted further up is removed first, and nothing is left connected to the group's attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context_param
|
ChunkParamBase
|
The lofted param on the group. |
required |
Source code in usd_chunks/chunk_stage.py
10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 | |
unwire_param
⚓︎
Drop a param's incoming wire and put it back to its default.
For a param the chunk has just hidden: a wire kept on it would come back, with possibly the wrong meaning, when the param is shown again. A param with no wire is left alone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
The param, or None. |
required |
Source code in usd_chunks/chunk_stage.py
view_cook_list
⚓︎
The chunks feeding view_chunk, following ALL input connections backward.
This is the cook set for a view: view-driven execution runs only these chunks. For the exec-only branch, see exec_upstream. Follows both the exec wire (inputs:chunk) AND data connections (any inputs:* to a source prim), so a node feeding another purely via data (e.g. a Transform between a Scatter and an RBD solver that reads its points) is still cooked -- otherwise it would be blocked and its downstream would read empty/stale input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_chunk
|
ChunkBase
|
The view. |
required |
stage
|
Stage
|
The stage. |
required |
scene
|
SceneSender
|
The scene. |
required |
Returns:
| Type | Description |
|---|---|
list[ChunkBase]
|
The chunks, roots first (a node's sources appear before it). The view chunk itself |
list[ChunkBase]
|
is excluded. |
Source code in usd_chunks/chunk_stage.py
view_slot
⚓︎
A View's slot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage. |
required |
view
|
ChunkBase
|
The View. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The slot, or 0 for an inert View (made from the chunk menu, not given one yet). |