Skip to content

Commit f3c8791

Browse files
committed
Merged two branches
2 parents dfbe1cd + 7e89c22 commit f3c8791

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

gcodetools-dev.py

+26-12
Original file line numberDiff line numberDiff line change
@@ -5276,7 +5276,7 @@ def get_tangent_knife_turn_gcode(s,si,tool,current_a, depth, penetration_feed) :
52765276
if s[1] in ["line","arc"] and point_to_point_d2(s[0],si[0]) < 1e-7 : continue
52775277
feed = f if lg not in ['G01','G02','G03'] else ''
52785278
if s[1] == 'move':
5279-
g += go_to_safe_distance + "G00" + c(si[0]) + "\n" + tool['gcode before path'] + "\n"
5279+
g += go_to_safe_distance + "G00" + c(si[0]) + "\n" + tool['gcode before path']
52805280
g += "(Subpath start)\n"
52815281
lg = 'G00'
52825282
elif s[1] == 'end':
@@ -5845,11 +5845,11 @@ def print_dxfpoints(points):
58455845
gcode=""
58465846
for point in points:
58475847
if self.options.drilling_strategy == 'drillg01':
5848-
gcode +="(drilling dxfpoint)\nG00 Z%f\nG00 X%f Y%f\nG01 Z%f F%f\nG04 P%f\nG00 Z%f\n" % (self.options.Zsafe,point[0],point[1],self.Zcoordinates[layer][1],self.tools[layer][0]["penetration feed"],0.2,self.options.Zsafe)
5848+
gcode +="(drilling dxfpoint)\nG00 Z%f\nG00 X%f Y%f\nG01 Z%f F%f\nG04 P%f\nG00 Z%f\n" % (self.options.Zsafe,point[0],point[1],point[2],self.tools[layer][0]["penetration feed"],0.2,self.options.Zsafe)
58495849
if self.options.drilling_strategy == 'drillg73':
5850-
gcode +="(drilling dxfpoint)\nG00 Z%f\nG73 X%f Y%f Z%f R%f Q%f F%f\n" % (self.options.Zsafe,point[0],point[1],self.Zcoordinates[layer][1], self.options.Zsafe, self.tools[layer][0]["depth step"], self.tools[layer][0]["penetration feed"])
5850+
gcode +="(drilling dxfpoint)\nG00 Z%f\nG73 X%f Y%f Z%f R%f Q%f F%f\n" % (self.options.Zsafe,point[0],point[1],point[2], self.options.Zsafe, self.tools[layer][0]["depth step"], self.tools[layer][0]["penetration feed"])
58515851
if self.options.drilling_strategy == 'drillg83':
5852-
gcode +="(drilling dxfpoint)\nG00 Z%f\nG83 X%f Y%f Z%f R%f Q%f F%f\n" % (self.options.Zsafe,point[0],point[1],self.Zcoordinates[layer][1], self.options.Zsafe, self.tools[layer][0]["depth step"], self.tools[layer][0]["penetration feed"])
5852+
gcode +="(drilling dxfpoint)\nG00 Z%f\nG83 X%f Y%f Z%f R%f Q%f F%f\n" % (self.options.Zsafe,point[0],point[1],point[2], self.options.Zsafe, self.tools[layer][0]["depth step"], self.tools[layer][0]["penetration feed"])
58535853
# print_(("got dxfpoints array=",points))
58545854
return gcode
58555855

@@ -5864,6 +5864,18 @@ def get_path_properties(node, recursive=True, tags={inkex.addNS('desc','svg'):"D
58645864
done = True
58655865
node = node.getparent()
58665866
return res
5867+
5868+
def get_depth_from_path_description(node):
5869+
desc = get_path_properties(node, True, {inkex.addNS('desc','svg'):"Description"})
5870+
# self.error(len(desc))
5871+
if (len(desc)>0):
5872+
r = re.search("depth\s*:\s*(-?[0-9.]+)",desc["Description"],re.M)
5873+
if r:
5874+
depth = float(r.group(1))
5875+
else:
5876+
depth = self.Zcoordinates[layer][1]
5877+
# self.error(depth)
5878+
return depth
58675879

58685880
if self.selected_paths == {} and self.options.auto_select_paths:
58695881
paths=self.paths
@@ -5923,11 +5935,12 @@ def set_comment(match, path):
59235935
tmp_curve=self.transform_csp(csp, layer)
59245936
x=tmp_curve[0][0][0][0]
59255937
y=tmp_curve[0][0][0][1]
5926-
print_("got dxfpoint (scaled) at (%f,%f)" % (x,y))
5927-
dxfpoints += [[x,y]]
5938+
z = get_depth_from_path_description(path)
5939+
print_("got dxfpoint (scaled) at (%f,%f,%f)" % (x,y,z))
5940+
dxfpoints += [[x,y,z]]
59285941
else:
5929-
5930-
zd,zs = self.Zcoordinates[layer][1], self.Zcoordinates[layer][0]
5942+
zd = get_depth_from_path_description(path)
5943+
zs = self.Zcoordinates[layer][0]
59315944
c = 1. - float(sum(colors[id_]))/255/3
59325945
curves += [
59335946
[
@@ -5960,17 +5973,18 @@ def set_comment(match, path):
59605973
keys = range(len(curves))
59615974
for key in keys:
59625975
d = curves[key][0][1]
5976+
gcode += gcode_comment_str("\nStart cutting path id: %s at depth: %s" % (curves[key][0][0],d))
59635977
for step in range( 0, int(ceil( abs((zs-d)/self.tools[layer][0]["depth step"] )) ) ):
59645978
z = max(d, zs - abs(self.tools[layer][0]["depth step"]*(step+1)))
59655979

5966-
gcode += gcode_comment_str("\nStart cutting path id: %s"%curves[key][0][0])
5980+
gcode += gcode_comment_str("path id: %s at depth step: %s" % (curves[key][0][0],z))
59675981
if curves[key][0][2] != "()" :
59685982
gcode += curves[key][0][2] # add comment
59695983

59705984
for curve in curves[key][1]:
59715985
gcode += self.generate_gcode(curve, layer, z)
59725986

5973-
gcode += gcode_comment_str("End cutting path id: %s\n\n"%curves[key][0][0])
5987+
gcode += gcode_comment_str("End cutting path id: %s at depth: %s" % (curves[key][0][0],d))
59745988

59755989
else: # pass by pass
59765990
mind = min( [curve[0][1] for curve in curves] )
@@ -5990,14 +6004,14 @@ def set_comment(match, path):
59906004
keys = range(len(curves_))
59916005
for key in keys:
59926006

5993-
gcode += gcode_comment_str("Start cutting path id: %s"%curves[key][0][0])
6007+
gcode += gcode_comment_str("Start cutting path id: %s at depth %s"%(curves[key][0][0],max(z,curves_[key][0][1])))
59946008
if curves[key][0][2] != "()" :
59956009
gcode += curves[key][0][2] # add comment
59966010

59976011
for subcurve in curves_[key][1]:
59986012
gcode += self.generate_gcode(subcurve, layer, max(z,curves_[key][0][1]))
59996013

6000-
gcode += gcode_comment_str("End cutting path id: %s\n\n"%curves[key][0][0])
6014+
gcode += gcode_comment_str("End cutting path id: %s at depth %s\n\n"%(curves[key][0][0],max(z,curves_[key][0][1])))
60016015

60026016

60036017
self.export_gcode(gcode)

0 commit comments

Comments
 (0)