https://wiki.freecad.org/api.php?action=feedcontributions&user=Cae2100&feedformat=atomFreeCAD Documentation - User contributions [en]2024-03-29T02:38:14ZUser contributionsMediaWiki 1.40.1https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=42007Macro 3d Printer Slicer2013-10-13T21:35:07Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Macro_3d_Printer_Slicer|Description=Export to slicing software for 3D printers. Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
==Description==<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for '''[http://kisslicer.com/ KISSlicer]''', but can be modified to use '''[http://slic3r.org/ Slic3r]''', '''[http://wiki.ultimaker.com/Cura Cura]''', or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines. <br />
<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 object, as it appears on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create an STL file with the same filename as the design file in the same directory as the design file as a backup.<br />
<br />
<br><br />
[[File:Macro_3d_Printer_Slicer_00.png|480px]]<br />
<br><br />
<br />
{{clear}}<br />
==Script==<br />
<br />
The SLICER variable can be changed to any slicing software of your choosing, just make sure to set it before you try running it or it'll flag an error with the script.<br />
<br />
'''Macro_3d_Printer_Slicer.py'''<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])<br />
<br />
== Credits ==<br />
<br />
Thanks to [http://sourceforge.net/apps/phpbb/free-cad/viewtopic.php?f=10&t=4686 Wmayer] for his help in writing this script.<br />
<br />
<br><br />
{{languages | {{fr|Macro_3d_Printer_Slicer/fr}} {{it|Macro_3d_Printer_Slicer/it}} }}</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=42006Macro 3d Printer Slicer2013-10-13T21:33:43Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Macro_3d_Printer_Slicer|Description=Export to slicing software for 3D printers. Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
==Description==<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for '''[http://kisslicer.com/ KISSlicer]''', but can be modified to use '''[http://slic3r.org/ Slic3r]''', '''[http://wiki.ultimaker.com/Cura Cura]''', or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines. <br />
<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 object, as it appears on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create an STL file with the same filename as the design file in the same directory as the design file as a backup.<br />
<br />
<br><br />
[[File:Macro_3d_Printer_Slicer_00.png|480px]]<br />
<br><br />
<br />
{{clear}}<br />
==Script==<br />
<br />
The SLICER variable can be changed to any slicing software of your choosing, just make sure to set it before you try running it or it'll flag an error with the script.<br />
<br />
'''Macro_3d_Printer_Slicer.py'''<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])<br />
<br />
== Credit ==<br />
<br />
Thanks to [http://sourceforge.net/apps/phpbb/free-cad/viewtopic.php?f=10&t=4686 Wmayer] for his help in writing this script.<br />
<br />
<br><br />
{{languages | {{fr|Macro_3d_Printer_Slicer/fr}} {{it|Macro_3d_Printer_Slicer/it}} }}</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=42005Macro 3d Printer Slicer2013-10-13T21:32:55Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Macro_3d_Printer_Slicer|Description=Export to slicing software for 3D printers. Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
==Description==<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for '''[http://kisslicer.com/ KISSlicer]''', but can be modified to use '''[http://slic3r.org/ Slic3r]''', '''[http://wiki.ultimaker.com/Cura Cura]''', or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines. <br />
<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 object, as it appears on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create an STL file with the same filename as the design file in the same directory as the design file as a backup.<br />
<br />
<br><br />
[[File:Macro_3d_Printer_Slicer_00.png|480px]]<br />
<br><br />
<br />
{{clear}}<br />
==Script==<br />
<br />
The SLICER variable can be changed to any slicing software of your choosing, just make sure to set it before you try running it or it'll flag an error with the script.<br />
<br />
'''Macro_3d_Printer_Slicer.py'''<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])<br />
<br />
== Special Thanks ==<br />
<br />
Thanks to [http://sourceforge.net/apps/phpbb/free-cad/viewtopic.php?f=10&t=4686 Wmayer] for his help in writing this script.<br />
<br />
<br><br />
{{languages | {{fr|Macro_3d_Printer_Slicer/fr}} {{it|Macro_3d_Printer_Slicer/it}} }}</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41988Macro 3d Printer Slicer2013-10-12T22:19:46Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Macro_3d_Printer_Slicer|Description=Export to slicing software for 3D printers. Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
==Description==<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for KISSlicer, but can be modified to use Slic3r, cura, or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines. <br />
<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 object, as it appears on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create an STL file with the same filename as the design file in the same directory as the design file as a backup.<br />
<br />
<br><br />
[[File:Macro_3d_Printer_Slicer_00.png|480px]]<br />
<br><br />
<br />
{{clear}}<br />
==Script==<br />
<br />
The SLICER variable can be changed to any slicing software of your choosing, just make sure to set it before you try running it or it'll flag an error with the script.<br />
<br />
Macro_3d_Printer_Slicer.py<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])<br />
<br />
== Credits ==<br />
<br />
Thanks to Wmayer for his help in writing this script.<br />
<br />
<br><br />
{{languages | {{fr|Macro_3d_Printer_Slicer/fr}} {{it|Macro_3d_Printer_Slicer/it}} }}</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41934Macro 3d Printer Slicer2013-10-09T20:43:24Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Export to slicing software for 3D printers|Description=Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for KISSlicer, but can be modified to use Slic3r, cura, or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines. <br />
<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 object, as it appears on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create an STL file with the same filename as the design file in the same directory as the design file as a backup.<br />
<br />
The SLICER varable can be changed to any slicing software of your choosing, just make sure to set it before you try running it or it'll flag an error with the script.<br />
<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])<br />
<br />
<br />
<br />
== Credits ==<br />
<br />
<br />
Thanks to Wmayer for his help in writing this script.</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41929Macro 3d Printer Slicer2013-10-09T20:27:06Z<p>Cae2100: /* Credits */</p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Export to slicing software for 3D printers|Description=Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for KISSlicer, but can be modified to use Slic3r, cura, or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines. <br />
<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 object, as it appears on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create an STL file with the same filename as the design file in the same directory as the design file as a backup.<br />
<br />
The SLICER varable can be changed to any slicing software of your choosing, just make sure to set it before you try running it or it'll flag an error with the script.<br />
<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<br />
visible_objs.append(obj)<br />
for obj in visible_objs:<br />
# {<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])<br />
<br />
<br />
<br />
== Credits ==<br />
<br />
<br />
Thanks to Wmayer for his help in writing this script.</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41925Macro 3d Printer Slicer2013-10-09T20:18:27Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Export to slicing software for 3D printers|Description=Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for KISSlicer, but can be modified to use Slic3r, cura, or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines. <br />
<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 object, as it appears on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create an STL file with the same filename as the design file in the same directory as the design file as a backup.<br />
<br />
The SLICER varable can be changed to any slicing software of your choosing, just make sure to set it before you try running it or it'll flag an error with the script.<br />
<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<br />
visible_objs.append(obj)<br />
for obj in visible_objs:<br />
# {<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])<br />
<br />
<br />
<br />
== Credits ==<br />
<br />
<br />
Thank you Wmayer for his help in writing this script.</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41924Macro 3d Printer Slicer2013-10-09T20:07:24Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Export to slicing software for 3D printers|Description=Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for KISSlicer, but can be modified to use Slic3r, cura, or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines. <br />
<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 object, as it appears on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create an STL file with the same filename as the design file in the same directory as the design file as a backup.<br />
<br />
The SLICER varable can be changed to any slicing software of your choosing, just make sure to set it before you try running it or it'll flag an error with the script.<br />
<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<br />
visible_objs.append(obj)<br />
for obj in visible_objs:<br />
# {<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41922Macro 3d Printer Slicer2013-10-09T20:02:36Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Export to slicing software for 3D printers|Description=Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for KISSlicer, but can be modified to use Slic3r, cura, or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines. It's 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 object, as it appears on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create an STL file with the same filename as the design file in the same directory as the design file as a backup.<br />
<br />
The SLICER varable can be changed to any slicing software of your choosing, just make sure to set it before you try running it or it'll flag an error with the script.<br />
<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<br />
visible_objs.append(obj)<br />
for obj in visible_objs:<br />
# {<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41920Macro 3d Printer Slicer2013-10-09T20:00:06Z<p>Cae2100: Exports to Slicing or CAM software for 3D printers or CNC machines</p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Export to slicing software for 3D printers|Description=Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for KISSlicer, but can be modified to use Slic3r, cura, or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines. It's 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 object, as it appears on the screen in FreeCAD will appear on your slicing software's interface, ready to slice. It will also create an STL file with the same filename as the design file in the same directory as the design file as a backup.<br />
<br />
The SLICER varable can be changed to any slicing software of your choosing, just make sure to set it before you try running it or it'll flag an error with the script.<br />
<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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 STL files will be placed<br />
OutDir = FreeCAD.ActiveDocument.FileName.replace(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<br />
visible_objs.append(obj)<br />
print "number of volumes "+str(len(visible_objs))<br />
for obj in visible_objs:<br />
# {<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41918Macro 3d Printer Slicer2013-10-09T19:55:48Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Export to slicing software for 3D printers|Description=Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for KISSlicer, but can be modified to use Slic3r, cura, or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines.<br />
<br />
The SLICER varable can be changed to any slicing software of your choosing, just make sure to change it before you try running it or it'll flag an error.<br />
<br />
<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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 STL files will be placed<br />
OutDir = FreeCAD.ActiveDocument.FileName.replace(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<br />
visible_objs.append(obj)<br />
print "number of volumes "+str(len(visible_objs))<br />
for obj in visible_objs:<br />
# {<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41917Macro 3d Printer Slicer2013-10-09T19:55:12Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Export to slicing software for 3D printers|Description=Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for KISSlicer, but can be modified to use Slic3r, cura, or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines.<br />
<br />
The SLICER varable can be changed to any slicing software of your choosing, just make sure to change it before you try running it or it'll flag an error.<br />
<br />
[code]<br />
import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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 STL files will be placed<br />
OutDir = FreeCAD.ActiveDocument.FileName.replace(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<br />
visible_objs.append(obj)<br />
print "number of volumes "+str(len(visible_objs))<br />
for obj in visible_objs:<br />
# {<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])[/code]</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41916Macro 3d Printer Slicer2013-10-09T19:54:38Z<p>Cae2100: </p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Export to slicing software for 3D printers|Description=Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}<br />
<br />
This code, when run, will export the currently open design to STL file, and open it in the slicing software that you use. This example is for KISSlicer, but can be modified to use Slic3r, cura, or any other 3d printer software. It can also be modified slightly to open up CAM software for CNC machines.<br />
<br />
The SLICER varable can be changed to any slicing software of your choosing, just make sure to change it before you try running it or it'll flag an error.<br />
<br />
[code] import FreeCAD<br />
import Mesh<br />
import sys<br />
import math<br />
import os<br />
import subprocess<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 STL files will be placed<br />
OutDir = FreeCAD.ActiveDocument.FileName.replace(FreeCAD.ActiveDocument.Label + ".fcstd", "")<br />
visible_objs = []<br />
SLICER = "/kisslicer location/" # Put your Slicer program location here<br />
os.chdir(SLICER)<br />
# Get Objects in document<br />
doc = App.ActiveDocument<br />
objs = doc.Objects<br />
# hide all<br />
for obj in objs:<br />
if obj.ViewObject.isVisible():<br />
visible_objs.append(obj)<br />
print "number of volumes "+str(len(visible_objs))<br />
for obj in visible_objs:<br />
# {<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(doc.Label)+".stl"<br />
Mesh.export(visible_objs,stlFile)<br />
subprocess.Popen([SLICER + "KISSlicer", stlFile])[/code]</div>Cae2100https://wiki.freecad.org/index.php?title=Macro_3d_Printer_Slicer&diff=41914Macro 3d Printer Slicer2013-10-09T19:43:32Z<p>Cae2100: Exports to Slicing or CAM software for 3D printers or CNC machines</p>
<hr />
<div>{{Macro|Icon=Text-x-python|Name=Export to slicing software for 3D printers|Description=Exports stl file in the same directory as original design file, then opens it in slicing software.|Author=cae2100}}</div>Cae2100https://wiki.freecad.org/index.php?title=Macros_recipes&diff=41912Macros recipes2013-10-09T19:40:13Z<p>Cae2100: /* Utility */</p>
<hr />
<div>This page contains macros to add functionality to your freecad installation<br />
<br />
== Macros ==<br />
<br />
=== Object creation ===<br />
<br />
* [[Image:Macro_makeCube.png|16px]] [[Macro_makeCube]] : creates a cube from 4 points<br />
* [[Macro draw2DFunction]]: draws a function described by an equation z=F(x)<br />
* [[Macro drawParametric2Dfunction]]: Based on the above macro, but for parametric and optionally polar equations.<br />
* [[Macro_Solid Sweep]]: creates a solid by sweeping a 2D profile along a trajectory previously selected in the 3D view. The 2D elements can be created through the regular tools in FreeCAD's GUI.<br />
* [[Macro Rectellipse]]: creates a parametric rectellipse<br />
* [[Image:Macro_Draft_Circle_3_Points.png|16px]] [[Macro_Make_Circle_3_Points|Macro_Make_Circle_3_Points]]: creates a circle on 3 selected points, the points can be objects (this example brings together the two examples below, all parameters simply settle on a graphic window).<br />
* [[Image:Macro_Draft_Circle_3_Points.png|16px]] [[Macro_Draft_Circle_3_Points]]: creates a circle from 3 selected points 2D orthogonal<br />
* [[Image:Macro_Draft_Circle_3_Points.png|16px]] [[Macro_Draft_Circle_3_Points_3D]]: creates a circle from 3 selected points in the space 3D<br />
* [[Macro screw_maker1_2]]: This macro creates a screw with or without thread, according to ISO standards.<br />
<br />
=== Object transformation ===<br />
<br />
* [[Macro ArrayCopy]]: copies the selected object several times, on an array grid<br />
* [[Macro FlattenWire]]: flattens draft wires that are not plane to their median Z coordinate<br />
* [[Macro MeshToPart]]: converts selected meshes to parts<br />
* [[Macro JointWire]]: allows to find and joint all non connected edge to the closest non connected one using a line<br />
* [[Macro Remove parametric history]]: removes all parametric associativity from an object, leaving it as a "dumb" shape<br />
* [[Macro SuperWire]]: Forces the creation of a Wire from lines and arcs that don't necessarily touch each other. Use this if normal wire operation fails<br />
* [[Macro HealArcs]]: Sometimes arcs are transformed into BSplines, for example when scale operations have been applied to them. This macro recreates valid arcs from them. Useful before exporting to dxf<br />
<br />
=== 3D View operations ===<br />
<br />
* [[Macro Rotate View]] This macro rotates the current view by 90° to the left. Only works if you are in Top view.<br />
* [[Macro View Rotation]] Provides a GUI to permit rotation of view by precise amounts in all three directions.<br />
* [[Macro Texture Objects]] This macro allows you to temporarily put a texture image on the selected objects.<br />
<br />
=== Wizards ===<br />
<br />
* [[Macro Automatic drawing]]: allows the user to get the view of his object in a drawing with 4 different position(front,top,iso,right). Need some modification to be perfecly effective<br />
* [[Macro Corner shapes wizard]]: pops up a dialog asking for the dimensions of your corner piece, then creates the object in the document and creates a page view with top, front and lateral views of the piece<br />
* [[Macro CartoucheFC]]: This GUI macro to fill simply all fields of the cartridge of the plan implementation worksheet FreeCAD, the format of the date and the symbol of the projection mode adapt to the EU region or US selected.<br />
* [[Macro unrollRuledSurface]]: allows to unroll ruled surfaces and to draw them on a page.<br />
* [[Macro unfoldBox]]: allows to unfold the surfaces of a box of any shape and to draw them on a page.<br />
<br />
=== Utility ===<br />
<br />
* [[Macro MessageBox]]: shows how to give information to the user through the GUI.<br />
* [[Image:FCInfo.png|16px]] [[Macro_FCInfo|Macro_FCInfo]] : Gives a series of information about the selected shape and can display a conversion of length, inclination (degrees, radian, grade) shape, surface, volume and the weight of the form in the density selected in various international and Anglo-Saxon units<br />
* [[Macro 3d Printer Slicer]]: Exports current design to slicer software or CAM software.<br />
<br />
== How to use? ==<br />
<br />
The above macros can easily be plugged on any FreeCAD installation<br />
* Copy the macro python code from the corresponding macro page<br />
* In FreeCAD, Macro->Macros->Create new, and give it a name<br />
* Paste the python code you copied<br />
* Hit the Save button, and restart FreeCAD<br />
* Open the Macro manager, select your new macro and click "execute"<br />
<br />
Additionally, you can also add your new macro to a custom toolbar<br />
* In FreeCAD, go to Tools -> Customize<br />
* In the Macros tab, add a new macro, and, if you like, define an icon and a keyboard shortcut<br />
* In the Toolbars tab, create a new toolbar, and add your macro, taking it from the "Macros" category.<br />
<br />
== Adding new macros to this repository ==<br />
<br />
* Create a new page, beginning its name with "Macro", for example "Macro_My_Excellent_Macro" (this can be done simply by editing this page, and adding a new link to your macro, like this: <nowiki>"[[Macro My Excellent Macro]]: My excellent macro"</nowiki>. A new page (red link) will be created.<br />
* In that page, paste the following text:<br />
<br />
(With the default icon)<br />
<nowiki>{{Macro|Icon=Text-x-python|Name=Macro_My_Excellent_Macro|Description=What my excellent macro does|Author=your username}}</nowiki><br />
<br />
(With the icon custom)<br />
<nowiki>{{Macro|Icon=Macro_My_Excellent_Macro|Name=Macro_My_Excellent_Macro|Description=What my excellent macro does|Author=your username}}</nowiki><br />
<br />
(Another language with the default icon (example "/fr" "/de" "/it"....))<br />
<nowiki>{{Macro/fr|Icon=Text-x-python|Name=Macro_My_Excellent_Macro|Name/fr=Macro_My_Excellent_Macro|Description=<br />
Description de l'utilisation de votre macro|Author=votre username}}</nowiki><br />
<br />
(Another language with the icon custom (example "/fr" "/de" "/it"....))<br />
<nowiki>{{Macro/fr|Icon=Macro_My_Excellent_Macro|Name=Macro_My_Excellent_Macro|Name/fr=Macro_My_Excellent_Macro|Description=<br />
Description de l'utilisation de votre macro|Author=votre username}}</nowiki><br />
<br />
*You can also [http://www.freecadweb.org/wiki/index.php?title=Special:Upload Upload ] a custom format icon'''.png'''<br>'''Note that the name of the icon must have the same name as the name of the macro'''.<br />
**example : " Macro_My_Excellent_Macro " '''without extension''' (the extension is given by the system), and, replace " Icon='''Text-x-python''' " by " Icon='''Macro_My_Excellent_Macro''' ")<br />
**'''Text-x-python''' [[Image:Text-x-python.png|32px]] is the default icon of the page dedicated to the Macro.<br />
<br />
* Paste your macro, and use the <nowiki><pre></pre></nowiki> preformated text wiki tags to avoid adding spaces into your script. This will display the macro in a monospace font inside a light grey box like the example above.<br />
* If you like, upload a .png icon with the exact same name as your macro page (ex. Macro_My_Excellent_Macro.png)<br />
* Optionally you can add some more info on how to use your macro, tips, limitations and workaround.<br />
* Add it to the above categories, create a new category if needed.<br />
<br />
{{languages | {{es|Macros_recipes/es}} {{fr|Macros_recipes/fr}} {{it|Macros_recipes/it}} {{se|Macros_recipes/se}} }}<br />
<br />
[[Category:User Documentation]]<br />
[[Category:Repository]]<br />
[[Category:Macros]]<br />
[[Category:Python Code]]<br />
[[Category:Tutorials]]</div>Cae2100