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):
generator = pycam.Exporters.GCodeExporter.GCodeGenerator(
handler, metric_units = (opts.unit_size == "mm"),
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)
path_mode = opts.gcode_path_mode
PATH_MODES = pycam.Exporters.GCodeExporter.PATH_MODES
......@@ -612,12 +613,19 @@ if __name__ == "__main__":
dest="gcode_no_start_stop_spindle", default=True,
action="store_false", help="do not start the spindle before " \
+ "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",
default="exact_path", action="store", type="choice",
choices=["exact_path", "exact_stop", "continuous"],
help="choose the GCode path mode from 'exact_path', 'exact_stop'" \
+ "and 'continuous'. See " \
+ "http://linuxcnc.org/docs/html/gcode_main.html for details")
help="choose the GCode path mode from 'exact_path', 'exact_stop' " \
+ "and 'continuous'. Use '--gcode-motion-tolerance' and " \
+ "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",
dest="gcode_motion_tolerance", default=None,
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
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkHBox" id="hbox28">
<object class="GtkTable" id="table14">
<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>
<object class="GtkLabel" id="SafetyHeightLabel">
<object class="GtkLabel" id="GCodeFilenameExtensionLabel">
<property name="visible">True</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>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
<property name="top_attach">1</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>
</child>
<child>
<object class="GtkSpinButton" id="SafetyHeightControl">
<property name="visible">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="adjustment">SafetyHeightValue</property>
<property name="digits">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="left_attach">1</property>
<property name="right_attach">2</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>
</child>
</object>
......@@ -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="spacing">4</property>
<child>
<object class="GtkLabel" id="dsfdc">
<object class="GtkLabel" id="GCodePathModeLabel">
<property name="visible">True</property>
<property name="xalign">0</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
<property name="position">2</property>
</packing>
</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>
</child>
</object>
......@@ -8038,4 +8079,8 @@ upon interesting bugs and weird results.</property>
<property name="visible">True</property>
<property name="stock">gtk-zoom-fit</property>
</object>
<object class="GtkAdjustment" id="GCodeMinimumStepValue">
<property name="upper">100</property>
<property name="step_increment">5.0000000000000004e-05</property>
</object>
</interface>
......@@ -37,7 +37,8 @@ PATH_MODES = {"exact_path": 0, "exact_stop": 1, "continuous": 2}
class GCodeGenerator:
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):
# open the file
self.destination = file(destination,"w")
......@@ -52,6 +53,7 @@ class GCodeGenerator:
self.gcode = gcode(safetyheight=self.safety_height)
self.toggle_spindle_status = toggle_spindle_status
self.comment = comment
self._minimum_step = minimum_step
self._finished = False
if comment:
self.add_comment(comment)
......@@ -66,9 +68,9 @@ class GCodeGenerator:
def set_speed(self, feedrate=None, spindle_speed=None):
if not feedrate is None:
self.append("F%.4f" % feedrate)
self.append("F%.5f" % feedrate)
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,
naive_cam_tolerance=None):
......@@ -103,9 +105,9 @@ class GCodeGenerator:
self.append(self.gcode.delay(2))
# At minimum this will stop the duplicate gcode
# And this is a place holder for when the GUI is linked
ResLimitX = 0.0001
ResLimitY = 0.0001
ResLimitZ = 0.0001
ResLimitX = self._minimum_step
ResLimitY = self._minimum_step
ResLimitZ = self._minimum_step
OldPosition = None
for pos, rapid in moves:
if OldPosition == None:
......
......@@ -126,6 +126,7 @@ PREFERENCES_DEFAULTS = {
"simulation_details_level": 3,
"drill_progress_max_fps": 2,
"gcode_safety_height": 25.0,
"gcode_minimum_step": 0.0,
"gcode_path_mode": 0,
"gcode_motion_tolerance": 0,
"gcode_naive_tolerance": 0,
......@@ -881,6 +882,9 @@ class ProjectGui:
self._task_property_signals.append((obj,
obj.connect("changed", self._handle_task_setting_change)))
# 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")
self.settings.add_item("gcode_safety_height",
gcode_safety_height.get_value, gcode_safety_height.set_value)
......@@ -3729,7 +3733,8 @@ class ProjectGui:
metric_units=(self.settings.get("unit") == "mm"),
safety_height=safety_height,
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_MODES = pycam.Exporters.GCodeExporter.PATH_MODES
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