Commit f338ee77 authored by sumpfralle's avatar sumpfralle

added configuration setting for default file extension of GCode files


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@900 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 8f1e3ca6
......@@ -9,6 +9,7 @@ Version 0.4.1 - UNRELEASED
* added a very simple "pocketing" mode for 2D models
* added support for DXF feature "LWPOLYLINE"
* added a configuration setting for automatically loading a custom task settings file on startup
* the default filename extension for exported GCode files is now configurable
* unify DropCutter behaviour for models that are higher than the defined bounding box
* always move up to safety height in this case
* optional visualization of toolpath direction
......
......@@ -5254,6 +5254,40 @@ 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>
......
......@@ -125,6 +125,7 @@ PREFERENCES_DEFAULTS = {
"gcode_motion_tolerance": 0,
"gcode_naive_tolerance": 0,
"gcode_start_stop_spindle": True,
"gcode_filename_extension": "",
"external_program_inkscape": "",
"external_program_pstoedit": "",
}
......@@ -876,6 +877,9 @@ class ProjectGui:
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)
gcode_filename_extension = self.gui.get_object("GCodeFilenameExtension")
self.settings.add_item("gcode_filename_extension",
gcode_filename_extension.get_text, gcode_filename_extension.set_text)
# configure locations of external programs
for auto_control_name, location_control_name, browse_button, key in (
("ExternalProgramInkscapeAuto",
......@@ -2346,7 +2350,7 @@ class ProjectGui:
else:
filter_ext = filter_ext[1:]
basename = os.path.basename(filename)
if (basename.rfind(".") == -1) or (basename[-5:].rfind(".") == -1):
if (basename.rfind(".") == -1) or (basename[-6:].rfind(".") == -1):
# The filename does not contain a dot or the dot is not within the
# last five characters. Dots within the start of the filename are
# ignored.
......@@ -3451,7 +3455,7 @@ class ProjectGui:
return toolpath_settings
def get_filename_via_dialog(self, title, mode_load=False, type_filter=None,
filename_templates=None):
filename_templates=None, filename_extension=None):
# we open a dialog
if mode_load:
dialog = gtk.FileChooserDialog(title=title,
......@@ -3479,7 +3483,9 @@ class ProjectGui:
filename_template = valid_templates[0]
# remove the extension
default_filename = os.path.splitext(filename_template)[0]
if type_filter:
if filename_extension:
default_filename += os.path.extsep + filename_extension
elif type_filter:
for one_type in type_filter:
label, extension = one_type
if isinstance(extension, (list, tuple, set)):
......@@ -3559,9 +3565,14 @@ class ProjectGui:
filename = widget
else:
# we open a dialog
if self.settings.get("gcode_filename_extension"):
filename_extension = self.settings.get("gcode_filename_extension")
else:
filename_extension = None
filename = self.get_filename_via_dialog("Save toolpath to ...",
mode_load=False, type_filter=FILTER_GCODE,
filename_templates=(self.last_toolpath_file, self.last_model_filename))
filename_templates=(self.last_toolpath_file, self.last_model_filename),
filename_extension=filename_extension)
if filename:
self.last_toolpath_file = filename
self.update_save_actions()
......
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