Python Scripting Tutorial - FreeCAD Documentation
Python Scripting Tutorial - FreeCAD Documentation
Python Scripting Tutorial - FreeCAD Documentation
1 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
22/10/2016 08:06
2 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
22/10/2016 08:06
3 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
doc= FreeCAD.newDocument()
22/10/2016 08:06
4 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
doc.
box=doc.addObject("Part::Box","myBox")
doc.recompute()
22/10/2016 08:06
5 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
doc.supportedTypes()
box.
box.Height
box.Height = 5
myvec= FreeCAD.Vector(2,0,0)
myvec
myvec.x
myvec.y
othervec= FreeCAD.Vector(0,3,0)
sumvec=myvec.add(othervec)
box.Placement.
box.Placement.Base
box.Placement.Base =sumvec
otherpla= FreeCAD.Placement()
box.Placement =otherpla
22/10/2016 08:06
6 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
vo=box.ViewObject
vo.Transparency = 80
vo.hide()
vo.show()
22/10/2016 08:06
7 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
doc.supportedTypes()
import Part
Part.
22/10/2016 08:06
8 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
import Mesh
mymesh= Mesh.createSphere()
mymesh.
mymesh.Facets
mymesh.Points
meshobj=doc.addObject("Mesh::Feature","MyMesh")
meshobj.Mesh =mymesh
doc.recompute()
22/10/2016 08:06
9 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
import Part
myshape= Part.makeSphere(10)
myshape.
myshape.Volume
myshape.Area
shapeobj=doc.addObject("Part::Feature","MyShape")
shapeobj.Shape =myshape
doc.recompute()
Part.show(myshape)
import Draft
Draft.
rec= Draft.makeRectangle(5,2)
mvec= FreeCAD.Vector(4,4,0)
Draft.move(rec,mvec)
Draft.move(box,mvec)
22/10/2016 08:06
10 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
22/10/2016 08:06
11 of 11
http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial
22/10/2016 08:06