https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer_Individual_Parts&feed=atom&action=history
Macro 3d Printer Slicer Individual Parts - Revision history
2024-03-29T14:11:36Z
Revision history for this page on the wiki
MediaWiki 1.40.1
https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer_Individual_Parts&diff=791057&oldid=prev
WayofWood at 10:43, 6 November 2020
2020-11-06T10:43:19Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 10:43, 6 November 2020</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 75:</td>
<td colspan="2" class="diff-lineno">Line 75:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> visible_objs.append(obj)</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> visible_objs.append(obj)</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>for obj in visible_objs:</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>for obj in visible_objs:</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> # get volume</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> volume = obj.Shape.Volume</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> # get Rotation and translation of volume</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> quat = obj.Placement.Rotation.Q</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> vect = obj.Placement.Base</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> pinfo = getPlacement(quat,vect,obj)</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> # reset placement, export it and set at original placement</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> oldPlacement = obj.Placement</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> obj.Placement = placement</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> obj.Placement = oldPlacement </div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> stlFile = OutDir+str(obj.Label)+".stl"</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> stlFile = OutDir+str(obj.Label)+".stl"</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> Mesh.export([obj],stlFile)</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> Mesh.export([obj],stlFile)</div></td>
</tr>
</table>
WayofWood
https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer_Individual_Parts&diff=790931&oldid=prev
Mario52: add SeeAlso
2020-11-05T12:07:17Z
<p>add SeeAlso</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 12:07, 5 November 2020</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 11:</td>
<td colspan="2" class="diff-lineno">Line 11:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|FCVersion=All</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|FCVersion=All</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|Download=[https://wiki.freecadweb.org/images/3/3d/Macro_3d_Printer_Slicer_Individual_Parts.svg ToolBar Icon]</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|Download=[https://wiki.freecadweb.org/images/3/3d/Macro_3d_Printer_Slicer_Individual_Parts.svg ToolBar Icon]</div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty diff-side-deleted"></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>|SeeAlso=[[Macro_3d_Printer_Slicer|Macro 3d Printer Slicer]] [[Image:Macro_3d_Printer_Slicer.png|24px]]</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}}</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}}</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
</tr>
<tr>
<td colspan="2" class="diff-lineno">Line 94:</td>
<td colspan="2" class="diff-lineno">Line 95:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Credits == <!--T:6--></div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Credits == <!--T:6--></div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Thanks to cae2100 for developing the original macro code - also available here.<br /> </div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Thanks to cae2100 for developing the original macro code - <ins style="font-weight: bold; text-decoration: none;">[[Macro_3d_Printer_Slicer|</ins>also available here<ins style="font-weight: bold; text-decoration: none;">]]</ins>.<br /> </div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Thanks to [http://forum.freecadweb.org/viewtopic.php?f=10&t=4686 Wmayer] for his help in writing this script.<br /></div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Thanks to [http://forum.freecadweb.org/viewtopic.php?f=10&t=4686 Wmayer] for his help in writing this script.<br /></div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Original forum topic: http://forum.freecadweb.org/viewtopic.php?f=10&t=4686</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Original forum topic: http://forum.freecadweb.org/viewtopic.php?f=10&t=4686</div></td>
</tr>
</table>
Mario52
https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer_Individual_Parts&diff=790916&oldid=prev
Mario52: minor
2020-11-05T11:27:50Z
<p>minor</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 11:27, 5 November 2020</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 3:</td>
<td colspan="2" class="diff-lineno">Line 3:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><!--T:1--></div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><!--T:1--></div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Macro</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Macro</div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty diff-side-deleted"></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>|Name=Macro 3d Printer Slicer Individual Parts</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>|Name=Macro_3d_Printer_Slicer_Individual_Parts</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|Icon=Macro_3d_Printer_Slicer_Individual_Parts.svg</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|Icon=Macro_3d_Printer_Slicer_Individual_Parts.svg</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|Description=Export to slicing software for 3D printers based on a similar macro by cae2100. Exports a single stl file for each visible part in the same directory as original design file, then opens it in slicing software.<br/>This code, when run, will export the currently open design to several STL files, named after the labels of the parts, and open it in the slicing software that you use. The macro is searching for '''[http://wiki.ultimaker.com/Cura Cura]''' in the path but you can add any other slicing by changing the string in the macro. </div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|Description=Export to slicing software for 3D printers based on a similar macro by cae2100. Exports a single stl file for each visible part in the same directory as original design file, then opens it in slicing software.<br/>This code, when run, will export the currently open design to several STL files, named after the labels of the parts, and open it in the slicing software that you use. The macro is searching for '''[http://wiki.ultimaker.com/Cura Cura]''' in the path but you can add any other slicing by changing the string in the macro. </div></td>
</tr>
</table>
Mario52
https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer_Individual_Parts&diff=789507&oldid=prev
WayofWood: Created page with "<languages/> <translate> <!--T:1--> {{Macro |Name=Macro_3d_Printer_Slicer_Individual_Parts |Icon=Macro_3d_Printer_Slicer_Individual_Parts.svg |Description=Export to slicing so..."
2020-11-01T08:33:36Z
<p>Created page with "<languages/> <translate> <!--T:1--> {{Macro |Name=Macro_3d_Printer_Slicer_Individual_Parts |Icon=Macro_3d_Printer_Slicer_Individual_Parts.svg |Description=Export to slicing so..."</p>
<p><b>New page</b></p><div><languages/><br />
<translate><br />
<!--T:1--><br />
{{Macro<br />
|Name=Macro_3d_Printer_Slicer_Individual_Parts<br />
|Icon=Macro_3d_Printer_Slicer_Individual_Parts.svg<br />
|Description=Export to slicing software for 3D printers based on a similar macro by cae2100. Exports a single stl file for each visible part in the same directory as original design file, then opens it in slicing software.<br/>This code, when run, will export the currently open design to several STL files, named after the labels of the parts, and open it in the slicing software that you use. The macro is searching for '''[http://wiki.ultimaker.com/Cura Cura]''' in the path but you can add any other slicing by changing the string in the macro. <br />
|Author=WayofWood<br />
|Version=1.1<br />
|Date=2020-10-30<br />
|FCVersion=All<br />
|Download=[https://wiki.freecadweb.org/images/3/3d/Macro_3d_Printer_Slicer_Individual_Parts.svg ToolBar Icon]<br />
}}<br />
<br />
<br />
==Description== <!--T:2--><br />
This code, when run, will export the visible bodies at the top level (bodies deeper in the tree will be ignored) of the currently open design to individual STL files, and open them it in the slicing software that you use. This macro will look for '''[http://wiki.ultimaker.com/Cura Cura]''' as the default but you can change it to any other slider by changing the SLICERAPP variable in the source code. <br />
<br />
<!--T:3--><br />
It is best used by creating a link to the macro on the toolbar, and when your ready to slice the object, just click it and your objects, as they appear on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create several STL files with the same filename as the design file and the part label in the same directory as the design file.<br />
<br />
<!--T:4--><br />
[[File:Screenshot_Cura_Example.png|480px]]<br />
<br />
==Script== <!--T:5--><br />
The SLICERAPP variable can be changed to any slicing software of your choosing. If a specific object is not exported you might have to add the respective type to the doexport array.<br />
</translate><br />
<br />
ToolBar Icon [[Image:Macro_3d_Printer_Slicer_Individual_Parts.svg|64px]]<br />
<br />
'''Macro_3d_Printer_Slicer_Individual_Parts.py'''<br />
<br />
{{MacroCode|code=<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<br />
<br />
SLICERAPP= "cura" # Put your Slicer program here<br />
<br />
# some fuctions<br />
def getPlacement(quat,vect,obj):<br />
if quat[3] > -1 and quat[3] < 1:<br />
delta = math.acos(quat[3])*2.0<br />
scale = math.sin(delta/2)<br />
rx = quat[0]/scale<br />
ry = quat[1]/scale<br />
rz = quat[2]/scale<br />
else:<br />
delta = 0<br />
rx = 0<br />
ry = 0<br />
rz = 1<br />
info0 = "translation "+str(vect.x)+" "+str(vect.y)+" "+str(vect.z)<br />
info1 = "rotation "+str(rx)+" "+str(ry)+" "+str(rz)+" "+str(delta)<br />
return info0+" "+info1<br />
# some definitions<br />
placement = App.Placement(App.Vector(0,0,0),App.Rotation(0,0,0,1))<br />
# user need to set this directory where slicing software is located<br />
OutDir = FreeCAD.ActiveDocument.FileName.replace(".FCStd", "--")<br />
visible_objs = []<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
stlFile = ""<br />
stlFiles = [ SLICERAPP ]<br />
# hide all<br />
for obj in objs:<br />
print(obj.Label + "//" + obj.TypeId)<br />
print(len(obj.InList))<br />
if obj.ViewObject.isVisible() and hasattr(obj, 'Shape') and (len(obj.InList) <= 1):<br />
visible_objs.append(obj)<br />
for obj in visible_objs:<br />
# get volume<br />
volume = obj.Shape.Volume<br />
# get Rotation and translation of volume<br />
quat = obj.Placement.Rotation.Q<br />
vect = obj.Placement.Base<br />
pinfo = getPlacement(quat,vect,obj)<br />
# reset placement, export it and set at original placement<br />
oldPlacement = obj.Placement<br />
obj.Placement = placement<br />
obj.Placement = oldPlacement <br />
stlFile = OutDir+str(obj.Label)+".stl"<br />
Mesh.export([obj],stlFile)<br />
stlFiles.append(stlFile)<br />
print ("Exporting " + stlFile + "\n")<br />
print ("Calling subprocess: " + str(stlFiles)+"\n")<br />
subprocess.Popen(stlFiles)<br />
}}<br />
<translate><br />
<br />
== Credits == <!--T:6--><br />
Thanks to cae2100 for developing the original macro code - also available here.<br /> <br />
Thanks to [http://forum.freecadweb.org/viewtopic.php?f=10&t=4686 Wmayer] for his help in writing this script.<br /><br />
Original forum topic: http://forum.freecadweb.org/viewtopic.php?f=10&t=4686<br />
</translate><br />
{{clear}}</div>
WayofWood