Commit 6a841011 authored by sumpfralle's avatar sumpfralle

added a new implementation of SimpleGCodeExporter

added new gcode settings:
 * start/stop spindle (M3/M5)
 * path mode (G61/G61.1/G64)
moved gcode settings to the general program preferences


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@633 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0e561ace
...@@ -220,6 +220,26 @@ ...@@ -220,6 +220,26 @@
</row> </row>
</data> </data>
</object> </object>
<object class="GtkListStore" id="GCodeCornerStyleList">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Exact path mode (G61)</col>
</row>
<row>
<col id="0" translatable="yes">Exact stop mode (G61.1)</col>
</row>
<row>
<col id="0" translatable="yes">Continuous with maximum speed (G64)</col>
</row>
<row>
<col id="0" translatable="yes">Continuous with tolerance (G64 P/Q)</col>
</row>
</data>
</object>
<object class="GtkWindow" id="ProjectWindow"> <object class="GtkWindow" id="ProjectWindow">
<property name="title" translatable="yes">PyCAM</property> <property name="title" translatable="yes">PyCAM</property>
<property name="destroy_with_parent">True</property> <property name="destroy_with_parent">True</property>
...@@ -2673,7 +2693,7 @@ It will spare some material close to the model (depending on the "step down" val ...@@ -2673,7 +2693,7 @@ It will spare some material close to the model (depending on the "step down" val
<child> <child>
<object class="GtkTable" id="table7"> <object class="GtkTable" id="table7">
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">5</property> <property name="n_rows">4</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">2</property> <property name="column_spacing">2</property>
<property name="row_spacing">2</property> <property name="row_spacing">2</property>
...@@ -2684,8 +2704,6 @@ It will spare some material close to the model (depending on the "step down" val ...@@ -2684,8 +2704,6 @@ It will spare some material close to the model (depending on the "step down" val
<property name="label" translatable="yes">Overlap [%]:</property> <property name="label" translatable="yes">Overlap [%]:</property>
</object> </object>
<packing> <packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
...@@ -2703,8 +2721,6 @@ Use high values for fine-grained toolpaths.</property> ...@@ -2703,8 +2721,6 @@ Use high values for fine-grained toolpaths.</property>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</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="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
...@@ -2716,8 +2732,8 @@ Use high values for fine-grained toolpaths.</property> ...@@ -2716,8 +2732,8 @@ Use high values for fine-grained toolpaths.</property>
<property name="label" translatable="yes">Material Allowance:</property> <property name="label" translatable="yes">Material Allowance:</property>
</object> </object>
<packing> <packing>
<property name="top_attach">2</property> <property name="top_attach">1</property>
<property name="bottom_attach">3</property> <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
...@@ -2739,8 +2755,8 @@ This operation is not available for engraving.</property> ...@@ -2739,8 +2755,8 @@ This operation is not available for engraving.</property>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">2</property> <property name="top_attach">1</property>
<property name="bottom_attach">3</property> <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
...@@ -2758,8 +2774,8 @@ This operation is not available for engraving.</property> ...@@ -2758,8 +2774,8 @@ This operation is not available for engraving.</property>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">3</property> <property name="top_attach">2</property>
<property name="bottom_attach">4</property> <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
...@@ -2771,36 +2787,8 @@ This operation is not available for engraving.</property> ...@@ -2771,36 +2787,8 @@ This operation is not available for engraving.</property>
<property name="label" translatable="yes">Max. Step Down:</property> <property name="label" translatable="yes">Max. Step Down:</property>
</object> </object>
<packing> <packing>
<property name="top_attach">3</property> <property name="top_attach">2</property>
<property name="bottom_attach">4</property> <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="SafetyHeightLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Safe Height:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</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">The drill will return between lines and slices to the safe height.</property>
<property name="invisible_char">&#x2022;</property>
<property name="adjustment">SafetyHeightValue</property>
<property name="digits">1</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
...@@ -2812,8 +2800,8 @@ This operation is not available for engraving.</property> ...@@ -2812,8 +2800,8 @@ This operation is not available for engraving.</property>
<property name="label" translatable="yes">Engrave Offset:</property> <property name="label" translatable="yes">Engrave Offset:</property>
</object> </object>
<packing> <packing>
<property name="top_attach">4</property> <property name="top_attach">3</property>
<property name="bottom_attach">5</property> <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
...@@ -2830,8 +2818,8 @@ This operation is not available for engraving.</property> ...@@ -2830,8 +2818,8 @@ This operation is not available for engraving.</property>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">4</property> <property name="top_attach">3</property>
<property name="bottom_attach">5</property> <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
...@@ -5107,6 +5095,246 @@ It is significantly faster, but the current release of ODE contains a nasty bug ...@@ -5107,6 +5095,246 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkFrame" id="GCodeTabFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment43">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox30">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkHBox" id="hbox28">
<property name="visible">True</property>
<property name="spacing">4</property>
<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="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SafetyHeightControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SafetyHeightValue</property>
<property name="digits">1</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="GCodeStartStopSpindle">
<property name="label" translatable="yes">Start / Stop Spindle (M3/M5)</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="GCodeCornerStyleExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkAlignment" id="alignment44">
<property name="visible">True</property>
<property name="left_padding">25</property>
<child>
<object class="GtkVBox" id="vbox31">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkHBox" id="hbox27">
<property name="visible">True</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel" id="dsfdc">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Path mode:</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="GCodeCornerStyleControl">
<property name="visible">True</property>
<property name="model">GCodeCornerStyleList</property>
<child>
<object class="GtkCellRendererText" id="GCodeCornerStyleName"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTable" id="GCodeToleranceTable">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">4</property>
<property name="row_spacing">3</property>
<child>
<object class="GtkSpinButton" id="GCodeCornerStyleCAMTolerance">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">GCodeCornerStyleCAMToleranceValue</property>
<property name="digits">3</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">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="GCodeCornerStyleMotionTolerance">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">GCodeCornerStyleMotionToleranceValue</property>
<property name="digits">3</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="GCodeCornerStyleMotionToleranceLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Motion blending tolerance:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="GCodeCornerStyleCAMToleranceLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Naive CAM tolerance:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="GCodePathModeHelpLink">
<property name="label" translatable="yes">See the EMC2 manual</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<property name="xalign">1</property>
<property name="uri">http://linuxcnc.org/docs/html/gcode_main.html#sub:G61,-G61.1,-G64:</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="GCodeCornerStyleExpanderLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Corner Style</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="GCodeFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;GCode settings&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="GCodePreferencesTabLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">GCode</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child> <child>
<object class="GtkFrame" id="frame13"> <object class="GtkFrame" id="frame13">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -5225,7 +5453,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug ...@@ -5225,7 +5453,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
...@@ -5234,7 +5462,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug ...@@ -5234,7 +5462,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="label" translatable="yes">Display Items</property> <property name="label" translatable="yes">Display Items</property>
</object> </object>
<packing> <packing>
<property name="position">1</property> <property name="position">2</property>
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
</packing> </packing>
</child> </child>
...@@ -5495,7 +5723,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug ...@@ -5495,7 +5723,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
...@@ -5504,7 +5732,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug ...@@ -5504,7 +5732,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="label" translatable="yes">Colors</property> <property name="label" translatable="yes">Colors</property>
</object> </object>
<packing> <packing>
<property name="position">2</property> <property name="position">3</property>
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
</packing> </packing>
</child> </child>
...@@ -5610,7 +5838,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug ...@@ -5610,7 +5838,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">3</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
...@@ -5619,7 +5847,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug ...@@ -5619,7 +5847,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="label" translatable="yes">OpenGL</property> <property name="label" translatable="yes">OpenGL</property>
</object> </object>
<packing> <packing>
<property name="position">3</property> <property name="position">4</property>
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
</packing> </packing>
</child> </child>
...@@ -5771,7 +5999,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug ...@@ -5771,7 +5999,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">4</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
...@@ -5780,7 +6008,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug ...@@ -5780,7 +6008,7 @@ It is significantly faster, but the current release of ODE contains a nasty bug
<property name="label" translatable="yes">Programs</property> <property name="label" translatable="yes">Programs</property>
</object> </object>
<packing> <packing>
<property name="position">4</property> <property name="position">5</property>
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
</packing> </packing>
</child> </child>
...@@ -6326,4 +6554,12 @@ Any selected group of dimensions will be scaled accordingly.</property> ...@@ -6326,4 +6554,12 @@ Any selected group of dimensions will be scaled accordingly.</property>
<property name="upper">100</property> <property name="upper">100</property>
<property name="step_increment">1</property> <property name="step_increment">1</property>
</object> </object>
<object class="GtkAdjustment" id="GCodeCornerStyleMotionToleranceValue">
<property name="upper">100</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="GCodeCornerStyleCAMToleranceValue">
<property name="upper">100</property>
<property name="step_increment">1</property>
</object>
</interface> </interface>
# -*- coding: utf-8 -*-
"""
$Id$
Copyright 2010 Lars Kruse <devel@sumpfralle.de>
Copyright 2008-2009 Lode Leroy
This file is part of PyCAM.
PyCAM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PyCAM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
from pycam.Exporters.gcode import gcode
import os
DEFAULT_HEADER = ("G40 (disable tool radius compensation)",
"G49 (disable_tool_length_compensation)",
"G80 (cancel_modal_motion)",
"G54 (select_coordinate_system_1)",
"G90 (use_absolute_coordinates)")
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, max_skip_safety_distance=None,
header=None, comment=None):
if isinstance(destination, basestring):
# open the file
self.destination = file(destination,"w")
self._close_stream_on_exit = True
else:
# assume that "destination" is something like a StringIO instance
# or an open file
self.destination = destination
# don't close the stream if we did not open it on our own
self._close_stream_on_exit = False
self.safety_height = safety_height
self.gcode = gcode(safetyheight=self.safety_height)
self.max_skip_safety_distance = max_skip_safety_distance
self.toggle_spindle_status = toggle_spindle_status
self.comment = comment
self._last_path_point = None
self._finished = False
if comment:
self.add_comment(comment)
if header is None:
self.append(DEFAULT_HEADER)
else:
self.append(header)
if metric_units:
self.append("G21 (metric)")
else:
self.append("G20 (imperial)")
def set_speed(self, feedrate=None, spindle_speed=None):
if not feedrate is None:
self.append("F%.4f" % feedrate)
if not spindle_speed is None:
self.append("S%.4f" % spindle_speed)
def set_path_mode(self, mode, motion_tolerance=None,
naive_cam_tolerance=None):
result = ""
if mode == PATH_MODES["exact_path"]:
result = "G61 (exact path mode)"
elif mode == PATH_MODES["exact_stop"]:
result = "G61.1 (exact stop mode)"
elif mode == PATH_MODES["continuous"]:
if motion_tolerance is None:
result = "G64 (continuous mode with maximum speed)"
elif naive_cam_tolerance is None:
result = "G64 P%f (continuous mode with tolerance)" \
% motion_tolerance
else:
result = ("G64 P%f Q%f (continuous mode with tolerance and " \
+ "cleanup") % (motion_tolerance, naive_cam_tolerance)
else:
raise ValueError("GCodeGenerator: invalid path mode (%s)" \
% str(mode))
self.append(result)
def add_path_list(self, paths, tool_id=None, max_skip_safety_distance=None,
comment=None):
if max_skip_safety_distance is None:
max_skip_safety_distance = self.max_skip_safety_distance
if not comment is None:
self.add_comment(comment)
if not tool_id is None:
# Move straight up to safety height (avoiding any collisions on the
# way to the tool changer).
self.append(self.gcode.safety())
self.append("T%d M6" % tool_id)
if self.toggle_spindle_status:
self.append("M3 (start spindle)")
self.append(self.gcode.delay(2))
# move straight up to safety height
self.append(self.gcode.safety())
for path in paths:
self.add_path(path)
# go back to safety height
self.append(self.gcode.safety())
if self.toggle_spindle_status:
self.append("M5 (stop spindle)")
def _check_distance_for_skipping_safety_height(self, new_point,
max_skip_safety_distance):
if (self._last_path_point is None) \
or (max_skip_safety_distance is None):
return False
distance = new_point.sub(self._last_path_point).norm
return distance <= max_skip_safety_distance
def add_path(self, path, max_skip_safety_distance=None):
if not path:
return
point = path.points[0]
# first move to the safety height if the distance to the last point
# does not exceed the given maximum
if not self._check_distance_for_skipping_safety_height(point,
max_skip_safety_distance):
# move to safety height at the end of the previous path
if not self._last_path_point is None:
self.append(self.gcode.safety())
# move to safety height for the start of the current path
self.append(self.gcode.rapid(point.x, point.y,
self.safety_height))
for point in path.points:
self.append(self.gcode.cut(point.x, point.y, point.z))
self._last_path_point = point
def finish(self):
self.append(self.gcode.safety())
self.append("M2 (end program)")
self._finished = True
def add_comment(self, comment):
if isinstance(comment, basestring):
lines = comment.split(os.linesep)
else:
lines = comment
for line in lines:
self.append(";%s" % line)
def append(self, command):
if self._finished:
raise TypeError("GCodeGenerator: can't add further commands to a " \
+ "finished GCodeGenerator instance: %s" % str(command))
if isinstance(command, basestring):
command = [command]
for line in command:
self.destination.write(line + os.linesep)
...@@ -17,16 +17,19 @@ ...@@ -17,16 +17,19 @@
class gcode: class gcode:
lastx = lasty = lastz = lasta = lastgcode = None def __init__(self, safetyheight=1.0, tool_id=1):
lastfeed = None
def __init__(self, homeheight=1.5, safetyheight=None, tool_id=1):
self.tool_id = tool_id self.tool_id = tool_id
if safetyheight is None:
safetyheight = max(homeheight, 0.04)
self.homeheight = homeheight
self.safetyheight = safetyheight self.safetyheight = safetyheight
self.lastz = self.safetyheight self.lastfeed = None
self.lastx = None
self.lasty = None
self.lastz = None
self.lasta = None
self.lastgcode = None
self.lastz = None
def delay(self, seconds):
return "G04 P%d" % seconds
def begin(self): def begin(self):
""" """
...@@ -37,12 +40,9 @@ class gcode: ...@@ -37,12 +40,9 @@ class gcode:
G90: use absolute coordinates instead of axis increments G90: use absolute coordinates instead of axis increments
G00 Z?: no x/y positioning - just go up to safety height G00 Z?: no x/y positioning - just go up to safety height
""" """
return "G40 G49 G54 G80 G90\n" \ return ("G40 G49 G54 G80 G90",
+ "G04 P3 T%d M6\n" % self.tool_id \ "G04 P3 T%d M6" % self.tool_id,
+ "G00 Z%.4f\n" % self.safetyheight "G00 Z%.4f" % self.safetyheight)
def end(self):
return self.safety() + "\n" + "M2\n"
def exactpath(self): def exactpath(self):
return "G61" return "G61"
...@@ -79,7 +79,11 @@ class gcode: ...@@ -79,7 +79,11 @@ class gcode:
if (gcode == "G01") and feed and (feed != self.lastfeed): if (gcode == "G01") and feed and (feed != self.lastfeed):
feedstring = " F%.4f" % (feed) feedstring = " F%.4f" % (feed)
self.lastfeed = feed self.lastfeed = feed
return gcodestring + feedstring + xstring + ystring + zstring + astring positionstring = xstring + ystring + zstring + astring
if len(positionstring) > 0:
return gcodestring + feedstring + positionstring
else:
return ""
def cut(self, x = None, y = None, z = None, a = None, feed=None): def cut(self, x = None, y = None, z = None, a = None, feed=None):
if x == None: x = self.lastx if x == None: x = self.lastx
...@@ -88,9 +92,6 @@ class gcode: ...@@ -88,9 +92,6 @@ class gcode:
if a == None: a = self.lasta if a == None: a = self.lasta
return self.rapid(x, y, z, a, gcode="G01", feed=feed) return self.rapid(x, y, z, a, gcode="G01", feed=feed)
def home(self):
return self.rapid(z=self.homeheight)
def safety(self): def safety(self):
return self.rapid(z=self.safetyheight) return self.rapid(z=self.safetyheight)
...@@ -22,7 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -22,7 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
""" """
import pycam.Exporters.SimpleGCodeExporter import pycam.Exporters.GCodeExporter
import pycam.Exporters.EMCToolExporter import pycam.Exporters.EMCToolExporter
import pycam.Gui.Settings import pycam.Gui.Settings
import pycam.Cutters import pycam.Cutters
...@@ -94,6 +94,11 @@ PREFERENCES_DEFAULTS = { ...@@ -94,6 +94,11 @@ PREFERENCES_DEFAULTS = {
"view_polygon": True, "view_polygon": True,
"simulation_details_level": 3, "simulation_details_level": 3,
"drill_progress_max_fps": 2, "drill_progress_max_fps": 2,
"gcode_safety_height": 25.0,
"gcode_path_mode": 0,
"gcode_motion_tolerance": 0,
"gcode_naive_tolerance": 0,
"gcode_start_stop_spindle": True,
"external_program_inkscape": "", "external_program_inkscape": "",
"external_program_pstoedit": "", "external_program_pstoedit": "",
} }
...@@ -507,9 +512,8 @@ class ProjectGui: ...@@ -507,9 +512,8 @@ class ProjectGui:
self.gui.get_object(objname).connect("toggled", self.update_process_controls) self.gui.get_object(objname).connect("toggled", self.update_process_controls)
if objname != "SettingEnableODE": if objname != "SettingEnableODE":
self.gui.get_object(objname).connect("toggled", self.handle_process_settings_change) self.gui.get_object(objname).connect("toggled", self.handle_process_settings_change)
for objname in ("SafetyHeightControl", "OverlapPercentControl", for objname in ("OverlapPercentControl", "MaterialAllowanceControl",
"MaterialAllowanceControl", "MaxStepDownControl", "MaxStepDownControl", "EngraveOffsetControl"):
"EngraveOffsetControl"):
self.gui.get_object(objname).connect("value-changed", self.handle_process_settings_change) self.gui.get_object(objname).connect("value-changed", self.handle_process_settings_change)
self.gui.get_object("ProcessSettingName").connect("changed", self.handle_process_settings_change) self.gui.get_object("ProcessSettingName").connect("changed", self.handle_process_settings_change)
# get/set functions for the current tool/process/bounds/task # get/set functions for the current tool/process/bounds/task
...@@ -622,6 +626,23 @@ class ProjectGui: ...@@ -622,6 +626,23 @@ class ProjectGui:
obj = self.gui.get_object(objname) obj = self.gui.get_object(objname)
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_safety_height = self.gui.get_object("SafetyHeightControl")
self.settings.add_item("gcode_safety_height",
gcode_safety_height.get_value, gcode_safety_height.set_value)
gcode_path_mode = self.gui.get_object("GCodeCornerStyleControl")
self.settings.add_item("gcode_path_mode", gcode_path_mode.get_active,
gcode_path_mode.set_active)
gcode_path_mode.connect("changed", self.update_gcode_controls)
gcode_motion_tolerance = self.gui.get_object("GCodeCornerStyleMotionTolerance")
self.settings.add_item("gcode_motion_tolerance",
gcode_motion_tolerance.get_value, gcode_motion_tolerance.set_value)
gcode_naive_tolerance = self.gui.get_object("GCodeCornerStyleCAMTolerance")
self.settings.add_item("gcode_naive_tolerance",
gcode_naive_tolerance.get_value, gcode_naive_tolerance.set_value)
gcode_start_stop_spindle = self.gui.get_object("GCodeStartStopSpindle")
self.settings.add_item("gcode_start_stop_spindle",
gcode_start_stop_spindle.get_active, gcode_start_stop_spindle.set_active)
# configure locations of external programs # configure locations of external programs
for auto_control_name, location_control_name, browse_button, key in ( for auto_control_name, location_control_name, browse_button, key in (
("ExternalProgramInkscapeAuto", ("ExternalProgramInkscapeAuto",
...@@ -686,6 +707,11 @@ class ProjectGui: ...@@ -686,6 +707,11 @@ class ProjectGui:
self.update_unit_labels() self.update_unit_labels()
self.update_support_grid_controls() self.update_support_grid_controls()
self.update_scale_controls() self.update_scale_controls()
self.update_gcode_controls()
def update_gcode_controls(self, widget=None):
path_mode = self.settings.get("gcode_path_mode")
self.gui.get_object("GCodeToleranceTable").set_sensitive(path_mode == 3)
def progress_activity_guard(func): def progress_activity_guard(func):
def progress_activity_guard_wrapper(self, *args, **kwargs): def progress_activity_guard_wrapper(self, *args, **kwargs):
...@@ -1632,8 +1658,8 @@ class ProjectGui: ...@@ -1632,8 +1658,8 @@ class ProjectGui:
if self.gui.get_object("UnitChangeProcesses").get_active(): if self.gui.get_object("UnitChangeProcesses").get_active():
# scale the process settings # scale the process settings
for process in self.process_list: for process in self.process_list:
for key in ("safety_height", "material_allowance", for key in ("material_allowance", "step_down",
"step_down", "engrave_offset"): "engrave_offset"):
process[key] *= factor process[key] *= factor
if self.gui.get_object("UnitChangeBounds").get_active(): if self.gui.get_object("UnitChangeBounds").get_active():
# scale the boundaries and keep their center # scale the boundaries and keep their center
...@@ -2193,8 +2219,7 @@ class ProjectGui: ...@@ -2193,8 +2219,7 @@ class ProjectGui:
if self.gui.get_object(name).get_active(): if self.gui.get_object(name).get_active():
return name return name
settings["path_postprocessor"] = get_path_postprocessor() settings["path_postprocessor"] = get_path_postprocessor()
for objname, key in (("SafetyHeightControl", "safety_height"), for objname, key in (("OverlapPercentControl", "overlap_percent"),
("OverlapPercentControl", "overlap_percent"),
("MaterialAllowanceControl", "material_allowance"), ("MaterialAllowanceControl", "material_allowance"),
("MaxStepDownControl", "step_down"), ("MaxStepDownControl", "step_down"),
("EngraveOffsetControl", "engrave_offset")): ("EngraveOffsetControl", "engrave_offset")):
...@@ -2217,8 +2242,7 @@ class ProjectGui: ...@@ -2217,8 +2242,7 @@ class ProjectGui:
def set_path_postprocessor(value): def set_path_postprocessor(value):
self.gui.get_object(value).set_active(True) self.gui.get_object(value).set_active(True)
set_path_postprocessor(settings["path_postprocessor"]) set_path_postprocessor(settings["path_postprocessor"])
for objname, key in (("SafetyHeightControl", "safety_height"), for objname, key in (("OverlapPercentControl", "overlap_percent"),
("OverlapPercentControl", "overlap_percent"),
("MaterialAllowanceControl", "material_allowance"), ("MaterialAllowanceControl", "material_allowance"),
("MaxStepDownControl", "step_down"), ("MaxStepDownControl", "step_down"),
("EngraveOffsetControl", "engrave_offset")): ("EngraveOffsetControl", "engrave_offset")):
...@@ -2349,7 +2373,8 @@ class ProjectGui: ...@@ -2349,7 +2373,8 @@ class ProjectGui:
items = (index, tp.name, tp.visible, tool["tool_radius"], items = (index, tp.name, tp.visible, tool["tool_radius"],
tool["id"], process["material_allowance"], tool["id"], process["material_allowance"],
tool["speed"], tool["feedrate"], tool["speed"], tool["feedrate"],
get_time_string(tp.get_machine_time())) get_time_string(tp.get_machine_time(
safety_height=self.settings.get("gcode_safety_height"))))
model.append(items) model.append(items)
if not new_index is None: if not new_index is None:
self._treeview_set_active_index(self.toolpath_table, new_index) self._treeview_set_active_index(self.toolpath_table, new_index)
...@@ -2648,7 +2673,6 @@ class ProjectGui: ...@@ -2648,7 +2673,6 @@ class ProjectGui:
process_settings["path_postprocessor"], process_settings["path_postprocessor"],
process_settings["path_direction"], process_settings["path_direction"],
process_settings["material_allowance"], process_settings["material_allowance"],
process_settings["safety_height"],
process_settings["overlap_percent"] / 100.0, process_settings["overlap_percent"] / 100.0,
process_settings["step_down"], process_settings["step_down"],
process_settings["engrave_offset"]) process_settings["engrave_offset"])
...@@ -2754,31 +2778,43 @@ class ProjectGui: ...@@ -2754,31 +2778,43 @@ class ProjectGui:
# no filename given -> exit # no filename given -> exit
if not filename: if not filename:
return return
if self.settings.get("gcode_safety_height") < self.settings.get("maxz"):
log.warn(("Safety height (%.4f) is below the top of the model " \
+ "(%.4f) - this can cause collisions of the tool with " \
+ "the material.") % (self.settings.get(
"gcode_safety_height"), self.settings.get("maxz")))
try: try:
destination = open(filename, "w") destination = open(filename, "w")
index = 0 generator = pycam.Exporters.GCodeExporter.GCodeGenerator(
for index in range(len(self.toolpath)): destination,
tp = self.toolpath[index] metric_units=(self.settings.get("unit") == "mm"),
# check if this is the last loop iteration safety_height=self.settings.get("gcode_safety_height"),
# only the last toolpath of the list should contain the "M2" toggle_spindle_status=self.settings.get("gcode_start_stop_spindle"),
# ("end program") G-code comment=self.get_meta_data())
if index + 1 == len(self.toolpath): path_mode = self.settings.get("gcode_path_mode")
is_last_loop = True PATH_MODES = pycam.Exporters.GCodeExporter.PATH_MODES
else: if path_mode == 0:
is_last_loop = False generator.set_path_mode(PATH_MODES["exact_path"])
elif path_mode == 1:
generator.set_path_mode(PATH_MODES["exact_stop"])
elif path_mode == 2:
generator.set_path_mode(PATH_MODES["continuous"])
else:
naive_tolerance = self.settings.get("gcode_naive_tolerance")
if naive_tolerance == 0:
naive_tolerance = None
generator.set_path_mode(PATH_MODES["continuous"],
self.settings.get("gcode_motion_tolerance"),
naive_tolerance)
for tp in self.toolpath:
settings = tp.get_toolpath_settings() settings = tp.get_toolpath_settings()
process = settings.get_process_settings() process = settings.get_process_settings()
tool = settings.get_tool_settings() tool = settings.get_tool_settings()
meta_data = [] generator.set_speed(tool["feedrate"], tool["speed"])
meta_data.append(self.get_meta_data()) generator.add_path_list(tp.get_path(), tool_id=tool["id"],
meta_data.append(tp.get_meta_data())
pycam.Exporters.SimpleGCodeExporter.ExportPathList(destination,
tp.get_path(), settings.get_unit_size(),
tool["feedrate"], tool["speed"],
safety_height=process["safety_height"],
tool_id=tool["id"], finish_program=is_last_loop,
max_skip_safety_distance=2*tool["tool_radius"], max_skip_safety_distance=2*tool["tool_radius"],
comment=os.linesep.join(meta_data)) comment=tp.get_meta_data())
generator.finish()
destination.close() destination.close()
log.info("GCode file successfully written: %s" % str(filename)) log.info("GCode file successfully written: %s" % str(filename))
except IOError, err_msg: except IOError, err_msg:
......
...@@ -131,7 +131,6 @@ speed: 1000 ...@@ -131,7 +131,6 @@ speed: 1000
[ProcessDefault] [ProcessDefault]
name: Remove material name: Remove material
path_direction: x path_direction: x
safety_height: 5
engrave_offset: 0.0 engrave_offset: 0.0
path_generator: PushCutter path_generator: PushCutter
path_postprocessor: PolygonCutter path_postprocessor: PolygonCutter
...@@ -181,7 +180,6 @@ tool_radius: 0.5 ...@@ -181,7 +180,6 @@ tool_radius: 0.5
[ProcessDefault] [ProcessDefault]
path_direction: x path_direction: x
safety_height: 25
engrave_offset: 0.0 engrave_offset: 0.0
[Process0] [Process0]
...@@ -272,7 +270,6 @@ process: 3 ...@@ -272,7 +270,6 @@ process: 3
"path_direction": str, "path_direction": str,
"path_generator": str, "path_generator": str,
"path_postprocessor": str, "path_postprocessor": str,
"safety_height": float,
"material_allowance": float, "material_allowance": float,
"overlap_percent": int, "overlap_percent": int,
"step_down": float, "step_down": float,
...@@ -294,7 +291,7 @@ process: 3 ...@@ -294,7 +291,7 @@ process: 3
"tool": ("name", "shape", "tool_radius", "torus_radius", "feedrate", "tool": ("name", "shape", "tool_radius", "torus_radius", "feedrate",
"speed"), "speed"),
"process": ("name", "path_generator", "path_postprocessor", "process": ("name", "path_generator", "path_postprocessor",
"path_direction", "safety_height", "material_allowance", "path_direction", "material_allowance",
"overlap_percent", "step_down", "engrave_offset"), "overlap_percent", "step_down", "engrave_offset"),
"bounds": ("name", "type", "x_low", "x_high", "y_low", "bounds": ("name", "type", "x_low", "x_high", "y_low",
"y_high", "z_low", "z_high"), "y_high", "z_low", "z_high"),
...@@ -592,7 +589,6 @@ class ToolpathSettings: ...@@ -592,7 +589,6 @@ class ToolpathSettings:
"postprocessor": str, "postprocessor": str,
"path_direction": str, "path_direction": str,
"material_allowance": float, "material_allowance": float,
"safety_height": float,
"overlap": float, "overlap": float,
"step_down": float, "step_down": float,
"engrave_offset": float, "engrave_offset": float,
...@@ -703,14 +699,13 @@ class ToolpathSettings: ...@@ -703,14 +699,13 @@ class ToolpathSettings:
return "mm" return "mm"
def set_process_settings(self, generator, postprocessor, path_direction, def set_process_settings(self, generator, postprocessor, path_direction,
material_allowance=0.0, safety_height=0.0, overlap=0.0, material_allowance=0.0, overlap=0.0,
step_down=1.0, engrave_offset=0.0): step_down=1.0, engrave_offset=0.0):
self.process_settings = { self.process_settings = {
"generator": generator, "generator": generator,
"postprocessor": postprocessor, "postprocessor": postprocessor,
"path_direction": path_direction, "path_direction": path_direction,
"material_allowance": material_allowance, "material_allowance": material_allowance,
"safety_height": safety_height,
"overlap": overlap, "overlap": overlap,
"step_down": step_down, "step_down": step_down,
"engrave_offset": engrave_offset, "engrave_offset": engrave_offset,
......
...@@ -63,13 +63,11 @@ class Dimension: ...@@ -63,13 +63,11 @@ class Dimension:
class DropCutter: class DropCutter:
def __init__(self, cutter, model, path_processor, physics=None, def __init__(self, cutter, model, path_processor, physics=None):
safety_height=INFINITE):
self.cutter = cutter self.cutter = cutter
self.model = model self.model = model
self.pa = path_processor self.pa = path_processor
self.physics = physics self.physics = physics
self.safety_height = safety_height
# remember if we already reported an invalid boundary # remember if we already reported an invalid boundary
self._boundary_warning_already_shown = False self._boundary_warning_already_shown = False
...@@ -130,7 +128,7 @@ class DropCutter: ...@@ -130,7 +128,7 @@ class DropCutter:
for p in points: for p in points:
self.pa.append(p) self.pa.append(p)
else: else:
p = Point(x, y, self.safety_height) p = Point(x, y, self.model.maxz)
self.pa.append(p) self.pa.append(p)
if not self._boundary_warning_already_shown: if not self._boundary_warning_already_shown:
log.warn("DropCutter: exceed the height of the " \ log.warn("DropCutter: exceed the height of the " \
......
...@@ -48,8 +48,8 @@ def generate_toolpath_from_settings(model, tp_settings, callback=None): ...@@ -48,8 +48,8 @@ def generate_toolpath_from_settings(model, tp_settings, callback=None):
return generate_toolpath(model, tp_settings.get_tool_settings(), return generate_toolpath(model, tp_settings.get_tool_settings(),
bounds_low, bounds_high, process["path_direction"], bounds_low, bounds_high, process["path_direction"],
process["generator"], process["postprocessor"], process["generator"], process["postprocessor"],
process["material_allowance"], process["safety_height"], process["material_allowance"], process["overlap"],
process["overlap"], process["step_down"], process["engrave_offset"], process["step_down"], process["engrave_offset"],
grid["type"], grid["distance_x"], grid["distance_y"], grid["type"], grid["distance_x"], grid["distance_y"],
grid["thickness"], grid["height"], grid["offset_x"], grid["thickness"], grid["height"], grid["offset_x"],
grid["offset_y"], grid["adjustments_x"], grid["adjustments_y"], grid["offset_y"], grid["adjustments_x"], grid["adjustments_y"],
...@@ -59,8 +59,8 @@ def generate_toolpath_from_settings(model, tp_settings, callback=None): ...@@ -59,8 +59,8 @@ def generate_toolpath_from_settings(model, tp_settings, callback=None):
def generate_toolpath(model, tool_settings=None, def generate_toolpath(model, tool_settings=None,
bounds_low=None, bounds_high=None, direction="x", bounds_low=None, bounds_high=None, direction="x",
path_generator="DropCutter", path_postprocessor="ZigZagCutter", path_generator="DropCutter", path_postprocessor="ZigZagCutter",
material_allowance=0, safety_height=None, overlap=0, step_down=0, material_allowance=0, overlap=0, step_down=0, engrave_offset=0,
engrave_offset=0, support_grid_type=None, support_grid_distance_x=None, support_grid_type=None, support_grid_distance_x=None,
support_grid_distance_y=None, support_grid_thickness=None, support_grid_distance_y=None, support_grid_thickness=None,
support_grid_height=None, support_grid_offset_x=None, support_grid_height=None, support_grid_offset_x=None,
support_grid_offset_y=None, support_grid_adjustments_x=None, support_grid_offset_y=None, support_grid_adjustments_x=None,
...@@ -122,7 +122,6 @@ def generate_toolpath(model, tool_settings=None, ...@@ -122,7 +122,6 @@ def generate_toolpath(model, tool_settings=None,
""" """
overlap = number(overlap) overlap = number(overlap)
step_down = number(step_down) step_down = number(step_down)
safety_height = number(safety_height)
engrave_offset = number(engrave_offset) engrave_offset = number(engrave_offset)
if bounds_low is None: if bounds_low is None:
# no bounds were given - we use the boundaries of the model # no bounds were given - we use the boundaries of the model
...@@ -252,16 +251,12 @@ def generate_toolpath(model, tool_settings=None, ...@@ -252,16 +251,12 @@ def generate_toolpath(model, tool_settings=None,
if isinstance(physics, basestring): if isinstance(physics, basestring):
return physics return physics
generator = _get_pathgenerator_instance(trimesh_model, contour_model, generator = _get_pathgenerator_instance(trimesh_model, contour_model,
cutter, path_generator, path_postprocessor, safety_height, physics) cutter, path_generator, path_postprocessor, physics)
if isinstance(generator, basestring): if isinstance(generator, basestring):
return generator return generator
if (overlap < 0) or (overlap >= 1): if (overlap < 0) or (overlap >= 1):
return "Invalid overlap value (%f): should be greater or equal 0 " \ return "Invalid overlap value (%f): should be greater or equal 0 " \
+ "and lower than 1" + "and lower than 1"
if safety_height < maxz:
return ("Safety height (%.4f) is within the bounding box height " \
+ "(%.4f) - this can cause collisions of the tool with " \
+ "the material.") % (safety_height, maxz)
# factor "2" since we are based on radius instead of diameter # factor "2" since we are based on radius instead of diameter
stepping = 2 * number(tool_settings["tool_radius"]) * (1 - overlap) stepping = 2 * number(tool_settings["tool_radius"]) * (1 - overlap)
if path_generator == "DropCutter": if path_generator == "DropCutter":
...@@ -303,7 +298,7 @@ def generate_toolpath(model, tool_settings=None, ...@@ -303,7 +298,7 @@ def generate_toolpath(model, tool_settings=None,
return toolpath return toolpath
def _get_pathgenerator_instance(trimesh_model, contour_model, cutter, def _get_pathgenerator_instance(trimesh_model, contour_model, cutter,
pathgenerator, pathprocessor, safety_height, physics): pathgenerator, pathprocessor, physics):
if pathgenerator == "DropCutter": if pathgenerator == "DropCutter":
if pathprocessor == "ZigZagCutter": if pathprocessor == "ZigZagCutter":
processor = pycam.PathProcessors.PathAccumulator(zigzag=True) processor = pycam.PathProcessors.PathAccumulator(zigzag=True)
...@@ -314,7 +309,7 @@ def _get_pathgenerator_instance(trimesh_model, contour_model, cutter, ...@@ -314,7 +309,7 @@ def _get_pathgenerator_instance(trimesh_model, contour_model, cutter,
+ "'ZigZagCutter' or 'PathAccumulator' are allowed") \ + "'ZigZagCutter' or 'PathAccumulator' are allowed") \
% str(pathprocessor) % str(pathprocessor)
return DropCutter.DropCutter(cutter, trimesh_model, processor, return DropCutter.DropCutter(cutter, trimesh_model, processor,
physics=physics, safety_height=safety_height) physics=physics)
elif pathgenerator == "PushCutter": elif pathgenerator == "PushCutter":
if pathprocessor == "PathAccumulator": if pathprocessor == "PathAccumulator":
processor = pycam.PathProcessors.PathAccumulator() processor = pycam.PathProcessors.PathAccumulator()
......
...@@ -101,7 +101,7 @@ class Toolpath(object): ...@@ -101,7 +101,7 @@ class Toolpath(object):
else: else:
self.color = color self.color = color
def get_machine_time(self, start_position=None): def get_machine_time(self, start_position=None, safety_height=0.0):
""" calculate an estimation of the time required for processing the """ calculate an estimation of the time required for processing the
toolpath with the machine toolpath with the machine
...@@ -122,7 +122,7 @@ class Toolpath(object): ...@@ -122,7 +122,7 @@ class Toolpath(object):
result["time"] += new_pos.sub(result["position"]).norm / feedrate result["time"] += new_pos.sub(result["position"]).norm / feedrate
result["position"] = new_pos result["position"] = new_pos
# move to safey height at the starting position # move to safey height at the starting position
safety_height = number(settings.get_process_settings()["safety_height"]) safety_height = number(safety_height)
move(Point(start_position.x, start_position.y, safety_height)) move(Point(start_position.x, start_position.y, safety_height))
for path in self.get_path(): for path in self.get_path():
# go to safety height (horizontally from the previous x/y location) # go to safety height (horizontally from the previous x/y location)
......
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