@@ -5276,7 +5276,7 @@ def get_tangent_knife_turn_gcode(s,si,tool,current_a, depth, penetration_feed) :
5276
5276
if s [1 ] in ["line" ,"arc" ] and point_to_point_d2 (s [0 ],si [0 ]) < 1e-7 : continue
5277
5277
feed = f if lg not in ['G01' ,'G02' ,'G03' ] else ''
5278
5278
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' ]
5280
5280
g += "(Subpath start)\n "
5281
5281
lg = 'G00'
5282
5282
elif s [1 ] == 'end' :
@@ -5845,11 +5845,11 @@ def print_dxfpoints(points):
5845
5845
gcode = ""
5846
5846
for point in points :
5847
5847
if self .options .drilling_strategy == 'drillg01' :
5848
- gcode += "(drilling dxfpoint)\n G00 Z%f\n G00 X%f Y%f\n G01 Z%f F%f\n G04 P%f\n G00 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)\n G00 Z%f\n G00 X%f Y%f\n G01 Z%f F%f\n G04 P%f\n G00 Z%f\n " % (self .options .Zsafe ,point [0 ],point [1 ],point [ 2 ],self .tools [layer ][0 ]["penetration feed" ],0.2 ,self .options .Zsafe )
5849
5849
if self .options .drilling_strategy == 'drillg73' :
5850
- gcode += "(drilling dxfpoint)\n G00 Z%f\n G73 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)\n G00 Z%f\n G73 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" ])
5851
5851
if self .options .drilling_strategy == 'drillg83' :
5852
- gcode += "(drilling dxfpoint)\n G00 Z%f\n G83 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)\n G00 Z%f\n G83 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" ])
5853
5853
# print_(("got dxfpoints array=",points))
5854
5854
return gcode
5855
5855
@@ -5864,6 +5864,18 @@ def get_path_properties(node, recursive=True, tags={inkex.addNS('desc','svg'):"D
5864
5864
done = True
5865
5865
node = node .getparent ()
5866
5866
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
5867
5879
5868
5880
if self .selected_paths == {} and self .options .auto_select_paths :
5869
5881
paths = self .paths
@@ -5923,11 +5935,12 @@ def set_comment(match, path):
5923
5935
tmp_curve = self .transform_csp (csp , layer )
5924
5936
x = tmp_curve [0 ][0 ][0 ][0 ]
5925
5937
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 ]]
5928
5941
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 ]
5931
5944
c = 1. - float (sum (colors [id_ ]))/ 255 / 3
5932
5945
curves += [
5933
5946
[
@@ -5960,17 +5973,18 @@ def set_comment(match, path):
5960
5973
keys = range (len (curves ))
5961
5974
for key in keys :
5962
5975
d = curves [key ][0 ][1 ]
5976
+ gcode += gcode_comment_str ("\n Start cutting path id: %s at depth: %s" % (curves [key ][0 ][0 ],d ))
5963
5977
for step in range ( 0 , int (ceil ( abs ((zs - d )/ self .tools [layer ][0 ]["depth step" ] )) ) ):
5964
5978
z = max (d , zs - abs (self .tools [layer ][0 ]["depth step" ]* (step + 1 )))
5965
5979
5966
- gcode += gcode_comment_str ("\n Start 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 ) )
5967
5981
if curves [key ][0 ][2 ] != "()" :
5968
5982
gcode += curves [key ][0 ][2 ] # add comment
5969
5983
5970
5984
for curve in curves [key ][1 ]:
5971
5985
gcode += self .generate_gcode (curve , layer , z )
5972
5986
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 ) )
5974
5988
5975
5989
else : # pass by pass
5976
5990
mind = min ( [curve [0 ][1 ] for curve in curves ] )
@@ -5990,14 +6004,14 @@ def set_comment(match, path):
5990
6004
keys = range (len (curves_ ))
5991
6005
for key in keys :
5992
6006
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 ])) )
5994
6008
if curves [key ][0 ][2 ] != "()" :
5995
6009
gcode += curves [key ][0 ][2 ] # add comment
5996
6010
5997
6011
for subcurve in curves_ [key ][1 ]:
5998
6012
gcode += self .generate_gcode (subcurve , layer , max (z ,curves_ [key ][0 ][1 ]))
5999
6013
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 ])) )
6001
6015
6002
6016
6003
6017
self .export_gcode (gcode )
0 commit comments