Commit 53030e64 authored by sumpfralle's avatar sumpfralle

splitted "Export toolpaths" into "Export all toolpaths" and "Export visible toolpaths"

* thanks to Peter Uithoven for the idea!


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@901 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent f338ee77
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
<menuitem action="SaveModel"/> <menuitem action="SaveModel"/>
<menuitem action="SaveAsModel"/> <menuitem action="SaveAsModel"/>
<separator /> <separator />
<menuitem action="ExportGCode"/> <menuitem action="ExportGCodeVisible"/>
<menuitem action="ExportGCodeAll"/>
<separator /> <separator />
<menuitem action="Quit"/> <menuitem action="Quit"/>
</menu> </menu>
......
...@@ -4777,9 +4777,15 @@ This feature requires the Open Dynamics Engine (ODE).</property> ...@@ -4777,9 +4777,15 @@ This feature requires the Open Dynamics Engine (ODE).</property>
<object class="GtkAction" id="SettingsMenu"> <object class="GtkAction" id="SettingsMenu">
<property name="label">_Settings</property> <property name="label">_Settings</property>
</object> </object>
<object class="GtkAction" id="ExportGCode"> <object class="GtkAction" id="ExportGCodeVisible">
<property name="label">_Export Toolpaths</property> <property name="label">_Export visible Toolpaths</property>
<property name="tooltip">Write all current toolpaths to a file.</property> <property name="tooltip">Write all visible toolpaths to a file.</property>
<property name="stock_id">gtk-execute</property>
<property name="always_show_image">True</property>
</object>
<object class="GtkAction" id="ExportGCodeAll">
<property name="label">_Export all Toolpaths</property>
<property name="tooltip">Write all toolpaths to a file.</property>
<property name="stock_id">gtk-execute</property> <property name="stock_id">gtk-execute</property>
<property name="always_show_image">True</property> <property name="always_show_image">True</property>
</object> </object>
......
...@@ -297,7 +297,8 @@ class ProjectGui: ...@@ -297,7 +297,8 @@ class ProjectGui:
("OpenModel", self.load_model_file, None, "<Control>o"), ("OpenModel", self.load_model_file, None, "<Control>o"),
("SaveModel", self.save_model, lambda: self.last_model_filename, "<Control>s"), ("SaveModel", self.save_model, lambda: self.last_model_filename, "<Control>s"),
("SaveAsModel", self.save_model, None, "<Control><Shift>s"), ("SaveAsModel", self.save_model, None, "<Control><Shift>s"),
("ExportGCode", self.save_toolpath, None, "<Control><Shift>e"), ("ExportGCodeAll", self.save_toolpath, None, "<Control><Shift>e"),
("ExportGCodeVisible", self.save_toolpath, True, None),
("ExportEMCToolDefinition", self.export_emc_tools, None, None), ("ExportEMCToolDefinition", self.export_emc_tools, None, None),
("Quit", self.destroy, None, "<Control>q"), ("Quit", self.destroy, None, "<Control>q"),
("GeneralSettings", self.toggle_preferences_window, None, "<Control>p"), ("GeneralSettings", self.toggle_preferences_window, None, "<Control>p"),
...@@ -3041,7 +3042,9 @@ class ProjectGui: ...@@ -3041,7 +3042,9 @@ class ProjectGui:
"%s (%d)" % (self._original_toolpath_tab_label, len(self.toolpath))) "%s (%d)" % (self._original_toolpath_tab_label, len(self.toolpath)))
toolpath_tab.show() toolpath_tab.show()
# enable/disable the export menu item # enable/disable the export menu item
self.gui.get_object("ExportGCode").set_sensitive(len(self.toolpath) > 0) self.gui.get_object("ExportGCodeAll").set_sensitive(len(self.toolpath) > 0)
visible_toolpaths = [tp for tp in self.toolpath if tp.visible]
self.gui.get_object("ExportGCodeVisible").set_sensitive(len(visible_toolpaths) > 0)
# reset the model data and the selection # reset the model data and the selection
if new_index is None: if new_index is None:
# keep the old selection - this may return "None" if nothing is selected # keep the old selection - this may return "None" if nothing is selected
...@@ -3556,7 +3559,7 @@ class ProjectGui: ...@@ -3556,7 +3559,7 @@ class ProjectGui:
self.last_dirname = os.path.dirname(os.path.abspath(filename)) self.last_dirname = os.path.dirname(os.path.abspath(filename))
@gui_activity_guard @gui_activity_guard
def save_toolpath(self, widget=None, data=None): def save_toolpath(self, widget=None, only_visible=False):
if not self.toolpath: if not self.toolpath:
return return
if callable(widget): if callable(widget):
...@@ -3585,12 +3588,16 @@ class ProjectGui: ...@@ -3585,12 +3588,16 @@ class ProjectGui:
+ "the material.") % (self.settings.get( + "the material.") % (self.settings.get(
"gcode_safety_height"), self.settings.get("maxz"))) "gcode_safety_height"), self.settings.get("maxz")))
try: try:
if only_visible:
export_toolpaths = [tp for tp in self.toolpath if tp.visible]
else:
export_toolpaths = self.toolpath
destination = open(filename, "w") destination = open(filename, "w")
safety_height=self.settings.get("gcode_safety_height") safety_height=self.settings.get("gcode_safety_height")
meta_data = self.get_meta_data() meta_data = self.get_meta_data()
machine_time = 0 machine_time = 0
# calculate the machine time and store it in the GCode header # calculate the machine time and store it in the GCode header
for tp in self.toolpath: for tp in export_toolpaths:
machine_time += tp.get_machine_time(safety_height) machine_time += tp.get_machine_time(safety_height)
all_info = meta_data + os.linesep \ all_info = meta_data + os.linesep \
+ "Estimated machine time: %g minutes" % machine_time + "Estimated machine time: %g minutes" % machine_time
...@@ -3615,7 +3622,7 @@ class ProjectGui: ...@@ -3615,7 +3622,7 @@ class ProjectGui:
generator.set_path_mode(PATH_MODES["continuous"], generator.set_path_mode(PATH_MODES["continuous"],
self.settings.get("gcode_motion_tolerance"), self.settings.get("gcode_motion_tolerance"),
naive_tolerance) naive_tolerance)
for tp in self.toolpath: for tp in export_toolpaths:
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()
......
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