-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathLLFaceOP.py
74 lines (56 loc) · 2.29 KB
/
LLFaceOP.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
import math
import LibLathe.LLBaseOP
import LibLathe.LLUtils as utils
from LibLathe.LLPoint import Point
from LibLathe.LLSegment import Segment
class FaceOP(LibLathe.LLBaseOP.BaseOP):
def generate_path(self):
'''
Generate the path for the profile operation
'''
xmin = self.stock.XMin - self.extra_dia
xmax = 0 - self.min_dia
zmax = self.stock.ZMax + self.start_offset
self.clearing_paths = []
length = zmax - self.part.ZMax
#width = self.stock.XLength/2 - self.min_dia + self.extra_dia
step_over = self.step_over
line_count = math.ceil(length / step_over)
zstart = self.part.ZMax + step_over * line_count
print("line count", line_count)
counter = 0
while counter < line_count + 1:
zpt = zstart - counter * self.step_over
pt1 = Point(xmin, 0 , zpt)
pt2 = Point(xmax, 0 , zpt)
path_line = Segment(pt1, pt2)
'''
roughing_boundary = self.offset_edges[-1]
for seg in roughing_boundary:
#if roughing_boundary.index(seg) == 0:
#print(roughing_boundary.index(seg), counter)
intersect, point = seg.intersect(path_line)
if intersect:
if type(point) is list:
point = pt1.nearest(point)
path_line = Segment(pt1, point)
#if utils.online(seg, point):
# path_line = Segment(pt1, point)
#break
'''
self.clearing_paths.append(path_line)
counter += 1
#clearing_lines = Part.makeCompound(self.clearing_paths)
#Part.show(clearing_lines, 'clearing_path')
def generate_gcode(self):
'''
Generate Gcode for the op segments
'''
Path = []
#for path in self.offset_edges:
# finish = utils.toPathCommand(path, self.step_over, self.hfeed, self.vfeed)
# Path.append(finish)
for path in self.clearing_paths:
rough = utils.toPathCommand([path], self.step_over, self.hfeed, self.vfeed)
Path.append(rough)
return Path