-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasePostPro.py
More file actions
79 lines (65 loc) · 2.49 KB
/
BasePostPro.py
File metadata and controls
79 lines (65 loc) · 2.49 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
import FreeCAD as App
class BasePostPro:
Ext = ""
def __init__(self):
pass
def writeComment(self, comment):
return f"({comment})"
def writeHeader(self):
h = []
h.append("%")
h.append("O0001")
h.append("G21 (mm)")
h.append("G90 (absolute programming)")
h.append("G40 (cutter radius compensation off)")
h.append("G80 (cancel canned cycle)")
h.append("G17 (XY plane selection)")
return '\n'.join(h)
def transformGCode(self, gcode):
return gcode
def writeFooter(self):
f = []
f.append("M30 ")
return '\n'.join(f)
def blockForm(self, stock):
bb = stock.Shape.BoundBox
s = f"{bb.XMin},{bb.YMin},{bb.ZMin} to {bb.XMax},{bb.YMax},{bb.ZMax}"
return f"{self.writeComment(s)}"
def toolChange(self, tool, cam_project):
tool_id = getattr(tool, 'Id', None)
tool_name = getattr(tool, 'Label', None)
spindle = getattr(tool, 'SpindleSpeed', None)
feed = getattr(tool, 'FeedRate', None)
gcode_lines = []
gcode_lines.append(f"(Changement d'outil: {tool_name if tool_name else ''})")
gcode_lines.append(f"M6 T{tool_id}")
if spindle:
gcode_lines.append(f"S{spindle} M3")
current_spindle = spindle
return '\n'.join(gcode_lines)
def G81(self, obj):
doc = App.ActiveDocument
geom = doc.getObject(obj.DrillGeometryName)
if geom and hasattr(geom, 'DrillPositions'):
points = geom.DrillPositions
safe_z = getattr(obj, 'SafeHeight').Value
gcode_lines = []
gcode_lines.append(f"G81 R{safe_z} Z{obj.FinalDepth.Value} F{obj.FeedRate.Value}")
for pt in points:
gcode_lines.append(f"G0 X{pt.x} Y{pt.y} Z{safe_z}")
gcode_lines.append(f"G80")
return '\n'.join(gcode_lines)
def G84(self, obj):
doc = App.ActiveDocument
geom = doc.getObject(obj.DrillGeometryName)
if geom and hasattr(geom, 'DrillPositions'):
points = geom.DrillPositions
safe_z = getattr(obj, 'SafeHeight').Value
spindle = getattr(obj, 'SpindleSpeed', None)
gcode_lines = []
gcode_lines.append(f"S{spindle} M3")
gcode_lines.append(f"G84 R{safe_z} Z{obj.FinalDepth.Value} F{obj.FeedRate.Value}")
for pt in points:
gcode_lines.append(f"G0 X{pt.x} Y{pt.y} Z{safe_z}")
gcode_lines.append(f"G80")
return '\n'.join(gcode_lines)