134 lines
6.9 KiB
HTML
134 lines
6.9 KiB
HTML
<html><head><title>Macro 3d Printer Slicer/it</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Macro 3d Printer Slicer/it</h1></div>
|
|
|
|
<div id="mw-content-text" lang="it" dir="ltr" class="mw-content-ltr"><hr/><div class="mw-parser-output"><table class="fcinfobox wikitable ct" width="100%" style="float: right; width: 230px; margin-left: 10px;">
|
|
<tr>
|
|
<td class="ctTitle">
|
|
<h3><span class="mw-headline" id="Slicer_per_stampanti_3D"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Text-x-python.png" class="image"><img alt="Text-x-python.png" src="32px-Text-x-python.png" width="32" height="32" srcset="/wiki/images/2/2c/Text-x-python.png 1.5x" /></a> Slicer per stampanti 3D</span></h3>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Descrizione
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven left">Esporta verso il software slicer per stampanti 3D. Esporta il file stl nella stessa directory del file originale del disegno, poi lo apre con il software di analisi.
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Autore
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Cae2100&action=edit&redlink=1" class="new" title="User:Cae2100 (page does not exist)">cae2100</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Link
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/it" title="Macros recipes/it">Esempi di macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/it" title="How to install macros/it">Come installare le Macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/it" title="Customize Toolbars/it">Personalizzare la barra degli strumenti</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Versione
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-version">1.0
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Data ultima modifica
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-date">2013-10-10
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctToc"><br /><div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
|
|
<ul>
|
|
<li class="toclevel-1"><a href="#Slicer_per_stampanti_3D"><span class="tocnumber">1</span> <span class="toctext">Slicer per stampanti 3D</span></a></li>
|
|
<li class="toclevel-1 tocsection-1"><a href="#Script"><span class="tocnumber">2</span> <span class="toctext">Script</span></a></li>
|
|
<li class="toclevel-1 tocsection-2"><a href="#Ringraziamenti"><span class="tocnumber">3</span> <span class="toctext">Ringraziamenti</span></a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</td></tr>
|
|
</table>
|
|
<p><br />
|
|
</p><p>Questo codice esporta il progetto attivo in un file STL, e lo apre con il software di analisi preferito. Questo esempio è adatto a <b><a rel="nofollow" class="external text" href="http://kisslicer.com/">KISSlicer</a></b>, ma può essere modificato e utilizzato con <b><a rel="nofollow" class="external text" href="http://slic3r.org/">Slic3r</a></b>, <b><a rel="nofollow" class="external text" href="http://wiki.ultimaker.com/Cura">Cura</a></b>, o qualsiasi altro software per stampanti 3d. Può anche essere leggermente modificato per essere aperto dai software CAM per macchine CNC (a controllo numerico).
|
|
</p><p>È meglio creare prima un collegamento nella barra degli strumenti che punti alla macro poi, quando si è pronti per analizzare l'oggetto, fare clic su di esso per far apparire l'oggetto nell'interfaccia del software di analisi, così come appare nello schermo di FreeCAD e pronto per essere analizzato. Inoltre, è possibile creare un file STL con lo stesso nome del file del progetto e nella stessa directory del file originale, come backup.
|
|
</p><p><br />
|
|
<a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_3d_Printer_Slicer_00.png" class="image"><img alt="Macro 3d Printer Slicer 00.png" src="480px-Macro_3d_Printer_Slicer_00.png" width="480" height="303" srcset="/wiki/images/thumb/d/d2/Macro_3d_Printer_Slicer_00.png/720px-Macro_3d_Printer_Slicer_00.png 1.5x, /wiki/images/thumb/d/d2/Macro_3d_Printer_Slicer_00.png/960px-Macro_3d_Printer_Slicer_00.png 2x" /></a>
|
|
</p>
|
|
<div style="clear:both"></div>
|
|
<p><br />
|
|
</p>
|
|
<h3><span class="mw-headline" id="Script">Script</span></h3>
|
|
<p>La variabile SLICER può essere cambiata a piacere per adattare il codice a qualsiasi software di analisi, basta accertarsi di impostarla, prima di eseguire lo script altrimenti si riceve un messaggio di errore.
|
|
</p><p><b>Macro_3d_Printer_Slicer.py</b>
|
|
</p>
|
|
<pre>import FreeCAD
|
|
import Mesh
|
|
import sys
|
|
import math
|
|
import os
|
|
import subprocess
|
|
# some fuctions
|
|
def getPlacement(quat,vect,obj):
|
|
if quat[3] > -1 and quat[3] < 1:
|
|
delta = math.acos(quat[3])*2.0
|
|
scale = math.sin(delta/2)
|
|
rx = quat[0]/scale
|
|
ry = quat[1]/scale
|
|
rz = quat[2]/scale
|
|
else:
|
|
delta = 0
|
|
rx = 0
|
|
ry = 0
|
|
rz = 1
|
|
info0 = "translation "+str(vect.x)+" "+str(vect.y)+" "+str(vect.z)
|
|
info1 = "rotation "+str(rx)+" "+str(ry)+" "+str(rz)+" "+str(delta)
|
|
return info0+" "+info1
|
|
# some definitions
|
|
placement = App.Placement(App.Vector(0,0,0),App.Rotation(0,0,0,1))
|
|
# user need to set this directory where slicing software is located
|
|
OutDir = FreeCAD.ActiveDocument.FileName.replace(FreeCAD.ActiveDocument.Label + ".fcstd", "")
|
|
visible_objs = []
|
|
SLICER = "/kisslicer location/" # Put your Slicer program location here
|
|
os.chdir(SLICER)
|
|
# Get Objects in document
|
|
doc = App.ActiveDocument
|
|
objs = doc.Objects
|
|
# hide all
|
|
for obj in objs:
|
|
if obj.ViewObject.isVisible():
|
|
visible_objs.append(obj)
|
|
for obj in visible_objs:
|
|
# get volume
|
|
volume = obj.Shape.Volume
|
|
# get Rotation and translation of volume
|
|
quat = obj.Placement.Rotation.Q
|
|
vect = obj.Placement.Base
|
|
pinfo = getPlacement(quat,vect,obj)
|
|
# reset placement, export it and set at original placement
|
|
oldPlacement = obj.Placement
|
|
obj.Placement = placement
|
|
obj.Placement = oldPlacement
|
|
stlFile = OutDir+str(doc.Label)+".stl"
|
|
Mesh.export(visible_objs,stlFile)
|
|
subprocess.Popen([SLICER + "KISSlicer", stlFile]) </pre>
|
|
<h3><span class="mw-headline" id="Ringraziamenti">Ringraziamenti</span></h3>
|
|
<p>Grazie a <a rel="nofollow" class="external text" href="http://forum.freecadweb.org/viewtopic.php?f=10&t=4686">Wmayer</a> per il suo aiuto nella stesura di questo script.
|
|
</p><p>Discussione nel forum : <a rel="nofollow" class="external free" href="https://forum.freecadweb.org/viewtopic.php?f=10&t=4686">https://forum.freecadweb.org/viewtopic.php?f=10&t=4686</a>
|
|
</p>
|
|
<div style="clear:both"></div>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div><div class="printfooter">
|
|
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_3d_Printer_Slicer/it&oldid=240903">http://www.freecadweb.org/wiki/index.php?title=Macro_3d_Printer_Slicer/it&oldid=240903</a>"</div>
|
|
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
|
|
</div>
|
|
</div>
|
|
<div id="mw-navigation">
|
|
<h2>Navigation menu</h2>
|
|
|
|
</body></html> |