Skip to content

[omniperf-agent] Add sample code#12

Closed
soowanpNV wants to merge 7 commits into
mainfrom
omniperf-agent/add-stage-stats-sample
Closed

[omniperf-agent] Add sample code#12
soowanpNV wants to merge 7 commits into
mainfrom
omniperf-agent/add-stage-stats-sample

Conversation

@soowanpNV

@soowanpNV soowanpNV commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Adds two sample scripts under dev/samples/:

  • export_stage_stats.py — collects USD / RTX Scene / Scene Optimizer statistics inside a Kit-based app by opening the Statistics window and querying the stats interface. Also writes stage_stats.json.
  • export_carb_settings.py — dumps the current Carbonite (carb) settings, enabled extensions, and selected env vars to carb_settings.json for diffing / debugging.

Adds ten read-only Kit Script-Editor analyzers under dev/samples/:

  • 01_largest_meshes.py — top-N largest meshes by vertex / triangle count and bbox volume.
  • 02_instancing.py — current PointInstancer and instance-proxy usage with prototype reuse counts.
  • 03_animation.py — redundant time samples reported by the SO optimizeTimeSamples op.
  • 04_small_objects.py — sub-threshold meshes flagged by the SO removeSmallGeometry op.
  • 05_slab.py — flat / slab-like meshes detected by bbox aspect ratio.
  • 06_instancing_opportunities.py — deduplication candidates via SO deduplicateGeometry plus USD signature grouping.
  • 07_so_printstats.py — invokes the SO printStats op directly in analysis mode and writes the payload to so_printstats.json.
  • 08_validators.py — runs SO findCoincidingGeometry, findOverlappingMeshes, and (optional) findOccludedMeshes in analysis mode.
  • 09_hierarchy_depth.py — prim tree depth and branch-factor distribution from stage.TraverseAll().
  • 10_pipe_density.py — cylinder-like mesh heuristic and axis-alignment ratio per stage volume.

Adds three more Kit Script-Editor analyzers plus one standalone CLI for follow-up vendor questions:

  • 11_usd_files_inventory.py — enumerates Sdf.Layer.GetLoadedLayers() for the open stage, resolves each layer to a real path, and reports per-file size on disk plus extension breakdown.
  • 12_pipe_geometry_detail.py — builds on 10_pipe_density.py: per pipe-like mesh, counts triangles (fan-triangulated face-vertex-counts), flags IsInstance / IsInstanceable / IsInstanceProxy, and checks prim-name / ancestor-name against a token list (pipe, tube, conduit, ...) for naming identifiability.
  • 13_triangle_aspect_ratio.py — fan-triangulates every face and reports the longest-edge / shortest-edge aspect ratio distribution across the stage, with a separate subset for pipe-like meshes (sliver vs equilateral).
  • standalone_usd_disk_scan.py — the only script in the folder that runs outside Kit. Pure Python 3.8+, walks a directory tree, counts .usd / .usda / .usdc / .usdz files and their sizes. Intended for pre-Kit triage of customer data drops.

Adds a HOOPS metadata category counter:

  • 14_hoops_category_pipes.py — walks Usd.PrimRange.Stage(stage, Usd.TraverseInstanceProxies()) and inspects the omni:hoops:metadata:Other:Category attribute on each prim (the tag attached by HOOPS Exchange when importing CAD data). Reports exact-case counts for "Pipe" and "Pipes", a case-insensitive sum, the full Category distribution (top-N), mesh vs non-mesh breakdown for matching prims, and fan-triangulation triangle totals for matching mesh prims. Writes hoops_category_pipes.csv and hoops_category_distribution.csv.

All analyzers are read-only (analysisMode=1), async (Script Editor stays responsive), introspect SceneOptimizerCore.getOperations() to skip ops that are not registered, and write CSV / JSON outputs to the current working directory for Windows compatibility.


🤖 Generated by OmniPerf Agent — AI-assisted merge request

soowanpNV and others added 4 commits May 12, 2026 05:51
Add stage stats export sample under dev/samples/.
Add six read-only Kit Script-Editor analyzers under dev/samples/:

- 01_largest_meshes.py        : top-N largest meshes by vertex/triangle count
- 02_instancing.py            : current PointInstancer / instance-proxy usage
- 03_animation.py             : redundant time-samples via SO optimizeTimeSamples
- 04_small_objects.py         : sub-threshold meshes via SO removeSmallGeometry
- 05_slab.py                  : flat/slab-like meshes by bbox aspect ratio
- 06_instancing_opportunities : dedup candidates via SO deduplicateGeometry +
                                USD signature grouping

All scripts:
- analysisMode=1 (read-only, no stage mutation)
- async with periodic next_update_async yield (keeps Script Editor responsive)
- introspect SceneOptimizerCore.getOperations() and gracefully fall back to
  pure-USD computation when an SO op is not registered in the running Kit
- op names / args / analysis output shapes verified against C++ source in
  omniverse-scene-optimizer and scene-optimizer-core

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ndly)

Changes to all sample scripts under dev/samples/:
- Output files (CSV / JSON) now write to ./<name>.csv instead of /tmp/<name>.csv
  so they work on Windows without modification.

New scripts:
- 07_so_printstats.py     : invoke SO printStats op in analysis mode
- 08_validators.py        : Find Coinciding / Occluded / Overlapping Meshes
- 09_hierarchy_depth.py   : prim tree depth + branch factor distribution
- 10_pipe_density.py      : cylinder-like mesh heuristic + axis-alignment

All scripts:
- analysisMode=1 (read-only, no stage mutation)
- async + periodic next_update_async yield
- SceneOptimizerCore.getOperations() introspection — un-registered ops skipped
- Op names, args, and analysis output shapes verified directly from C++ source
  in omniverse-scene-optimizer (findCoincidingGeometry, findOccludedMeshes,
  findOverlappingMeshes, printStats, optimizeTimeSamples, removeSmallGeometry,
  deduplicateGeometry).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@soowanpNV soowanpNV marked this pull request as draft May 12, 2026 12:45
soowanpNV and others added 3 commits May 12, 2026 12:52
Adds OUTPUT_JSON='./stage_stats.json' and writes the returned stats dict
to a JSON file in addition to printing to console. Path is CWD-relative
for Windows compatibility, consistent with the other dev/samples scripts.
…tions

Adds three Kit Script Editor scripts (numbered 11-13) and one standalone CLI
to cover follow-up questions raised after PR review:

- 11_usd_files_inventory.py    - count and size loaded USD layers
- 12_pipe_geometry_detail.py   - triangle count, instancing, naming check on pipe-like meshes
- 13_triangle_aspect_ratio.py  - longest/shortest-edge ratio per triangle, with pipe subset
- standalone_usd_disk_scan.py  - runs OUTSIDE Kit, scans a folder for USD files + sizes

The standalone script is intentionally unnumbered to mark it as the only
script in the folder that does not run inside Kit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…gory_pipes.py)

Counts prims in the stage whose omni:hoops:metadata:Other:Category
attribute equals 'Pipe' or 'Pipes' (the HOOPS Exchange CAD-category tag).
Reports exact-case + case-insensitive matches, full Category distribution,
mesh vs non-mesh breakdown, and fan-triangulation triangle totals for
matching mesh prims. Writes hoops_category_pipes.csv and
hoops_category_distribution.csv.
@soowanpNV soowanpNV closed this May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant