-
Notifications
You must be signed in to change notification settings - Fork 3
/
HAnim.py
83 lines (76 loc) · 2.72 KB
/
HAnim.py
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
80
81
82
83
import xml.etree.ElementTree as ET
# list Joint centers in Katy's format
tree = ET.parse("../../specifications/X3dUnifiedObjectModel-4.0.xml")
root = tree.getroot()
sites = root.findall(".//SimpleType[@name='hanimFeaturePointNameValues']")
joints = root.findall(".//SimpleType[@name='hanimJointNameValues']")
segments = root.findall(".//SimpleType[@name='hanimSegmentNameValues']")
#versions = root.findall(".//SimpleType[@name='hanimVersionChoices']")
print("--------------------------------")
print("Joints")
for elem in joints:
# print(ET.tostring(elem))
enums = elem.findall(".//enumeration")
for enum in enums:
# print(ET.tostring(enum))
print("--------------------------------")
print(enum.get('value'))
print("Type:", "joint")
print("Parent:", enum.get('parent'))
print("Index:", enum.get('index'))
xyz = enum.get('default')
# print(xyz)
if xyz is not None:
default = xyz.split(" ")
print("X:", default[0], "m")
print("Y:", default[1], "m")
print("Z:", default[2], "m")
else:
print("X:", "x", "m")
print("Y:", "y", "m")
print("Z:", "z", "m")
if enum.get('alias') is not None:
print("Aliases:", enum.get('alias'))
print("")
print("--------------------------------")
print("Sites")
for elem in sites:
# print(ET.tostring(elem))
enums = elem.findall(".//enumeration")
for enum in enums:
#print(ET.tostring(enum))
print("--------------------------------")
print(enum.get('value'))
print("Type:", "site")
print("Parent:", enum.get('parent'))
print("Index:", enum.get('index'))
xyz = enum.get('default')
if xyz is not None:
default = xyz.split(" ")
# print(default)
print("X:", default[0], "m")
print("Y:", default[1], "m")
print("Z:", default[2], "m")
else:
print("X:", "x", "m")
print("Y:", "y", "m")
print("Z:", "z", "m")
print("")
if enum.get('alias') is not None:
print("Aliases:", enum.get('alias'))
print("")
print("--------------------------------")
print("Segments")
for elem in segments:
# print(ET.tostring(elem))
enums = elem.findall(".//enumeration[@value]")
for enum in enums:
# print(ET.tostring(enum))
print("--------------------------------")
print(enum.get('value'))
print("Parent:", enum.get('parent'))
print("Type:", "segment")
print("Index:", enum.get('index'))
if enum.get('alias') is not None:
print("Aliases:", enum.get('alias'))
print("")