Repository navigation
Expand file tree
/
Copy pathvisualization_xyz_script.py
More file actions
79 lines (57 loc) · 2.05 KB
/
Copy pathvisualization_xyz_script.py
File metadata and controls
79 lines (57 loc) · 2.05 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
# /// script
# dependencies = []
# ///
"""
Test XYZ Point Visualization
Demonstrates geometry visualization in 3D view.
Similar to RevitDevTool.DotnetDemo/XYZVisualization.cs
"""
from Autodesk.Revit import UI, DB
from Autodesk.Revit.UI.Selection import ObjectType
def test_single_point(uidoc: UI.UIDocument):
"""Pick a point and visualize it"""
try:
print("Select a point on an element...")
ref = uidoc.Selection.PickObject(ObjectType.PointOnElement)
point = ref.GlobalPoint
print(f"Selected point: X={point.X:.2f}, Y={point.Y:.2f}, Z={point.Z:.2f}")
print(point) # Visualize in 3D view
except Exception as e:
print(f"ERROR: {e}")
def test_multiple_points(uidoc: UI.UIDocument):
"""Pick multiple points and visualize them"""
try:
print("Select multiple points (ESC when done)...")
refs = uidoc.Selection.PickObjects(ObjectType.PointOnElement)
if len(refs) == 0:
print("WARNING: No points selected")
return
print(f"Selected {len(refs)} points")
# Visualize each point
for i, ref in enumerate(refs):
point = ref.GlobalPoint
print(f"Point {i + 1}: X={point.X:.2f}, Y={point.Y:.2f}, Z={point.Z:.2f}")
print(point)
except Exception as e:
print(f"ERROR: {e}")
def test_generated_points():
"""Generate and visualize a grid of points"""
try:
print("Generating 5x5 point grid...")
points = []
for x in range(5):
for y in range(5):
point = DB.XYZ(x * 10.0, y * 10.0, 0.0)
points.append(point)
print(point) # Visualize each point
print(f"Generated {len(points)} points")
except Exception as e:
print(f"ERROR: {e}")
def main():
print("=== XYZ Visualization Test ===")
uidoc: UI.UIDocument = __revit__.ActiveUIDocument # type: ignore # noqa: F821
test_single_point(uidoc)
# test_multiple_points(uidoc)
# test_generated_points()
if __name__ == "__main__":
main()