Skip to content

Commit

Permalink
New pref: Destination dir to be used for all exported STL files
Browse files Browse the repository at this point in the history
E.g. set it to /tmp if you use STL files only as intermediate steps
and don't want to keep them around.
  • Loading branch information
mbenkmann committed Jan 5, 2020
1 parent 850dc75 commit 09c681e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 11 deletions.
73 changes: 63 additions & 10 deletions Resources/ui/slcr-prefs.ui
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@
<property name="title" stdset="0">
<string>Hello World</string>
</property>

<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>431</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Path to slic3r executable:</string>
</property>
</widget>

<widget class="Gui::PrefFileChooser" name="fileChooser" native="true">
<property name="geometry">
<rect>
Expand Down Expand Up @@ -44,37 +59,73 @@
<cstring>Mod/slcr</cstring>
</property>
</widget>
<widget class="QLabel" name="label">

<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<y>90</y>
<width>431</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Path to slic3r executable:</string>
<string>Path to slic3r profile .ini file:</string>
</property>
</widget>
<widget class="QLabel" name="label_2">

<widget class="Gui::PrefFileChooser" name="fileChooser_2" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>431</width>
<y>120</y>
<width>500</width>
<height>30</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1000</width>
<height>16777215</height>
</size>
</property>
<property name="prefEntry" stdset="0">
<cstring>slic3rIniPath</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/slcr</cstring>
</property>
</widget>

<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>10</x>
<y>170</y>
<width>550</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Path to slic3r profile .ini file:</string>
<string>Destination directory for .stl (empty =&gt; same as document):</string>
</property>
</widget>
<widget class="Gui::PrefFileChooser" name="fileChooser_2" native="true">

<widget class="Gui::PrefFileChooser" name="fileChooser_3" native="true">
<property name="mode" >
<enum>Gui::FileChooser::Directory</enum>
</property>

<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<y>200</y>
<width>500</width>
<height>30</height>
</rect>
Expand All @@ -92,13 +143,15 @@
</size>
</property>
<property name="prefEntry" stdset="0">
<cstring>slic3rIniPath</cstring>
<cstring>stlExportPath</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/slcr</cstring>
</property>
</widget>

</widget>

<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
Expand Down
10 changes: 9 additions & 1 deletion SlcrDoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ def getStlFileName(self):
if self.doc.FileName=="":
raise Exception("Please save the document first to give it a filename.")

return os.path.splitext(self.doc.FileName)[0]+".stl"
dir, name = os.path.split(self.doc.FileName)
name = os.path.splitext(name)[0]+".stl"

preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/slcr")
stlPath = preferences.GetString('stlExportPath').strip()
if stlPath:
dir = stlPath

return os.path.join(dir, name)

def getGcodeFileName(self):
if self.doc.FileName=="":
Expand Down

0 comments on commit 09c681e

Please sign in to comment.