File size: 1,919 Bytes
7622175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from isaacsim import SimulationApp

# Chạy headless siêu nhẹ
simulation_app = SimulationApp({"headless": True})

from pxr import Usd

# Trỏ vào file tay phải bạn vừa cắt
USD_PATH = os.path.abspath("/workspace/IsaacLab/GR-1/GR1T2_fourier_hand_6dof/GR1T2_fourier_hand_6dof.usd") 
# Tên file log xuất ra
LOG_FILE = os.path.abspath("usd_structure.log")

stage = Usd.Stage.Open(USD_PATH)

if not stage:
    print(f"[LỖI] Không thể mở file: {USD_PATH}")
else:
    print(f"⏳ Đang quét cấu trúc file USD và lưu vào {LOG_FILE}...")
    
    # Mở file log để ghi (chế độ 'w' - ghi đè)
    with open(LOG_FILE, "w", encoding="utf-8") as f:
        f.write("=========================================================\n")
        f.write(f"🔍 CẤU TRÚC CÂY THƯ MỤC CỦA FILE: {USD_PATH}\n")
        f.write("=========================================================\n\n")
        
        # TraverseAll quét toàn bộ cây
        for prim in stage.TraverseAll():
            path = str(prim.GetPath())
            
            # Đếm số gạch chéo để làm thụt lề
            depth = path.count('/') - 1
            indent = "    " * depth
            
            name = prim.GetName()
            prim_type = prim.GetTypeName()
            type_str = f"[{prim_type}]" if prim_type else "[No Type]"
            
            # Ghi dòng dữ liệu vào file (nhớ thêm \n để xuống dòng)
            f.write(f"{indent}├── {name} {type_str}\n")
            
            # Nếu bạn muốn lưu luôn cả đường dẫn tuyệt đối (path) để nhúng vào code RL cho chuẩn:
            f.write(f"{indent}│   └─ Path: {path}\n")

        f.write("\n=========================================================\n")
    
    print("✅ Đã xuất log thành công! Bạn có thể mở file để xem.")

simulation_app.close()