0% found this document useful (0 votes)
559 views

Python Scripting Tutorial - FreeCAD Documentation

This document is a tutorial on Python scripting in FreeCAD, an open-source parametric 3D modeler. It covers basic concepts like creating documents, adding objects like boxes and modifying their properties. It also demonstrates working with vectors, meshes, importing other objects and manipulating them using Python modules. The tutorial shows how to display messages and includes examples of importing different Python libraries for tasks in FreeCAD.

Uploaded by

Bolarinwa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
559 views

Python Scripting Tutorial - FreeCAD Documentation

This document is a tutorial on Python scripting in FreeCAD, an open-source parametric 3D modeler. It covers basic concepts like creating documents, adding objects like boxes and modifying their properties. It also demonstrates working with vectors, meshes, importing other objects and manipulating them using Python modules. The tutorial shows how to display messages and includes examples of importing different Python libraries for tasks in FreeCAD.

Uploaded by

Bolarinwa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Python scripting tutorial - FreeCAD Documentation

1 of 11

http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial

22/10/2016 08:06

Python scripting tutorial - FreeCAD Documentation

2 of 11

http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial

22/10/2016 08:06

Python scripting tutorial - FreeCAD Documentation

3 of 11

http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial

doc= FreeCAD.newDocument()

22/10/2016 08:06

Python scripting tutorial - FreeCAD Documentation

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

Python scripting tutorial - FreeCAD Documentation

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

Python scripting tutorial - FreeCAD Documentation

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

Python scripting tutorial - FreeCAD Documentation

7 of 11

http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial

doc.supportedTypes()

import Part
Part.

22/10/2016 08:06

Python scripting tutorial - FreeCAD Documentation

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

Python scripting tutorial - FreeCAD Documentation

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

Python scripting tutorial - FreeCAD Documentation

10 of 11

http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial

from PySide import QtGui


QtGui.QMessageBox.information(None,"Apolloprogram","Houston,wehaveaproblem")

22/10/2016 08:06

Python scripting tutorial - FreeCAD Documentation

11 of 11

http://www.freecadweb.org/wiki/index.php?title=Python_scripting_tutorial

22/10/2016 08:06

You might also like