Scripting

This page is the starting point for scripting in FreeCAD. As FreeCAD use Python as its scripting language we encourage you to first learn the basics of Python programming before diving into the amazing world of FreeCAD scripting. In the FreeCAD Help Menu, you will find a couple of useful items: a "Python Manuals" item, taking you to the official python manual, and a "Python Modules" entry, which will open a complete description of the python modules, classes and functions available to you in FreeCAD.

Basics
If you are new to python scripting, you'll find here several good tutorials to help you to get the basics. If you already know a bit of python language, you can jump directly to the FreeCAD Scripting Basics to discover how easily python scripting can be done in FreeCAD.


 * Official python tutorial - A very complete tutorial for discovering python
 * Non-programmer tutorial for python - an excellent wikibook
 * Python for newbies - one big tutorial covering all the basics
 * FreeCAD Scripting Basics

Modules
As the functionality of FreeCAD is separated in Modules which deal with special data types and applications. FreeCAD has built-in modules and Extension Modules (plug-ins). Once plugin modules are installed, they become availible to you as easily as the built-in modules. The modules described below are the default modules, includeed in every FreeCAD installation.


 * The Builtin modules are the principal FreeCAD modules. They contain tools for manipulating general FreeCAD configurations, documents and their contents.
 * The Mesh Module handles triangulated meshes. The mesh module can be extensively manipulated by Mesh Scripting.
 * The Part Module deals with the CAD data structures. The Topological data scripting page describes how to script it.
 * The Drawing Module is in place for bringing the 3D world onto paper or drawings.
 * The Cam Module is dedicated to mechanical machining like milling.
 * The Raytracing Module brings all kind of shapes to renderers (like PovRay).

Examples, Exercises and Customization
After reading what each module can do, you may want to start building your own scripts. You'll find below several documents that can help you to start.


 * Code snippets : A collection of pieces of FreeCAD python code, to serve as ingredients in your scripts...
 * Line drawing function : An example showing how to construct a simple line drawing function
 * Dialog creation : An example showing how to design a Qt dialog and show/use it in FreeCAD
 * Extra python modules : Extend the FreeCAD python interpreter with these powerful modules!
 * The Draft Module adds basic 2d drawing functions to freecad. This module is not scriptable, but is written entirely in python, so it can be a good example if you want to write your own modules.
 * FreeCAD vector math library : A couple of handy functions to manipulate FreeCAD vectors. This library is also included in the Draft module.

Advanced tutorials
PyQt - How to create and manage FreeCAD's Qt UI interface from python


 * Basic PyQt tutorial : A simple and short linux-based tutorial that will explain how to work with PyQt and Qt Designer
 * First programs in PyQt4 : A platform-agnostic tutorial showing the interns of python + qt
 * programming Qt applications in python : A more in-depth tutorial covering all the process of working with qt and python.

Pivy - How to interact with FreeCAD's 3D scenes


 * Basic Pivy tutorial : A very simple tutorial form the official Pivy site
 * Introducing Pivy into studiersturbe : A document that is not really a tutorialbut that illustrates well how Pivy works