5050delta_4060_post.export(object,"/path/to/file.ncc","")
5151"""
5252
53- # Preamble text will appear at the beginning of the GCODE output file.
54- PREAMBLE = """G17
55- G90
56- G80
57- G40
58- """
59-
60- # Postamble text will appear following the last operation.
61- POSTAMBLE = """M05
62- G80
63- G40
64- G17
65- G90
66- M30
67- """
68-
6953parser = argparse .ArgumentParser (prog = "delta_4060" , add_help = False )
7054parser .add_argument ("--no-header" , action = "store_true" , help = "suppress header output" )
7155parser .add_argument ("--no-comments" , action = "store_true" , help = "suppress comment output" )
7862parser .add_argument ("--precision" , default = "3" , help = "number of digits of precision, default=3" )
7963parser .add_argument (
8064 "--preamble" ,
81- help = 'set commands to be issued before the first command, default="'
82- + PREAMBLE .replace ("\n " , "\\ n" )
83- + '"' ,
84- default = PREAMBLE ,
65+ help = 'set commands to be issued before the first command, default="G17\\ nG90\\ nG80\\ nG40\\ n"' ,
8566)
8667parser .add_argument (
8768 "--postamble" ,
88- help = 'set commands to be issued after the last command, default="'
89- + POSTAMBLE .replace ("\n " , "\\ n" )
90- + '"' ,
91- default = POSTAMBLE ,
69+ help = 'set commands to be issued after the last command, default="M09\\ nM05\\ nG80\\ nG40\\ nG17\\ nG90\\ nM30\\ n"' ,
9270)
9371parser .add_argument (
9472 "--inches" , action = "store_true" , help = "Convert output for US imperial mode (G70)"
131109UNITS = "G71" # G71 for metric, G70 for US standard
132110UNIT_SPEED_FORMAT = "mm/min"
133111UNIT_FORMAT = "mm"
134- MACHINE_NAME = "Delta 4060 "
112+ MACHINE_NAME = "Delta_4060 "
135113CORNER_MIN = {"x" : 0 , "y" : 0 , "z" : 0 }
136114CORNER_MAX = {"x" : 660 , "y" : 355 , "z" : 152 }
137115PRECISION = 3
151129 "G59" : "E06" ,
152130}
153131
132+ # Preamble text will appear at the beginning of the GCODE output file.
133+ PREAMBLE = """G17
134+ G90
135+ G80
136+ G40
137+ """
138+
139+ # Postamble text will appear following the last operation.
140+ POSTAMBLE = """M05
141+ G80
142+ G40
143+ G17
144+ G90
145+ M30
146+ """
154147# Create following variable for use with the 2nd reference plane.
155148clearanceHeight = None
156149
@@ -299,7 +292,7 @@ def export(objectslist, filename, argstring):
299292
300293 if FreeCAD .GuiUp and SHOW_EDITOR :
301294 dia = PostUtils .GCodeEditorDialog ()
302- dia .editor .setPlainText (gcode )
295+ dia .editor .setText (gcode )
303296 result = dia .exec_ ()
304297 if result :
305298 final = dia .editor .toPlainText ()
@@ -405,7 +398,33 @@ def parse(pathobj):
405398
406399 if c .Name .startswith ("(" ) and not OUTPUT_COMMENTS : # command is a comment
407400 continue
408-
401+ # Handle G84/G74 tapping cycles
402+ if command in ("G84" , "G74" ) and "F" in c .Parameters :
403+ pitch_mm = float (c .Parameters ["F" ])
404+ c .Parameters .pop ("F" ) # Remove F from output, we'll handle it
405+
406+ # Get spindle speed (from S param or last known value)
407+ spindle_speed = None
408+ if "S" in c .Parameters :
409+ spindle_speed = float (c .Parameters ["S" ])
410+ c .Parameters .pop ("S" )
411+
412+ # Convert pitch to inches if needed
413+ if UNITS == "G70" : # imperial
414+ pitch = pitch_mm / 25.4
415+ else :
416+ pitch = pitch_mm
417+
418+ # Calculate feed rate
419+ if spindle_speed is not None :
420+ feed_rate = pitch * spindle_speed
421+ speed = Units .Quantity (feed_rate , UNIT_SPEED_FORMAT )
422+ outstring .append (
423+ "F" + format (float (speed .getValueAs (UNIT_SPEED_FORMAT )), precision_string )
424+ )
425+ else :
426+ # No spindle speed found, output pitch as F
427+ outstring .append ("F" + format (pitch , precision_string ))
409428 # Now add the remaining parameters in order
410429 for param in params :
411430 if param in c .Parameters :
@@ -425,7 +444,7 @@ def parse(pathobj):
425444 # This fixes an error thrown by Dynapath due to missing and
426445 # required XYZ move after Tool change.
427446 elif param == "Z" and (
428- c .Parameters ["Z" ] == clearanceHeight and c . Parameters [ "Z" ] != lastZ
447+ c .Parameters ["Z" ] == clearanceHeight and command in [ "G0" , "G00" ]
429448 ):
430449 x = 0
431450 y = 0
@@ -505,7 +524,7 @@ def parse(pathobj):
505524 ) # First Reference plan (Safe Height)
506525 elif param == "P" :
507526 outstring .append (
508- "L" + format (c .Parameters [param ], precision_string )
527+ "L" + format (c .Parameters [param ], ".1f" )
509528 ) # Converts "P" to "L" for dynapath.
510529 else :
511530 if (
0 commit comments