Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Python Scripting Tutorial - FreeCAD Documentation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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