Skip to content

Commit cc2072c

Browse files
authored
Merge pull request #21 from Matter-and-Form/RC/11.7.0
Update Schema for some group issues
2 parents cb19836 + c54ebc2 commit cc2072c

File tree

3 files changed

+108
-4
lines changed

3 files changed

+108
-4
lines changed

V3Schema

three/MF/V3/Descriptors/Project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ class Group:
2626
"""
2727
V3 project scan group tree descriptor.
2828
"""
29-
def __init__(self, index: int, name: str, visible: bool, collapsed: bool, color: List[float] = None, rotation: List[float] = None, translation: List[float] = None, scan: int = None, groups: List['Project.Group'] = None):
29+
def __init__(self, index: int, name: str, color: List[float] = None, visible: bool = None, collapsed: bool = None, rotation: List[float] = None, translation: List[float] = None, scan: int = None, groups: List['Project.Group'] = None):
3030
# Group index.
3131
self.index = index
3232
# Group name.
3333
self.name = name
34+
# Color in the renderer.
35+
self.color = color
3436
# Visibility in the renderer.
3537
self.visible = visible
3638
# Collapsed state in the group tree.
3739
self.collapsed = collapsed
38-
# Color in the renderer.
39-
self.color = color
4040
# Axis-angle rotation vector. The direction of the vector is the rotation axis. The magnitude of the vector is rotation angle in radians.
4141
self.rotation = rotation
4242
# Translation vector.

three/examples/align.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Quick script to connect to MF THREE scanner, open a project, and run alignment.
4+
"""
5+
6+
from three.scanner import Scanner
7+
from three.MF.V3 import Task, TaskState
8+
from three.MF.V3.Settings.Align import Align
9+
from three.MF.V3.Descriptors.Project import Project
10+
import time
11+
12+
def main():
13+
# Callback functions for handling scanner events
14+
def on_task(task: Task):
15+
"""Handle task updates (progress, completion, errors)"""
16+
if task.Progress:
17+
print(f"Task {task.Type} - Progress: {task.Progress.current}/{task.Progress.total}")
18+
elif task.State == TaskState.Completed.value:
19+
print(f"Task {task.Type} completed successfully")
20+
elif task.State == TaskState.Failed.value:
21+
print(f"Task {task.Type} failed: {task.Error}")
22+
23+
def on_message(message):
24+
"""Handle general system messages"""
25+
print(f"Message received: {message}")
26+
27+
def on_buffer(descriptor, buffer_data):
28+
"""Handle buffer data (images, scans, etc.)"""
29+
print(f"Buffer received: {descriptor.Size} bytes")
30+
31+
# Create scanner instance
32+
scanner = Scanner(
33+
OnTask=on_task,
34+
OnMessage=on_message,
35+
OnBuffer=on_buffer
36+
)
37+
38+
try:
39+
# Connect to scanner (replace with your scanner's IP if not using Zeroconf)
40+
print("Connecting to scanner...")
41+
scanner.Connect("ws://matterandform.local:8081", timeoutSec=10)
42+
print("Connected successfully!")
43+
44+
# List available projects
45+
print("\nListing projects...")
46+
projects_task = scanner.list_projects()
47+
48+
if projects_task.Error:
49+
print(f"Error listing projects: {projects_task.Error}")
50+
return
51+
52+
if not projects_task.Output or len(projects_task.Output) == 0:
53+
print("No projects found. Please create a project first.")
54+
return
55+
56+
# Display available projects
57+
print("Available projects:")
58+
for i, project_data in enumerate(projects_task.Output):
59+
project = Project.Brief(**project_data)
60+
print(f" {i}: {project.name} (Index: {project.index})")
61+
62+
# Select the first project (or modify to select a specific one)
63+
selected_project_index = 16
64+
selected_project = Project.Brief(**projects_task.Output[selected_project_index])
65+
print(f"\nSelected project: {selected_project.name}")
66+
67+
# Open the selected project
68+
print("Opening project...")
69+
open_task = scanner.open_project(selected_project.index)
70+
71+
if open_task.Error:
72+
print(f"Error opening project: {open_task.Error}")
73+
return
74+
75+
print("Project opened successfully!")
76+
77+
list_groups = scanner.list_groups()
78+
for i, group_data in enumerate(list_groups.Output['groups']):
79+
group = Project.Group(**group_data)
80+
print(f"Group {i}: {group.name} (Index: {group.index})")
81+
82+
83+
# Run alignment on the project
84+
print("Starting alignment...")
85+
align_task = scanner.align(19, 14, rough=Align.Rough(method=Align.Rough.Method.Ransac))
86+
87+
if align_task.Error:
88+
print(f"Error running alignment: {align_task.Error}")
89+
return
90+
91+
print("Alignment completed successfully!")
92+
93+
except Exception as e:
94+
print(f"Error: {e}")
95+
96+
finally:
97+
# Clean up connection
98+
if scanner.IsConnected():
99+
print("Disconnecting...")
100+
scanner.Disconnect()
101+
print("Disconnected.")
102+
103+
if __name__ == "__main__":
104+
main()

0 commit comments

Comments
 (0)