chiark / gitweb /
SD Card Folder Structure replication.
authorpmsimard <pierrem.simard@gmail.com>
Mon, 29 Sep 2014 04:44:06 +0000 (00:44 -0400)
committerpmsimard <pierrem.simard@gmail.com>
Wed, 7 Jan 2015 02:31:19 +0000 (21:31 -0500)
In the preference settings there is now a sd card section regrouping the sd card auto detect option and the new base folder to replicate.
If the path is defined it will copy an gcode from stl located under that folder and place it at the same location on the sd card.

Cura/gui/preferencesDialog.py
Cura/gui/sceneView.py
Cura/util/profile.py

index 9aed77822117fe2e24d1d087839e76ef6956862c..3f9acd21ac199389a6ae99b2cb4fc6ced873c7f8 100644 (file)
@@ -45,10 +45,11 @@ class preferencesDialog(wx.Dialog):
                #configBase.TitleRow(right, 'Slicer settings')
                #configBase.SettingRow(right, 'save_profile')
 
-               #configBase.TitleRow(right, 'SD Card settings')
-
-               configBase.TitleRow(right, _("Cura settings"))
+               configBase.TitleRow(right, 'SD Card settings')
                configBase.SettingRow(right, 'auto_detect_sd')
+               configBase.SettingRow(right, 'sdcard_rootfolder')
+               
+               configBase.TitleRow(right, _("Cura settings"))
                configBase.SettingRow(right, 'check_for_updates')
                configBase.SettingRow(right, 'submit_slice_information')
 
index bfa742779c0ca182499207c8d8eebe31b6dba0c9..de7ccd8b22e0d87c16d1b0f04f8d680254e357a6 100644 (file)
@@ -253,6 +253,19 @@ class SceneView(openglGui.glGuiPanel):
                                else:
                                        drive = drives[0]
                                filename = self._scene._objectList[0].getName() + profile.getGCodeExtension()
+                               
+                               #check if the file is part of the root folder. If so, create folders on sd card to get the same folder hierarchy.
+                               repDir = profile.getPreference("sdcard_rootfolder")
+                               if os.path.exists(repDir) and os.path.isdir(repDir):
+                                       repDir = os.path.abspath(repDir)
+                                       originFilename = os.path.abspath( self._scene._objectList[0].getOriginFilename() )
+                                       if os.path.dirname(originFilename).startswith(repDir):
+                                               filename = os.path.splitext(originFilename[len(repDir):])[0] + profile.getGCodeExtension()
+                                               sdPath = os.path.dirname(os.path.join( drive[1], filename))
+                                               if not os.path.exists(sdPath):
+                                                       print "Creating replication directory:", sdPath
+                                                       os.makedirs(sdPath)
+
                                threading.Thread(target=self._saveGCode,args=(drive[1] + filename, drive[1])).start()
                        elif connectionGroup is not None:
                                connections = connectionGroup.getAvailableConnections()
index 691c0571d8b236fc7b2e536ef8ca9492602f6c8e..f22efe5039a54df3349c85a81e7672ffea2d6ced 100644 (file)
@@ -485,6 +485,7 @@ setting('save_profile', 'False', bool, 'preference', 'hidden').setLabel(_("Save
 setting('filament_cost_kg', '0', float, 'preference', 'hidden').setLabel(_("Cost (price/kg)"), _("Cost of your filament per kg, to estimate the cost of the final print."))
 setting('filament_cost_meter', '0', float, 'preference', 'hidden').setLabel(_("Cost (price/m)"), _("Cost of your filament per meter, to estimate the cost of the final print."))
 setting('auto_detect_sd', 'True', bool, 'preference', 'hidden').setLabel(_("Auto detect SD card drive"), _("Auto detect the SD card. You can disable this because on some systems external hard-drives or USB sticks are detected as SD card."))
+setting('sdcard_rootfolder', '', str, 'preference', 'hidden').setLabel(_("Base folder to replicate on SD card"), _("The specified folder will be used as a base path. Any gcode generated from object coming from within that folder will be automatically saved on the SD card at the same sub-folder. Any object coming from outside of this path will save the gcode on the root folder of the card."))
 setting('check_for_updates', 'True', bool, 'preference', 'hidden').setLabel(_("Check for updates"), _("Check for newer versions of Cura on startup"))
 setting('submit_slice_information', 'False', bool, 'preference', 'hidden').setLabel(_("Send usage statistics"), _("Submit anonymous usage information to improve future versions of Cura"))
 setting('youmagine_token', '', str, 'preference', 'hidden')