jithenderchoudary commited on
Commit
7db39e6
·
verified ·
1 Parent(s): e8b355d

Update utils/toolpath_generation.py

Browse files
Files changed (1) hide show
  1. utils/toolpath_generation.py +26 -0
utils/toolpath_generation.py CHANGED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Path
2
+ import PathScripts
3
+
4
+ def generate_toolpath(part, tool_size, operation_type):
5
+ """
6
+ Generate a simple toolpath based on the operation type.
7
+ This can be extended to handle more complex operations like pocketing, contouring, etc.
8
+ """
9
+ toolpath = Path.Path()
10
+
11
+ # Toolpath based on operation type
12
+ if operation_type == 'Milling':
13
+ toolpath.addSegment(Path.Line(Point(0, 0, 0), Point(100, 0, 0))) # Simple line milling
14
+ elif operation_type == 'Drilling':
15
+ toolpath.addSegment(Path.Circle(Point(50, 50, 0), tool_size)) # Drill path
16
+
17
+ return toolpath
18
+
19
+ def generate_gcode(toolpath):
20
+ """
21
+ Generate G-code from the toolpath
22
+ """
23
+ path_controller = PathScripts.PathToolController(toolpath)
24
+ gcode_file = "generated_part.gcode"
25
+ path_controller.export(gcode_file)
26
+ return gcode_file