forked from Heeks/heekscnc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
turning.py
63 lines (47 loc) · 1.63 KB
/
turning.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
import kurve
import area
from nc.nc import *
def make_area_for_roughing(k):
num_spans = kurve.num_spans(k)
if num_spans == 0:
raise "sketch has no spans!"
d, startx, starty, ex, ey, cx, cy = kurve.get_span(k, 0)
d, sx, sy, endx, endy, cx, cy = kurve.get_span(k, num_spans - 1)
a = area.new()
largey = 500
for span in range(0, num_spans):
d, sx, sy, ex, ey, cx, cy = kurve.get_span(k, span)
if span == 0:# first span
area.add_point(a, 0, startx, largey, 0, 0)
area.add_point(a, 0, startx, starty, 0, 0)
area.add_point(a, d, ex, ey, cx, cy)
# close the area
area.add_point(a, 0, endx, largey, 0, 0)
area.add_point(a, 0, startx, largey, 0, 0)
return a
def rough(k, tool_radius, tool_angle, front_angle, back_angle, clearance):
# make a closed area from the kurve
a = make_area_for_roughing(k)
# adjust the shape to add clearance for front angle and back angle
# to do
# offset it by the tool radius
area.offset(a, tool_radius)
# move it to take into account where the driven point is
# to do
# do some clever things with intersecting rectangular area with this one to make some tool path
# for now do some sample tool path to indicate the kind of thing this will do when it's finished
rapid(20, 20)
rapid(2, 8)
feed(-30, 8)
rapid(-29, 9)
rapid(2, 9)
rapid(2, 6)
feed(-30, 6)
rapid(-29, 7)
rapid(2, 7)
rapid(2, 4)
feed(-30, 4)
rapid(-29, 5)
rapid(2, 5)
# rapid away maybe
rapid(20, 20)