Commit b65b6498 authored by sumpfralle's avatar sumpfralle

added a "minimum_step" parameter for GCode generation to the user interface

this allows to change the hard-coded accuracy stepping implemented by paulusmax in r925


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@927 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 4caabd20
...@@ -375,7 +375,8 @@ def execute(parser, opts, args, pycam): ...@@ -375,7 +375,8 @@ def execute(parser, opts, args, pycam):
generator = pycam.Exporters.GCodeExporter.GCodeGenerator( generator = pycam.Exporters.GCodeExporter.GCodeGenerator(
handler, metric_units = (opts.unit_size == "mm"), handler, metric_units = (opts.unit_size == "mm"),
safety_height=opts.safety_height, safety_height=opts.safety_height,
toggle_spindle_status=opts.gcode_no_start_stop_spindle) toggle_spindle_status=opts.gcode_no_start_stop_spindle,
minimum_step=opts.gcode_minimum_step)
generator.set_speed(opts.tool_feedrate, opts.tool_spindle_speed) generator.set_speed(opts.tool_feedrate, opts.tool_spindle_speed)
path_mode = opts.gcode_path_mode path_mode = opts.gcode_path_mode
PATH_MODES = pycam.Exporters.GCodeExporter.PATH_MODES PATH_MODES = pycam.Exporters.GCodeExporter.PATH_MODES
...@@ -612,12 +613,19 @@ if __name__ == "__main__": ...@@ -612,12 +613,19 @@ if __name__ == "__main__":
dest="gcode_no_start_stop_spindle", default=True, dest="gcode_no_start_stop_spindle", default=True,
action="store_false", help="do not start the spindle before " \ action="store_false", help="do not start the spindle before " \
+ "and stop it after each operation (M3/M5)") + "and stop it after each operation (M3/M5)")
group_gcode.add_option("", "--gcode-minimum-step",
dest="gcode_minimum_step", default=0.0,
type="float", action="store", help="mimimum axial distance " \
+ "between two machine positions. Any shorter move is not " \
+ "written to GCode (default: 0.0).")
group_gcode.add_option("", "--gcode-path-mode", dest="gcode_path_mode", group_gcode.add_option("", "--gcode-path-mode", dest="gcode_path_mode",
default="exact_path", action="store", type="choice", default="exact_path", action="store", type="choice",
choices=["exact_path", "exact_stop", "continuous"], choices=["exact_path", "exact_stop", "continuous"],
help="choose the GCode path mode from 'exact_path', 'exact_stop'" \ help="choose the GCode path mode from 'exact_path', 'exact_stop' " \
+ "and 'continuous'. See " \ + "and 'continuous'. Use '--gcode-motion-tolerance' and " \
+ "http://linuxcnc.org/docs/html/gcode_main.html for details") + "and '--gcode-naive-tolerance' if you want to limit the " \
+ "deviation. See http://linuxcnc.org/docs/html/gcode_main.html " \
+ "(G61) for details.")
group_gcode.add_option("", "--gcode-motion-tolerance", group_gcode.add_option("", "--gcode-motion-tolerance",
dest="gcode_motion_tolerance", default=None, dest="gcode_motion_tolerance", default=None,
action="store", help="the optional motion tolerance for " \ action="store", help="the optional motion tolerance for " \
......
...@@ -5114,32 +5114,107 @@ ODE can't be used in combination with parallel processing or server mode.</prope ...@@ -5114,32 +5114,107 @@ ODE can't be used in combination with parallel processing or server mode.</prope
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child> <child>
<object class="GtkHBox" id="hbox28"> <object class="GtkTable" id="table14">
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">50</property> <property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">2</property>
<child> <child>
<object class="GtkLabel" id="SafetyHeightLabel"> <object class="GtkLabel" id="GCodeFilenameExtensionLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">Safety Height:</property> <property name="label" translatable="yes">Custom GCode filename extension:</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="top_attach">1</property>
<property name="position">0</property> <property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="GCodeFilenameExtension">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Select a file extension to be used when storing GCode files.
Leave this field empty if you are satisfied with the default: "ngc".
This is just a convenience setting. The "Export Toolpath" dialog
still allows you to choose the file extension freely.</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">6</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSpinButton" id="SafetyHeightControl"> <object class="GtkSpinButton" id="SafetyHeightControl">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Rapid moves are allowed at this z-level.
This should be clearly above the stock material.
Choose a small value to minimize rapid moves up and down.</property>
<property name="invisible_char">&#x25CF;</property> <property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SafetyHeightValue</property> <property name="adjustment">SafetyHeightValue</property>
<property name="digits">1</property> <property name="digits">1</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="left_attach">1</property>
<property name="fill">False</property> <property name="right_attach">2</property>
<property name="position">1</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="SafetyHeightLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Safety Height:</property>
</object>
<packing>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="GCodeMinimumStepLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Minimum step size:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="GCodeMinimumStep">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Specify the minimum step width of your machine.
PyCAM will not write GCode for moves that are smaller
(in all directions) than this step width. This can reduce
machine time slightly since no-move commands do not
need to be processed at all.
Use the default (0.0) if you want to export all GCode
moves regardless of their length.</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">7</property>
<property name="adjustment">GCodeMinimumStepValue</property>
<property name="digits">5</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing> </packing>
</child> </child>
</object> </object>
...@@ -5181,7 +5256,7 @@ ODE can't be used in combination with parallel processing or server mode.</prope ...@@ -5181,7 +5256,7 @@ ODE can't be used in combination with parallel processing or server mode.</prope
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">4</property> <property name="spacing">4</property>
<child> <child>
<object class="GtkLabel" id="dsfdc"> <object class="GtkLabel" id="GCodePathModeLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">Path mode:</property> <property name="label" translatable="yes">Path mode:</property>
...@@ -5313,40 +5388,6 @@ ODE can't be used in combination with parallel processing or server mode.</prope ...@@ -5313,40 +5388,6 @@ ODE can't be used in combination with parallel processing or server mode.</prope
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkHBox" id="hbox37">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="GCodeFilenameExtensionLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Custom GCode filename extension:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="GCodeFilenameExtension">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">The file extension to be used when storing a GCode file.
Leave this field empty to use the default ("ngc").</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>
...@@ -8038,4 +8079,8 @@ upon interesting bugs and weird results.</property> ...@@ -8038,4 +8079,8 @@ upon interesting bugs and weird results.</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-zoom-fit</property> <property name="stock">gtk-zoom-fit</property>
</object> </object>
<object class="GtkAdjustment" id="GCodeMinimumStepValue">
<property name="upper">100</property>
<property name="step_increment">5.0000000000000004e-05</property>
</object>
</interface> </interface>
...@@ -37,7 +37,8 @@ PATH_MODES = {"exact_path": 0, "exact_stop": 1, "continuous": 2} ...@@ -37,7 +37,8 @@ PATH_MODES = {"exact_path": 0, "exact_stop": 1, "continuous": 2}
class GCodeGenerator: class GCodeGenerator:
def __init__(self, destination, metric_units=True, safety_height=0.0, def __init__(self, destination, metric_units=True, safety_height=0.0,
toggle_spindle_status=False, header=None, comment=None): toggle_spindle_status=False, header=None, comment=None,
minimum_step=0.0):
if isinstance(destination, basestring): if isinstance(destination, basestring):
# open the file # open the file
self.destination = file(destination,"w") self.destination = file(destination,"w")
...@@ -52,6 +53,7 @@ class GCodeGenerator: ...@@ -52,6 +53,7 @@ class GCodeGenerator:
self.gcode = gcode(safetyheight=self.safety_height) self.gcode = gcode(safetyheight=self.safety_height)
self.toggle_spindle_status = toggle_spindle_status self.toggle_spindle_status = toggle_spindle_status
self.comment = comment self.comment = comment
self._minimum_step = minimum_step
self._finished = False self._finished = False
if comment: if comment:
self.add_comment(comment) self.add_comment(comment)
...@@ -66,9 +68,9 @@ class GCodeGenerator: ...@@ -66,9 +68,9 @@ class GCodeGenerator:
def set_speed(self, feedrate=None, spindle_speed=None): def set_speed(self, feedrate=None, spindle_speed=None):
if not feedrate is None: if not feedrate is None:
self.append("F%.4f" % feedrate) self.append("F%.5f" % feedrate)
if not spindle_speed is None: if not spindle_speed is None:
self.append("S%.4f" % spindle_speed) self.append("S%.5f" % spindle_speed)
def set_path_mode(self, mode, motion_tolerance=None, def set_path_mode(self, mode, motion_tolerance=None,
naive_cam_tolerance=None): naive_cam_tolerance=None):
...@@ -103,9 +105,9 @@ class GCodeGenerator: ...@@ -103,9 +105,9 @@ class GCodeGenerator:
self.append(self.gcode.delay(2)) self.append(self.gcode.delay(2))
# At minimum this will stop the duplicate gcode # At minimum this will stop the duplicate gcode
# And this is a place holder for when the GUI is linked # And this is a place holder for when the GUI is linked
ResLimitX = 0.0001 ResLimitX = self._minimum_step
ResLimitY = 0.0001 ResLimitY = self._minimum_step
ResLimitZ = 0.0001 ResLimitZ = self._minimum_step
OldPosition = None OldPosition = None
for pos, rapid in moves: for pos, rapid in moves:
if OldPosition == None: if OldPosition == None:
......
...@@ -126,6 +126,7 @@ PREFERENCES_DEFAULTS = { ...@@ -126,6 +126,7 @@ PREFERENCES_DEFAULTS = {
"simulation_details_level": 3, "simulation_details_level": 3,
"drill_progress_max_fps": 2, "drill_progress_max_fps": 2,
"gcode_safety_height": 25.0, "gcode_safety_height": 25.0,
"gcode_minimum_step": 0.0,
"gcode_path_mode": 0, "gcode_path_mode": 0,
"gcode_motion_tolerance": 0, "gcode_motion_tolerance": 0,
"gcode_naive_tolerance": 0, "gcode_naive_tolerance": 0,
...@@ -881,6 +882,9 @@ class ProjectGui: ...@@ -881,6 +882,9 @@ class ProjectGui:
self._task_property_signals.append((obj, self._task_property_signals.append((obj,
obj.connect("changed", self._handle_task_setting_change))) obj.connect("changed", self._handle_task_setting_change)))
# gcode settings # gcode settings
gcode_minimum_step = self.gui.get_object("GCodeMinimumStep")
self.settings.add_item("gcode_minimum_step",
gcode_minimum_step.get_value, gcode_minimum_step.set_value)
gcode_safety_height = self.gui.get_object("SafetyHeightControl") gcode_safety_height = self.gui.get_object("SafetyHeightControl")
self.settings.add_item("gcode_safety_height", self.settings.add_item("gcode_safety_height",
gcode_safety_height.get_value, gcode_safety_height.set_value) gcode_safety_height.get_value, gcode_safety_height.set_value)
...@@ -3729,7 +3733,8 @@ class ProjectGui: ...@@ -3729,7 +3733,8 @@ class ProjectGui:
metric_units=(self.settings.get("unit") == "mm"), metric_units=(self.settings.get("unit") == "mm"),
safety_height=safety_height, safety_height=safety_height,
toggle_spindle_status=self.settings.get("gcode_start_stop_spindle"), toggle_spindle_status=self.settings.get("gcode_start_stop_spindle"),
comment=all_info) comment=all_info,
minimum_step=self.settings.get("gcode_minimum_step"))
path_mode = self.settings.get("gcode_path_mode") path_mode = self.settings.get("gcode_path_mode")
PATH_MODES = pycam.Exporters.GCodeExporter.PATH_MODES PATH_MODES = pycam.Exporters.GCodeExporter.PATH_MODES
if path_mode == 0: if path_mode == 0:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment