-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscan_physics.py
More file actions
executable file
·79 lines (66 loc) · 2.42 KB
/
Copy pathscan_physics.py
File metadata and controls
executable file
·79 lines (66 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
"""掃描 USD 場景裡所有與物理相關的 authored 屬性,列出「現在設了什麼」。
只列 authored(場景檔真的寫下的值),不列 schema 預設 —— 兩者要分開看,
才知道哪些是刻意設定、哪些是吃預設。
用法: scan_physics.py <scene.usd> [prim_path ...]
不給 prim_path 時掃底下 DEFAULT_TARGETS 那組。
⚠ DEFAULT_TARGETS 是某個特定場景的 prim 路徑,**換場景一定要改**。
留著是為了示範「要掃哪幾層」:場景層(PhysicsScene)、車體根、
articulation 底下的作動件、物理材質、被搬物的每一層。
"""
import sys
from pxr import Usd
DEFAULT_TARGETS = [
"/World/RT_A/PhysicsScene",
"/World/RT_A",
"/World/RT_A/main",
"/World/RT_A/main/fork_liftA1",
"/World/RT_A/main/fork_tilt",
"/World/RT_A/main/fork_tilt/fork_tilt_01",
"/World/PhysicsMaterials/high_friction_fork_pallet",
"/target_pallet",
"/target_pallet/target_pallet",
"/target_pallet/target_pallet/SM_RecycledWoodPallet_A04_01",
"/target_pallet/target_pallet/Cube",
]
PHYS_PREFIX = ("physics:", "physx", "newton", "material:binding")
def scan(stage, path):
prim = stage.GetPrimAtPath(path)
if not prim or not prim.IsValid():
print(" %-58s <不存在>" % path)
return
prim.Load()
rows = []
for attr in prim.GetAttributes():
name = attr.GetName()
if not name.startswith(PHYS_PREFIX):
continue
if not attr.HasAuthoredValue():
continue
try:
rows.append((name, attr.Get()))
except Exception as e:
rows.append((name, "<讀取失敗 %s>" % e))
# apiSchemas 決定貼了哪些標籤
apis = prim.GetMetadata("apiSchemas")
api_list = list(apis.appendedItems) if apis else []
print("\n── %s <%s>" % (path, prim.GetTypeName()))
if api_list:
print(" apiSchemas: %s" % ", ".join(str(a) for a in api_list))
if not rows:
print(" (無 authored 物理屬性)")
for name, val in sorted(rows):
print(" %-46s = %s" % (name, val))
def main():
if len(sys.argv) < 2:
print(__doc__)
return 2
scene = sys.argv[1]
targets = sys.argv[2:] or DEFAULT_TARGETS
stage = Usd.Stage.Open(scene, load=Usd.Stage.LoadNone)
print("=== %s ===" % scene)
for t in targets:
scan(stage, t)
return 0
if __name__ == "__main__":
sys.exit(main())