Sei sulla pagina 1di 395

FreeCAD 0.

14
Manual

May 2014

Online Help Startpage

Welcome to the FreeCAD on-line help


This document has been automatically created from the contents of the official FreeCAD wiki documentation, which can be read online at
http://www.freecadweb.org/wiki/index.php?title=Main_Page. Since the wiki is actively maintained and continuously developed by the FreeCAD
community of developers and users, you may find that the online version contains more or newer information than this document. There you will also find
in-progress translations of this documentation in several languages. But nevertheless, we hope you will find here all information you need. In case you
have questions you can't find answers for in this document, have a look on the FreeCAD forum, where you can maybe find your question answered, or
someone able to help you.

How to use
This document is divided into several sections: introduction, usage, scripting and development, the last three address specifically the three broad
categories of users of FreeCAD: end-users, who simply want to use the program, power-users, who are interested by the scripting capabilities of
FreeCAD and would like to customize some of its aspects, and developers, who consider FreeCAD as a base for developing their own applications. If
you are completely new to FreeCAD, we suggest you to start simply from the introduction.

Contribute
As you may have experienced sometimes, programmers are really bad help writers! For them it is all completely clear because they made it that way.
Therefore it's vital that experienced users help us to write and revise the documentation. Yes, we mean you! How, you might ask? Just go to the Wiki at
http://www.freecadweb.org/wiki/index.php in the User section. You will need a sourceforge account to log in, and then ask on the forum or on the
irc channel for write permission (the wiki is write-protected to avoid spamming). Then you can start editing! Also, check out the page at
http://www.freecadweb.org/wiki/index.php?title=Help_FreeCAD for more ways you can help FreeCAD.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Online_Help_Startpage&oldid=85211"

Online Help Toc


Here is the table of contents for the online help system in FreeCAD. The articles referenced here are automatically included in the FreeCAD.chm file by
the wiki2chm.py tool. You find that tool under src/Tools/wiki2chm.py. A printable version of this manual is also available.
Welcome
Introduction
About FreeCAD
Features
Installing on Windows
Installing on Linux/Unix
Installing on Mac
Working with FreeCAD
Getting started
Navigating in the 3D space
The FreeCAD Document
Setting user preferences
Customizing the interface
Object properties
Working with workbenches
The PartDesign workbench
The Mesh workbench
The Part workbench
The Drawing workbench
The Raytracing workbench
The Image workbench
The Draft workbench
The Architecture workbench
The Robot workbench
List of all FreeCAD commands
Tutorials
Scripting and Macros
Working with macros
Introduction to python
Python scripting tutorial
FreeCAD Scripting Basics
Mesh Scripting
Part Scripting
Converting between Meshes and Parts
The Coin Scenegraph
Working with Pivy
Working with PyQt
Creating parametric objects
Embedding FreeCAD
API documentation
Scripting Examples
Code snippets
Line drawing function
Dialog creation
Developing applications for FreeCAD
Licence
Compiling FreeCAD
Finding assistance
Compiling on Windows
Compiling on Unix
Compiling on Mac
Third Party Libraries
Third Party Tools
Start up and Configuration
Build Support Tools
The FreeCAD build tool
Adding an application module
Debugging FreeCAD
Testing FreeCAD
Modifying FreeCAD
Branding
Translating FreeCAD
Installing extra python modules
Source documentation
Credits
Contributors

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Online_Help_Toc&oldid=41328"

About FreeCAD

FreeCAD is a general purpose parametric 3D CAD modeler. The development is completely Open Source (LGPL License). FreeCAD is aimed directly
at mechanical engineering and product design but also fits in a wider range of uses around engineering, such as architecture or other engineering
specialties.
FreeCAD features tools similar to Catia, SolidWorks or Solid Edge, and therefore also falls into the category of MCAD, PLM, CAx and CAE. It is a
feature based parametric modeler with a modular software architecture which makes it easy to provide additional functionality without modifying the
core system.
As with many modern 3D CAD modelers it has many 2D components in order to sketch 2D shapes or extract design detail from the 3D model to create
2D production drawings, but direct 2D drawing (like AutoCAD LT) is not the focus, neither are animation or organic shapes (like Maya, 3ds Max,
Blender or Cinema 4D), although, thanks to its wide adaptability, FreeCAD might become useful in a much broader area than its current focus.
FreeCAD makes heavy use of all the great open-source libraries that exist out there in the field of Scientific Computing. Among them are
OpenCascade, a powerful CAD kernel, Coin3D, an incarnation of Open Inventor, Qt, the world-famous UI framework, and Python, one of the best
scripting languages available. FreeCAD itself can also be used as a library by other programs.
FreeCAD is also fully multi-platform, and currently runs flawlessly on Windows and Linux/Unix and Mac OSX systems, with the exact same look and
functionality on all platforms.
For more about FreeCAD's capabilities, take a look at the Feature list, the latest release notes or the Getting started articles, or head directly to the
User hub!
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=About_FreeCAD&oldid=73489"

Feature list
This is an extensive, hence not complete, list of features FreeCAD implements. If you want to look into the future see the Development roadmap for a
quick overview of what's coming next. Also, the Screenshots are a nice place to go.

Release notes
Release
Release
Release
Release

0.11 - March 2011


0.12 - December 2011
0.13 - January 2013
0.14 - March 2014

Key features

A complete Open CASCADE Technology-based geometry kernel allowing complex 3D operations on complex shape types, with native
support for concepts like brep, nurbs curves and surfaces, a wide range of geometric entities, boolean operations and fillets, and built-in support of
STEP and IGES formats

A full parametric model. All FreeCAD objects are natively parametric, which means their shape can be based on properties or even depend on
other objects, all changes being recalculated on demand, and recorded by the undo/redo stack. New object types can be added easily, that can
even be fully programmed in Python

A modular architecture that allow plugins (modules) to add functionality to the core application. Those extensions can be as complex as whole
new applications programmed in C++ or as simple as Python scripts or self-recorded macros. You have complete access from the Python builtin interpreter, macros or external scripts to almost any part of FreeCAD, being geometry creation and transformation, the 2D or 3D
representation of that geometry (scenegraph) or even the FreeCAD interface

Import/export to standard formats such as STEP, IGES, OBJ, STL, DXF, SVG, STL, DAE, IFC or OFF, NASTRAN, VRML in addition to
FreeCAD's native Fcstd file format. The level of compatibility between FreeCAD and a given file format can vary, since it depends on the module
that implements it.

A Sketcher with constraint-solver, allowing to sketch geometry-constrained 2D shapes. The sketcher currently allows you to build several types
of constrained geomerty, and use them as a base to build other objects throughout FreeCAD.

A Robot simulation module that allows to study robot movements. The robot module already has an extended graphical interface allowing GUIonly workflow.

A Drawing sheets module that permit to put 2D views of your 3D models on a sheet. This modules then produces ready-to-export SVG or PDF
sheets. The module is still sparse but already features a powerful Python functionality.

A Rendering module that can export 3D objects for rendering with external renderers. Currently only supports povray, but is expected to be
extended to other renderers in the future.

A n Architecture module that allows BIM-like workflow, with IFC compatibility. The making of the Arch module is heavily discussed by the
community here.

General features
FreeCAD is multi-platform. It runs and behaves exactly the same way on Windows Linux and Mac OSX platforms.
FreeCAD is a full GUI application. FreeCAD has a complete Graphical User Interface based on the famous Qt framework, with a 3D viewer
based on Open Inventor, allowing fast rendering of 3D scenes and a very accessible scene graph representation.
FreeCAD also runs as a command line application, with low memory footprint. In command line mode, FreeCAD runs without its interface,
but with all its geometry tools. It can be, for example, used as server to produce content for other applications.

FreeCAD can be imported as a Python module, inside other applications that can run python scripts, or in a python console. Like in console
mode, the interface part of FreeCAD is unavailable, but all geometry tools are accessible.
Workbench concept: In the FreeCAD interface, tools are grouped by workbenches. This allows to display only the tools used to accomplish a
certain task, keeping the workspace uncluttered and responsive, and the application fast to load.
Plugin/Module framework for late loading of features/data-types. FreeCAD is divided into a core application and modules, that are loaded
only when needed. Almost all the tools and geometry types are stored in modules. Modules behave like plugins, and can be added or removed to
an existing installation of FreeCAD.
Parametric associative document objects: All objects in a FreeCAD document can be defined by parameters. Those parameters can be
modified on the fly, and recomputed anytime. The relationship between objects is also stored, so modifying one object also modifies its
dependent objects.
Parametric primitive creation (box, sphere, cylinder, etc)
Graphical modification operations like translation, rotation, scaling, mirroring, offset (trivial or after Jung/Shin/Choi) or shape conversion, in
any plane of the 3D space
Boolean operations (union, difference, intersect)
Graphical creation of simple planar geometry like lines, wires, rectangles, arcs or circles in any plane of the 3D space
Modeling with straight or revolution extrusions, sections and fillets.
Topological components like vertices, edges, wires and planes (via python scripting).
Testing and repairing tools for meshes: solid test, non-two-manifolds test, self-intersection test, hole filling and uniform orientation.
Annotations like texts or dimensions
Undo/Redo framework: Everything is undo/redoable, with access to the undo stack, so multiple steps can be undone at a time.
Transaction management: The undo/redo stack stores document transactions and not single actions, allowing each tool to define exactly what
must be undone or redone.
Built-in scripting framework: FreeCAD features a built-in Python interpreter, and an API that covers almost any part of the application, the
interface, the geometry and the representation of this geometry in the 3D viewer. The interpreter can run single commands up to complex scripts,
in fact entire modules can even be programmed completely in Python.
Built-in Python console with syntax highlighting, autocomplete and class browser: Python commands can be issued directly in FreeCAD and
immediately return results, permitting scriptwriters to test functionality on the fly, explore the contents of the modules and easily learn about
FreeCAD internals.
User interaction mirroring on the console: Everything the user does in the FreeCAD interface executes python code, which can be printed on
the console and recorded in macros.
Full macro recording & editing: The python commands issued when the user manipulates the interface can then be recorded, edited if needed,
and saved to be reproduced later.
Compound (ZIP based) document save format: FreeCAD documents saved with .fcstd extension can contain many different types of
information, such as geometry, scripts or thumbnail icons.
Fully customizable/scriptable Graphical User Interface. The Qt-based interface of FreeCAD is entirely accessible via the python interpreter.
Aside from the simple functions that FreeCAD itself provides to workbenches, the whole Qt framework is accessible too, allowing any operation
on the GUI, such as creating, adding, docking, modifying or removing widgets and toolbars.
Thumbnailer (Linux systems only at the moment): The FreeCAD document icons show the contents of the file in most file manager applications
such as gnome's nautilus.
A modular MSI installer allows flexible installations on Windows systems. Packages for Ubuntu systems are also maintained.

In development

An Assembly module that allows to work with multiple projects, multiple shapes, multiple documents, multiple files, multiple relationships...

A Cam Module dedicated to mechanical machining like milling, and will be able to output, display and adjust G code. This module is currently in
planning state.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Feature_list&oldid=80327"

Install on Windows
The easiest way to install FreeCAD on Windows is to download the installer below.
Windows 32-bit
After downloading the .msi (Microsoft Installer) file, just double-click on it to start the installation process.
Below is more information about technical options. If it looks daunting, don't worry! Most Windows users will not need anything more than the .msi to
install FreeCAD and Get started!

Simple Microsoft Installer Installation


The easiest way to install FreeCAD on Windows is by using the installer above. This page describes the usage and the features of the Microsoft
Installer for more installation options.
If you would like to download either a 64 bit or unstable development version, see the Download page.

Command Line Installation


With the msiexec.exe command line utility, additional features are available, like non-interactive installation and administrative installation.
Non-interactive Installation
With the command line
msiexec /i FreeCAD<version>.msi
installation can be initiated programmatically. Additional parameters can be passed at the end of this command line, like
msiexec /i FreeCAD-2.5.msi TARGETDIR=r:\FreeCAD25
Limited user interface
The amount of user interface that installer displays can be controlled with /q options, in particular:
/qn - No interface
/qb - Basic interface - just a small progress dialog
/qb! - Like /qb, but hide the Cancel button
/qr - Reduced interface - display all dialogs that don't require user interaction (skip all modal dialogs)
/qn+ - Like /qn, but display "Completed" dialog at the end
/qb+ - Like /qb, but display "Completed" dialog at the end
Target directory
The property TARGETDIR determines the root directory of the FreeCAD installation. For example, a different installation drive can be specified with
TARGETDIR=R:\FreeCAD25
The default TARGETDIR is [WindowsVolume\Programm Files\]FreeCAD<version>.
Installation for All Users
Adding
ALLUSERS=1
causes an installation for all users. By default, the non-interactive installation install the package just for the current user, and the interactive installation
offers a dialog which defaults to "all users" if the user is sufficiently privileged.
Feature Selection
A number of properties allow selection of features to be installed, reinstalled, or removed. The set of features for the FreeCAD installer is
DefaultFeature - install the software proper, plus the core libraries
Documentation - install documentation
Source code - install the sources
... ToDo
In addition, ALL specifies all features. All features depend on DefaultFeature, so installing any feature automatically installs the default feature as well.
The following properties control features to be installed or removed
ADDLOCAL - list of feature to be installed on the local machine
REMOVE - list of features to be removed
ADDDEFAULT - list of features added in their default configuration (which is local for all FreeCAD features)
REINSTALL - list of features to be reinstalled/repaired
ADVERTISE - list of feature for which to perform an advertise installation
There are a few additional properties available; see the MSDN documentation for details.
With these options, adding

ADDLOCAL=Extensions
installs the interpreter itself and registers the extensions, but does not install anything else.

Uninstallation
With
msiexec /x FreeCAD<version>.msi
FreeCAD can be uninstalled. It is not necessary to have the MSI file available for uninstallation; alternatively, the package or product code can also be
specified. You can find the product code by looking at the properties of the Uninstall shortcut that FreeCAD installs in the start menu.

Administrative installation
With
msiexec /a FreeCAD<version>.msi
an "administrative" (network) installation can be initiated. The files get unpacked into the target directory (which should be a network directory), but no
other modification is made to the local system. In addition, another (smaller) msi file is generated in the target directory, which clients can then use to
perform a local installation (future versions may also offer to keep some features on the network drive altogether).
Currently, there is no user interface for administrative installations, so the target directory must be passed on the command line.
There is no specific uninstall procedure for an administrative install - just delete the target directory if no client uses it anymore.

Advertisement
With
msiexec /jm FreeCAD<version>.msi
it would be possible, in principle, to "advertise" FreeCAD to a machine (with /ju to a user). This would cause the icons to appear in the start menu, and
the extensions to become registered, without the software actually being installed. The first usage of a feature would cause that feature to be installed.
The FreeCAD installer currently supports just advertisement of start menu entries, but no advertisement of shortcuts.

Automatic Installation on a Group of Machines


With Windows Group Policy, it is possible to automatically install FreeCAD an a group of machines. To do so, perform the following steps:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Log on to the domain controller


Copy the MSI file into a folder that is shared with access granted to all target machines.
Open the MMC snapin "Active Directory users and computers"
Navigate to the group of computers that need FreeCAD
Open Properties
Open Group Policies
Add a new policy, and edit it
In Computer Configuration/Software Installation, choose New/Package
Select the MSI file through the network path
Optionally, select that you want the FreeCAD to be deinstalled if the computer leaves the scope of the policy.

Group policy propagation typically takes some time - to reliably deploy the package, all machines should be rebooted.

Installation on Linux using Crossover Office


You can install the windows version of FreeCAD on a Linux system using CXOffice 5.0.1. Run msiexec from the CXOffice command line, assuming that
the install package is placed in the "software" directory which is mapped to the drive letter "Y:":
msiexec /i Y:\\software\\FreeCAD<version>.msi
FreeCAD is running, but it has been reported that the OpenGL display does not work, like with other programs running under Wine i.e. Google
SketchUp.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Install_on_Window s&oldid=45156"

Install on Unix
The installation of FreeCAD on the most well-known linux systems has been now endorsed by the community, and FreeCAD should be directly available
via the package manager available on your distribution. The FreeCAD team also provides a couple of "official" packages when new releases are made,
and a couple of experimental PPA repositories for testing bleeding-edge features.
Once you've got FreeCAD installed, it's time to get started!

Ubuntu and Ubuntu-based systems


Many Linux distributions are based on Ubuntu and share its repositories. Besides official variants (Kubuntu, Lubuntu and Xubuntu), there are non official
distros such as Linux Mint, Voyager and others. The installation options below should be compatible to these systems.

Official Ubuntu repository


FreeCAD is available from Ubuntu repositories and can be installed via the Software Center or with this command in a terminal:
sudo apt-get install freecad
But chances are this version will be outdated, and not have the latest features.

Latest Stable Release from the PPA


The FreeCAD community provides a PPA repository on Launchpad with the latest stable FreeCAD version.
Installing from the GUI
Add to your system's Software Sources the following PPA (read What are PPAs and how do I use them? if you don't know how):
ppa:freecad-maintainers/freecad-stable
When a dialog window asks you to refresh your software sources, click OK.
Now you can install FreeCAD and FreeCAD documentation through the Ubuntu Software Center, or your package manager of choice.
Installing from the console
Type (or copy-paste) these commands in a console to add the PPA and install FreeCAD along with the documentation:
sudo add-apt-repository ppa:freecad-maintainers/freecad-stable
Then:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install freecad freecad-doc

Install PySide
sudo apt-get install python-pyside
sudo apt-get install libpyside-dev

Unstable version of FreeCAD


If you want to be on the bleeding edge of FreeCAD development, there is a different PPA repository providing daily builds.

Debian and other debian-based systems


Since Debian Lenny, FreeCAD is available directly from the Debian software repositories and can be installed via synaptic or simply with:
sudo apt-get install freecad

OpenSUSE
FreeCAD is typically installed with:
zypper install FreeCAD

Gentoo
FreeCAD can be built/installed simply by issuing:
emerge freecad

Other
If you find out that your system features FreeCAD but is not documented in this page, please tell us on the forum!
Many alternative, non-official FreeCAD packages are available on the net, for example for systems like slackware or fedora. A search on the net can

quickly give you some results.

Manual install on .deb based systems


If for some reason you cannot use one of the above methods, you can always download one of the .deb packages available on the Download page.
Ubuntu 32/64bit
Once you downloaded the .deb corresponding to your system version, if you have the Gdebi package installed (usually it is), you just need to navigate
to where you downloaded the file, and double-click on it. The necessary dependencies will be taken care of automatically by your system package
manager. Alternatively you can also install it from the terminal, navigating to where you downloaded the file, and type:
sudo dpkg -i Name_of_your_FreeCAD_package.deb
changing Name_of_your_FreeCAD_package.deb by the name of the file you downloaded.
After you installed FreeCAD, a startup icon will be added in the "Graphic" section of your Start Menu.

Installing on other Linux/Unix systems


Unfortnately, at the moment, no precompiled package is available for other Linux/Unix systems,so you will need to compile FreeCAD yourself.

Installing Windows Version on Linux


See the Install on Windows page.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Install_on_Unix&oldid=65934"

Install on Mac
FreeCAD can be installed on Mac OS X in one step using the Installer.
Mac OS X Lion 64-bit
This page describes the usage and features of the FreeCAD installer. It also includes uninstallation instructions. Once installed, you can get started!

Simple Installation
The FreeCAD installer is provided as a Installer package (.mpkg) enclosed in a disk image file.
You can download the latest installer from the Download page. After downloading the file, just mount the disk image, then run the Install FreeCAD
package.

The installer will present you with a Customize Installation screen that lists the packages that will be installed. If you know that you already have any
of these packages, you can deselect them using the checkboxes. If you're not sure, just leave all items checked.

Uninstallation

There currently isn't an uninstaller for FreeCAD. To completely remove FreeCAD and all installed components, drag the following files and folders to the
Trash:
In /Applications:
FreeCAD
in /Library/Frameworks/
SoQt.framework
Inventor.framework
Then, from the terminal, run:
sudo /Developer/Tools/uninstall-qt.py
sudo rm -R /usr/local/lib/OCC
sudo rm -R /usr/local/include/OCC
That's it. Eventually, FreeCAD will be available as a self-contained application bundle so all this hassle will go away.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Install_on_Mac&oldid=45285"

Getting started
What's new
Version
Version
Version
Version

0.11 Release
0.12 Release
0.13 Release
0.14 Release

notes :
notes :
notes :
notes :

Check
Check
Check
Check

what's
what's
what's
what's

new in the 0.11 release of FreeCAD


new in the 0.12 release of FreeCAD
new in the 0.13 release of FreeCAD
new in the 0.14 release of FreeCAD

Foreword
FreeCAD is a 3D CAD/CAE parametric modeling application. It is primarily made for mechanical design, but also serves all other uses where you
need to model 3D objects with precision and control over modeling history.
FreeCAD is still in the early stages of development, so, although it already offers you a large (and growing) list of features, much is still missing,
specially comparing it to commercial solutions, and you might not find it developed enough yet for use in production environment. Still, there is a fastgrowing community of enthusiastic users, and you can already find many examples of quality projects developed with FreeCAD.
Like all open-source projects, the FreeCAD project is not a one-way work delivered to you by its developers. It depends much on its community to grow,
gain features, and stabilize (get bugs fixed). So don't forget this when starting to use FreeCAD, if you like it, you can directly influence and help the
project!

Installing
First of all (if not done already) download and install FreeCAD. See the Download page for information about current versions and updates, and the
Installing page for information about how to install FreeCAD. There are install packages ready for Windows (.msi), Ubuntu & Debian (.deb) openSUSE
(.rpm) and Mac OSX. As FreeCAD is open-source, if you are adventurous, but want to have a look at the brand-new features being developed right now,
you can also grab the source code and compile FreeCAD yourself.

Exploring FreeCAD

1.
2.
3.
4.
5.
6.

The 3D view, showing the contents of your document


The tree view, which shows the hierarchy and construction history of all the objects in your document
The properties editor, which allows you to view and modify properties of the selected object(s)
The output window, which is where FreeCAD prints messages, warnings and errors
The python console, where all the commands executed by FreeCAD are printed, and where you can enter python code
The workbench selector, where you select the active workbench

The main concept behind the FreeCAD interface is that it is separated into workbenches. A workbench is a collection of tools suited for a specific task,
such as working with meshes, or drawing 2D objects, or constrained sketches. You can switch the current workbench with the workbench selector
(6). You can customize the tools included in each workbench, add tools from other workbenches or even self-created tools, that we call macros. There
is also a generic workbench which gathers the most commonly used tools from other workbenches, called the complete workbench.
When you start FreeCAD for the first time, you are presented with the start center:

The Start Center allows you to quickly jump to one of the most common workbenches, open one of the recent files, or see the latest news from the
FreeCAD world. You can change the default workbench in the preferences.

Navigating in the 3D space


FreeCAD has four different navigation modes available, that change the way you use your mouse to interact with the objects in the 3D view and the
view itself. One of them is specifically made for touchpads, where the middle mouse button is not used. The following table describes the default mode,
called CAD Navigation (You can quickly change the current navigation mode by right-clicking on an empty area of the 3D view):

Select

Pan

Zoom

Rotate View

Alternate Method

Press the left mouse


Click the middle mouse Use the mouse wheel to
button over an object
button and move the
zoom in and out.
you want to select.
object around to pan
Holding down ctrl allows
the selection of multiple
objects.

Click first with the


middle mouse button,
hold it down, and then
click the left mouse
button and drag the
mouse in the desired
direction. The cursor
location at the middle
mouse button click
determines the center of
rotation. Rotation works
like spinning a ball
which rotates around its
center. If the buttons are
released before you
stop the mouse motion,
the object continues
spinning, if this is
enabled. A double click
with the middle mouse
button sets a new center
of rotation.

Press and hold Ctrl


key and click and
release right mouse
button to pan (rev 0.14)

Once in Pan mode, click


and momentary hold left
mouse button to rotate,
to exit back to pan
mode press and release
right mouse button (rev
0.14)

Once in Pan mode,


press and release left
mouse button to Zoom,
to exit back to pan
mode press and release
right mouse button (rev
0.14)

Rotate View

Click first with the


middle mouse button,
hold it down, and then
click the right mouse
button and drag the
mouse in the desired
direction. This method
works just like the
previously described
Rotate View that uses
Middle Mouse Button +
Left Mouse Button,
except that the middle
mouse button may be
released after the right
mouse button is
pressed. Users who use
the mouse with their
right hand may find this
Rotate View method
easier than the previous
method.

You also have several view presets (top view, front view, etc) available in the View menu and on the View toolbar, and by numeric shortcuts ( 1 , 2 ,
etc...), and by right-clicking on an object or on an empty area of the 3D view, you have quick access to some common operations, such as setting a
particular view, or locating an object in the Tree view.

First steps with FreeCAD

FreeCAD's focus is to allow you to make high-precision 3D models, to keep tight control over those models (being able to go back into modelling history
and change parameters), and eventually to build those models (via 3D printing, CNC machining or even construction worksite). It is therefore very different
from some other 3D applications made for other purposes, such as animation film or gaming. Its learning curve can be steep, specially if this is your first
contact with 3D modeling. If you are struck at some point, don't forget that the friendly community of users on the FreeCAD forum might be able to get
you out in no time.
The workbench you will start using in FreeCAD depends on the type of job you need to do: If you are going to work on mechanical models, or more
generally any small-scale objects, you'll probably want to try the PartDesign Workbench. If you will work in 2D, then switch to the Draft Workbench,
or the Sketcher Workbench if you need constraints. If you want to do BIM, launch the Arch Workbench. If you are working with ship design, there is a
special Ship Workbench for you. And if you come from the OpenSCAD world, try the OpenSCAD Workbench.
You can switch workbenches at any time, and also customize your favorite workbench to add tools from other workbenches.

Working with the PartDesign and Sketcher workbenches


The PartDesign Workbench is specially made to build complex objects, starting from simple shapes, and adding or removing pieces (that we call
"features"), until you get to your final object. All the features you applied during the modelling process are stored in a separate view called the tree view,
which also contains the other objects in your document. You can think of a PartDesign object as a succession of operations, each one applied to the
result of the preceding one, forming one big chain. In the tree view, you see your final object, but you can expand it and retrieve all preceding states, and
change any of their parameter, which automatically updates the final object.
The PartDesign workbench makes heavy use of another workbench, the Sketcher Workbench. The sketcher allows you to draw constrained 2D
shapes, which means that some parts of your 2D shape can have constraints. For example, you might draw a rectangle, and set a length constraint to
one of its sides. That side then cannot be resized anymore.
Those 2D shapes made with the sketcher are used a lot in the PartDesign workbench, for example to extrude volumes, or to draw areas on the faces of
your object, that will then be hollowed from its main volume. This is a typical PartDesign workflow:
1.
2.
3.
4.
5.
6.
7.
8.
9.

Create a new sketch


Draw a closed shape (make sure all points are joined)
Close the sketch
Extrude it with the pad tool
Select one face of the extruded volume
Create a second sketch (this time it will be drawn on the selected face)
Draw a closed shape
Close the sketch
Create a pocket from the second sketch, on the first object

Which gives you an object like this:

At any moment, you can select the original sketches and modify them, or change the extrusion parameters of the pad or pocket operations, which will
update the final object.

Working with the Draft and Arch workbenches


The Draft Workbench and Arch Workbench behave a bit differently than the other workbenches above, although they follow the same rules, which are
common to all of FreeCAD. In short, while the Sketcher and PartDesign are made primarily to design single pieces, Draft and Arch are made to ease
your work when working with several, simpler objects.
The Draft Workbench offers you 2D tools a bit similar to what you can find in traditional 2D CAD applications such as AutoCAD. However, 2D drafting
being far away from the scope of FreeCAD, don't expect to find there the full array of tools that these dedicated applications offer. Most of the Draft tools
work not only in a 2D plane but also in the full 3D space, and benefit from special helper systems such as Work planes and object snapping.
The Arch Workbench adds BIM tools to FreeCAD, allowing you to build architectural models with parametric objects. The Arch workbench relies much
on other modules such as Draft and Sketcher. All the Draft tools are also present in the Arch workbench, and most Arch tools make use of the Draft
helper systems.
A typical workflow with Arch and Draft workbenches might be:
1.
2.
3.
4.
5.
6.
7.

Draw a couple of lines with the Draft Line tool


Select each line and press the Wall tool to build a wall on each of them
Join the walls by selecting them and pressing the Arch Add tool
Create a floor object, and move your walls in it from the Tree view
Create a building object, and move your floor in it from the Tree view
Create a window by clicking the Window tool, select a preset in its panel, then click on a face of a wall
Add dimensions by first setting the working plane if necessary, then using the Draft Dimension tool

Which will give you this:

More on the Tutorials page.

Scripting
And finally, one of the most powerful features of FreeCAD is the scripting environment. From the integrated python console (or from any other external
Python script), you can gain access to almost any part of FreeCAD, create or modify geometry, modify the representation of those objects in the 3D
scene or access and modify the FreeCAD interface. Python scripting can also be used in macros, which provide an easy method to create custom
commands.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Getting_started&oldid=80336"

Mouse Model
The FreeCAD mouse model consists of the commands used to visually navigate the 3D space and interact with the objects displayed. FreeCAD
supports multiple mouse model navigation styles. The default navigation style is referred to as "CAD Navigation," and is very simple and practical, but
FreeCAD also provides alternative navigation styles, that you can choose according to your preferences.

Navigation
The object handling is common to all workbenches. The following mouse gestures can be used to control the object position and view according to which
Navigation style is selected.
There are two ways to change the navigation style:
In the Preferences Editor, Display section, 3D View tab;
By right-clicking in empty space in the 3D view area, then selecting Navigation style in the contextual menu.

CAD Navigation (default)


This is the default navigation style and allows the user a simple control of the view, and does not require the use of keyboard keys except to make multiselections.

Select

Pan

Zoom

Rotate View

Alternate Method

Press the left mouse


Click the middle mouse Use the mouse wheel to
button over an object
button and move the
zoom in and out.
you want to select.
object around to pan
Holding down ctrl allows
the selection of multiple
objects.

Click first with the


middle mouse button,
hold it down, and then
click the left mouse
button and drag the
mouse in the desired
direction. The cursor
location at the middle
mouse button click
determines the center of
rotation. Rotation works
like spinning a ball
which rotates around its
center. If the buttons are
released before you
stop the mouse motion,
the object continues
spinning, if this is
enabled. A double click
with the middle mouse
button sets a new center
of rotation.

Press and hold Ctrl


key and click and
release right mouse
button to pan (rev 0.14)

Once in Pan mode, click


and momentary hold left
mouse button to rotate,
to exit back to pan
mode press and release
right mouse button (rev
0.14)

Once in Pan mode,


press and release left
mouse button to Zoom,
to exit back to pan
mode press and release
right mouse button (rev
0.14)

Rotate View

Click first with the


middle mouse button,
hold it down, and then
click the right mouse
button and drag the
mouse in the desired
direction. This method
works just like the
previously described
Rotate View that uses
Middle Mouse Button +
Left Mouse Button,
except that the middle
mouse button may be
released after the right
mouse button is
pressed. Users who use
the mouse with their
right hand may find this
Rotate View method
easier than the previous
method.

Inventor Navigation
In Inventor Navigation, modeled after Open Inventor (not to be confused with Autodesk Inventor), there is no mouse-only selection. In order to select
objects, you must hold down the CTRL key.

Select

Pan

Zoom

Rotate View

ctrl +
Hold ctrl and press the left
mouse button over an object
you want to select.

or
Click the left mouse button and Use the mouse wheel to zoom Click and drag with the left
move the object around.
in and out, or click and hold the mouse button to rotate
middle mouse button and click
the left mouse button.

Blender Navigation
In Blender Navigation, modeled after Blender, there is no mouse-only panning. In order to pan the view, you must hold down the SHIFT key.

Select

Press the left mouse button


over an object you want to
select.

Pan

Zoom

Rotate View

shift +
Hold shift and click the middle Use the mouse wheel to zoom Click and drag with the middle
mouse button and move the
in and out.
mouse button.
object around.

Touchpad Navigation
In Touchpad Navigation, neither panning, nor zooming, nor rotating the view, are mouse-only (or touchpad-only) operations.

Select

Pan

Zoom

Rotate View

PgUp / PgDn
shift +
Press the left mouse button
over an object you want to
select.

alt +

Hold shift and move the object Use PgUp and PgDn to zoom Hold alt and move the pointer.
around.
in and out.
or

or

shift + ctrl +

shift + ctrl +

Hold down both the shift and


the ctrl keys, press the left
mouse button, and move the
pointer.

Hold down both the shift and


the ctrl keys and move the
pointer.

Selecting objects
Simple selection
Objects can be selected by a click with the left mouse button either by clicking on the object in the 3D-view or by selecting it in the tree view.

Preselection
There is also a Preselection mechanism that highlights objects and displays information before selection by just hovering the mouse over the objects. If
you don't like this behaviour or you have a slow machine, you can switch preselection off in the preferences.

Manipulating Objects
FreeCAD offers manipulators that are handles that can be used to modify an object's appearance, shape, or other parameters.

Obsolete

activation the clipping plane object appears and shows seven obvious manipulators as little boxes: One on each end of its three coordinate axes and one
on the center of the plane normal axis. There are four more that are not as obvious: The plane itself and the thin part of the three axis objects.
Scaling
To scale the object click with the left mouse button on the box manipulators at the end of the axes and pull them back and forth. Depending on
the object the manipulators work independently or synchronously.
Out of plane shifting
To shift the object along its normal vector, pull the long box on the center of an axis with the left mouse button. For the clipping plane there is only
one manipulator along the normal vector.
In plane shifting
To move the center of the clipping plane, click on the plane object and pull it to the desired location.
Rotation
Clicking on the thin part of the axes puts the manipulator in rotation mode.

Hardware support
FreeCAD also supports some 3D input devices.

Mac OS X Issues
Recently we got reports on the forum from Mac users that those mouse button and key combination do not work as expected. Unfortunately, none of
the developers owns a Mac, neither do the other regular contributors. We need your help to determine which mouse buttons and key combination work
so we can update this wiki.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Mouse_Model&oldid=79572"

Document structure

A FreeCAD document contains all the objects of your scene. It can contain groups, and objects made with any workbench. You can therefore switch
between workbenches, and still work on the same document. The document is what gets saved to disk when you save your work. You can also open
several documents at the same time in FreeCAD, and open several views of the same document.
Inside the document, the objects can be moved into groups, and have a unique name. Managing groups, objects and object names is done mainly from
the Tree view. It can also be done, of course, like everything in FreeCAD, from the python interpreter. In the Tree view, you can create groups, move
objects to groups, delete objects or groups, by right-clicking in the tree view or on an object, rename objects by double-clicking on their names, or
possibly other operations, depending on the current workbench.
The objects inside a FreeCAD document can be of different types. Each workbench can create its own types of objects, for example the Mesh
Workbench creates mesh objects, the Part Workbench create Part objects, the Draft Workbench also creates Part objects, etc.
If there is at least one document open in FreeCAD, there is always one and only one active document. That's the document that appears in the current
3D view, the document you are currently working on.

Application and User Interface


Like almost everything else in FreeCAD, the user interface part (Gui) is separated from the base application part (App). This is also valid for documents.
The documents are also made of two parts: the Application document, which contains our objects, and the View document, which contains the
representation on screen of our objects.
Think of it as two spaces, where the objects are defined. Their constructive parameters (is it a cube? a cone? which size?) are stored in the Application
document, while their graphical representation (is it drawn with black lines? with blue faces?) are stored in the View document. Why is that? Because
FreeCAD can also be used WITHOUT graphical interface, for example inside other programs, and we must still be able to manipulate our objects, even if
nothing is drawn on the screen.
Another thing that is contained inside the View document are 3D views. One document can have several views opened, so you can inspect your
document from several points of view at the same time. Maybe you would want to see a top view and a front view of your work at the same time? Then,
you will have two views of the same document, both stored in the View document. Creating new views or closing views can be done from the View menu
or by right-clicking on a view tab.

Scripting
Documents can be easily created, accessed and modified from the python interpreter. For example:
FreeCAD.ActiveDocument
Will return the current (active) document
FreeCAD.ActiveDocument.Blob
Would access an object called "Blob" inside your document
FreeCADGui.ActiveDocument
Will return the view document associated to the current document
FreeCADGui.ActiveDocument.Blob
Would access the graphical representation (view) part of our Blob object
FreeCADGui.ActiveDocument.ActiveView
Will return the current view
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Document_structure&oldid=45361"

Preferences Editor
The preferences system of FreeCAD is located in the Edit menu -> Preferences.
FreeCAD functionality is divided into different modules, each module being responsible for the working of a specific workbench. FreeCAD also uses a
concept called late loading, which means that components are loaded only when they are needed. You may have noticed that when you select a
workbench on the FreeCAD toolbar, that workbench and all its components get loaded at that moment. This includes its preferences settings.

The general preferences settings


When you start FreeCAD with no workbench loaded, you will then have a minimal preferences window. As you load additional modules, new sections
will appear in the preferences window, allowing you to configure the details of each workbench.
Without any module loaded, you will have access to two configuration sections, responsible for the general application settings and for the display
settings.

The display settings


FreeCAD is always in constant evolution, so the contents of those screens might differ from the above screenshots. The settings are usually selfexplanatory, so you shouldn't have any difficulty configuring FreeCAD to your needs.

The Draft module has its preferences screen


Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Preferences_Editor&oldid=79853"

Interface Customization
Since FreeCAD interface is based on the modern Qt toolkit, it has a state-of-the-art organization. Widgets, menus, toolbars and other tools can be
modified, moved, shared between workbenches, keyboard shortcuts can be set, modified, and macros can be recorded and played. The customization
window is accessed from the Tools -> Customize menu:

The Commands tab lets you browse all available FreeCAD commands, organized by their category.
In Keyboard, you can see the keyboard shortcuts associated with every FreeCAD command, and if you want, modify or assign new shortcut to any
command. This is where to come if you use a particular workbench often, and would like to speed up its use by using the keyboard.
The Toolbars and Toolbox bars tabs let you modify existing toolbars, or create your own custom toolbars.
The Macros tab lets you manage your saved Macros.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Interface_Customization&oldid=45453"

Property editor
Overview
The Property Editor is one of the most important tools of FreeCAD and a main element while working with FreeCAD. The Property Editor allows
managing the properties of the objects in your document.
Generally the Property Editor is intended to deal with just one object at one time. The values shown in the Property Editor belong to the active object of
your active document (be careful of which document is really active if you work on multiple documents). If you did not select any element (or there are no
elements), the Property Editor will be blank.
Not all the properties can be modified in any moment. Depending on the specific status, some properties will be shown as read-only.
The properties of an object are grouped in View properties and Data properties, and shown under different tabs.
Different objects may have different properties. However, some properties are common among all objects, for instance the position and the rotation of an
object are Data properties that can be manipulated.

Property definition
A property is a piece of information like a number or a text string that is attached to a FreeCAD document or an object in a document. Properties can
be viewed and - if allowed - modified with the Property editor.
Properties play a very important part in FreeCAD, since it is from the beginning made to work with parametric objects, which are objects defined only by
their properties.
Custom scripted objects in FreeCAD can have properties of the following types:
Boolean
Float
FloatList
FloatConstraint
Angle
Distance
Integer
IntegerConstraint
Percent
Enumeration
IntegerList
String
StringList
Link
LinkList
Matrix
Vector
VectorList
Placement
PlacementLink
Color
ColorList
Material
Path
File
FileIncluded
PartShape
FilletContour
Circle

Function
The Property Editor has two tabs: the View tab and the Data tab.
The View tab provides access to the properties related to the visual display of the object
The Data tab allows modification of the physical parameters of an object.

Example of Part object properties


Properties
There are two types of feature properties, accessible through tabs at the bottom of the Property editor:

View

VIEW

View : properties related to the visual display of the object.

DATA

Data : properties related to the physical parameters of an object.

Base

Data

VIEW

Bounding Box : To view the occupation, and, overall, of the object dimensions in space. Value FALSE, or TRUE (Default, FALSE).

VIEW

Control Point : Value FALSE, or TRUE (Default, FALSE).

VIEW

Deviation :

VIEW

Display Mode :Display mode of the form, Flat lines, Shaded, Wireframe, Points

VIEW

Lighting : Lighting One side, Two side

VIEW

Line Color : Gives the color of the line (edges) (Default, 25, 25, 25).

VIEW

Line Width : Gives the thickness of the line (edges) (Default, 2).

VIEW

Point Color : Gives the color of the points (ends of the form) (Default, 25, 25, 25).

VIEW

Point Size : Gives the size of the points (Default, 2).

VIEW

Selectable : Allows the selection of the form. Value FALSE, ou TRUE (Default, TRUE).

VIEW

Shape Color : Give the color shape (default, 204, 204, 204).

VIEW

Transparency : Sets the degree of transparency in the form of 0 to 100 (Default, 0).

VIEW

Visibility : Determines the visibility of the form (like the bar SPACE ). Value FALSE, or TRUE (Default, TRUE).

. (Default, Flat lines).

. (Default, Two side).

Base DATA

Angle : The argument Angle, indicates the angle that will be used with the option Axis (below). Here, an angle is defined, the angle on the
axis, is set with the option Axis.
The object takes the specified angle around the specified axis.
An example, if you create an object with a required revolution should be rotate functionality of a certain amount, in order to enable it to take the same
angle that another element existing.
Axis : This option specifies the axis/axes to rotate the created object. The exact value of rotation comes from the angle (see above) option.
This option takes three arguments, these arguments, are transmitted in the form of numbers, x, y or z. Adding a value, more of an axis, will the rotation
to each specified axis angle.
For example, with a Angle of 15 : specifying, 1.0 for x and 2.0 for y, will rotate 15 and 30 in the y-axis and the x-axis (final position),
DATA

DATA

Base : This option specifies the offset in either axes x, y, or z, and accept any number as the argument for each field.

DATA

Label : The Label is the name given to the operation, this name can be changed at convenience.

Placement : [(0.00 0.00 1.00);0.00;(0.00 0.00 0.00)] Summary below data. Every feature has a placement that can be controlled through the Data
Properties table. It controls the placement of the part with respect to the coordinate system. NOTE: The placement options do not affect the physical
dimensions of the feature, but merely its position in space!
If you select the title Placement
, a button with tree small points appears, clicking this button ... , you
have access to the options window Tasks_Placement.
DATA

Angle : The Angle argument specifies the angle to be used with the axis option (below). An angle is set here, and the axis that the angle acts
upon is set with the axis option. The feature is rotated by the specified angle, about the specified axis. A usage example might be if you created a
revolution feature as required, but then needed to rotate the whole feature by some amount, in order to allow it to line-up with another pre-existing feature.
DATA

Axis : This option specifies the axis/axes about which the created feature is to be rotated. The exact value of rotation comes from the angle option
(above). This option takes three arguments, which are passed as numbers to either the x, y, or z boxes in the tool. Adding a value to more than one of
the axes will cause the part to be rotated by the angle in each axis. For example, with an angle of 15 set, specifying a value of 1.0 for x, and 2.0 for y
will cause the finished part to be rotated 15 in the x-axis AND 30 in the y-axis.
DATA

Position : This option specifies the base point to which all dimensions refer. This option takes three arguments, which are passed as numbers to
either the x, y, or z boxes in the tool. Adding a value to more than one of the boxes will cause the part to be translated by the number of units along the
corresponding axis.
DATA

PS: The displayed properties can vary, depending on the tool used.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Property_editor&oldid=45494"

Workbenches
FreeCAD, like many modern design applications such as Revit or CATIA, is based on the concept of Workbench. A workbench can be considered as
a set of tools specially grouped for a certain task. In a traditional furniture workshop, you would have a work table for the person who works with wood,
another one for the one who works with metal pieces, and maybe a third one for the guy who mounts all the pieces together.
In FreeCAD, the same concept applies. Tools are grouped into workbenches according to the tasks they are related to.
The following workbenches are available:
The Part Design Workbench for building Part shapes from sketches
The Draft Workbench for doing basic 2D CAD drafting
The Mesh Workbench for working with triangulated meshes
The Part Workbench for working with CAD parts
The Image Workbench for working with bitmap images
The Raytracing Workbench for working with ray-tracing (rendering)
The Drawing workbench for displaying your 3D work on a 2D sheet
The Robot Workbench for studying robot movements
The Sketcher Workbench for working with geometry-constrained sketches
The Arch Workbench for working with architectural elements
The OpenSCAD Workbench for interoperability with OpenSCAD and repairing CSG model history
The Assembly Workbench for working with multiple shapes, multiple documents, multiple files, multiple relationships...
The Fem Workbench for Pre- and Post-processing FEM studies
The Ship Workbench FreeCAD-Ship works over Ship entities, that must be created on top of provided geometry.
The Plot Workbench The Plot module allows to edit and save output plots created from other modules and tools.
The Spreadsheet Workbench for creating and manipulating spreadsheet data
New workbenches are in development, stay tuned!
When you switch from one workbench to another, the tools available on the interface change. Toolbars, command bars and eventually other parts of the
interface switch to the new workbench, but the contents of your scene doesn't change. You could, for example, start drawing 2D shapes with the Draft
Workbench, then work further on them with the Part Workbench.
Note that sometimes a Workbench is referred to as a Module. However, Workbenches and Modules are different entities. A Module is any extension of
FreeCAD, while a Workbench is a special GUI configuration that groups some toolbars and menus. Usually every Module contains its own Workbench,
hence the cross-use of the name.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Workbenches&oldid=45510"

PartDesign Workbench
The Part Design Workbench aims to provide tools for modelling complex solid parts and is based on a Feature editing methodology. It is intricately
linked with the Sketcher Workbench.

Basic Workflow
The sketch is the building block for creating and editing solid parts. The workflow can be summarized by this: a sketch containing 2D geometry is
created first, then a solid creation tool is used on the sketch. At the moment the available tools are:
Pad which extrudes a sketch
Pocket which creates a pocket on an existing solid
Revolve which creates a solid by revolving a sketch along an axis
Groove' which creates a groove in an existing solid
More tools are planned in future releases.
A very important concept in the PartDesign workbench is the sketch support. Sketches can be created on standard planes (XY, XZ, YZ and planes
parallel to them) or on the face of an existing solid. For this last case, the existing solid becomes the support of the sketch. Several tools will only work
with sketches that have a support, for example, Pocket - without a support there would be nothing to remove material from!
After solid geometry has been created it can be modified with chamfers and fillets or transformed, e.g. mirrored or patterned.
The Partdesign workbench is meant to create a single, connected solid. Multiple solids will be possible with the Assembly workbench.

The Tools
The Part Design tools are all located in the Part Design menu that appears when you load the Part Design module.
They include the Sketcher Workbench tools, since the Part Design module is so dependent on them.

The Sketcher Tools


Sketcher Geometries
These are tools for creating objects.

Point: Draws a point


Arc: Draws an arc segment from center, radius, start angle and end angle
Circle: Draws a circle from center and radius
2-point Line: Draws a line segment from 2 points
Polyline (multiple-point line): Draws a line made of multiple line segments
Rectangle: Draws a rectangle from 2 opposite points
Fillet: Makes a fillet between two lines joined at one point. Select both lines or click on the corner point, then activate the tool.
Trimming: Trims a line, circle or arc with respect to the clicked point.
External Geometry: Creates an edge linked to external geometry.
Construction Mode: Toggles an element to/from construction mode. A construction object will not be used in a 3D geometry operation.
Sketcher Constraints

Constraints are used to set rules between sketch elements, and to lock the sketch along the vertical and horizontal axes.

Lock: Creates a lock constraint on the selected item by setting vertical and horizontal dimensions relative to the origin (dimensions can be
edited afterwards).
Coincident: Creates a coincident (point-on-point) constraint between two selected points.
Point On Object: Creates a point-on-object constraint on selected items.
Horizontal Distance: Fixes the horizontal distance between 2 points or line ends. If only one item is selected, the distance is set to the
origin.
Vertical Distance: Fixes the vertical distance between 2 points or line ends. If only one item is selected, the distance is set to the origin.
Vertical: Creates a vertical constraint to the selected lines or polylines elements. More than one object can be selected.
Horizontal: Creates a horizontal constraint to the selected lines or polylines elements. More than one object can be selected.
Length: Creates a length constraint on a selected line.
Radius: Creates a radius constraint on a selected arc or circle.
Parallel: Creates a parallel constraint between two selected lines.
Perpendicular: Creates a perpendicular constraint between two selected lines.
InternalAngle: Creates an internal angle constraint between two selected lines.
Tangent: Creates a tangent constraint between two selected entities, or a colinear constraint between two line segments.
Equal Length: Creates an equality constraint between two selected entities. If used on circle or arcs, the radius will be set equal.
Symmetric: Creates a symmetric constraint between 2 points with respect to a line.
Other

New Sketch: Creates a new sketch on a selected face or plane. If none were selected, the default work plane XY will be used.
View sketch: Sets the model view perpendicular to the sketch plane.
Map sketch: maps a sketch to the previously selected face of a solid.
Leave Sketch: Leave the Sketch editing mode.
Sketcher Reorient: Allows you to change the position of a sketch

The Part Design Tools


Construction tools
These are tools for creating solid objects or removing material from an existing solid object.

Pad: Extrudes a solid object from a selected sketch.


Pocket: Creates a pocket from a selected sketch. The sketch must be mapped to an existing solid object's face.
Revolution: Creates a solid by revolving a sketch around an axis. The sketch must be a closed profile to get a solid object.
Groove: Creates a groove by revolving a sketch around an axis. The sketch must be mapped to an existing solid object's face.
Modification tools
These are tools for modifying existing objects. They will allow you to choose which object to modify.

Fillet: Fillets (rounds) edges of an object.


Chamfer: Chamfers edges of an object.
Draft: Applies angular draft to faces of an object.
Transformation tools
These are tools for transforming existing features. They will allow you to choose which features to transform.

Mirrored: Mirrors features on a plane or face.


Linear Pattern: Creates a linear pattern of features.

Polar Pattern: Creates a polar pattern of features.


Scaled: Scales features to a different size.
MultiTransform: Allows creating a pattern with any combination of the other transformations.

Extras
<translate>
Extras
Some optional functionality that has been created for the PartDesign Workbench:

Shaft design wizard: Generates a shaft from a table of values and allows to analyze forces and moments
Involute gear: allows you to create gear
</translate>

Feature properties
Properties
There are two types of feature properties, accessible through tabs at the bottom of the Property editor:
VIEW

View : properties related to the visual display of the object.

DATA

Data : properties related to the physical parameters of an object.

VIEW

Bounding Box : To view the occupation, and, overall, of the object dimensions in space. Value FALSE, or TRUE (Default, FALSE).

VIEW

Control Point : Value FALSE, or TRUE (Default, FALSE).

VIEW

Deviation :

VIEW

Display Mode :Display mode of the form, Flat lines, Shaded, Wireframe, Points

VIEW

Lighting : Lighting One side, Two side

VIEW

Line Color : Gives the color of the line (edges) (Default, 25, 25, 25).

VIEW

Line Width : Gives the thickness of the line (edges) (Default, 2).

VIEW

Point Color : Gives the color of the points (ends of the form) (Default, 25, 25, 25).

VIEW

Point Size : Gives the size of the points (Default, 2).

VIEW

Selectable : Allows the selection of the form. Value FALSE, ou TRUE (Default, TRUE).

View

Base

. (Default, Two side).

. (Default, Flat lines).

VIEW

Shape Color : Give the color shape (default, 204, 204, 204).

VIEW

Transparency : Sets the degree of transparency in the form of 0 to 100 (Default, 0).

VIEW

Visibility : Determines the visibility of the form (like the bar SPACE ). Value FALSE, or TRUE (Default, TRUE).

Data

Base DATA

Angle : The argument Angle, indicates the angle that will be used with the option Axis (below). Here, an angle is defined, the angle on the
axis, is set with the option Axis.
The object takes the specified angle around the specified axis.
An example, if you create an object with a required revolution should be rotate functionality of a certain amount, in order to enable it to take the same
angle that another element existing.
Axis : This option specifies the axis/axes to rotate the created object. The exact value of rotation comes from the angle (see above) option.
This option takes three arguments, these arguments, are transmitted in the form of numbers, x, y or z. Adding a value, more of an axis, will the rotation
to each specified axis angle.
For example, with a Angle of 15 : specifying, 1.0 for x and 2.0 for y, will rotate 15 and 30 in the y-axis and the x-axis (final position),
DATA

DATA

Base : This option specifies the offset in either axes x, y, or z, and accept any number as the argument for each field.

DATA

Label : The Label is the name given to the operation, this name can be changed at convenience.

Placement : [(0.00 0.00 1.00);0.00;(0.00 0.00 0.00)] Summary below data. Every feature has a placement that can be controlled through the Data
Properties table. It controls the placement of the part with respect to the coordinate system. NOTE: The placement options do not affect the physical
dimensions of the feature, but merely its position in space!
If you select the title Placement
, a button with tree small points appears, clicking this button ... , you
have access to the options window Tasks_Placement.
DATA

Angle : The Angle argument specifies the angle to be used with the axis option (below). An angle is set here, and the axis that the angle acts
upon is set with the axis option. The feature is rotated by the specified angle, about the specified axis. A usage example might be if you created a
revolution feature as required, but then needed to rotate the whole feature by some amount, in order to allow it to line-up with another pre-existing feature.
DATA

Axis : This option specifies the axis/axes about which the created feature is to be rotated. The exact value of rotation comes from the angle option
(above). This option takes three arguments, which are passed as numbers to either the x, y, or z boxes in the tool. Adding a value to more than one of
the axes will cause the part to be rotated by the angle in each axis. For example, with an angle of 15 set, specifying a value of 1.0 for x, and 2.0 for y
will cause the finished part to be rotated 15 in the x-axis AND 30 in the y-axis.
DATA

Position : This option specifies the base point to which all dimensions refer. This option takes three arguments, which are passed as numbers to
either the x, y, or z boxes in the tool. Adding a value to more than one of the boxes will cause the part to be translated by the number of units along the
corresponding axis.
DATA

PS: The displayed properties can vary, depending on the tool used.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Workbench&oldid=53359"

PartDesign Bearingholder Tutorial I


This tutorial is for the development version of FreeCAD. Compile from here:
http://sourceforge.net/p/free-cad/code/ci/jriegel/dev-assembly/~/tree/

Bearing Holder Tutorial - Finished bearing holder (top)


This is an introductory tutorial to modeling with the PartDesign workbench in FreeCAD. The purposes of the tutorial are to introduce you to two different
workflows for creating a cast part with drafts and fillets. Depending on what other CAD programs you have been using, one or the other might be familiar
to you. As a working example we will be modeling a simple bearing holder.
This is the first part of the tutorial. It will use what might be called the 'single body' workflow, using the (simpler) top part of the holder as an example.
Obviously, to follow through this tutorial you must activate the PartDesign workbench.
You can find my version of the part created by this tutorial [here].

Design data
The holder should be able to hold a diameter 90mm bearing with a width of up to 33mm (e.g. DIN 630 type 2308). The bearing requires a shoulder height
of at least 4.5mm in the holder (and on the shaft). The top part of the holder will be bolted to the bottom with two 12mm bolts. There should be a groove
on both sides of the bearing able to hold a standard shaft sealing ring DIN 3760: 38x55x7 or 40x55x7 on one side, 50x68x8 on the other side.
The holder will be a sand cast with a minimum wall thickness of 5mm, a draft angle of 2 degrees, and a minimum fillet radius of 3mm.

Setting up the skeleton geometry

Bearing holder with the two most important skeleton planes


The idea of skeleton geometry is to capture the basic design dimensions in a single datum feature (e.g. a plane or an axis). When the design dimension
changes, all that needs to be done is to change the skeleton feature. If the model is well built, then all its feature will recompute to reflect the design
change. This reduces the danger that in a complex model, where the basic design dimensions are used in multiple places, you forget to change it
somewhere.
The alternative to skeleton geometry is to have a table of the basic design dimensions that assign a symbolic name to each dimension, and then use the
symbolic name wherever the dimensions is required to build the model. FreeCAD does not allow this approach yet.

Base planes and all datum planes


For the case of the bearing holder, the two most important design dimensions are the distance between the bolts (which limits the size of the bearing
that can be used) and the height of the bolt heads. The dimensions chosen are
Distance between bolts: Radius of bearing (45) + wall thickness (5) plus radius of hole for bolt (7) = 57mm, so the vertical plane will be 57mm
offset from the YZ-plane. To create this datum plane, select the YZ-plane and then choose to create a new datum plane. Enter the offset in the
dialog that opens up
Height of bolt heads: This was chosen as an offset of 28mm from the XZ-plane
For convenience, two further datum planes can be created to reflect the amount of material that must be cut away from the sides of the bearing holder.
They are offset +22 and -22 from the XY-plane.
It is advisable to give clear names to the skeleton geometry. Most of the time, you will want to turn off visibility for datum planes because they clutter up
the screen, and if the planes have self-explanatory names you can just pick them by name instead of from the screen.

The solid geometry

Sketch of the first pad


Now its time to start creating some real geometry. The sketch for the first pad is shown on the right. It is placed on the XY-plane. There are just three
dimensions: The inner radius (22.5mm), the machining allowance (3mm) at the base as an offset to the XZ-plane and the distance from the datum plane
representing the bolt axis (7mm). This means that if you later move the datum plane, the pad will automatically adjust its outer radius. Remember that
before you can use the datum plane for dimensioning, you need to introduce it as external geometry to the sketcher.
You are probably wondering why there is a small straight segment at the bottom of each arc. This segment ensures that there will be a draft angle of 2
degrees on the arcs. This might look like a lot of work for a very small benefit, but many CAD programs (and maybe FreeCAD one day) have tools that
highlight a solid model in different colours and immediately show you all faces where the draft angle is not correct. You don't want that to happen to your
model, especially after putting on a lot of fillets!
When you have done the sketch (which is a bit tricky because of the 2 degree tangential lines), just pad it symmetrically to the sketch plane with a
length of 62mm: 34mm for the bearing, 2x 9mm for the sealing rings, 2x 5mm for the wall thickness.

Sketch of the cut-away at the side of the pad


Next we want to cut away some material where the sealing rings are, because their outer diameter is much less than the bearing's. The easiest way to
create the sketches is to select the sketch of the pad and then choose "Duplicate selection" from the edit menu. You can then remap the sketch to the
side of the pad, and modify it as shown in the picture.
The only two important dimensions in the sketch are 3mm of machining allowance at the bottom, and a inner diameter of 78mm: 68mm for the outer
diameter of the sealing ring + 2x 5mm wall thickness. Since the sealing ring on the other side will only have a diameter of 55mm, the cut-out can be
65mm here.
After you have created the sketch, pocket it up to the datum plane marking the bearing side plus 5mm wall thickness. If you ever want to modify the
holder to be able to hold wider bearings, all you have to do is to change the dimension of these datum planes, and the cut-out depth will follow along.

Sketch of the cut-away inside the pad


To reduce the amount of machining required, we also want to cut away some material inside the holder. Again, duplicating the sketch of the first pad is
convenient. It doesn't even have to be remapped. Again, the only important dimensions are the machining allowance (3mm) and the outer diameters:
84mm for the place where the bearing will be (90mm - 2x machining allowance), 49mm for the smaller sealing ring (55mm - 2x 3mm) and 62mm for the
larger sealing ring.
After creating the sketches, pocket them: Symetrically 28mm for the bearing cut-out (34mm - 2x machining allowance) and one-sided 23mm for the cutouts for the sealing rings: 34mm / 2 for half the bearing width + 9mm for the sealing rings - 3mm machining allowance.

Main geometry of the holder top


Your part should now look like the picture on the right. Note how the different cut-aways combine to create an almost uniform wall thickness, which will
make the casting easier and less liable to have pores.

Sketch with draft where the bolts will be


Now all that remains is to create some material for the bolts to go through. You might be tempted to sketch these as a circle and then pad them, but
this will head you for trouble when you try to put the draft onto them later (I assume that is a weakness of OpenCascade). So to circumvent the
problems, it is better to create a sketch with the draft angle included and then rotate it through 360 degrees.
Here again the skeleton planes come in useful. You will need the bolt axis plane and the bolt head plane as external geometry. Then, create a straight
line for the rotation axis and make sure it is constrained to the bolt axis plane reference. Toggle it to be construction geometry. Then, sketch the rest of
the contour. The important dimensions are the machining allowance at the top and bottom and the radius of 12mm: 7mm for the hole radius + 5mm wall
thickness.

Finished geometry of the holder top (without draft and fillets)


Create a revolution feature from the sketch and then mirror it on the YZ-plane. This is all the solid geometry we need to model. The rest is draft and
fillets.

Applying draft to the side faces

The neutral plane for creating drafts


The next step is to apply drafts on all faces. Its important to consider the location of the neutral plane, that is, the plane which the face is "rotated"
around. If we choose as neutral plane the bottom of the holder, then we will have a problem with the wall thickness in the top part of the holder.
Therefore, we create a datum plane at an offset of 40mm from the XZ plane as a compromise between the top of the holder becoming to thin and the
bottom becoming to wide.

Applying draft to the side faces of the holder


To put draft on a face, select this face and create the draft feature. You can then select more faces to apply the draft on. If you have a large part, it is
advisable to draft only one face at a time. This means that if you change the geometry and a draft fails, only this one feature will fail, whereas if you put
all faces in one draft feature, then the whole feature might fail because of one face failing. For a small part like the bearing holder, its sufficient to create
two draft features: One for the four outside faces, and one for the inside faces.
The dialog will force you to select a neutral plane before completing. You can leave the pull direction empty, in this case it will be normal to the neutral
plane. Don't forget to set the draft angle to 2 degrees.

Filleting the holder

Fillet where the bolts will go


We can now fillet the part. The picture shows the first set of fillets. Start with the small circular fillets and make them 4mm radius. Even though 3mm
would be enough as per specification of the part, a radius of 4mm means that after machining 1mm of the fillet is left, reducing the sharp edge produced
by the machining. The large fillets are 6mm radius to help spread the force from the bolts into the rest of the part. It would be nice to make this radius
even larger, but unfortunately OpenCascade can't handle overlapping fillets yet.
As with drafts, in a complex part you should fillet only one edge at a time to avoid unnecessary failures if the base geometry changes.

Filleting the outside of the holder


The rest of the fillets are simply 3mm radius. Looking at the picture on the right, the two highlighted fillets could actually be filleted with 5mm to achieve
a more uniform wall thickness for the casting. After machining, the minimum wall thickness of 5mm would still be maintained. But again the fact that
OpenCascade can't handle overlapping fillets prevents us from doing this for the inner of the two highlighted fillets.

Filleting the inside of the holder - problematic edge


Filleting the inside of the part presents us with a difficulty that cannot be solved with the current tools in the PartDesign workbench. The highlighted edge
cannot be filleted at all, again because the rounds would overlap. This could be worked around by creating a sweep instead of a fillet, except that sweeps
are not implemented in PartDesign yet. For the time being, we are forced to leave the edge as it is.

The filleted part (except for the impossible edge)


The picture on the right shows the finished part in the state it will be before machining (except for the one edge that is impossible to fillet). You will notice
that one edge that runs around the whole part has been left unfilleted on purpose. This is the edge where the bottom and the top of the mould meet.
Here, no fillet is possible (and none is required anyway).

Machining

Machining the top and bottom of the holder

Machining the inside of the bearing holder


Now we can cut away the material that will be machined off the raw cast part. This is very easy with the skeleton geometry defined. The idea is to create
all machining features (Pockets and Grooves) using datum features only. This means they will be totally independent of the solid geometry of the bearing
holder, which gives us some big advantages:
No matter how you change the solid geometry, the features for the machining can never fail.
You can create the machining geometry before finalizing the solid, which gives you useful visual feedback.
If you move the skeleton datum planes, then both the solid geometry and the machining will adapt automatically.
If you make a mistake in your solid geometry, the machining will still be in the correct position, and very likely the mistake will become glaringly
obvious (e.g. a wall thickness becoming 2mm instead of 5mm). Whereas if you reference the machining to the solid geometry, it will adapt to the
error in the solid and e.g. maintain the 5mm wall thickness, just in the same wrong location as the solid is.
Before starting on the machining geometry, I like to place a datum point in the tree and name it something like "Machining_starts_here". This is useful if
you want to switch between the raw and the machined state of the part because you can see at a glance where to move the insert point to get the raw
state.
To machine the bottom of the holder, just sketch a large rectangle on the XZ plane and pocket it. For the top, sketch a circle on the datum plane defining
the bolt head location, and then mirror the pocket on the YZ plane. In the same way, create a pocket for the hole which the bolt will go through and
mirror it. To machine the inside of the holder, create a sketch on the YZ plane and groove it.

Finished part
Once you have done the machining, you can have a nice visual effect by colouring all the machined faces so that you can see at one glance which parts
are raw casting and which are machined after casting.

Final notes
We have modelled the bearing holder top with the dimensions it will have after casting. To create the casting mould, you need to apply shrinkage to your
part because after casting, when the hot metal cools down, it will shrink by a few percent (depending on the material). Usually it is best to leave the
application of shrinkage to the foundry making the part because they have the required special knowledge. They should also tell you if your part has
problematic areas, e.g. very thick walls suddenly joining to very thin sections without a properly tapered section between them.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Bearingholder_Tutorial_I&oldid=49253"

PartDesign Revolve
Introduction

PartDesign_Revolution

This tool revolves a selected sketch or 2D object about a given axis.


For all the following explanations of this command the example sketch below will be used:

Menu location
PartDesign -> Revolution
Workbenches
PartDesign, Complete
Default shortcut
None
See also
None

Example sketch: A complex sketch with many constraints. Sketch is oriented in


the x-y plane, with x being the horizontal axis, and y being the vertical axis
(shown in image as the two blue lines). Other important things to note about this
sketch is that it are mirrored about the y axis and that the base of it is coincident
with the x axis.

Options
When creating a revolution, the 'revolution parameters' dialogue offers several parameters specifying how the sketch should be revolved.

Axis
This option specifies the axis about which the sketch is to be revolved. Currently,
only the horizontal or vertical sketch axis can be selected here. But in the
Properties table, an arbitrary axis can be defined. Base is a point through which
the axis goes. The axis option itself takes three arguments, which are passed as
numbers to either the x, y, or z boxes in the tool. Adding a value of 1.0 to only one
of the boxes will cause the tool to make the revolution about that axis. Example
revolutions 1, 2 and 3 in the examples section demonstrate scenarios where the
example sketch is revolved about either the x or the y axis. Adding a non-zero
value to more than one of the axes will cause the part to be revolved by a weighted
amount in each axis. e.g. an x value of 1 and a y value of 2 will mean that the
revolution about the y-axis is twice as strong as that about the x. This is fairly
difficult to comprehend, Example Revolution 4 shows an example where more
than one of the boxes has a non-zero value.

Angle
This controls the angle through which the revolution is to be formed, e.g. 360
would be a full, contiguous revolution. The images in the examples section
demonstrate some of the possibilities with specifying different angles. It is not
possible to specify negative angles (use the Reversed option instead) or angles
greater than 360.

Symmetric to plane
The revolution will extend half of the specified angle in both directions from the
sketch plane.

Reversed
The direction of revolution will be reversed.

Examples
Note: All the examples refer to Base, Axis and Placement being edited directly through the feature properties table.

Example revolution 1: In this image the angle has been set to 70, revolution is about the x-axis and there is a yoffset of 100mm. The sketch is the face not shown in the image (i.e. the 'back' face).

Example revolution 2: In this image the angle is 70, revolution is about the y-axis and there is a y-offset of 100mm.

Example revolution 3: In this image the angle is 270, revolution is about the x-axis and there are 0 offsets

Example revolution 4: In this image the angle is 270, revolution is about the x-axis (value 1.00) and the y-axis (value 2.00) and there is a y-offset of 100mm

Useful links
An example with the practice on the forum.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Rev olv e&oldid=54925"

PartDesign MultiTransform
Introduction

PartDesign_MultiTransform

'Make a pattern from combinations of transformations' - This tool takes a set of one or more selected
Menu location
features as its input (the 'originals'), and allows to apply several transformations in sequence to them. For
example, to produce a flange with a double row of holes, the hole (the 'original') is first patterned in a linear PartDesign -> MultiTransform
pattern in the X direction, and then patterned eight times in a polar pattern around the Y axis.

Workbenches
PartDesign, Complete
Default shortcut
None
See also
None

Options

When creating a multitransform feature, the 'multitransform parameters' dialogue


offers two different list views.

Select originals
The list view shows the 'originals', the features that are to be patterned. Clicking
on any feature will add it to the list.

Select transformations
This list can be filled with a combination of the simple transformations mirrored,
linear pattern, polar pattern and scaled. The transformations will be applied
one after the other. The context menu offers the following entries:
Edit
Allows editing the parameters of a transformation in the list (double-clicking will
have the same effect)
Delete
Removes a transformation from the list
Add transformation
Adds a transformation to the list
Move Up/Down
Allows changing the order of transformations in the list

Limitations
A scaled transformation should not be the first in the list
The scaled transformation must have the same number of occurrences as the transformation immediately preceding it in the list
For further limitations, see the linear pattern feature

Examples

The smallest pad was first patterned three times in X direction and then scaled to factor two (so the three occurrences have scaling factor 1.0, 1.5 and
2.0). Then a polar pattern was applied with 8 occurrences.

The pocket was first mirrored on the YZ plane and then patterned with two linear patterns to give a rectangular pattern.

PartDesign LinearPattern
Introduction

PartDesign_LinearPattern

'Make a linear pattern of features' - This tool takes a set of one or more selected features as its input (the
'originals'), and produces with it a second set of features translated in a given direction. For example:

Menu location
PartDesign -> LinearPattern
Workbenches
PartDesign, Complete
Default shortcut
None
See also
None

Options

When creating a linear pattern feature, the 'linear pattern parameters' dialog offers
two different ways of specifying the pattern direction.

Standard axis
One of the standard axes X, Y or Z can be chosen with the radio buttons. The
pattern direction can be reversed by ticking 'Reverse direction'.

Select a face
Pressing the button labeled 'Direction' allows to select a face or an edge from a
pre-existing solid to specify the direction. The pattern direction will be normal to
the face if a face is selected. Note that the button must be pressed again every
time to select a new face or edge.

Select originals
The list view shows the 'originals', the features that are to be patterned. Clicking
on any feature will add it to the list.

Length and Occurrences


Specifies the length to be covered by the pattern, and the total number of pattern
shapes (including the original feature). For example, six occurrences in a length of
150 would give a spacing of 30 between patterns (150 divided by 5, since there
are 5 'gaps' between a total of six occurrences!).

Limitations
Pattern shapes may not overlap one another except for the special case of only two occurrences (original plus one copy)
Any pattern shapes that do not overlap the original's support will be excluded. This ensures that a PartDesign feature always consists of a single,
connected solid
For further limitations, see the mirrored feature
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_LinearPattern&oldid=55148"

PartDesign Pocket
Introduction

PartDesign_Pocket

'Create a pocket with the selected sketch' - This tool takes a selected sketch as its input, and produces with it a
pock et. A pocket being essentially an extrusion of a sketch that subtracts from the geometry it protrudes into. For Menu location
example, if a sketch were made simply of one circle on one face of a cube, then the pocket formed by that sketch PartDesign -> Pocket
would manifest as a hole 'drilled' into the cube:

Workbenches
PartDesign, Complete
Default shortcut
None
See also
None

Options
When creating a pocket, the 'pocket parameters' dialogue offers four different
ways of specifying the length (depth) to which the pocket will be extruded

Dimension
Enter a numeric value for the depth of the pocket. The default direction for
extrusion is into the support. Extrusions occur normal to the defining sketch plane.
Negative dimensions are not possible.

To first
The pocket will extrude up to the first face of the support in the extrusion direction.
In other words, it will cut through all material until it reaches an empty space.

Through all
The pocket will cut through all material in the extrusion direction. With the option
Symmetric to plane the pad will cut through all material in both directions.

Up to face
The pocket will extrude up to a face in the support that can be chosen by clicking
on it.

Limitations
Use the type Dimension or Through All wherever possible because the other types sometimes give trouble when they are being patterned
Otherwise, the pocket feature has the same limitations as the pad feature.

Useful links
An example with the practice on the forum.

PartDesign Scaled
Introduction

PartDesign_Scaled

'Scale features' - This tool takes a set of one or more selected features as its input (the 'originals'), and scales them
by a given factor. Since the scaling takes place around the centre of gravity of the selected features, they usually Menu location
disappear inside the scaled versions. Therefore, normally it is only useful to use scaling as part of the MultiTransform PartDesign -> Scaled
feature.

Workbenches
PartDesign, Complete
Default shortcut
None
See also
None

Options

When creating a scaled feature, the 'scaled


parameters' dialogue offers the following options:

Select originals
The list view shows the 'originals', the features that
are to be scaled. Clicking on any feature will add it
to the list.

Factor and Occurrences


Specifies the maximum factor which the features
are to be scaled to, and the total number of scaled
shapes (including the original feature).

Limitations
Scaling always happens with the centre of gravity of the feature as the base point.
See linear pattern feature for other limitations
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Scaled&oldid=55233"

PartDesign Pad
PartDesign_Pad

Introduction

'Pad a selected sketch' - This tool takes a selected sketch as its input (the 'defining sketch'), and produces with it a Menu location
'pad'. A pad is essentially an extrusion of a sketch. For example, if a sketch were made of two concentric circles, PartDesign -> Pad
and the pad tool were subsequently used on this sketch, the result would be a cylinder:

Workbenches
PartDesign, Complete
Default shortcut
None
See also
None

Options
When creating a pad, the 'pad parameters' dialogue offers five different ways of specifying the length to which the pad will be extruded

Dimension
Enter a numeric value for the length of the pad. The default direction for extrusion
is away (outside of) the support, but it can be changed by ticking the Reversed
option. Extrusions occur normal to the defining sketch plane. With the option
Symmetric to plane the pad will extend half of the given length to either side of
the sketch plane. Negative dimensions are not possible. Use the Reversed
option instead.

Two dimensions
This allows to enter a second length in which the pad should extend in the
opposite direction (into the support). Again can be changed by ticking the
Reversed option.

To last
The pad will extrude up to the last face of the support in the extrusion direction. If
there is no support, an error message will appear.

To first
The pad will extrude up to the first face of the support in the extrusion direction. If
there is no support, an error message will appear.

Up to face
The pad will extrude up to a face in the support that can be chosen by clicking on
it. If there is no support, no selections will be accepted.

Limitations
The algorithm used for To First and To Last is:

Create a line through the centre of gravity of the sketch


Find all faces of the support cut by this line
Choose the face where the intersection point is nearest/furthest from the sketch
This means that the face that is found might not always be what you expected. If you run into this problem, use the Up to face type instead, and
pick the face you want.
For the very special case of extrusion to a concave surface, where the sketch is larger than this surface, extrusion will fail. This is a unresolved
bug.
There is no automatic cleanup, e.g. of adjacent planar surfaces into a single surface. You can fix this manually in the Part workbench with Refine
shape.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Pad&oldid=54839"

PartDesign project
Here the project plan for the PartDesign as part of the Development roadmap.

Purpose and principles


This is a software development project aimed to implement a Part Design capabilities. Its about implementing some core features into the CAD
modules of FreeCAD, Part, PartDesign and Assembly.
The development steps are planed here and tracked in the Issue tracking system to get a well formed change log: Issue tracker

Outcome
Aim of the project is to enable FreeCAD accomplish a design task like the one at the right.

This will be achived by using the Sketcher and the PartDesign to design special part and Part to load standard part as STEP (like the linear bearing).
The Assembly puts it all together with constrains.
Also an important outcome is the Feature editing methodology. Which gives the user an intuitive approach to instantiating and editing Features. This
is importand for all other Modules and Workbenches to be come, to comply to a consistent user interface!

Sketcher
A parametric sketcher with a geometrical constraints solver, for more details see the Sketcher project.

PartDesign
Body feature
Since a history based modeling can have a lot of steps leading to the final shape a bracket is needed. Thats the Body, which holds the final outcome of
the modeling and acts as a group to all the features of the history tree.

Pad feature

A Pad feature extrude a Sketch (or any Part2DObject) in its normal direction. Always guaranty a solid, or fail.
Pocket feature
Imprint a sketch in a base solid either defined by depth or "Up to last | Up to first). Also guaranty a solid.
Bore feature
Very good bore parameter definition from the NaroCad specification:

NaroCAD Bore definitions

Pattern
Replicate one of the above features
RectangularPattern

Replicate one of the above features along an x,y pattern


CircularPattern

Replicate one of the above features along a pattern in polar coordinates


ScriptedPattern

Replicate one of the above features according to a general rule provided in form of a script.

Brainstorming
What others do
SolidWorks examples

Pattern Implementation
The Pattern feature class can be implemented as a tabular pattern and serve as a base class for the Rectangular, Circular and Scripted Pattern features.
These derived classes will only have to fill in the repetitions table of the base class.
Each line of the repetitions table of the base Pattern class has to hold at least a transformation matrix to applied to the Placement of the original feature
to be replicated. Additionally we could have optional transformation rules like for example manipulating some parameter value the feature to be replicated
(e.g. in order to create a pattern of holes with varying radius).

Organizing
Modeling objects hierarchy
This UML chart shows the planed object hierarchy and its relationships. Yellow is a abstract base class, blue implemented and grey is planed.

Next actions
Next actions are defined in the Roadmap entry for PartDesign:

Body
Since the parametric/associative nature of the PartDesign we need finally a "Body" which groups and organizes a construction history. The Body itself
holds the end result as a shape and has grouped as children the PartDesign features. It also defines the actual head of the modeling history. Its also
related to the Assembly project since its the building block for products and compounds.

Additional features
The Pad and Pocket features are the first teaser for the PartDesign. There is still work to do especially the visibility control and the visual manipulators.
But then additional features are needed.
Pattern
Pattern feature which repeatingly apply a Pad or Pocket feature according to a circular or rectangular patter. An Example in IronCAD.
Done [jrheinlaender]
BoreHole
Classical bore hole with all parameters for threading and counter bore....
Sweep
Sweeps a Sketch along a curve and create a Solid.
Revolve
Rotate a Sketch along one of its Axis and a certain angle.
Done [jrheinlaender et al.]

TODO List
1. Fillet/Chamfer Part
1a. Apply fillet/chamfer operation to different selection types (face/faces pair/whole body)
2. Pad Tool
2a. Create 'up to next' mode DONE [mrlukeparry]
2b. Create 'up to surface/face' mode [mrlukeparry]
2c. Create draft property for pad DONE [mrlukeparry]
2d. If pad is selected on face automatically create a sketch?
2e. Create 'midplane' mode DONE [jrheinlaender]
3. Pocket Tool
3a. Create 'up to first', 'up to last', 'through all', 'up to surface/face' modes DONE [jrheinlaender]
3b. If pocket is selected on face automatically create a sketch?
4. Revolution Part
4a. Allow a generic line segment/axis to be used for reference
4b. Create 'midplane' mode DONE [jrheinlaender]
5. Hole Feature
6. Pattern Feature DONE [jrheinlaender]
7. Sweep Feature
8. Body Feature
9. Reference Geometry
9a. Plane
10. Mirror Tool DONE [jrheinlaender]
11. Copy feature Tool
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_proj ect&oldid=42295"

PartDesign Groove
Introduction

PartDesign_Groove

This tool revolves a selected sketch or 2D object about a given axis, cutting out material from the support. For
Menu
example, the picture shows a groove cut out of a shaft.

location
PartDesign -> Groove
Workbenches
PartDesign, Complete
Default shortcut
None
See also
None

Options

When creating a groove, the 'groove parameters' dialogue offers several parameters specifying how the sketch should be revolved. They have exactly the
same meaning as for the revolution feature.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Groov e&oldid=54956"

PartDesign WizardShaft
Introduction

PartDesign
WizardShaft

This tool allows you to create a shaft from a table of values, and to analyse forces and moments. You can start the
wizard from the Part Design menu or by typing
Menu

location
Part Design Shaft design
Gui.runCommand('PartDesign_WizardShaft')
wizard...
into the Python console of FreeCAD. The wizard will start and show a default table, the corresponding shaft part and Workbenches
force/moment graphs.
PartDesign, Complete
Default shortcut
None
See also
None

The top of the window is taken up by the table. It is organized into numbered columns which correspond to segments of the shaft. A shaft segment is
characterized by having certain length and diameter. The main window shows two tabs. One is the shaft part itself (a revolution feature), shown in the
image above. The second tab shows graphs of the shear forces and moments created by the loads defined in the table.

Prerequisites
The shaft design wizard depends on the matplotlib library to create and display the graphs of shear force and bending moment. On Debian/Ubuntubased systems, it is available through the python-matplotlib package.

Parameters
For each shaft segment, the following parameters can be defined
Length of the segment
Diameter of the segment
Load type. Note that you have to click on the desired entry in the menu after scrolling to it, otherwise it will not be selected!
None: No load
Fixed: The end of the shaft is fixed (e.g. welded to another part). This load type can only be defined for the first or last segment.
Static: There is a static load on this shaft segment
Load on the shaft segment
Location where the load is applied to the segment. The location is counted from the left-hand edge of the segment
(Other rows and load types exist but no functionality has been implemented yet)

Menus
To add a new shaft segment, right-click into the empty space to the right of the table, and choose "Add column".

Limitations
It is not possible to have adjacent shaft segments with the same diameter.

Planned functionality
Table-driven chamfers and rounds on the shaft edges
Recognize a previously created shaft wizard part and initialize the table values from it
Shaft stress calculation
Visualization of loads on the shaft (can use the same functionality as for FEM module)
Definition of loads as a Document Object (can use the same functionality as for FEM module)
Material database
Allow loads in the Z-direction as well as in Y-direction (requires definition of loads as a Document Object, otherwise the table will become very
long)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_WizardShaft&oldid=82251"

PartDesign Mirrored
Introduction

PartDesign_Mirrored

'Mirror features' - This tool takes a set of one selected features as its input (the 'original'), and produces with it a
Menu
second set of features mirrored on a plane. For example:

location
PartDesign -> Mirrored
Workbenches
PartDesign, Complete
Default shortcut
None
See also
None

Use

When creating a mirrored feature, the 'Mirrored parameters' dialogue offers two
different ways of specifying the mirror plane.

Standard plane
One of the standard planes XY, YZ or XZ can be chosen with the radio buttons.

Select a face
Pressing the button labeled 'Plane' allows to select a face from a pre-existing solid
as the mirror plane. Note that the button must be pressed again every time to
select a new face.

Preview
The mirror result can be previewed in real time before clicking OK by checking
"Update view".

Limitations
Currently, only the last feature in the feature tree can be chosen as the 'original'
Therefore, it is not possible to choose more than one feature to be mirrored
Therefore, it is not possible to select more features to add to the list view of 'originals'
Once the Mirrored feature has been started or been completed, it is not possible to replace the original feature for a different one.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Mirrored&oldid=55107"

PartDesign Draft
PartDesign_Draft

Description
This tool creates angular draft on the selected faces of an object. A new separate Draft entry (followed by a
sequential number if there are already existing drafts in the document) is created in the Project tree.

Select one or more faces


on the object before
starting the tool. Here, 2
faces have been selected. Usage

Showing Draft Parameter


in TaskPanel.

Select one or more faces on an object, then start the tool either
by clicking its icon or going into the menu.
In Draft Parameters on the TaskPanel, set the required
parameters and/or options as described below.
Click OK to validate.
To edit the draft after the function has been validated, either
double-click on the Draft label in the Project tree, or right-click on
it and select Edit Draft.

Parameters and Options


Add Face / Remove Face
2 faces have been added,
and a 10 deg. draft
applied. The bottom plane
has remained
dimensionally stable,
while the draft has made
the top plane smaller.

Click Add Face or Remove Face, then select a single face to update
the list of active faces. Repeat as needed.
Draft Angle
Set the Draft Angle by entering a value or by clicking on the up/down
arrows. The applied draft angle is shown in real time.
Neutral Plane
Click Neutral Plane, then select the plane that must not change
dimensionally. The change is made in real time.

The Neutral Plane has


been changed to the Top
Surface. Now, the top
plane has stayed
dimensionally stable,
while the draft has made
the bottom plane larger.

Pull Direction
Click Pull Direction, then select an edge. Pull Direction is only
effective if the Neutral Plane has been set. Results can be
unpredictable.
Reverse Pull Direction
Checking Reverse Pull Direction will toggle the draft between positive
and negative angles.

Special Cases
Pull direction is set to the
lower right edge, resulting
in the draft pulling to the
left.

Checking the Reverse

The Draft tool will only function on faces that are normal to each other.
If there are any tangential faces attached to the face you wish to apply
draft to, it will fail. A common cause of failure is attempting to apply
draft to a face that already has a fillet or chamfer applied to it. In this
case, remove the tangential surface, apply the draft as need, then reapply the fillet or chamfer.

Menu location
Part Design -> Draft
Workbenches
Part Design
Default shortcut
None
See also
None

Direction box has applied


an inward draft rather than
outward.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Draft&oldid=57525"

PartDesign Fillet
PartDesign Fillet

Description
This tool creates fillets (rounds) on the selected edges of an object. A new separate Fillet entry (followed by a
sequential number if there are already existing fillets in the document) is created in the Project tree.

Menu location
PartDesign Fillet
Workbenches
PartDesign, Complete
Default shortcut
None
See also
Part Fillet

Select edges on the object


before starting the tool.

Set the fillet radius in the Fillet


parameters.

A Fillet object is added in the


Project tree.
Usage
Select a single or multiple edges on an object, then start the tool either by clicking its icon or going into the menu.
In Fillet parameters in the TaskPanel, set the fillet radius either by entering the value, or by clicking on the up/down arrows. The applied fillet is
shown in real time.
Click OK to validate.
For a chain of edges tangential to one another, one single edge can be selected; the fillet will propagate along the chain.
To edit the fillet after the function has been validated, either double-click on the Fillet label in the Project tree, or right-click on it and select Edit
Fillet.
PartDesign Fillet VS. Part Fillet
The PartDesign Fillet is not to be confused with its Part workbench counterpart. Although they share the same icon, they are not the same, and
are not used the same way. Here is how they differ from each other:
The PartDesign Fillet is parametric. After a fillet has been applied, its radius can be edited; this is not possible with the Part Fillet.
Edges must be selected on an object before activating the PartDesign Fillet. WIth the Part Fillet, the tool can be started, then a solid is selected,
then edges.
The PartDesign Fillet creates a separate Fillet entry (followed by a sequential number if there are already existing fillets) in the Project tree. The
Part Fillet becomes the parent of the object it was applied to.
The PartDesign Fillet offers a live preview of the fillet applied to the object before validating the function.
The Part Fillet supports variable radii (with a start radius and an end radius). The PartDesign fillet doesn't.

Scripting
The tool

Fillet can be used in a macro, and, from the Python console using the following function :

Box = Box.makeFillet(3,[Box.Edges[0]]) # 1 Fillet


Box = Box.makeFillet(3,[Box.Edges[1],Box.Edges[2],Box.Edges[3],Box.Edges[4]]) # for several Fillets
3 = radius
Box.Edges[2] = Edge with its number
Example :
import PartDesign
from FreeCAD import Base
Box = Part.makeBox(10,10,10)
Box = Box.makeFillet(3,[Box.Edges[0]]) # pour 1 Fillet
Box = Box.makeFillet(3,[Box.Edges[1],Box.Edges[2],Box.Edges[3],Box.Edges[4]]) # for several Fillets
Part.show(Box)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Fillet&oldid=55041"

PartDesign Chamfer
PartDesign
Chamfer

Description

Slection des artes


avant de dmarrer la
commande.

Usage
1.
2.
3.

PartDesign Chamfer VS. Part Chamfer


Rglage de la dimension
du chanfrein dans les
paramtres de chanfrein.

Un lment Chamfer est


ajout dans
l'arborescence Projet.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Chamfer&oldid=57498"

Menu location
Part Design Chamfer
Workbenches
PartDesign, Complete
Default shortcut
None
See also
Chamfer Part

PartDesign PolarPattern
Introduction

PartDesign_PolarPattern

'Make a polar pattern of features' - This tool takes a set of one or more selected features as its input (the
'originals'), and produces with it a second set of features rotated around a given axis. For example:

Menu location
PartDesign -> PolarPattern
Workbenches
PartDesign, Complete
Default shortcut
None
See also
None

Options

When creating a polar pattern feature, the 'polar pattern parameters' dialogue
offers two different ways of specifying the pattern rotation axis.

Standard axis
One of the standard axes X, Y or Z can be chosen with the radio buttons. The
pattern direction can be reversed by ticking 'Reverse direction'.

Select a face
Pressing the button labeled 'Direction' allows to select an edge from a pre-existing
solid to specify the direction. Note that the button must be pressed again every
time to select a new edge.

Select originals
The list view shows the 'originals', the features that are to be patterned. Clicking on
any feature will add it to the list.

Angle and Occurrences


Specifies the angle to be covered by the pattern, and the total number of pattern
shapes (including the original feature). For example, four occurrences in an angle
of 180 degrees would give a spacing of 60 degrees between patterns. There is
one exception: If the angle is 360 degrees, since first and last occurrence are
identical, four occurrences will be spaced 90 degrees apart.

Limitations
See linear pattern feature

Examples

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_PolarPattern&oldid=55189"

PartDesign InvoluteGear
32px PartDesign
Involute gear

This tool allows you to create a gear.

Original
file:
https://github.com/FreeCAD/FreeCAD_sf_master/blob/master/src/Mod/PartDesign/InvoluteGearFeature.py Menu
Recent
forum
f=22&t=5977&p=47725&hilit=involutegear#p47725

location
Part
Design
Involute
link: http://forum.freecadweb.org/viewtopic.php?
gear...
Workbenches
PartDesign
Default shortcut
None
See also
None

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PartDesign_Inv oluteGear&oldid=84786"

Constraint Vertical
Description

Constraint
Vertical

Creates a vertical constraint to the selected lines or polylines elements. More than one object can be selected.
Usage
See Constraint Horizontal

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_Vertical&oldid=56718"

Menu location
Sketch Sketcher
constraints Constrain
vertically
Workbenches
Sketcher, PartDesign
Default shortcut
None
See also
Constraint Horizontal

Constraint Symmetric
Description

Constraint
Symmetric

The symmetrical constraint constrains two selected points to be symmetrical around a given line, i.e., both selected
points are constrained to lie on a normal to the line through both points and are constrained to be equidistant from
Menu
the line. Alternatively it can constrain two points to be symmetric with respect to a third one.
Operation

location
Sketch Sketcher
constraints Constrain
symmetrical
Workbenches
Sketcher, PartDesign
Default shortcut
None
See also
Constraint Parallel

Select two points (vertexes) in the sketch and a line in the sketch. The selected points and the line will be dark green.

Click on the SymmetricalConstraint icon


in the Sketcher toolbar or select the Constrain Symmetrical menu item from the Sketcher Constraints sub
menu of the Sketcher (or Part Design) menu item. This will apply the constraint to the selected items.

This is a geometric constraint and has no editable parameters.


Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_Symmetric&oldid=57132"

Constraint InternalAngle
Description

Constraint
InternalAngle

This tool constrains the angle between two selected lines in a sketch to be a specified value. By default, the internal
angle, the smaller of the angles formed at the intersection of two lines (or their extensions) is constrained.
Menu
If a single line is selected, the angle is constrained relative to the horizontal axis of the selected sketcher plane

location
Sketch Sketcher
Operation
constraints Constrain
angle
Select any two lines in the sketch by clicking on them in sequence. They will change colour to dark green when
Workbenches
selected. The direction of the line form the first point created to the end point is significant in calculation of the angle
between the lines.
Sketcher, PartDesign
Default shortcut
A
See also
Constraint Length,
Constraint Perpendicular

Then click on the ConstraintAngle icon( ) in the Sketcher or Part Design toolbar or select the ConstrainAngle menu item from the Sketcher constraints
sub menu of either the Sketcher (Sketcher workbench) or Part Design (Part Design workbench)menu item to add the constraint.
The constraint is initially set to the current internal angle between the lines and the Constraint is added to the Tasks tab in the Combo View panel.

Doubleclicking on the Constraint in the Tasks tab will bring up a pop-up dialog box in which this value may be edited to set it to a desired value.
Alternatively, the datum text in the 3D view may be double clicked to bring up the pop-up dialog to set the value.

The value can be set to values greater than 180 (or even 360), in which case it becomes a constraint on the external angle and the angle is interpreted
as modulo 360 degrees.
The absolute mode is invoked by only selecting one line before applying the constraint.

Applying the constraint, the angle is constrained relative to the horizontal axis of the selected sketch plane.

Selecting the second line which was drawn from the upper right to lower left.

And applying the constraint as before,

the line is now constrained to have a value relative to the direction of the horizontal axis in the clockwise direction (angle values are restricted to 180
degrees anticlockwise or clockwise).
As before by double clicking on the constraint in either the Tasks tab of the Combo view or on the constraint in the 3D view will allow editing of the value
of the constrained angle.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_InternalAngle&oldid=56934"

Constraint Radius
Description
This constraint constrains the value of the radius of a circle or arc to have a specific value. Only one arc or circle can
be constrained at a time.

Operation

Constraint
Radius
Menu location
Sketch Sketcher
constraints Constrain
radius
Workbenches
Sketcher, PartDesign
Default shortcut
None
See also
Constraint Distance,
Constraint Horizontal,
Constraint Vertical

Select an arc or circle in the sketch by clicking on is ( turns dark green to indicate selection).

Apply the constraint by clicking on the Constrain Radius icon


in the Sketcher toolbar or selecting the Constrain radius menu item from the Sketcher
constraints sub menu of the the Sketcher (or Part Design) menu item (depending upon which workbench is selected).

The radius is constrained to have its current value when the constraint is applied.
To change the constraint value either double click on the constraint in the 3D display (turning red indicates the constraint is currently selected) or by
double clicking on the constraint in the Constraints panel of the Tasks tab of the Combo View.
This will bring up a pop-up window.

Enter the desired value for the radius into the pop-up window and click OK to set the value of the constraint.

The constraint value is set to the value entered in the pop-up window.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_Radius&oldid=56783"

Constraint Perpendicular
Description
The Constrain perpendicular constraint forces two selected lines or line segments in the sketch to be perpendicular
to each other
Operation
The sketch below has two lines at a random angle.

Constraint
Perpendicular
Menu location
Sketch Sketcher
constraints Constrain
perpendicular
Workbenches
Sketcher, PartDesign
Default shortcut
N
See also
Constraint Angle

Select the two line segments you require to be perpendicular

then click the Constrain Perpendicular icon


in the Sketcher toolbar or select the Constrain Perpendicular menu item from the Sketcher constraints
sub menu of the Sketcher or Part Design menus (depending upon whether the Sketcher or Part Design workbench is selected) to apply the constraint to
the selected lines.

The lines are constrained to be perpendicular.


Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_Perpendicular&oldid=56888"

Constraint Tangent
Description

Constraint
Tangent

The Constraint tangent tool constrains a selected line (or an extension of it beyond its endpoints) to be tangential to
a selected line, circle or arc in the sketch. Where the selected entities are two line segments, they are constrained
Menu
to lie on the same line, i.e. be collinear.
Operation
Curve and a line.

location
Sketch Sketcher
constraints Constrain
tangent
Workbenches
Sketcher, PartDesign
Default shortcut
None
See also
Constraint point on object

Select the line and a circle in the sketch by clicking on them (highlighted in dark green).

Apply the Constraint tangent by either clicking on the Constrain tangent icon
in the Sketcher Constraints toolbar or selecting the Constrain Tangent
menu item from the Sketcher constraints sub-menu of the Sketcher menu (or the Part Design menu if the Part Design workbench is selected rather than
the Sketcher workbench.

The line (or an extension of it beyond its endpoints) will be constrained to be tangent to the circle or arc by altering any or all of the line slope, the circle
or arc radius or center point of the circle or arc depending upon what other constraints are operational in the sketch.
The tangent constraint can also operate on two selected points or a selected point and an edge(line)as illustrated in the following sequence.

First select two points (vertices) at the ends of an arc and a line.

Apply the Tangent Constraint as before.

The line is constrained to be tangent to the arc and the two points become coincident with the straight line continuing the arc. ( If applied to two straight
lines, they are forced to be collinear).
Similarly by selecting a point at the end of an arc and a line,

and applying the Tangent Constraint as before

the line is forced to be tangent to the arc at the point selected on the curve.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_Tangent&oldid=56970"

Constraint VerticalDistance
Description
Fixes the vertical distance between 2 points or line ends. If only one item is selected, the distance is set to the
origin.
Usage
1. Pick one or two points
2. Activate the constraint

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_VerticalDistance&oldid=56617"

Constraint
VerticalDistance
Menu location
Sketch Sketcher
geometries Constrain
vertical distance
Workbenches
Sketcher, PartDesign
Default shortcut
None
See also
Constraint
HorizontalDistance,
Constraint Length

Constraint Lock
"Create a lock constraint on the selected item"

Description

Sketcher
ConstrainLock

Menu location
Sketch Sketcher
NOTE: It is advised that this tool be exclusively used on points for the time-being:
constraints Constrain lock
Owing to the fact that FreeCAD is still under development - this tool exhibits strange behaviour when it attempts to
Workbenches
'lock' anything other than a point. For example (as of V0.12 R4802), when locking a circle by its circumferential line
rather than its centre point, a horizontal constraint and a vertical constraint appear in the constraints dialogue, but Sketcher, PartDesign
they are both of value zero and do not appear in the graphics window.
Default shortcut
None
Operation
See also
1. Firstly it is necessary to highlight an item you wish to constrain. For reasons alluded-to above it is wise to Constraint Coincident
This constraint tool attempts to fully constrain any selected item.

only highlight a point.

2. Highlighting of a drawing item is achieved by moving the mouse over the item and clicking the left-mouse-button. A highlighted item will change
colour to green.

3. Once an item is highlighted, left-clicking on the lock constraint serves to lock the highlighted item in-place. This usually manifests as two
constraints: a horizontal distance constraint from the drawing axis origin, and a vertical constraint from the drawing axis origin. These are set by
default to the current co-ordinates of the point.

4. The vertical and horizontal constraints forming the lock can be edited by double clicking on the appropriate constraint to be edited either in the
drawing itself or in the Constraint tab of the Combo View pane. This will open a dialog box to edit the constraint. Clicking on the horizontal
constraint component produces:

.
5. Enter the desired value into the dialog box and click OK.

6. The new value of the constraint is applied to the drawing.

7. The vertical constraint may be similarly edited to constrain the point to the desired location.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_Lock&oldid=56493"

Constraint Parallel
Description

Constraint
Parallel

The Constrain Parallel constraint forces two selected straight lines or edges to be parallel to each other.
Operation
The sketch contains two randomly oriented lines.

Menu location
Sketch Sketcher
constraints Constrain
parallel
Workbenches
Sketcher, PartDesign
Default shortcut
None
See also
Constraint Vertical,
Constraint Horizontal

Select both lines by clicking successively on each of them.

Apply the Constrain Parallel constraint by selecting the Constrain Parallel icon
from the Sketcher constraints toolbar or by selecting the Constraint
Parallel menu item from the Sketcher constraints sub menu of the Sketcher (Sketcher workbench selected) or Part Design (Part Design workbench
selected) menu item.

The selected lines are forced to be parallel to each other. Changing the orientation of one line will change the orientation of the other to be the same.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_Parallel&oldid=56919"

Constraint Horizontal
Description
The Horizontal Constraint forces a selected line or lines in the image to be parallel to the horizontal axis of the
sketch.
Operation

Constraint
Horizontal
Menu location
Sketch Sketcher
constraints Constrain
horizontally
Workbenches
Sketcher, PartDesign
Default shortcut
None
See also
Constraint Vertical

Select a line in the sketch by clicking on it.

The line turns dark green.

Apply the Horizontal Constraint by clicking on the Horizontal Constraint icon


in the Sketcher Constraints toolbar or by selecting the Constrain
horizontally menu item in the Sketcher constraints sub menu of the Sketcher menu item in the Sketcher work bench (or the Part Design menu item of
the Part Design work bench). The selected line is constrained to be parallel to the horizontal axis of the sketch.

Multiple lines may be selected,

and then applying the constraint as described above, they are constrained to be parallel to the sketch horizontal axis.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_Horizontal&oldid=56687"

Constraint PointOnPoint
"Create a coincident constraint on the selected item"
Description

Constraint
PointOnPoint

This constraint tool takes two points as its argument and serves to make the two points coincident. (Meaning to Menu location
make them as-one-point). In practical terms this constraint tool is useful when there is a break in a profile for Sketch Sketcher
example - where two lines end near each other and need to be joined - a coincident constraint on their end-points will constraints Constrain
close the gap.

coincident
Workbenches
Usage
Sketcher, PartDesign
As stated above, this tool takes two arguments - both are points.
Default shortcut
1. Firstly it is necessary to highlight two distinct points. (Note this will not work if, for example, you attempt to None
select the start and end point of the same line).
2. Highlighting of a drawing item is achieved by moving the mouse over the item and clicking the left-mouse- See also
button.
Constraint Lock,
3. A highlighted item will change colour to green.
Constraint Point onto
4. Subsequent items can be highlighted by repeating the above procedure(s) NOTE: There is no-need to holdObject
down any special key like Ctrl to achieve multiple item selection in a drawing.
5. Once you have two points highlighted, left-clicking on the 'PointOnPoint' constraint will cause the two points
to become coincident and be replaced by a single point.
NOTE: In order to make two points coincident, FreeCAD must necessarily move one, or both, of the original points.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_PointOnPoint&oldid=55702"

Constraint Length
Description

Constraint
Length

Constraint Length constrains the length of a line, the perpendicular distance between a point and a line or the
distance between two points to have a specified value.

Menu location
Sketch Sketcher
Hint
constraints Constrain
If applicable please consider using the Horizontal Distance or Vertical Distance constraints instead. These distance
constraints are more robust and faster to calculate than the here documented length constraint.
Workbenches
Sketcher, PartDesign
Operation
Default shortcut
Select a line in the sketch,
None
See also
Constraint
HorizontalDistance,
Constraint
VerticalDistance

by clicking on the line (it turns dark green).

Apply the Length Constraint by selecting the icon


from the Sketcher Constraints toolbar or selecting the Constrain distance menu item from the
Sketcher Constraints sub-menu of the Sketcher menu item in the Sketcher workbench (or Part Design in the Part Design workbench).

The length of the line is constrained to its current value.Double clicking on the constraint in the 3D view or in the Tasks tab of the Combo View will bring
up a dialog box to allow the constraint value to be edited.

Enter the required value and click OK to set the constraint length.

The Length Constraint also constrains the distance between a line and a point.

Select the line and a point in the sketch,

then apply the constraint as before.


The perpendicular distance between the point and the line is constrained to its current value. this may be edited as described above to set the constraint
to a desired value.

The constraint may also be applied to two points, selected here at either end of a poly-line.

Applying the constraint as before, the distance between the two selected points is constrained. As described above it may be edited to set a desired
value.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_Length&oldid=56743"

Constraint PointOnObject
Description

Constraint
PointOnObject

Usage

Menu location
Sketch Sketcher
constraints Constrain
point onto object
Workbenches
Sketcher, PartDesign
Default shortcut
None
See also
Constraint Coincident
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_PointOnObj ect&oldid=55737"

Constraint HorizontalDistance
Description
Fixes the horizontal distance between 2 points or line ends. If only one item is selected, the distance is set to the
origin.

Usage
1. Pick one or two points
2. Activate the constraint
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_HorizontalDistance&oldid=56679"

Constraint
HorizontalDistance
Menu location
Sketch Sketcher
constraints Constrain
horizontal distance
Workbenches
Sketcher, PartDesign
Default shortcut
None
See also
Constraint Length,
Constraint
VerticalDistance

Constraint EqualLength
Constraint
EqualLength

Description

The Constrain Equal constraint forces two or more line segments in a line , poly-line or rectangle to have equal
length. If applied to arcs or circles the radii are constrained to be equal. It cannot be applied to geometry primitives
Menu
which are not of the same type (e.g. line segments and arcs).
Operation
The example sketch below contains a number of sketch primitives ( line,poly-line, rectangle, arc and circle).

location
Sketch Sketcher
constraints Constrain
equal
Workbenches
Sketcher, PartDesign
Default shortcut
None
See also
Constraint Radius

Select two or more line segments (e.g. line and one side of the rectangle).

Click on the Constrain Equal icon


in the Sketcher toolbar (in either the Sketcher or Part Design workbenches) or select the Constrain Equal menu
item from the Sketcher constraints sub menu item in either the Sketch or Part Design menu item depending upon which workbench is selected
(Sketcher or Part Design) to apply the constraint to the selected items.

Now select the arc and the circle in the sketch.

and apply the Constrain Equal

constraint as before.

Now select the line segment, all segments of the poly-line and one of the remaining unconstrained sides of the rectangle

and apply the Constrain Equal

constraint as before.

Select the line segment and the arc

and apply the Constrain Equal


constraint as before. A pop-up message indicates that the constrained items have to be of the same geometrical type
(lines of zero curvature or lines of non-zero curvature).

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Constraint_EqualLength&oldid=57098"

Mesh Module
(Redirected from Mesh Module)
The Mesh Workbench handles triangle meshes. Meshes are a special type of 3D object, composed of triangles conected by their edges and their
corners (also called vertices).

An example of a mesh object


Many 3D applications use meshes as their primary type of 3D object, like sketchup, blender, maya or 3d studio max. Since meshes are very simple
objects, containing only vertices (points), edges and (triangular) faces, they are very easy to create, modify, subdivide, stretch, and can easily be passed
from one application to another without any loss. Besides, since they contain very simple data, 3D applications can usually manage very large quantities
of them without any problem. For those reasons, meshes are often the 3D object type of choice for applications dealing with movies, animation, and
image creation.
In the field of engineering, however, meshes present one big limitation: They are very dumb objects, only composed of points,lines and faces. They are
only made of surfaces, and have no mass information, so they don't behave as solids. In a mesh there is no automatic way to know if a point is inside or
outside the object. This means that all solid-based operations, such as addition or subtraction, are always a bit difficult to perform on meshes, and return
errors often.
In FreeCAD, since it is an engineering application, we would obviously prefer to work with more intelligent types of 3D objects, that can carry more
informations, such as mass, solid behaviour, or even custom parameters. The mesh module was first created to serve as a testbed, but to be able to
read, manipulate and convert meshes is also highly important for FreeCAD. Very often, in your workflow, you will receive 3D data in mesh format. You
will need to handle that data, analyse it to detect errors or other problems that prevent converting them to more intelligent objects, and finally, convert
them to more intelligent objects, handled by the Part Module.

Using the mesh module


The mesh module has currently a very simple interface, all its functions are grouped in the Mesh menu entry. The most important operations you can
currently do with meshes are:
Import meshes in several file formats
Export meshes in several file formats
Convert Part objects into meshes
Analyse curvature, faces, and check if a mesh can be safely converted into a solid
Flip mesh normals
Close holes in meshes
Remove faces of meshes
Union, subtract and intersect meshes
Create mesh primitives, like cubes, spheres, cones or cylinders
Cut meshes along a line
These are only some of the basic operations currently present in the Mesh module interface. But the FreeCAD meshes can also be handled in many
more ways by scripting.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Mesh_Workbench&oldid=45560"

Mesh to Part
Converting Part objects to Meshes
Converting higher-level objects such as Part shapes into simpler objects such as meshes is a pretty simple operation, where all faces of a Part object
get triangulated. The result of that triangulation (tessellation) is then used to construct a mesh:
#let's assume our document contains one part object
import Mesh
faces = []
shape = FreeCAD.ActiveDocument.ActiveObject.Shape
triangles = shape.tessellate(1) # the number represents the precision of the tessellation)
for tri in triangles[1]:
face = []
for i in range(3):
vindex = tri[i]
face.append(triangles[0][vindex])
faces.append(face)
m = Mesh.Mesh(faces)
Mesh.show(m)
Sometimes the triangulation of certain faces offered by OpenCascade is quite ugly. If the face has a rectangular parameter space and doesn't contain
any holes or other trimming curves you can also create a mesh on your own:
import Mesh
def makeMeshFromFace(u,v,face):
(a,b,c,d)=face.ParameterRange
pts=[]
for j in range(v):
for i in range(u):
s=1.0/(u-1)*(i*b+(u-1-i)*a)
t=1.0/(v-1)*(j*d+(v-1-j)*c)
pts.append(face.valueAt(s,t))
mesh=Mesh.Mesh()
for j in range(v-1):
for i in range(u-1):
mesh.addFacet(pts[u*j+i],pts[u*j+i+1],pts[u*(j+1)+i])
mesh.addFacet(pts[u*(j+1)+i],pts[u*j+i+1],pts[u*(j+1)+i+1])
return mesh

Converting Meshes to Part objects


Converting Meshes to Part objects is an extremely important operation in CAD work, because very often you receive 3D data in mesh format from other
people or outputted from other applications. Meshes are very practical to represent free-form geometry and big visual scenes, as it is very lightweight, but
for CAD we generally prefer higher-level objects that carry much more information, such as the idea of solid, or faces made of curves instead of triangles.
Converting meshes to those higher-level objects (handled by the Part Module in FreeCAD) is not an easy operation. Meshes can be made of thousands
of triangles (for example when generated by a 3D scanner), and having solids made of the same number of faces would be extremely heavy to
manipulate. So you generally want to optimize the object when converting.
FreeCAD currently offers two methods to convert Meshes to Part objects. The first method is a simple, direct conversion, without any optimization:
import Mesh,Part
mesh = Mesh.createTorus()
shape = Part.Shape()
shape.makeShapeFromMesh(mesh.Topology,0.05) # the second arg is the tolerance for sewing
solid = Part.makeSolid(shape)
Part.show(solid)
The second method offers the possibility to consider mesh facets coplanar when the angle between them is under a certain value. This allows to build
much simpler shapes:
# let's assume our document contains one Mesh object
import Mesh,Part,MeshPart
faces = []
mesh = App.ActiveDocument.ActiveObject.Mesh
segments = mesh.getPlanes(0.00001) # use rather strict tolerance here
for i in segments:
if len(i) > 0:
# a segment can have inner holes
wires = MeshPart.wireFromSegment(mesh, i)
# we assume that the exterior boundary is that one with the biggest bounding box
if len(wires) > 0:
ext=None
max_length=0
for i in wires:
if i.BoundBox.DiagonalLength > max_length:
max_length = i.BoundBox.DiagonalLength
ext = i
wires.remove(ext)
# all interior wires mark a hole and must reverse their orientation, otherwise Part.Face fails
for i in wires:

i.reverse()
# make sure that the exterior wires comes as first in the lsit
wires.insert(0, ext)
faces.append(Part.Face(wires))
shell=Part.Compound(faces)
Part.show(shell)
#solid = Part.Solid(Part.Shell(faces))
#Part.show(solid)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Mesh_to_Part&oldid=16733"

Part Module
The CAD capabilities of FreeCAD are based on the OpenCasCade kernel. The Part module allows FreeCAD to access and use the OpenCasCade
objects and functions. OpenCascade is a professional-level CAD kernel, that features advanced 3D geometry manipulation and objects. The Part
objects, unlike Mesh Module objects, are much more complex, and therefore permit much more advanced operations, like coherent boolean operations,
modifications history and parametric behaviour.

Example of Part shapes in FreeCAD

The tools
The Part module tools are all located in the Part menu that appears when you load the Part module.

Primitives
These are tools for creating primitive objects.

Box: Draws a box by specifying its dimensions


Cone: Draws a cone by specifying its dimensions
Cylinder: Draws a cylinder by specifying its dimensions
Sphere: Draws a sphere by specifying its dimensions
Torus: Draws a torus (ring) by specifying its dimensions
CreatePrimitives: A tool to create various parametric geometric primitives
Shapebuilder: A tool to create more complex shapes from various parametric geometric primitives

Modifying objects
These are tools for modifying existing objects. They will allow you to choose which object to modify.

Booleans: Performs boolean operations on objects


Fuse: Fuses (unions) two objects
Common: Extracts the common (intersection) part of two objects
Cut: Cuts (subtracts) one object from another
Extrude: Extrudes planar faces of an object
Fillet: Fillets (rounds) edges of an object
Revolve: Creates a solid by revolving another object (not solid) around an axis
Section: Creates a section by intersecting an object with a section plane
Chamfer: Chamfers edges of an object

Mirror: Mirrors the selected object on a given mirror plane


32px Ruled Surface:
Sweep: Sweeps one or more profiles along a path
Loft: Lofts from one profile to another

Boolean Operations

An example of union (Fuse), intersection (Common) and difference (Cut)

Explaining the concepts


In OpenCasCade terminology, we distinguish between geometric primitives and (topological) shapes. A geometric primitive can be a point, a line, a
circle, a plane, etc. or even some more complex types like a B-Spline curve or surface. A shape can be a vertex, an edge, a wire, a face, a solid or a
compound of other shapes. The geometric primitives are not made to be directly displayed on the 3D scene, but rather to be used as building geometry
for shapes. For example, an edge can be constructed from a line or from a portion of a circle.
We could say, to resume, that geometry primitive are "shapeless" building blocks, and shapes are the real spatial geometry built on it.
To get a complete list of all of them refer to the OCC documentation (Alternative: sourcearchive.com) and search for Geom_* (for geometry) and
TopoDS_* (for shapes). There you can also read more about the differences between geometric objects and shapes. Please note that unfortunately the
official OCC documentation is not available online (you must download an archive) and is mostly aimed at programmers, not at end-users. But hopefully
you'll find enough information to get started here.
The geometric types actually can be divided into two major groups: curves and surfaces. Out of the curves (line, circle, ...) you can directly build an
edge, out of the surfaces (plane, cylinder, ...) a face can be built. For example, the geometric primitive line is unlimited, i.e. it is defined by a base vector
and a direction vector while its shape representation must be something limited by a start and end point. And a box -- a solid -- can be created by six
limited planes.
From an edge or face you can also go back to its geometric primitive counter part.
Thus, out of shapes you can build very complex parts or, the other way round, extract all sub-shapes a more complex shape is made of.

Scripting
The main data structure used in the Part module is the BRep data type from OpenCascade. Almost all contents and object types of the Part module are
now available to python scripting. This includes geometric primitives, such as Line and Circle (or Arc), and the whole range of TopoShapes, like
Vertexes, Edges, Wires, Faces, Solids and Compounds. For each of those objects, several creation methods exist, and for some of them, especially
the TopoShapes, advanced operations like boolean union/difference/intersection are also available. Explore the contents of the Part module, as
described in the FreeCAD Scripting Basics page, to know more.

Examples
To create a line element switch to the Python console and type in:
import Part,PartGui
doc=App.newDocument()
l=Part.Line()
l.StartPoint=(0.0,0.0,0.0)
l.EndPoint=(1.0,1.0,1.0)
doc.addObject("Part::Feature","Line").Shape=l.toShape()
doc.recompute()
Let's go through the above python example step by step:
import Part,PartGui
doc=App.newDocument()
loads the Part module and creates a new document
l=Part.Line()
l.StartPoint=(0.0,0.0,0.0)
l.EndPoint=(1.0,1.0,1.0)

Line is actually a line segment, hence the start and endpoint.


doc.addObject("Part::Feature","Line").Shape=l.toShape()
This adds a Part object type to the document and assigns the shape representation of the line segment to the 'Shape' property of the added object. It is
important to understand here that we used a geometric primitive (the Part.Line) to create a TopoShape out of it (the toShape() method). Only Shapes can
be added to the document. In FreeCAD, geometry primitives are used as "building structures" for Shapes.
doc.recompute()
Updates the document. This also prepares the visual representation of the new part object.
Note that a Line can be created by specifying its start and endpoint directly in the constructor, for example Part.Line(point1,point2), or we can create a
default line and set its properties afterwards, as we did here.
A circle can be created in a similar way:
import Part
doc = App.activeDocument()
c = Part.Circle()
c.Radius=10.0
f = doc.addObject("Part::Feature", "Circle")
f.Shape = c.toShape()
doc.recompute()
Note again, we used the circle (geometry primitive) to construct a shape out of it. We can of course still access our construction geometry afterwards,
by doing:
s = f.Shape
e = s.Edges[0]
c = e.Curve
Here we take the shape of our object f, then we take its list of edges. In this case there will be only one because we made the whole shape out of a
single circle, so we take only the first item of the Edges list, and we takes its curve. Every Edge has a Curve, which is the geometry primitive it is based
on.
Head to the Topological data scripting page if you would like to know more.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Module&oldid=45577"

Part CreatePrimitives
A tool to create various parametric geometric primitives.
Currently this tools can create a parametric
Plane
Box
Cylinder
Cone
Sphere
Ellipsoid
Torus
Prism available in version 0.14
Wedge
Helix
Spiral available in version 0.14
Circle
Ellipse
Line (Edge)
Point (Vertex)
Regular Polygon

available in version 0.14

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_CreatePrimitiv es&oldid=72612"

Part_CreatePrimitives
Menu location
Part -> CreatePrimitives...
Workbenches
Part
Default shortcut
None
See also
Part Shapebuilder

Part Line
32px Part Line
Menu location
Part Create Primitives
Line
Workbenches
Part, OpenSCAD
Default shortcut
None
See also
..

Geometric Primitives

Line
Parameter
Start point
End point
Location

Property

View
..
Data
Base
Dati
Dati

Label:
Placement: placement

Vertex 1 Start
Dati
Dati
Dati

X1 :
X1 :
X1 :

Vertex 2 Finish
Dati
Dati
Dati

X2 :
X2 :
X2 :

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Line&oldid=73146"

Part Ellipse
32px Part Ellipse
Menu location
Part Create Primitives
Ellipse
An Ellipse geometric primitive is available from the Create Primitives dialogue in the Part workbench.
Workbenches
Part, OpenSCAD
The Create Primitives dialogue can be accessed via the CreatePrimitives icon
located in the Part menu or Default shortcut
the Part toolbar, in the Part Workbench.
None
See also
..
Geometric Primitives

Description

Ellipse
Parameter
Major radius
Minor radiuse
Angle 1
Angle 2
Location

Property

View
..
Data
Base
Dati
Dati
Dati
Dati
Dati
Dati

Angle0 :
Angle1 :
Label:
Major Radius :
Minor Radius :
Placement: Placement

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Ellipse&oldid=83882"

Part Point
32px Part Point
Menu location
Part Create Primitives
Point
A Point (vertex) geometric primitive is available from the Create Primitives dialogue in the Part workbench.
Workbenches
Part, OpenSCAD
The Create Primitives dialogue can be accessed via the CreatePrimitives icon
located in the Part menu or
Default shortcut
the Part toolbar, in the Part Workbench.
None
See also
Geometric Primitives
..

Description

Point
Parameter
X
Y
Z
Location

Property

View
..
Data
Base
Dati
Dati
Dati
Dati
Dati

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Point&oldid=84288"

Label:
Placement: placement
X:
Y:
Z:

Part Helix
Part Helix

Description

Menu location
Part Create Primitives
A Helix geometric primitive is available from the Create Primitives dialogue in the Part workbench.
Helix
Workbenches
The Create Primitives dialogue can be accessed via the CreatePrimitives icon
located in the Part menu or Part, OpenSCAD
the Part toolbar, in the Part Workbench.
Default shortcut
None
How to use
See also
Parameter
..
Pitch:The pitch corresponds
to the space between two
consecutive "turns" of the
helix measured along the
main axis of the helix.
Height: The height
corresponds to the overall
height of the helix measured
along the main axis of the
helix.
Radius: The radius
corresponds to the radius of
the circle built by the helix by
viewing the helix from the top
/ bottom.
Angle: Per default the helix
is built on a imaginary
cylinder. With this option it is
possible to build the helix on
a imaginay conus. This angle
corresponds to the angle of
the conus. The value must be
comprised between -90 deg
and +90 deg.
Right-handed or Lefthanded: This parameter
specifies the handedness
of the helix.
Location
X: The main axis of the helix
will be translated along the x
axis of the value you indicate
in this field.
Y: The main axis of the helix
will be translated along the y
axis of the value you indicate
in this field.
Z: The main axis of the helix
will be translated along the z
axis of the value you indicate
in this field.
Direction: Per default the
main axis of the helix is the z
axis. Here you have the
possibility to edit the main
axis of the helix. If you select
the parameter "user
defined..." , you will be
invited to indicate the main
axis of the helix by entering
the coordinates of its vector.
3D View: allows you select
center in the 3D view

Options
Properties
Once you have created the helix you have the possibility to edit its parameters.

The parameters in this menu are similar to those described above.


Base
Placement: allows you to move or rotate the helix
Angle:

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Helix&oldid=84270"

Part Booleans
Part Booleans
This command is a generic all-in-one boolean tool. It allows you to specify what operation to perform and what
parameters to use via the dialog below. For quicker boolean operations, see also Part Fuse, Part Common and
Part Cut.
Menu location
Part Booleans
Workbenches
Part,Complete
Default shortcut
None
See also
Part Fuse, Part Common
and Part Cut

See also Part Refine Shape

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Booleans&oldid=84691"

Part Plane
Create a simple parametric plane 10 x 10 mm, with the parameters of position, length, and width.
By default, the plane is positioned at the origin (0,0,0).

Part_CreatePrimitives
Menu location
Part Create Primitives
Plane
Workbenches
Part, OpenSCAD
Default shortcut
None
See also
Create Primitives

Usage
The standard plane is created with its lower left corner at the origin point 0,0,0. To change these parameters, open the Location section and enter the
desired values in the respective input fields, or click on the 3D view and select a point, the point coordinates are taken from the fields. In the Direction
menu you can also define a standard vector (X, Y or Z) normal to the plane, or click User Defined ... to open the dialog box that allows you to set a
different carrier (eg direction 1.0 , -1 creates a plane inclined 45 with respect to X and Z).
The properties can be changed later in the Combined View Data, after selecting the item.

Properties

View
You have the standard properties view.
Data
Base - Object placement data
Label : String name of the object, defaults to 'Plane'. User may
rename it.
DATA Placement: Placement of feature is defined by below angle, axis
and position.
DATA Angle : Angle of rotation relative to the below axis.
DATA Axis : Defines the axis of rotation plane: X, Y, or Z. Defaults to Z
axis, Z = 1
DATA Position : Position X, Y, Z, relative to the origin 0, 0, 0.
DATA

Plane - Plane Specific Parameters


Length : Length is the dimension along the X axis The default value
is 10 mm
DATA Width : Width is the size of the Y-axis The default value is 10 mm
DATA

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Plane&oldid=70344"

Part Torus
Part_Torus
Creates a simple parametric torus, with position, angle1, angle2, angle3, radius1 and radius2 parameters. The torus
will be positioned at origin (point 0,0,0) on creation. The angle parameters permit to make a portion of torus instead
of a full one (they are set to 360 by default), the radius 1 and 2 define respectively the size of the hole and the ring Menu location
thickness of the torus.

Part -> Torus


Workbenches
Part_Module,Complete
Default shortcut
None
See also
Part_CreatePrimitives

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Torus&oldid=70319"

Part RuledSurface
Description

32px Part
RuledSurface
Menu location
Part RuledSurface
Workbenches
Part, Complete
Default shortcut
None
See also

How to use
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_RuledSurface&oldid=73087"

Part RefineShape
Part RefineShape

Description

Menu location
Part Refine Shape
Cleans its unnecessary lines. After a Boolean operation some lines defining the previous form remain visible, this tool
Workbenches
creates a copy of the totally cleaned.
Part, OpenSCAD
Default shortcut
None
See also

Use
1. Select the shape to be cleaned.
2. Click the Part Refine shape menu.
A copy of the object is created and totally cleaned, the original object is rendered hiden.
The newly created copy is independent of the original.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_RefineShape&oldid=73563"

Part Offset
This documentation is not finished. Please help and contribute documentation.
See Draft ShapeString for good documented Command. Gui Command gives an overview over commands.
And see List of Commands for other commands.
Go to Help FreeCAD to contribute.

32px Part_Offset

Description
ToDo

Utilizzo
ToDo

Esempio

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Offset&oldid=42078"

Menu location
Part Offset
Workbenches
Part, Complet
Default shortcut
None
See also
Thickness

Part Cylinder
Part_Cylinder
Creates a simple parametric cylinder, with position, angle, radius and height parameters.

Menu location

The default is for a full cylinder to be positioned, the centre of one circular face coincident with the global origin (point
0,0,0), with a radius of 2mm and height of 10mm.
Part -> Cylinder
The properties can later be edited in the data tab for the cylinder:
The angle parameter permits the creation of a portion of cylinder (it is set to 360 by default).
The height is the distance in the z-axis.
The radius defines a plane in x-y.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Cylinder&oldid=70225"

Workbenches
Part_Module,Complete
Default shortcut
None
See also
Part_CreatePrimitives

Part Section
Extracts a section from the intersection of two selected shapes, the second one being used as a section plane. This
operation is fully parametric and the components can be modified and the result recomputed.

Part Section
Menu location
Part -> Section
Workbenches
Part,Complete
Default shortcut
None
See also

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Section&oldid=72958"

Part Sphere
Part_Sphere
Creates a simple parametric sphere, with position, angle1, angle2, angle3 and radius parameters. The sphere will be
positioned at origin (point 0,0,0) on creation. The angle parameters permit to make a portion of sphere instead of a
full sphere (they are set to 360 by default)
Menu location
Part -> Sphere
Workbenches
Part_Module,Complete
Default shortcut
None
See also
Part_CreatePrimitives
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Sphere&oldid=70293"

Part Prism
32px Part_Prism

Description

Menu location
Part Create Primitives
Prism
Workbenches
located in the Part menu or Part, OpenSCAD
Default shortcut
None
See also
Part Primitives Box

A Part Prism is available from the Create Primitives dialogue in the Part workbench. A Part Prism is a solid defined
by a regular polygon cross section and a height.

The Create Primitives dialogue can be accessed via the CreatePrimitives icon
the Part toolbar, in the Part Workbench.

Parameters

Polygon - the number of sides of the polygon which describes the cross section of the Part Prism
cirumradius - the circumradius is the distance from the centre of the polygon to a vertex.
Height - the height of the Part Prism
available in version 0.14

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Prism&oldid=84279"

Part Mirror
Introduction

Part Mirror

'Mirror Object' - This tool creates a new object (image) which is a reflection of the original object (source). The image Menu location
object is created behind a mirror plane. The mirror plane may be standard plane (XY, YZ, or XZ), or any plane parallel Part -> Mirror
to a standard plane.
An example:

Workbenches
Part, Complete
Default shortcut
None
See also

Before

After (mirrored through YZ plane)

Usage

Select the source object from the list. Select a standard Mirror plane from the dropbox. Press OK to create the image object.

Options
The Base point boxes can be used to move the mirror plane parallel to the selected standard miror plane. Only one of the X, Y, or Z boxes is effective
for a given standard plane.

Standard Plane Base Point Box

Effect

XY
XY

Z
X, Y

Move mirror plane along Z axis.


No effect.

XZ
XZ

Y
X, Z

Move mirror plane along Y axis.


No effect.

YZ
YZ

X
Y, Z

Move mirror plane along X axis.


No effect.

Limitations
Arbitrary mirror planes (ie not parallel to a standard plane) are not supported (as of FC version 0.13).
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Mirror&oldid=72896"

Part Sweep
This documentation is not finished. Please help and contribute documentation.
See Draft ShapeString for good documented Command. Gui Command gives an overview over commands.
And see List of Commands for other commands.
Go to Help FreeCAD to contribute.

Part_Sweep

Overview

Menu location

The FreeCAD Part Sweep tool (Part Workbench), is used to create a face, shell or a solid shape from two or more
profiles, projected along a path.
Part -> Sweep...

Workbenches
Part
The profiles can be a point (vertex), line (Edge), wire or face. Edges and wires may be either open or closed. There
are various profile limitations and complications, see below, however the profiles may come from the Part Default shortcut
Workbench primitives, Draft Workbench features and a Sketch.
None
The path can be a line (Edge) or series of connecting lines, wire or various Part Workbench primitives, Draft See also
Workbench features or a Sketch. The path is selected directly from the main model window. The path can either be Part_Loft
The Part Sweep tool is similar to Part_Loft with the addition of a path to define the projection between profiles.

an entire appropriate shape or an appropriate sub-component of a more advance shape (for example, an edge of a
Part Cube could be selected as the path). The path may be either open or closed and will thus create either an open
or closed Sweep. A closed path such as a Part Circle will result in a closed Sweep. For example a Sweep of a smaller circle around a path of a larger
circle will create a torus.

Properties
The Sweep has two parameters, "Solid" and "Frenet" each with a value of either "true" or "false", as well as a third parameter "Transition" which
describes the transition style of the Sweep at a joint in the path, if the path does not define the corner transition (for example where the path is a wire).
If "Solid" is "true" FreeCAD creates a solid if the profiles are of closed geometry, if "false" FreeCAD creates a face or (if more than one face) a shell for
either open or closed profiles.
If "Frenet" is "true" the orientation of the profile will be consistent to the local orientation of the path, along a helical path.

Profile limitations and complications


A vertex or point
vertex or point may only be used as the first and/or last profile in the list of profiles.
For example
you can not Sweep from a circle to a point, to a ellipse.
However you could Sweep from a point to a circle to an ellipse to another point.
Open or closed geometry profiles can not be mixed in one single Sweep
In one Sweep, all profiles (lines wires etc.) must be either open or closed.
For example
FreeCAD can not Sweep between one Part_Circle and one default Part_Line.
Draft Workbench features
Draft Workbench features can be directly used as a profile in FreeCAD 0.14 or later.
For example the following Draft features can be used as profiles in a Part Sweep
Draft Polygon.
Draft Point, Line, wire,
Draft B-spline, Bezier Curve
Draft Circle, Ellipse, Rectangle
PartDesign Sketches
The profile may be created with a sketch. However only a valid sketch will be shown in the list to be available for selection.
The sketch must contain only one open or closed wire or line (can be multiple lines, if those lines are all connected as they are then a
single wire)
Part Workbench
the profile can be a valid Part geometric primitive which can be created with the Part_CreatePrimitives tool
For example the following Part geometric primitives can be a valid profile
Point (Vertex), Line (Edge)
Helix, Spiral
Circle, Ellipse
Regular Polygon
Plane (Face)

FreeCAD - Version
0.13
0.14 some of the above is extended functionality added in 0.14
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Sw eep&oldid=83348"

Part Revolve
Part Revolve
Revolves the selected object around a given axis. The following shape types are allowed, and lead to the listed output
shapes (See Notes for exceptions):
Menu

Input shape Output shape


Vertex
Edge
Edge
Face
Wire
Shell
Face
Solid
Shell
Compound solid

location
Part Revolve
Workbenches
Part, Complete
Default shortcut
None
See also

Solids or compound solids are not allowed as input shapes. Normal compounds are currently not allowed, too.
Future versions will check the actual shape type of compound objects.

The Angle argument specifies how far the object is to be turned. The coordinates move the origin of the axis of revolving, relative to the origin of the
coordinate system.
If you select a user defined axis, the numbers define the direction of the revolving axis with respect to the coordinate system: If the Z coordinate is 0 and
the Y and X coordinate are non-zero, then the axis will lie in the X-Y-plane. Its angle is such that its tangent is the ratio of the given X and Y coordinates.

Notes
If your version of FreeCAD has a check box for Solid in the Revolve dialog, you can make Solids from closed Wires and Edges.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Rev olv e&oldid=80318"

Part Spiral
Part_CreatePrimitives

Description

Menu location
Part Create Primitives
Spiral
Workbenches
located in the Part menu or
Part, OpenSCAD
Default shortcut
None
See also
Create Primitives

A Spiral geometric primitive is available from the Create Primitives dialogue in the Part workbench.

The Create Primitives dialogue can be accessed via the CreatePrimitives icon
the Part toolbar, in the Part Workbench.

available in version 0.14

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Spiral&oldid=83881"

Part Loft
THIS PAGE IS STILL UNDER CONSTRUCTION

Part_Loft

Overview

Menu location
The FreeCAD Loft tool (Part Workbench), is used to create a face, shell or a solid shape from two or more profiles. Part -> Loft...
The profiles can be a point (vertex), line (Edge), wire or face. Edges and wires may be either open or closed. There Workbenches
are various limitations and complications, see below, however the profiles may come from the Part Workbench
Part
primitives, Draft Workbench features and a Sketch.
Default shortcut
The Loft has three parameters, "Ruled","Solid" and "Closed" each with a value of either "true" or "false".
None
If "Ruled" is "true" FreeCAD creates a face, faces or a solid from ruled surfaces. Ruled surface page on See also
Wikipedia.
Part_Sweep
If "Solid" is "true" FreeCAD creates a solid if the profiles are of closed geometry, if "false" FreeCAD creates a face or
(if more than one face) a shell for either open or closed profiles.
If "Closed" is "true" FreeCAD attempts to loft the last profile to the first profile to create a closed figure.

Part_Loft. From three profiles which are two Part_Circles and one Part_Ellipse. Parameters are Solid "True" and Ruled
"True"

limitations and complications


A vertex or point
vertex or point may only be used as the first and/or last profile in the list of profiles.
For example
you can not loft from a circle to a point, to a ellipse.
However you could Loft from a point to a circle to an ellipse to another point.
Open or closed geometry profiles can not be mixed in one single Loft
In one Loft, all profiles (lines wires etc.) must be either open or closed.
For example
FreeCAD can not Loft between one Part_Circle and one default Part_Line.

Draft Workbench features


Draft Workbench features can be directly used as a profile in FreeCAD 0.14 or later.
For example the following Draft features can be used as profiles in a Part Loft
Draft Polygon.
Draft Point, Line, wire,
Draft B-spline, Bezier Curve
Draft Circle, Ellipse, Rectangle
PartDesign Sketches
The profile may be created with a sketch. However only a valid sketch will be shown in the list to be available for selection.
The sketch must contain only one open or closed wire or line (can be multiple lines, if those lines are all connected as they are then a
single wire)
Part Workbench
the profile can be a valid Part geometric primitive which can be created with the Part_CreatePrimitives tool
For example the following Part geometric primitives can be a valid profile
Point (Vertex), Line (Edge)
Helix, Spiral
Circle, Ellipse
Regular Polygon
Plane (Face)
Closed Lofts
The results of closed lofts may be unexpected - the loft may develop twists or kinks. Lofting is very sensitive to the Placement of the
profiles and the complexity of the curves required to connect the corresponding Vertices in all the profiles.

An example Loft
The Loft tool is in the Part Workbench, menu Part -> Loft... or via the icon in the tool bar.

In the "Tasks" will be two lists: "node / wire" and "free form".

Selection of the elements


In the "node / wire" the available items are displayed. Two elements must be selected one after the first in this list.

Thereafter, with the blue arrow that item is added to the list of "free form".

The selected items must be of the same type, so .


Tip: the active / selected items in the list are displayed in the 3D area as active / selected.

command complete
If both elements are selected, the command can be completed with "OK".

result
From closed lines arise surfaces which might be taken at a superficial look for solids / solids.

If indeed a solid / solid to be created, can be used either when you create the button "Create Solid" or after creating the field properties tab data created
the free-form surface of the switch "Solid" by pop be set to "true" / set properly.
The procedure is analogous open polylines.

FreeCAD Version
added Version 0.13
"closed" property added Version 0.14
Ability to use a face as a profile added Version 0.14

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Loft&oldid=83343"

Part scripting
(Redirected from Part scripting)
This page describes several methods for creating and modifying Part shapes from python. Before reading this page, if you are new to python, it is a
good idea to read about python scripting and how python scripting works in FreeCAD.

Introduction
We will here explain you how to control the Part Module directly from the FreeCAD python interpreter, or from any external script. Be sure to browse
the Scripting section and the FreeCAD Scripting Basics pages if you need more information about how python scripting works in FreeCAD.

Class Diagram
This is a Unified Modeling Language (UML) overview of the most important classes of the Part module:

Geometry
The geometric objects are the building block of all topological objects:
Geom Base class of the geometric objects
Line A straight line in 3D, defined by starting point and and point
Circle Circle or circle segment defined by a center point and start and end point
...... And soon some more ;-)

Topology
The following topological data types are available:
Compound A group of any type of topological object.
Compsolid A composite solid is a set of solids connected by their faces. It expands the notions of WIRE and SHELL to solids.
Solid A part of space limited by shells. It is three dimensional.
Shell A set of faces connected by their edges. A shell can be open or closed.
Face In 2D it is part of a plane; in 3D it is part of a surface. Its geometry is constrained (trimmed) by contours. It is two dimensional.
Wire A set of edges connected by their vertices. It can be an open or closed contour depending on whether the edges are linked or not.
Edge A topological element corresponding to a restrained curve. An edge is generally limited by vertices. It has one dimension.
Vertex A topological element corresponding to a point. It has zero dimension.
Shape A generic term covering all of the above.

Quick example : Creating simple topology

We will now create a topology by constructing it out of simpler geometry. As a case study we use a part as seen in the picture which consists of four
vertexes, two circles and two lines.

Creating Geometry
First we have to create the distinct geometric parts of this wire. And we have to take care that the vertexes of the geometric parts are at the same
position. Otherwise later on we might not be able to connect the geometric parts to a topology!
So we create first the points:
from
V1 =
V2 =
V3 =
V4 =

FreeCAD import Base


Base.Vector(0,10,0)
Base.Vector(30,10,0)
Base.Vector(30,-10,0)
Base.Vector(0,-10,0)

Arc

To create an arc of circle we make a helper point and create the arc of circle through three points:
VC1 = Base.Vector(-10,0,0)
C1 = Part.Arc(V1,VC1,V4)
# and the second one
VC2 = Base.Vector(40,0,0)
C2 = Part.Arc(V2,VC2,V3)
Line

The line can be created very simple out of the points:


L1 = Part.Line(V1,V2)
# and the second one
L2 = Part.Line(V4,V3)
Putting all together
The last step is to put the geometric base elements together and bake a topological shape:
S1 = Part.Shape([C1,C2,L1,L2])
Make a prism
Now extrude the wire in a direction and make an actual 3D shape:
W = Part.Wire(S1.Edges)
P = W.extrude(Base.Vector(0,0,10))
Show it all
Part.show(P)

Creating basic shapes


You can easily create basic topological objects with the "make...()" methods from the Part Module:
b = Part.makeBox(100,100,100)
Part.show(b)
A couple of other make...() methods available:
makeBox(l,w,h): Makes a box located in p and pointing into the direction d with the dimensions (l,w,h)
makeCircle(radius): Makes a circle with a given radius
makeCone(radius1,radius2,height): Makes a cone with a given radii and height
makeCylinder(radius,height): Makes a cylinder with a given radius and height.
makeLine((x1,y1,z1),(x2,y2,z2)): Makes a line of two points
makePlane(length,width): Makes a plane with length and width
makePolygon(list): Makes a polygon of a list of points
makeSphere(radius): Make a sphere with a given radius
makeTorus(radius1,radius2): Makes a torus with a given radii
See the Part API page for a complete list of available methods of the Part module.

Importing the needed modules


First we need to import the Part module so we can use its contents in python. We'll also import the Base module from inside the FreeCAD module:
import Part
from FreeCAD import Base
Creating a Vector
Vectors are one of the most important pieces of information when building shapes. They contain a 3 numbers usually (but not necessarily always) the x,
y and z cartesian coordinates. You create a vector like this:
myVector = Base.Vector(3,2,0)
We just created a vector at coordinates x=3, y=2, z=0. In the Part module, vectors are used everywhere. Part shapes also use another kind of point
representation, called Vertex, which is acually nothing else than a container for a vector. You access the vector of a vertex like this:
myVertex = myShape.Vertexes[0]
print myVertex.Point
> Vector (3, 2, 0)
Creating an Edge
An edge is nothing but a line with two vertexes:
edge = Part.makeLine((0,0,0), (10,0,0))
edge.Vertexes
> [<Vertex object at 01877430>, <Vertex object at 014888E0>]
Note: You can also create an edge by passing two vectors:
vec1
vec2
line
edge

=
=
=
=

Base.Vector(0,0,0)
Base.Vector(10,0,0)
Part.Line(vec1,vec2)
line.toShape()

You can find the length and center of an edge like this:
edge.Length
> 10.0
edge.CenterOfMass
> Vector (5, 0, 0)
Putting the shape on screen
So far we created an edge object, but it doesn't appear anywhere on screen. This is because we just manipulated python objects here. The FreeCAD 3D
scene only displays what you tell it to display. To do that, we use this simple method:
Part.show(edge)
An object will be created in our FreeCAD document, and our "edge" shape will be attributed to it. Use this whenever it's time to display your creation on
screen.
Creating a Wire
A wire is a multi-edge line and can be created from a list of edges or even a list of wires:
edge1 = Part.makeLine((0,0,0), (10,0,0))
edge2 = Part.makeLine((10,0,0), (10,10,0))
wire1 = Part.Wire([edge1,edge2])
edge3 = Part.makeLine((10,10,0), (0,10,0))
edge4 = Part.makeLine((0,10,0), (0,0,0))
wire2 = Part.Wire([edge3,edge4])
wire3 = Part.Wire([wire1,wire2])
wire3.Edges
> [<Edge object at 016695F8>, <Edge object at 0197AED8>, <Edge object at 01828B20>, <Edge object at 0190A788>]
Part.show(wire3)
Part.show(wire3) will display the 4 edges that compose our wire. Other useful information can be easily retrieved:
wire3.Length
> 40.0
wire3.CenterOfMass
> Vector (5, 5, 0)
wire3.isClosed()
> True
wire2.isClosed()
> False
Creating a Face
Only faces created from closed wires will be valid. In this example, wire3 is a closed wire but wire2 is not a closed wire (see above)
face = Part.Face(wire3)
face.Area

> 99.999999999999972
face.CenterOfMass
> Vector (5, 5, 0)
face.Length
> 40.0
face.isValid()
> True
sface = Part.Face(wire2)
face.isValid()
> False
Only faces will have an area, not wires nor edges.
Creating a Circle
A circle can be created as simply as this:
circle = Part.makeCircle(10)
circle.Curve
> Circle (Radius : 10, Position : (0, 0, 0), Direction : (0, 0, 1))
If you want to create it at certain position and with certain direction:
ccircle = Part.makeCircle(10, Base.Vector(10,0,0), Base.Vector(1,0,0))
ccircle.Curve
> Circle (Radius : 10, Position : (10, 0, 0), Direction : (1, 0, 0))
ccircle will be created at distance 10 from origin on x and will be facing towards x axis. Note: makeCircle only accepts Base.Vector() for position and
normal but not tuples. You can also create part of the circle by giving start angle and end angle as:
from math import pi
arc1 = Part.makeCircle(10, Base.Vector(0,0,0), Base.Vector(0,0,1), 0, 180)
arc2 = Part.makeCircle(10, Base.Vector(0,0,0), Base.Vector(0,0,1), 180, 360)
Both arc1 and arc2 jointly will make a circle. Angles should be provided in degrees, if you have radians simply convert them using formula: degrees =
radians * 180/PI or using python's math module (after doing import math, of course):
degrees = math.degrees(radians)
Creating an Arc along points
Unfortunately there is no makeArc function but we have Part.Arc function to create an arc along three points. Basically it can be supposed as an arc
joining start point and end point along the middle point. Part.Arc creates an arc object on which .toShape() has to be called to get the edge object, the
same way as when using Part.Line instead of Part.makeLine.
arc = Part.Arc(Base.Vector(0,0,0),Base.Vector(0,5,0),Base.Vector(5,5,0))
arc
> <Arc object>
arc_edge = arc.toShape()
Arc only accepts Base.Vector() for points but not tuples. arc_edge is what we want which we can display using Part.show(arc_edge). You can also
obtain an arc by using a portion of a circle:
from math import pi
circle = Part.Circle(Base.Vector(0,0,0),Base.Vector(0,0,1),10)
arc = Part.Arc(c,0,pi)
Arcs are valid edges, like lines. So they can be used in wires too.
Creating a polygon
A polygon is simply a wire with multiple straight edges. The makePolygon function takes a list of points and creates a wire along those points:
lshape_wire = Part.makePolygon([Base.Vector(0,5,0),Base.Vector(0,0,0),Base.Vector(5,0,0)])
Creating a Bezier curve
Bzier curves are used to model smooth curves using a series of poles (points) and optional weights. The function below makes a Part.BezierCurve from
a series of FreeCAD.Vector points. (Note: pole and weight indices start at 1, not 0.)
def makeBCurve(Points):
c = Part.BezierCurve()
c.setPoles(Points)
return(c)
Creating a Plane
A Plane is simply a flat rectangular surface. The method used to create one is this: makePlane(length,width,[start_pnt,dir_normal]). By default
start_pnt = Vector(0,0,0) and dir_normal = Vector(0,0,1). Using dir_normal = Vector(0,0,1) will create the plane facing z axis, while dir_normal =
Vector(1,0,0) will create the plane facing x axis:
plane = Part.makePlane(2,2)
plane
><Face object at 028AF990>
plane = Part.makePlane(2,2, Base.Vector(3,0,0), Base.Vector(0,1,0))

plane.BoundBox
> BoundBox (3, 0, 0, 5, 0, 2)
BoundBox is a cuboid enclosing the plane with a diagonal starting at (3,0,0) and ending at (5,0,2). Here the BoundBox thickness in y axis is zero, since
our shape is totally flat.
Note: makePlane only accepts Base.Vector() for start_pnt and dir_normal but not tuples
Creating an ellipse
To create an ellipse there are several ways:
Part.Ellipse()
Creates an ellipse with major radius 2 and minor radius 1 with the center in (0,0,0)
Part.Ellipse(Ellipse)
Create a copy of the given ellipse
Part.Ellipse(S1,S2,Center)
Creates an ellipse centered on the point Center, where the plane of the ellipse is defined by Center, S1 and S2, its major axis is defined by Center and
S1, its major radius is the distance between Center and S1, and its minor radius is the distance between S2 and the major axis.
Part.Ellipse(Center,MajorRadius,MinorRadius)
Creates an ellipse with major and minor radii MajorRadius and MinorRadius, and located in the plane defined by Center and the normal (0,0,1)
eli = Part.Ellipse(Base.Vector(10,0,0),Base.Vector(0,5,0),Base.Vector(0,0,0))
Part.show(eli.toShape())
In the above code we have passed S1, S2 and center. Similarly to Arc, Ellipse also creates an ellipse object but not edge, so we need to convert it into
edge using toShape() to display.
Note: Arc only accepts Base.Vector() for points but not tuples
eli = Part.Ellipse(Base.Vector(0,0,0),10,5)
Part.show(eli.toShape())
for the above Ellipse constructor we have passed center, MajorRadius and MinorRadius
Creating a Torus
Using the method makeTorus(radius1,radius2,[pnt,dir,angle1,angle2,angle]). By default pnt=Vector(0,0,0),dir=Vector(0,0,1),angle1=0,angle2=360
and angle=360. Consider a torus as small circle sweeping along a big circle. Radius1 is the radius of big cirlce, radius2 is the radius of small circle, pnt
is the center of torus and dir is the normal direction. angle1 and angle2 are angles in radians for the small circle, the last parameter angle is to make a
section of the torus:
torus = Part.makeTorus(10, 2)
The above code will create a torus with diameter 20(radius 10) and thickness 4 (small cirlce radius 2)
tor=Part.makeTorus(10,5,Base.Vector(0,0,0),Base.Vector(0,0,1),0,180)
The above code will create a slice of the torus
tor=Part.makeTorus(10,5,Base.Vector(0,0,0),Base.Vector(0,0,1),0,360,180)
The above code will create a semi torus, only the last parameter is changed i.e the angle and remaining angles are defaults. Giving the angle 180 will
create the torus from 0 to 180, that is, a half torus.
Creating a box or cuboid
Using makeBox(length,width,height,[pnt,dir]). By default pnt=Vector(0,0,0) and dir=Vector(0,0,1)
box = Part.makeBox(10,10,10)
len(box.Vertexes)
> 8
Creating a Sphere
U s i n g makeSphere(radius,[pnt, dir, angle1,angle2,angle3]). By default pnt=Vector(0,0,0), dir=Vector(0,0,1), angle1=-90, angle2=90 and
angle3=360. angle1 and angle2 are the vertical minimum and maximum of the sphere, angle3 is the sphere diameter itself.
sphere = Part.makeSphere(10)
hemisphere = Part.makeSphere(10,Base.Vector(0,0,0),Base.Vector(0,0,1),-90,90,180)
Creating a Cylinder
Using makeCylinder(radius,height,[pnt,dir,angle]). By default pnt=Vector(0,0,0),dir=Vector(0,0,1) and angle=360
cylinder = Part.makeCylinder(5,20)
partCylinder = Part.makeCylinder(5,20,Base.Vector(20,0,0),Base.Vector(0,0,1),180)

Creating a Cone
Using makeCone(radius1,radius2,height,[pnt,dir,angle]). By default pnt=Vector(0,0,0), dir=Vector(0,0,1) and angle=360
cone = Part.makeCone(10,0,20)
semicone = Part.makeCone(10,0,20,Base.Vector(20,0,0),Base.Vector(0,0,1),180)

Modifying shapes
There are several ways to modify shapes. Some are simple transformation operations such as moving or rotating shapes, other are more complex, such
as unioning and subtracting one shape from another. Be aware that

Transform operations
Translating a shape
Translating is the act of moving a shape from one place to another. Any shape (edge, face, cube, etc...) can be translated the same way:
myShape = Part.makeBox(2,2,2)
myShape.translate(Base.Vector(2,0,0))
This will move our shape "myShape" 2 units in the x direction.
Rotating a shape
To rotate a shape, you need to specify the rotation center, the axis, and the rotation angle:
myShape.rotate(Vector(0,0,0),Vector(0,0,1),180)
The above code will rotate the shape 180 degrees around the Z Axis.
Generic transformations with matrixes
A matrix is a very convenient way to store transformations in the 3D world. In a single matrix, you can set translation, rotation and scaling values to be
applied to an object. For example:
myMat = Base.Matrix()
myMat.move(Base.Vector(2,0,0))
myMat.rotateZ(math.pi/2)
Note: FreeCAD matrixes work in radians. Also, almost all matrix operations that take a vector can also take 3 numbers, so those 2 lines do the same
thing:
myMat.move(2,0,0)
myMat.move(Base.Vector(2,0,0))
When our matrix is set, we can apply it to our shape. FreeCAD provides 2 methods to do that: transformShape() and transformGeometry(). The
difference is that with the first one, you are sure that no deformations will occur (see "scaling a shape" below). So we can apply our transformation like
this:
myShape.trasformShape(myMat)
or
myShape.transformGeometry(myMat)
Scaling a shape
Scaling a shape is a more dangerous operation because, unlike translation or rotation, scaling non-uniformly (with different values for x, y and z) can
modify the structure of the shape. For example, scaling a circle with a higher value horizontally than vertically will transform it into an ellipse, which
behaves mathematically very differenty. For scaling, we can't use the transformShape, we must use transformGeometry():
myMat = Base.Matrix()
myMat.scale(2,1,1)
myShape=myShape.transformGeometry(myMat)

Boolean Operations
Subtraction
Subtracting a shape from another one is called "cut" in OCC/FreeCAD jargon and is done like this:
cylinder = Part.makeCylinder(3,10,Base.Vector(0,0,0),Base.Vector(1,0,0))
sphere = Part.makeSphere(5,Base.Vector(5,0,0))
diff = cylinder.cut(sphere)
Intersection
The same way, the intersection between 2 shapes is called "common" and is done this way:
cylinder1 = Part.makeCylinder(3,10,Base.Vector(0,0,0),Base.Vector(1,0,0))
cylinder2 = Part.makeCylinder(3,10,Base.Vector(5,0,-5),Base.Vector(0,0,1))
common = cylinder1.common(cylinder2)

Union
Union is called "fuse" and works the same way:
cylinder1 = Part.makeCylinder(3,10,Base.Vector(0,0,0),Base.Vector(1,0,0))
cylinder2 = Part.makeCylinder(3,10,Base.Vector(5,0,-5),Base.Vector(0,0,1))
fuse = cylinder1.fuse(cylinder2)
Section
A Section is the intersection between a solid shape and a plane shape. It will return an intersection curve, a compound with edges
cylinder1 = Part.makeCylinder(3,10,Base.Vector(0,0,0),Base.Vector(1,0,0))
cylinder2 = Part.makeCylinder(3,10,Base.Vector(5,0,-5),Base.Vector(0,0,1))
section = cylinder1.section(cylinder2)
section.Wires
> []
section.Edges
> [<Edge object at 0D87CFE8>, <Edge object at 019564F8>, <Edge object at 0D998458>,
<Edge object at 0D86DE18>, <Edge object at 0D9B8E80>, <Edge object at 012A3640>,
<Edge object at 0D8F4BB0>]
Extrusion
Extrusion is the act of "pushing" a flat shape in a certain direction resulting in a solid body. Think of a circle becoming a tube by "pushing it out":
circle = Part.makeCircle(10)
tube = circle.extrude(Base.Vector(0,0,2))
If your circle is hollow, you will obtain a hollow tube. If your circle is actually a disc, with a filled face, you will obtain a solid cylinder:
wire = Part.Wire(circle)
disc = Part.makeFace(wire)
cylinder = disc.extrude(Base.Vector(0,0,2))

Exploring shapes
You can easily explore the topological data structure:
import Part
b = Part.makeBox(100,100,100)
b.Wires
w = b.Wires[0]
w
w.Wires
w.Vertexes
Part.show(w)
w.Edges
e = w.Edges[0]
e.Vertexes
v = e.Vertexes[0]
v.Point
By typing the lines above in the python interpreter, you will gain a good understanding of the structure of Part objects. Here, our makeBox() command
created a solid shape. This solid, like all Part solids, contains faces. Faces always contain wires, which are lists of edges that border the face. Each
face has at least one closed wire (it can have more if the face has a hole). In the wire, we can look at each edge separately, and inside each edge, we
can see the vertexes. Straight edges have only two vertexes, obviously.

Edge analysis
In case of an edge, which is an arbitrary curve, it's most likely you want to do a discretization. In FreeCAD the edges are parametrized by their lengths.
That means you can walk an edge/curve by its length:
import Part
box = Part.makeBox(100,100,100)
anEdge = box.Edges[0]
print anEdge.Length
Now you can access a lot of properties of the edge by using the length as a position. That means if the edge is 100mm long the start position is 0 and
the end position 100.
anEdge.tangentAt(0.0)
# tangent direction at the beginning
anEdge.valueAt(0.0)
# Point at the beginning
anEdge.valueAt(100.0)
# Point at the end of the edge
anEdge.derivative1At(50.0) # first derivative of the curve in the middle
anEdge.derivative2At(50.0) # second derivative of the curve in the middle
anEdge.derivative3At(50.0) # third derivative of the curve in the middle
anEdge.centerOfCurvatureAt(50) # center of the curvature for that position
anEdge.curvatureAt(50.0)
# the curvature
anEdge.normalAt(50)
# normal vector at that position (if defined)

Using the selection


Here we see now how we can use the selection the user did in the viewer. First of all we create a box and shows it in the viewer

import Part
Part.show(Part.makeBox(100,100,100))
Gui.SendMsgToActiveView("ViewFit")
Select now some faces or edges. With this script you can iterate all selected objects and their sub elements:
for o
print
for s
print
for s
print

in Gui.Selection.getSelectionEx():
o.ObjectName
in o.SubElementNames:
"name: ",s
in o.SubObjects:
"object: ",s

Select some edges and this script will calculate the length:
length = 0.0
for o in Gui.Selection.getSelectionEx():
for s in o.SubObjects:
length += s.Length
print "Length of the selected edges:" ,length

Complete example: The OCC bottle


A typical example found on the OpenCasCade Getting Started Page is how to build a bottle. This is a good exercise for FreeCAD too. In fact, you can
follow our example below and the OCC page simultaneously, you will understand well how OCC structures are implemented in FreeCAD. The complete
script below is also included in FreeCAD installation (inside the Mod/Part folder) and can be called from the python interpreter by typing:
import Part
import MakeBottle
bottle = MakeBottle.makeBottle()
Part.show(bottle)

The complete script


Here is the complete MakeBottle script:
import Part, FreeCAD, math
from FreeCAD import Base
def makeBottle(myWidth=50.0, myHeight=70.0, myThickness=30.0):
aPnt1=Base.Vector(-myWidth/2.,0,0)
aPnt2=Base.Vector(-myWidth/2.,-myThickness/4.,0)
aPnt3=Base.Vector(0,-myThickness/2.,0)
aPnt4=Base.Vector(myWidth/2.,-myThickness/4.,0)
aPnt5=Base.Vector(myWidth/2.,0,0)
aArcOfCircle = Part.Arc(aPnt2,aPnt3,aPnt4)
aSegment1=Part.Line(aPnt1,aPnt2)
aSegment2=Part.Line(aPnt4,aPnt5)
aEdge1=aSegment1.toShape()
aEdge2=aArcOfCircle.toShape()
aEdge3=aSegment2.toShape()
aWire=Part.Wire([aEdge1,aEdge2,aEdge3])
aTrsf=Base.Matrix()
aTrsf.rotateZ(math.pi) # rotate around the z-axis
aMirroredWire=aWire.transformGeometry(aTrsf)
myWireProfile=Part.Wire([aWire,aMirroredWire])
myFaceProfile=Part.Face(myWireProfile)
aPrismVec=Base.Vector(0,0,myHeight)
myBody=myFaceProfile.extrude(aPrismVec)
myBody=myBody.makeFillet(myThickness/12.0,myBody.Edges)
neckLocation=Base.Vector(0,0,myHeight)
neckNormal=Base.Vector(0,0,1)
myNeckRadius = myThickness / 4.
myNeckHeight = myHeight / 10
myNeck = Part.makeCylinder(myNeckRadius,myNeckHeight,neckLocation,neckNormal)
myBody = myBody.fuse(myNeck)
faceToRemove = 0
zMax = -1.0
for xp in myBody.Faces:
try:
surf = xp.Surface
if type(surf) == Part.Plane:
z = surf.Position.z
if z > zMax:
zMax = z
faceToRemove = xp
except:
continue
myBody = myBody.makeThickness([faceToRemove],-myThickness/50 , 1.e-3)
return myBody

Detailed explanation
import Part, FreeCAD, math
from FreeCAD import Base
We will need,of course, the Part module, but also the FreeCAD.Base module, which contains basic FreeCAD structures like vectors and matrixes.
def makeBottle(myWidth=50.0, myHeight=70.0, myThickness=30.0):
aPnt1=Base.Vector(-myWidth/2.,0,0)
aPnt2=Base.Vector(-myWidth/2.,-myThickness/4.,0)
aPnt3=Base.Vector(0,-myThickness/2.,0)
aPnt4=Base.Vector(myWidth/2.,-myThickness/4.,0)
aPnt5=Base.Vector(myWidth/2.,0,0)
Here we define our makeBottle function. This function can be called without arguments, like we did above, in which case default values for width, height,
and thickness will be used. Then, we define a couple of points that will be used for building our base profile.
aArcOfCircle = Part.Arc(aPnt2,aPnt3,aPnt4)
aSegment1=Part.Line(aPnt1,aPnt2)
aSegment2=Part.Line(aPnt4,aPnt5)
Here we actually define the geometry: an arc, made of 3 points, and two line segments, made of 2 points.
aEdge1=aSegment1.toShape()
aEdge2=aArcOfCircle.toShape()
aEdge3=aSegment2.toShape()
aWire=Part.Wire([aEdge1,aEdge2,aEdge3])
Remember the difference between geometry and shapes? Here we build shapes out of our construction geometry. 3 edges (edges can be straight or
curved), then a wire made of those three edges.
aTrsf=Base.Matrix()
aTrsf.rotateZ(math.pi) # rotate around the z-axis
aMirroredWire=aWire.transformGeometry(aTrsf)
myWireProfile=Part.Wire([aWire,aMirroredWire])
Until now we built only a half profile. Easier than building the whole profile the same way, we can just mirror what we did, and glue both halfs together.
So we first create a matrix. A matrix is a very common way to apply transformations to objects in the 3D world, since it can contain in one structure all
basic transformations that 3D objects can suffer (move, rotate and scale). Here, after we create the matrix, we mirror it, and we create a copy of our wire
with that transformation matrix applied to it. We now have two wires, and we can make a third wire out of them, since wires are actually lists of edges.
myFaceProfile=Part.Face(myWireProfile)
aPrismVec=Base.Vector(0,0,myHeight)
myBody=myFaceProfile.extrude(aPrismVec)
myBody=myBody.makeFillet(myThickness/12.0,myBody.Edges)
Now that we have a closed wire, it can be turned into a face. Once we have a face, we can extrude it. Doing so, we actually made a solid. Then we apply
a nice little fillet to our object because we care about good design, don't we?
neckLocation=Base.Vector(0,0,myHeight)
neckNormal=Base.Vector(0,0,1)
myNeckRadius = myThickness / 4.
myNeckHeight = myHeight / 10
myNeck = Part.makeCylinder(myNeckRadius,myNeckHeight,neckLocation,neckNormal)
Then, the body of our bottle is made, we still need to create a neck. So we make a new solid, with a cylinder.
myBody = myBody.fuse(myNeck)
The fuse operation, which in other apps is sometimes called union, is very powerful. It will take care of gluing what needs to be glued and remove parts
that need to be removed.
return myBody
Then, we return our Part solid as the result of our function. That Part solid, like any other Part shape, can be attributed to an object in a FreeCAD
document, with:
myObject = FreeCAD.ActiveDocument.addObject("Part::Feature","myObject")
myObject.Shape = bottle
or, more simple:
Part.show(bottle)

Box pierced
Here a complete example of building a box pierced.
The construction is done side by side and when the cube is finished, it is hollowed out of a cylinder through.
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, PyQt4
from math import sqrt, pi, sin, cos, asin
from FreeCAD import Base
size = 10

poly = Part.makePolygon( [ (0,0,0), (size, 0, 0), (size, 0, size), (0, 0, size), (0, 0, 0)])
face1
face2
face3
face4
face5
face6

=
=
=
=
=
=

Part.Face(poly)
Part.Face(poly)
Part.Face(poly)
Part.Face(poly)
Part.Face(poly)
Part.Face(poly)

myMat = FreeCAD.Matrix()
myMat.rotateZ(math.pi/2)
face2.transformShape(myMat)
face2.translate(FreeCAD.Vector(size, 0, 0))
myMat.rotateZ(math.pi/2)
face3.transformShape(myMat)
face3.translate(FreeCAD.Vector(size, size, 0))
myMat.rotateZ(math.pi/2)
face4.transformShape(myMat)
face4.translate(FreeCAD.Vector(0, size, 0))
myMat = FreeCAD.Matrix()
myMat.rotateX(-math.pi/2)
face5.transformShape(myMat)
face6.transformShape(myMat)
face6.translate(FreeCAD.Vector(0,0,size))
myShell = Part.makeShell([face1,face2,face3,face4,face5,face6])
mySolid = Part.makeSolid(myShell)
mySolidRev = mySolid.copy()
mySolidRev.reverse()
myCyl = Part.makeCylinder(2,20)
myCyl.translate(FreeCAD.Vector(size/2, size/2, 0))
cut_part = mySolidRev.cut(myCyl)
Part.show(cut_part)

Loading and Saving


There are several ways to save your work in the Part module. You can of course save your FreeCAD document, but you can also save Part objects
directly to common CAD formats, such as BREP, IGS, STEP and STL.
Saving a shape to a file is easy. There are exportBrep(), exportIges(), exportStl() and exportStep() methods availables for all shape objects. So, doing:
import Part
s = Part.makeBox(0,0,0,10,10,10)
s.exportStep("test.stp")
this will save our box into a STEP file. To load a BREP, IGES or STEP file, simply do the contrary:
import Part
s = Part.Shape()
s.read("test.stp")
To convert an .stp in .igs file simply :
import Part
s = Part.Shape()
s.read("file.stp")
# incoming file igs, stp, stl, brep
s.exportIges("file.igs") # outbound file igs
Note that importing or opening BREP, IGES or STEP files can also be done directly from the File -> Open or File -> Import menu, while exporting is with
File -> Export
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Topological_data_scripting&oldid=42021"

Part Common
Extracts the common part (intersection) between selected Part objects. This operation is fully parametric and the
components can be modified and the result recomputed.

Part Common
Menu location
Part Common
Workbenches
Part,Complete
Default shortcut
None
See also
Part Fuse, Part Cut

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Common&oldid=72732"

Part Cut
Cuts (subtracts) selected Part objects, the last one being subtracted from the first one. This operation is fully
parametric and the components can be modified and the result recomputed.

Part Cut
Menu location
Part Cut
Workbenches
Part,Complete
Default shortcut
None
See also
Part Fuse, Part Common

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Cut&oldid=72766"

Part Cone
Description

Part_Cone

Menu location
Part -> Cone
Workbenches
The default values create a truncated parametric cone, defined by radius1, radius2 height and angle, parameters. The Part,Complete
default cone will be positioned at origin (point 0,0,0) on creation. The angle parameter permits the creation of a
portion of cone (it is set to 360 by default), and the radius 1 and 2 correspond to base and top radius of the Default shortcut
truncated cone.
None
See also
Parameters
Part_CreatePrimitives
A parametric truncated Part Cone primitive is available in the Part workbench from the Part tool bar, Part menu
(primitives sub-menu) and the Create Primitives dialogue.

Radius 1 - radius of the arc or circle defining the lower face


Radius 2 - radius of the arc or circle defining the upper face
Height - the height of the Part Cone
Angle - the number of degrees of the arc or circles defining the upper and lower faces of the truncated cone. The default 360 creates circular
faces, a lower value will create a portion of a cone as defined by upper and lower faces each with edges defined by an arc of the number of
degrees and two radii.
The image below shows a Part Cone with the parameter "Angle" set to 270 degrees and all other parameters are at their default values.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Cone&oldid=84304"

Part Shapebuilder
A tool to create more complex shapes from various parametric geometric primitives.

Part
Shapebuilder
Menu location
Part -> Shapebuilder...
Workbenches
Part
Default shortcut
None
See also
Part CreatePrimitives

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Shapebuilder&oldid=73837"

Part RegularPolygon
Description

32px
Part_RegularPolygon

Menu location
Part Create Primitives
Regular Polygon
The Create Primitives dialogue can be accessed via the CreatePrimitives icon
located in the Part menu or
the Part toolbar, in the Part Workbench.
Workbenches
Part, OpenSCAD
Default shortcut
Parameters
None
See also
Polygon - the number of sides of the polygon which describes the cross section of the Part Prism
..
cirumradius - the circumradius is the distance from the centre of the polygon to a vertex.
A RegularPolygon geometric primitive is available from the Create Primitives dialogue in the Part workbench.

available in version 0.14

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_RegularPolygon&oldid=84296"

Part Chamfer
Chamfers the selected edges of an object. A dialog allows you to choose which objects and which edges to work on.

Part Chamfer
Menu location
Part -> Chamfer
Workbenches
Part, Complete
Default shortcut
None
See also

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Chamfer&oldid=73058"

Part Fillet
Description

Part Fillet

Menu location
Part Fillet
Workbenches
Usage
Part, Complete
Start the tool from the Part toolbar or from the menu. You can either select the object before or after starting
Default shortcut
the tool.
If the shape was not selected prior to starting the tool, select it in the Shape drop down list in the TaskPanel. None
Select the fillet type, either constant radius (default) or variable radius.
See also
Select the edges either in the 3D model view, or by ticking them in the edge list in TaskPanel.
Set the radius value.
Part Chamfer
This tool creates a fillet (round) on the selected edges of an object. A dialog allows you to choose which objects and
which edges to work on.

Click OK to validate.

Part Fillet VS. PartDesign Fillet


There is another fillet tool in the PartDesign workbench. Please note that their operation is quite different. Check out the PartDesign Fillet reference
page for more details on their differences.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Fillet&oldid=73002"

Part Ellipsoid
This documentation is not finished. Please help and contribute documentation.
See Draft ShapeString for good documented Command. Gui Command gives an overview over commands.
And see List of Commands for other commands.
Go to Help FreeCAD to contribute.

32px Part Ellipsoid

Description

Menu location
Part Create Primitives
Ellipsoid
Workbenches
Part, OpenSCAD
Default shortcut
None
See also
..

Geometric Primitives

Ellipsoid
Parameter
Radius 1
Radius 2
U parametric:
V parametric:
V parametric:
Location

Property

View
.
Data
Base
DATA
DATA

Label:
Placement: placement

Ellipsoid
Dati
DATA

Angle1 :
Angle2 :

DATA
DATA
DATA

Angle3 :
Radius1 :
Radius2 :

Example
See Sphere
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Ellipsoid&oldid=73819"

Part Fuse
Fuses (unions) selected Part objects into one. This operation is fully parametric and the components can be
modified and the result recomputed.

Part Fuse
Menu location
Part -> Fuse
Workbenches
Part,Complete
Default shortcut
None
See also

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Fuse&oldid=72695"

Part Box
Part Box

Description

A parametric Rectangular cuboid primitive is available in the Part workbench from the Part tool bar, Part menu Menu location
(primitives sub-menu) and the Create Primitives dialogue. Beginning in FreeCAD version 0.14, a Part Box is referred Part -> Box
to in the GUI elements as a Cube and the default label is "Cube".

Parameters
The parametric rectangular cuboid is defined by the parameters
length,
width,
height,
as well as the standard set of Placement Parameters.

Workbenches
Part, Complete
Default shortcut
None
See also
Part CreatePrimitives

The default is a cube with parameter values for height, length and width being 10mm. The default placement values will locate the cuboid's local origin at
the global origin (the location where all axis are 0) and the orientation such that

The length is the distance in the x-axis.


The width is the distance in the y-axis.
The height is the distance in the z-axis.

FreeCAD - Version
available in version 0.14

Beginning in FreeCAD version 0.14, a Part Box is referred to in the GUI elements as a Cube and the default label is "Cube".

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Box&oldid=85344"

Part Circle
32px Part_Circle
Menu location
Part Create Primitives
Circle
A Circle geometric primitive is available from the Create Primitives dialogue in the Part workbench.
Workbenches
Part, OpenSCAD
The Create Primitives dialogue can be accessed via the CreatePrimitives icon
located in the Part menu or Default shortcut
the Part toolbar, in the Part Workbench.
None
See also
..
Geometric Primitives

Description

Circle
Parameter
Radius:
Angle 1:
Angle 2:
From three points:
Location

Property

View
..
Data
Base
Dati
Dati
Dati
Dati

Angle0 :
Angle1 :
Placement:
Radius :

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Circle&oldid=83883"

Part Extrude
Description

Part Extrude

A parametric Extrusion feature is available in the Part workbench from the Part tool bar and Part menu. Part Extrude Menu location
extends a shape by a specified distance, in a specified direction. The output shape type will vary depending on the Part -> Extrude
input shape type and the options selected.

Workbenches
Part, Complete
Default shortcut
Extrude a Vertex (point), will produce a lineal Edge (Line)
Extrude a open edge (e.g. line, arc), will produce a open face (e.g. plane)
None
Extrude a closed edge (e.g. circle), will optionally produce a closed face (e.g. an open ended cylinder) or if the
See also
parameter "solid" is "true" will produce a solid (e.g. a closed solid cylinder)

In most common scenarios, the following lists the expected output shape type from a given input shape type,

Extrude a open Wire (e.g. a Draft Wire), will produce a open shell (several joined faces)
Extrude a closed Wire (e.g. a Draft Wire), will optionally produce a shell (several joined faces) or if the
parameter "solid" is "true" will produce a solid
Extrude a face (e.g. plane), will produce a solid (e.g. Cuboid)
Extrude a Draft Shape String, will produce a compound of solids (the string is a compound of the letters which are each a solid)

Parameters
The parametric rectangular cuboid is defined by the parameters
Base, - the input shape, (the shape upon which the Part Extrude was applied)
Dir, the direction and distance to extend the shape, as defined by a specified distance in each of the x, y and Z axis.
solid, true or false, toggles between a surface or a solid where not other wise defined by the nature of the extrusion
Taper Angle,
Placement, the standard placement parameters
Label,

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Extrude&oldid=85371"

Part Wedge
32px Part Wedge
Create a parametric Wedge object. This Wedge defaults to a larger square base and a smaller square top.

Menu location
Part -> Part
Placement: The default orientation places the base in the XZ plane and the top outward in the Y axis direction. The CreatePrimitives -> Wedge
default base corner is the 0,0,0 origin.
Workbenches
Base Face:
Part
Default shortcut
X : 10 mm
Z : 10 mm
None
See also
Height:
Part_CreatePrimitives
Default Size and Placement

Y : 0-10 mm

Top Face:
X : 2-8 mm
Z : 2-8 mm

Parametric Inputs

Using the default placement, the below inputs are:


DATA
DATA
DATA
DATA
DATA

X min/max : Base face X axis span


Y min/max: Wedge height span
Z min/max : Base face Z axis span
X2 min/max : Top face X axis span
Z2 min/max : Top face Z axis span

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Part_Wedge&oldid=73229"

Drawing Module
The Drawing module allows you to put your 3D work on paper. That is, to put views of your models in a 2D window and to insert that window in a
drawing, for example a sheet with a border, a title and your logo and finally print that sheet. The Drawing module is currently under construction and
more or less a technology preview!

GUI Tools
These are tools for creating, configuring and exporting 2D drawing sheets

Open scalable vector graphic: Opens a drawing sheet previously saved as an SVG file
New A3 landscape drawing: Creates a new drawing sheet from FreeCAD's default A3 template
Insert a view: Inserts a view of the selected object in the active drawing sheet
Annotation: Adds an annotation to the current drawing sheet
Clip: Adds a clip group to the current drawing sheet
Open Browser: Opens a preview of the current sheet in the browser
Ortho Views: Automatically creates orthographic views of an object on the current drawing sheet
Symbol: Adds the contents of a SVG file as a symbol on the current drawing sheet
Save sheet: Saves the current sheet as a SVG file
Note The Draft Module has its own Draft_Drawing tool to place Draft objects on paper. It has a couple of extra capabilities over the standard Drawing
tools, and supports specific objects like Draft dimensions.

In the picture you see the main concepts of the Drawing module. The document contains a shape object (Schenkel) which we want to extract to a
drawing. Therefore a "Page" is created. A page gets instantiated through a template, in this case the "A3_Landscape" template. The template is an SVG
document which can hold your usual page frame, your logo or comply to your presentation standards.
In this page we can insert one or more views. Each view has a position on the page (Properties X,Y), a scale factor (Property scale) and additional
properties. Every time the page or the view or the referenced object changes the page gets regenerated and the page display updated.

Scripting
At the moment the end user(GUI) workflow is very limited, so the scripting API is more interesting. Here follow examples on how to use the scripting API
of the drawing module.
Here a script that can easily fill the Macro_CartoucheFC leaf FreeCAD A3_Landscape.

Simple example
First of all you need the Part and the Drawing module:
import FreeCAD, Part, Drawing
Create a small sample part
Part.show(Part.makeBox(100,100,100).cut(Part.makeCylinder(80,100)).cut(Part.makeBox(90,40,100)).cut(Part.makeBox(20,85,100)))
Direct projection. The G0 means hard edge, the G1 is tangent continuous.
Shape = App.ActiveDocument.Shape.Shape
[visibleG0,visibleG1,hiddenG0,hiddenG1] = Drawing.project(Shape)
print "visible edges:", len(visibleG0.Edges)
print "hidden edges:", len(hiddenG0.Edges)
Everything was projected on the Z-plane:

print "Bnd Box shape: X=",Shape.BoundBox.XLength," Y=",Shape.BoundBox.YLength," Z=",Shape.BoundBox.ZLength


print "Bnd Box project: X=",visibleG0.BoundBox.XLength," Y=",visibleG0.BoundBox.YLength," Z=",visibleG0.BoundBox.ZLength
Different projection vector
[visibleG0,visibleG1,hiddenG0,hiddenG1] = Drawing.project(Shape,App.Vector(1,1,1))
Project to SVG
resultSVG = Drawing.projectToSVG(Shape,App.Vector(1,1,1))
print resultSVG

The parametric way


Create the body
import FreeCAD
import Part
import Drawing
# Create three boxes and a cylinder
App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.Box.Length=100.00
App.ActiveDocument.Box.Width=100.00
App.ActiveDocument.Box.Height=100.00
App.ActiveDocument.addObject("Part::Box","Box1")
App.ActiveDocument.Box1.Length=90.00
App.ActiveDocument.Box1.Width=40.00
App.ActiveDocument.Box1.Height=100.00
App.ActiveDocument.addObject("Part::Box","Box2")
App.ActiveDocument.Box2.Length=20.00
App.ActiveDocument.Box2.Width=85.00
App.ActiveDocument.Box2.Height=100.00
App.ActiveDocument.addObject("Part::Cylinder","Cylinder")
App.ActiveDocument.Cylinder.Radius=80.00
App.ActiveDocument.Cylinder.Height=100.00
App.ActiveDocument.Cylinder.Angle=360.00
# Fuse two boxes and the cylinder
App.ActiveDocument.addObject("Part::Fuse","Fusion")
App.ActiveDocument.Fusion.Base = App.ActiveDocument.Cylinder
App.ActiveDocument.Fusion.Tool = App.ActiveDocument.Box1
App.ActiveDocument.addObject("Part::Fuse","Fusion1")
App.ActiveDocument.Fusion1.Base = App.ActiveDocument.Box2
App.ActiveDocument.Fusion1.Tool = App.ActiveDocument.Fusion
# Cut the fused shapes from the first box
App.ActiveDocument.addObject("Part::Cut","Shape")
App.ActiveDocument.Shape.Base = App.ActiveDocument.Box
App.ActiveDocument.Shape.Tool = App.ActiveDocument.Fusion1
# Hide all the intermediate shapes
Gui.ActiveDocument.Box.Visibility=False
Gui.ActiveDocument.Box1.Visibility=False
Gui.ActiveDocument.Box2.Visibility=False
Gui.ActiveDocument.Cylinder.Visibility=False
Gui.ActiveDocument.Fusion.Visibility=False
Gui.ActiveDocument.Fusion1.Visibility=False
Insert a Page object and assign a template
App.ActiveDocument.addObject('Drawing::FeaturePage','Page')
App.ActiveDocument.Page.Template = App.getResourceDir()+'Mod/Drawing/Templates/A3_Landscape.svg'
Create a view on the "Shape" object, define the position and scale and assign it to a Page
App.ActiveDocument.addObject('Drawing::FeatureViewPart','View')
App.ActiveDocument.View.Source = App.ActiveDocument.Shape
App.ActiveDocument.View.Direction = (0.0,0.0,1.0)
App.ActiveDocument.View.X = 10.0
App.ActiveDocument.View.Y = 10.0
App.ActiveDocument.Page.addObject(App.ActiveDocument.View)
Create a second view on the same object but this time the view will be rotated by 90 degrees.
App.ActiveDocument.addObject('Drawing::FeatureViewPart','ViewRot')
App.ActiveDocument.ViewRot.Source = App.ActiveDocument.Shape
App.ActiveDocument.ViewRot.Direction = (0.0,0.0,1.0)
App.ActiveDocument.ViewRot.X = 290.0
App.ActiveDocument.ViewRot.Y = 30.0
App.ActiveDocument.ViewRot.Scale = 1.0
App.ActiveDocument.ViewRot.Rotation = 90.0
App.ActiveDocument.Page.addObject(App.ActiveDocument.ViewRot)
Create a third view on the same object but with an isometric view direction. The hidden lines are activated too.
App.ActiveDocument.addObject('Drawing::FeatureViewPart','ViewIso')
App.ActiveDocument.ViewIso.Source = App.ActiveDocument.Shape
App.ActiveDocument.ViewIso.Direction = (1.0,1.0,1.0)
App.ActiveDocument.ViewIso.X = 335.0
App.ActiveDocument.ViewIso.Y = 140.0
App.ActiveDocument.ViewIso.ShowHiddenLines = True
App.ActiveDocument.Page.addObject(App.ActiveDocument.ViewIso)
Change something and update. The update process changes the view and the page.
App.ActiveDocument.View.X = 30.0
App.ActiveDocument.View.Y = 30.0

App.ActiveDocument.View.Scale = 1.5
App.ActiveDocument.recompute()

Accessing the bits and pieces


Get the SVG fragment of a single view
ViewSVG = App.ActiveDocument.View.ViewResult
print ViewSVG
Get the whole result page (it's a file in the document's temporary directory, only read permission)
print "Resulting SVG document: ",App.ActiveDocument.Page.PageResult
file = open(App.ActiveDocument.Page.PageResult,"r")
print "Result page is ",len(file.readlines())," lines long"
Important: free the file!
del file
Insert a view with your own content:
App.ActiveDocument.addObject('Drawing::FeatureView','ViewSelf')
App.ActiveDocument.ViewSelf.ViewResult = """<g id="ViewSelf"
stroke="rgb(0, 0, 0)"
stroke-width="0.35"
stroke-linecap="butt"
stroke-linejoin="miter"
transform="translate(30,30)"
fill="#00cc00"
>
<ellipse cx="40" cy="40" rx="30" ry="15"/>
</g>"""
App.ActiveDocument.Page.addObject(App.ActiveDocument.ViewSelf)
App.ActiveDocument.recompute()
del ViewSVG
That leads to the following result:

General Dimensioning and Tolerancing


Drawing dimensions an toleranecs are still under development but you can get some basic functionality with a bit of work.
First you need to get the gdtsvg python module from here (WARNING: This could be broken at any time!):
https://github.com/jcc242/FreeCAD
To get a feature control frame, try out the following:
import gdtsvg as g # Import the module, I like to give it an easy handle
ourFrame = g.ControlFrame("0","0", g.Perpendicularity(), ".5", g.Diameter(), g.ModifyingSymbols("M"), "A",
g.ModifyingSymbols("F"), "B", g.ModifyingSymbols("L"), "C", g.ModifyingSymbols("I"))
Here is a good breakdown of the contents of a feature control frame: http://www.cadblog.net/adding-geometric-tolerances.htm
The parameters to pass to control frame are:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

X-coordinate in SVG-coordinate system (type string)


Y-coordinate in SVG-coordinate system (type string)
The desired geometric characteristic symbol (tuple, svg string as first, width of symbol as second, height of symbol as third)
The tolerance (type string)
(optional) The diameter symbol (tuple, svg string as first, width of symbol as second, height of symbol as third)
(optional) The condition modifying material (tuple, svg string as first, width of symbol as second, height of symbol as third)
(optional) The first datum (type string)
(optional) The first datum's modifying condition (tuple, svg string as first, width of symbol as second, height of symbol as third)
(optional) The second datum (type string)
(optional) The second datum's modifying condition (tuple, svg string as first, width of symbol as second, height of symbol as third)

11. (optional) The third datum (type string)


12. (optional) The third datum's material condition (tuple, svg string as first, width of symbol as second, height of symbol as third)
The ControlFrame function returns a type containing (svg string, overall width of control frame, overall height of control frame)
To get a dimension, try out the following:
import gdtsvg
ourDimension = linearDimension(point1, point2, textpoint, dimensiontext, linestyle=getStyle("visible"),
arrowstyle=getStyle("filled"), textstyle=getStyle("text")
Inputs for linear dimension are:
1.
2.
3.
4.
5.
6.
7.

point1, an (x,y) tuple with svg-coordinates, this is one of the points you would like to dimension between
point2, an (x,y) tuple with svg-coordinates, this is the second point you would like to dimension between
textpoint, an (x,y) tuple of svg-coordinates, this is where the text of your dimension will be
dimensiontext, a string containing the text you want the dimension to say
linestyle, a string containing svg (i.e. css) styles, using the getStyle function to retrieve a preset string, for styling the how the lines look
arrowstyle, a string containing svg (i.e. css) styles, using the getStyle function to retrieve a preset string, for styling how the arrows look
textstyle, a string containing svg (i.e. css) styles, using the getStyle function to retrieve a preset string, for styling how the text looks

With those two, you can proceed as above for displaying them on the drawing page. This module is very buggy and can be broken at any given moment,
bug reports are welcome on the github page for now, or contact jcc242 on the forums if you post a bug somewhere else.

Templates
FreeCAD comes bundled with a set of default templates, but you can find more on the Drawing templates page.

Extending the Drawing Module


Some notes on the programming side of the drawing module will be added to the Drawing Documentation page. This is to help quickly understand
how the drawing module works, enabling programmers to rapidly start programming for it.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_Module&oldid=70981"

Drawing Orthoviews
This tool insert an orthographic projection of the selected object in the active drawing sheet.

How to use

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_Orthov iew s&oldid=79482"

Drawing
Orthoviews
Menu location
Drawing Insert
orthographic views
Workbenches
Drawing, Complete
Default shortcut
none
See also
Drawing Landscape A3

Drawing Documentation
This page documents jcc242's understanding of the Drawing module. It includes files and features that he is currently working on and may not yet be in
the master branch. The source for those files is on his Github, but be careful as that is very unstable!

Base (Mod/Drawing)
gdtsvg.py
Python script that generates svg snippets for things such as gd&t symbols, dimension symbols, and basic svg elements such as lines, circles, and
paths.
It has several support files that don't really do much. Run DrawingTest.py to create a bunch of svg icons in the icon directory that previews various icons
in the gdtsvg.py file. settingslist.py and dimesettings, and convert.py are all deprecated from older settings methods and should probably be removed as
the Drawing branch approaches merging into master.

DrawingAlgos.py
Creates svg lines from a list of vertices, supports both hidden and visible edges. Should probably be merged with gdtsvg.py as that file matures.
createSVG
Accepts part as an argument, projects the part into lines from the Drawing.project object and then draws creates the svg for each line.

App
Contains the backend side of the drawing module.

AppDrawing.cpp
Initializes the various namespaces and modules and stuff used in the drawing module. Will throw an error if it cannot load the Part module.

DrawingExport.cpp
Two classes: SVGOutput and DXFOutput. They both contain methods to put out the code in their respective language. Typically require an object of the
appropriate typedef, and sometimes some additional identifier information.

FeatureClip.cpp
Callback (?) methods for the feature clipping gui, so it would seem. Called alone it will create the clip path, if ShowFrame.getValue is TRUE set it will
show the frame border as well.

FeaturePage.cpp
Manages the views. onChanged() for doing stuff when properties get changed. execute() for recalculating a feature view, or so it claims. It seems to have
stuff for checking for editable texts and saving drawings. Need to investigate further. getEditableTextsFromTemplate() for retrieving text that can be edited
by FreeCAD from an SVG file.

FeatureProjection.cpp
Flattens object to a 2D image?

FeatureView.cpp
Defines the properties for views.

FeatureViewAnnotation.cpp
Defines properties for annotations (right now just text), has an execute method to update the text if changed/moved.

FeatureViewPart.cpp
Constructor to add properties. Gets appearance stuff for projected parts.

PageGroup.cpp
Just adds a property for a list of pages, does not much else.

Precompiled.cppp
Just #include "PreCompiled.h"

ProjectionAlgos.cpp
The constructor just runs the execute() method to update it's stuff invertY: since SVG does its y-axis backwards to every other coordinate system in the
world, we must invert it when converting from a FreeCAD part to an SVG projection for the Drawing view.
getSVG: fetches the SVG code from the DrawingExport stuff. Formats depending on type of line (hidden or not and some other stuff I need to figure out).
getDXF: same as getSVG except for DXF format.

Gui
AppDrawingGui.cpp

Initializes the drawing gui.

AppDrawingGuiPy.cpp
Provides opening, importing, and exporting interfaces? Looks like it is python accessible.

Command.cpp
Handles commands (from the toolbar?) such as creating new drawings and stuff. It looks like this handles QT calls from clicking the button to whatever
command it needs to go to (e.g. clicking the CmdDrawingOrthoViews button will show the Ortho views gui in the task dialog spot.

DrawingView.cpp
Does a bunch of qt gui stuff, need to read more on it.

TaskDialog.cpp
Creates the task dialog thing on the side and probably switches to it from the tree view, as appropriate.

TaskOrthoViews.cpp
Creates the task dialog for placing the orthographic views!
Does a lot of the calculations for where to position stuff (automatic calculations as well, it seems).
Takes the input from the TaskOrthoViews gui and does stuff with it. Uses the single inheritance method talked about on the qt website.

ViewProviderPage.cpp
Constructor adds some properties for the view stuff. Destructor does nothing. Attaches something (attaches what? attaches the view to the page?) sets
and gets display modes (what are display modes? what do they do and what are possible options?) Does something about updating some kind of data
has a context menu that says "Show drawing", figure out what this means Has a thing for double clicking to select the view (I think?) showDrawingView
seems to do some work on settings things up: gets the current document, sets the window icon and title, adds it to the main window (of FreeCAD?)

ViewProviderView.cpp
Doesn't seem to do much, though I am sure it is important.

Workbench.cpp
Adds the icons to the toolbars and stuff.

Workflow
Program Flow
CanvasView is the actual QGraphicsScene object and DrawingView processes a list of FeatureView that are linked by reference in
/App/FeatureViewPage. DrawingView then chooses the appropriate QGraphicsItem class (QGraphicsItemViewPart or QGraphicsItemViewDimension)
and then calls a function in CanvasView to create this and add it to the scene.

Adding commands to the Drawing Workbench


4 simple steps:
1.
2.
3.
4.

Add a class to Command.cpp. Follow the others for an example of the formatting.
Add a title, icon, tooltip, etc., again, follow the existing classes in command.cpp
Add your class to the bottom of Command.cpp
Add your information to Workbench.cpp, this will tell FreeCAD/Drawing module where to place the icons defined in command.cpp in the actual
freecad interface (the toolbars, dropdowns, etc.)

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_Documentation&oldid=83920"

Drawing Landscape A3
Drawing
This tool creates a new drawing sheet from already installed templates. Currently, even though the menu and the
toolbar allow for A0 to A4 landscape formats, only an A3 Landscape template is available.
Landscape A3
A Page object will be added to the Project tree, taking the form of a folder icon. Views that will be created afterward
will be placed underneath this folder.
Menu

location
To open the Drawing viewer to display the page, simply double-click on the Page object, or right-click Show Drawing Insert new
drawing. The page will be opened in a new tab. You can close the tab and open it again at any time the same way. drawing A3 Landscape
Workbenches
If the page does not display, click on the
refresh icon in the main toolbar, or go to Edit Refresh menu, or
Drawing, Complete
shortcut CTRL+R .
Default shortcut
none
See also
None

Options
The template used by a Page can be changed through its Template property in Data view. Click on the value field, then on the "..." button and
navigate to a suitable template. Then refresh the view.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_Landscape_A3&oldid=55977"

Drawing Save
This tool saves the current Drawing sheet as an SVG (scalable vector graphics) file. Such a file can then be edited in
a scalable vector graphics program such as Inkscape.

Drawing Save
Menu location
Export page...
Workbenches
Drawing, Complete
Default shortcut
none
See also
Drawing Open SVG

SVG files are common and can be viewed in most modern browsers and image viewers. It can be a useful way to
share a design with people who don't have FreeCAD installed on their PC.
Drawing

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_Sav e&oldid=56113"

Drawing Open SVG


Drawing
This tool opens a drawing sheet previously saved as an SVG (scalable vector graphics) file. It can also be used to
display any SVG.
SVG

Open

Menu location
Drawing Open SVG...
Workbenches
Drawing, Complete
Default shortcut
none
See also
Drawing Save
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_Open_SVG&oldid=55949"

Drawing Openbrowser
Description

Drawing
Openbrowser

This command allows you to display a selected Drawing page using FreeCAD's internal web browser. The normal
Drawing page viewer of FreeCAD is based on Qt's built-in SVG rendering module, which only supports a tiny Menu location
subset of the full SVG specification. As a result, some more advanced SVG features, such as pattern fills or
Drawing Open Browser
multiline texts are not supported by this viewer. The FreeCAD internal web browser, however, is built on webkit,
which is one of the best SVG renderers available, and will correctly render your page with all its features.
Workbenches

How to use
1.
2.
3.
4.

Create a Drawing page


Add some views or other content to your page
Refresh the view if a Drawing view wasn't opened
Press the
Drawing Openbrowser button

Drawing, Complete
Default shortcut
none
See also
None

Limitations
A page opened in the web browser will not refresh automatically on changes. You must use right-click -> reload manually.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_Openbrow ser&oldid=76097"

Drawing Annotation
Description
This command allows you to place a block of text on a Drawing page.

How to use
1.
2.
3.
4.

Create a Drawing page


Refresh the view if a Drawing view wasn't opened
Press the
Drawing Annotation button
Adjust the desired properties, such as text contents, font, size and position.

Limitations
Texts spanned on multiple lines are not supported by the internal Qt-based Svg viewer, but the Open
Browser command shows these texts correctly.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_Annotation&oldid=76114"

Drawing
Annotation
Menu location
Drawing Annotation
Workbenches
Drawing, Complete
Default shortcut
none
See also
None

Drawing Symbol
Description

Drawing Symbol

This command allows you to add the contents of a SVG image on a selected Drawing page. These contents can Menu location
then be moved and rescaled on the page. The contents of the SVG image are copied into the FreeCAD document, Drawing Symbol
so it is independent from the original file, and will display the same way on another computer that doesn't have the
Workbenches
original SVG file.

How to use
1.
2.
3.
4.
5.

Create a Drawing page


Refresh the view if a Drawing viewer wasn't opened
Press the
Drawing Symbol button
Select a SVG file
Adjust the needed properties, like position and scale.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_Symbol&oldid=76100"

Drawing, Complete
Default shortcut
none
See also
None

Drawing Clip
Description

Drawing_Clip

This command allows you to place a clipping rectangle on a Drawing page. Drawing View objects can then be Menu location
added to that clipping rectangle, and their display will be truncated by the borders of the rectangle.
Drawing Clip

How to use
1.
2.
3.
4.
5.

Create a Drawing page


Refresh the view if a Drawing view wasn't opened
Press the
Drawing Clip button
Adjust the desired properties, such as size and position.
Drag and Drop Drawing View objects on the Clip object in the Tree View

Workbenches
Drawing, Complete
Default shortcut
none
See also
None

Options
A property allows you to show or hide the clipping rectangle itself.

Limitations
Clipping objects are not displayed properly by the internal Qt-based Svg viewer, but the Open Browser command shows them correctly.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_Clip&oldid=75966"

Drawing View
Drawing View

This tool creates a new view of the selected object in the active drawing sheet.

Menu location
Drawing Insert view in
drawing
Workbenches
Drawing, Complete
Default shortcut
none
See also
Drawing Landscape A3

How to use
Select an object either in the 3D view or the Project tree, then click on the Drawing View tool. By default, a top view scaled at 1:1 (real scale) will be
placed at the top left of the page. It may not be visible if it's too small or too big for the page.
A View object is added to the Page object in the Project tree. For subsequent views, a three-digit number will be appended to the name. Click on the
arrow in front of the Page object to unfold it and display the views it contains.

Modify an existing view


Unfold the Page object in the Project tree, and select the View. Its parameters can be edited in the Property View Data tab.

Isometric
view
with
smooth lines visibility off

Isometric
view
with
smooth lines visibility on
Label: changes the view's label in the Project tree. You can also click on the View in the tree and right-click Rename, or press F2 .
Rotation: rotates the view. For example, an isometric view will require a 60 degree rotation (see also Direction parameter below)
Scale: sets the view scale.
X: sets the view's horizontal position on the page in millimeters.
Y: sets the view's vertical position on the page in millimeters. Please note that coordinate (0,0) is located at the top left of the page, so the higher

the number, the lower in the page the view will be.
Direction: changes the view direction. It is set by xyz values that define a vector normal to the page. Top view will be (0,0,1), and isometric will be
(1,1,1). Values can be negative.
Show Hidden Lines: toggles the hidden lines visibility on or off by selecting True or False.
Show Smooth Lines: toggles the smooth lines visibility on or off by selecting True or False. Smooth lines are also called tangency edges.
These edges indicate surface changes between tangent surfaces.

Drawing View Wizard


To generate a drawing sheet with standard views automatically, use the Automatic drawing Macro.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draw ing_View &oldid=56042"

Raytracing Module
The Raytracing module is used to generate photorealistic images of your models, by rendering them with an external renderer. The Raytracing
workbench works with templates, the same way as the Drawing workbench, by allowing you to create a Raytracing project, in which you add views of
your objects. The project can then be exported to a ready-to-render file, or be rendered directly.

Currenly, two renderers are supported: povray and luxrender. To be able to render directly from FreeCAD, at least one of those renderers must be
installed on your system, and its path configured in the FreeCAD Raytracing preferences. Without any renderer installed, yhough, you are still able to
export a scene file that can be used in any of those renderers later, or on another machine.
The raytracing workbench works with templates, which are complete scene files for the given external renderer, including lights and possibly additional
geometry such as ground planes. These scene files contain placeholders, where FreeCAD will insert the position of the camera, and geometry and
materials information of each of the objects you insert in the project. That modified scene file is what is then exported to the external renderer.

Tools
Raytracing project tools
These are the main tools for exporting your 3D work to external renderers

New PovRay project: Insert new PovRay project in the document


New LuxRender project: Insert new LuxRender project in the document
Insert part: Insert a view of a Part in a raytracing project
Reset camera: Matches the camera position of a raytracing project to the current view
Export project: Exports a raytracing project to a scene file for rendering in an external renderer
Render: Renders a raytracing project with an external renderer

Utilities
These are helper tools to perform specific tasks manually

Export view to povray: Write the active 3D view with camera and all its content to a povray file
Export camera to povray: Export the camera position of the active 3D view in POV-Ray format to a file
Export part to povray: Write the selected Part (object) as a povray file

Typical workflow
1.
2.
3.
4.

Create or open a FreeCAD project, add some Part-based objects (meshes are currently not supported)
Create a Raytracing project (luxrender or povray)
Select the objects you wish to add to the raytracing project and add them to the project with the "Insert Part" tool
Export or render directly

Creating a povray file manually


The utility tools described above allow you to export the current 3D view and all of its content to a Povray file. First, you must load or create your CAD
data and position the 3D View orientation as you wish. Then choose "Utilities->Export View..." from the raytracing menu.

You get ask for a location to save the resulting *.pov file. After that you can open it in Povray and render:

As usual in a rendererer you can make big and nice pictures:

Scripting
Outputting render files
The Raytracing and RaytracingGui modules provide several methods to write scene contents as povray or luxrender data. The most useful are
Raytracing.getPartAsPovray() and Raytracing.getPartAsLux() to render a FreeCAD Part object into a povray or luxrender definition, and
RaytracingGui.povViewCamera() and RaytracinGui.luxViewCamera() to get the current point of view of the FreeCAD 3D window into povray or luxrender
format.
Here is how to write a povray file from python, assuming your document contains a "Box" object:
import Raytracing,RaytracingGui
OutFile = open('C:/Documents and Settings/jriegel/Desktop/test.pov','w')
OutFile.write(open(App.getResourceDir()+'Mod/Raytracing/Templates/ProjectStd.pov').read())
OutFile.write(RaytracingGui.povViewCamera())
OutFile.write(Raytracing.getPartAsPovray('Box',App.activeDocument().Box.Shape,0.800000,0.800000,0.800000))
OutFile.close()
del OutFile
And the same for luxrender:
import Raytracing,RaytracingGui
OutFile = open('C:/Documents and Settings/jriegel/Desktop/test.lxs','w')
OutFile.write(open(App.getResourceDir()+'Mod/Raytracing/Templates/LuxClassic.lxs').read())
OutFile.write(RaytracingGui.luxViewCamera())
OutFile.write(Raytracing.getPartAsLux('Box',App.activeDocument().Box.Shape,0.800000,0.800000,0.800000))
OutFile.close()
del OutFile

Creating a custom render object


Apart from standard povray and luxrender view objects, that provide a view of an existing Part object, and that can be inserted in povray and luxrender
projects respectively, a third object exist, called RaySegment, that can be inserted either in povray or luxrender projects. That RaySegment object is not
linked to any of the FreeCAD objects, and can contain custom povray or luxrender code, that you might wish to insert into your raytracing project. You
can also use it, for example, to output your FreeCAD objects a certain way, if you are not happy with the standard way. You can create and use it like
this from the python console:
myRaytracingProject = FreeCAD.ActiveDocument.PovProject
myCustomRenderObject = FreeCAD.ActiveDocument.addObject("Raytracing::RaySegment","myRenderObject")
myRaytracingProject.addObject(myCustomRenderObject)
myCustomRenderObject.Result = "// Hello from python!"

Links
POVRay
http://www.spiritone.com/~english/cyclopedia/

http://en.wikipedia.org/wiki/POV-Ray

Luxrender
http://www.luxrender.net/

Future possible renderers to implement


http://www.yafaray.org/
http://www.mitsuba-renderer.org/
http://www.kerkythea.net/
Currently there is a new Renderer Workbench in development to support multiple back-ends such as Lux Renderer and Yafaray. Information for using the
development version can be viewed at Render_project
For Development status of the Render Module look here Raytracing_project

Templates
FreeCAD comes with a couple of default templates for povray and luxrender, but you can easily create your own. All you need to do is to create a scene
file for the given renderer, then edit it manually with a text editor to insert special tags that FreeCAD will recognize and where it will insert its contents
(camera and objects data)

Povray
Povray scene files (with extension .pov) can be created manually with a text editor (povray is made primarily to be used as a scripting language), but
also with a wide range of 3D applications, such as blender. On the povray website you can find further information and a list of applications able to
produce .pov files.
When you have a .pov file ready, you need to open it with a text editor, and do two operations:
1. Strip out the camera information, because FreeCAD will place its own camera data. To do so, locate a text block like this: camera { ... },
which describes the camera parameters, and delete it (or put "//" in front of each line to comment them out).
2. Insert the following line somewhere: //RaytracingContent. This is where FreeCAD will insert its contents (camera and objects data). You
can, for example, put this line at the very end of the file.
Note that FreeCAD will also add some declarations, that you can use in your template, after the //RaytracingContent tag. These are:
cam_location: the location of the camera
cam_look_at: the location of the target point of the camera
cam_sky: the up vector of the camera.
cam_angle: the angle of the camera
If you want, for example, to place a lamp above the camera, you can use this:
light_source {
cam_location + cam_angle * 100
color rgb <10, 10, 10>
}

Luxrender
Luxrender scene files (with extension.lxs) can either be single files, or a master .lxs file that includes world definition (.lxw), material definition (.lxm) and
geometry definition (.lxo) files. You can work with both styles, but it is also easy to transform a group of 4 files in a single .lxs file, by copying the
contents of each .lxw, .lxm and .lxo file and pasting it at the point where that file is inserted in the master .lxs file.
Luxrender scene files are hard to produce by hand, but are easy to produce with many 3D applications such as blender. On the luxrender website,
you'll find more information and plugins for the main 3D applications out there.
If you will work with separated .lxw, .lxm and .lxo files, beware that the final .lxs exported by FreeCAD might be at a different location than the template
file, and therefore these files might not be found by Luxrender at render time. In this case you should or copy these files to the location of your final file,
or edit their paths in the exported .lxs file.
If you are exporting a scene file from blender, and wish to merge everything into one single file, you will need to perform one step before exporting: By
default, the luxrender exporter in blender exports all mesh geometry as separate .ply files, instead of placing the mesh geometry directly inside the .lxo
file. To change that behaviour, you need to select each of your meshes in blender, go to the "mesh" tab and set the option "export as" to "luxrender
mesh" for each one of them.
After you have your scene file ready, to turn it into a FreeCAD template, you need to perform the following steps:
1. Locate the camera position, a single line that begins with LookAt, and delete it (or place a "#" at the beginning of the line to comment it out)
2. At that place, insert the following line: #RaytracingCamera
3. At a desired point (for example just after the end of the materials definition, before the geometry information, or at the very end, just before the
final WorldEnd line, insert the following line: #RaytracingContent. That is where FreeCAD will insert its own objects.
Note that in luxrender, the objects stored in a scene file can define transformation matrixes, that perform location, rotation or scaling operations. These
matrixes can stack and affect everything that come after them, so, by placing your #RaytracingContent tag at the end of the file, you might see
your FreeCAD objects affected by a transformation matrix placed earlier in the template. To make sure that this doesn't happen, place your
#RaytracingContent tag before any other geometry object present in the template. FreeCAD itself won't define any of those transformation matrixes.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Raytracing_Module&oldid=76998"

Raytracing project
This is the FreeCAD Raytracing development project. It follows the rules of the Getting things done process. The projects are collected in the
Development roadmap.

Purpose and principles


This project is to update the current render module [Raytracing_Module] that currently uses povray, a biased renderer which gives satisfactory results
and allow more modern renderers such as Lux Render, Yafaray, Indigo renderers to be used.
Also to provide a generic interface to allow multiple render back-ends to be used to visualise Features within FreeCad. Providing a more generic
programming interface will allow render plugins to be created more easily.
The interface will allow both open source and proprietary external renderers to be used by generating a compatible scene file and launching a separate
process in the background. The output can then be previewed inside Freecad directly by opening the temporary output file (if available).
Each renderer will be a plugin into a generic interface and provide compatible materials and rendering modes.

Outcome
Nice Visuals!!! Produce high quality outputs of parts within the Freecad document and provide a very simple interface with presets to allow quick
initialisation for rendering and previews.
The user interface should allow more complex situations to be created and possibly previewed such as changing and modifying lights and positions.
However, the aim is to not provide a full featured render suite.

Brainstorming
A library of material 'must' be created for each render plugin along with presets. Material properties can be changed. Scene presets should allow users
with inexperience with Rendering to produce nice visuals in little time.

Organising
The generic inteface is currently being created and to test the integration Lux render, an unbiased renderer will be first implemented. Current work is
being completed by mrlukeparry on his render branch Github Render Branch.
Currently it is possible to render objects to Lux Render:

Featured is a part that was creating using PartDesign/Sketcher then rendered using the new render workbench being developed in Lux Render. Lux
Render allows nice effects such as DOF to be created to improve realism.

Next actions
Create the Abstraction to provide the interface between renderers (Done)
Implement an interface for describing generic materials and collecting these (Done)

Implement an interface for describing render presets (Done)


Implement an interface for describing templates (Done)
Implement a feature to store all this information permanently (WIP)

Create a workbench environment for displaying the output (Done)


Create workbench tools for changing render properties (Done)
Create workbench tools for browsing, changing and applying materials to part features (Done)
Create automake scripts (WIP)
Remove any GUI dependencies from Raytracing/App (Done)
Bounding Box data structure should not use coin3d SbBox3f (Done)
QWidget Included in QProcess for some reason (Fixed)
Test compatibility with Windows (in progress)
Update Libpack to include QT 4.7 - QT 4.8
Remove compiler warnings and errors
Implement saving of Material Properties (Done)
Tidying the QML interface (WIP)
Creating Render Templates / Render Materials / Render Presets
Create a blender scene to lux template converter
Convert LuxBlender Materials .lbm (http://www.luxrender.net/lrmdb/en/material/) to useful Render Materials
Create python bindings for Render Materials, Cameras, Lights
Create a RenderCamera Document object
Allow scene template to be imported into the render feature.
User defined preset/material/template directories
Improve the View Provider
Convert Povray/Yafaray to use the new Render Module Infrastructure
Testing
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Raytracing_proj ect&oldid=13203"

Image Module
The image module manages different types of bitmap images, and lets you open them in FreeCAD. Currently, the modules lets you open .bmp, .jpg,
.png and .xpm file formats in a separate viewer window.
The image workbenches also allow to open an image on a plane in the 3D-space of FreeCAD. This function is available via the second button of the

image workbench.
The plane can be moved in 3D-space by editing the placement in the Property editor. The major use is tracing over the image, in order to generate a
new part at using the image as template.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Image_Module&oldid=76913"

Draft Module
The Draft workbench allows to quickly draw simple 2D objects in the current document, and offers several tools to modify them afterwards. Some of
these tools also work on all other FreeCAD objects, not only those created with the Draft workbench. It also provides a complete snapping system, and
several utilities to manage objects and settings.

Drawing objects
These are tools for creating objects.
Line: Draws a line segment between 2 points
Wire: Draws a line made of multiple line segments (polyline)
Circle: Draws a circle from center and radius
Arc: Draws an arc segment from center, radius, start angle and end angle
Ellipse: Draws an ellipse from two corner points
Polygon: Draws a regular polygon from a center and a radius
Rectangle: Draws a rectangle from 2 opposite points
Text: Draws a multi-line text annotation
Dimension: Draws a dimension annotation
BSpline: Draws a B-Spline from a series of points
Point: Inserts a point object
ShapeString: The ShapeString tool inserts a compound shape representing a text string at a given point in the current document
Facebinder: Creates a new object from selected faces on existing objects
Bezier Curve: Draws a Bezier curve from a series of points

Modifying objects
These are tools for modifying existing objects. They work on selected objects, but if no object is selected, you will be invited to select one.
Move: Moves object(s) from one location to another
Rotate: Rotates object(s) from a start angle to an end angle
Offset: Moves segments of an object about a certain distance
Trim/Extend (Trimex): Trims or extends an object
Upgrade: Joins objects into a higher-level object
Downgrade: Explodes objects into lower-level objects
Scale: Scales selected object(s) around a base point
Drawing: Writes selected objects to a Drawing sheet
Edit: Edits a selected object
Wire to BSpline: Converts a wire to a BSpline and vice-versa
Add point: Adds a point to a wire or BSpline
Delete point: Deletes a point from a wire or BSpline
Shape 2D View: Creates a 2D object which is a flattened 2D view of another 3D object
Draft to Sketch: Converts a Draft object to Sketch and vice-versa
Array: Creates a polar or rectangular array from selected objects
Path Array: Creates an array of objects by placing the copies along a path
Clone: Clones the selected objects

Utility tools
Additional tools available via right-click context menu, depending on the selected objects.

Set working plane: Sets a working plane from a standard view or a selected face
Finish line: Ends the drawing of the current wire or bspline, without closing it
Close line: Ends the drawing of the current wire or bspline, and closes it
Undo line: Undoes the last segment of a line
Toggle construction mode: Toggles the Draft construction mode on/off
Toggle continue mode: Toggles the Draft continue mode on/off
Apply style: Applies the current style and color to selected objects
Toggle display mode: Switches the display mode of selected objects between "flat lines" and "wireframe"
Add to group: Quickly adds selected objects to an existing group
Select group contents: Selects the contents of a selected group
Toggle snap: Toggles object snapping on/off
Toggle grid: Toggles the grid on/off
Show snap bar: Shows/hides the snapping toolbar
Heal: Heals problematic Draft objects found in very old files
Flip Dimension: Flips the orientation of the text of a dimension

File formats
The Draft module provides FreeCAD with importers and exporters for the following file formats:
Autodesk .DXF: Imports and exports Drawing Exchange Format files created with 2D CAD applications
SVG (as geometry): Imports and exports Scalable Vector Graphics files created with vector drawing applications
Open Cad format .OCA: Imports and exports OCA/GCAD files, a potentially new open CAD file format
Airfoil Data Format .DAT: Imports DAT files describing Airfoil profiles
Autodesk .DWG: Import and exports DWG files via the DXF importer, when the Teigha Converter utility is installed.

Additional features
Snapping: Allows to place new points on special places on existing objects
Constraining: Allows to place new points horizontally or vertically in relation to previous points
Working with manual coordinates: Allows to enter manual coordinates instead of clicking on screen
Working plane: Allows you to define a plane in the 3D space, where next operations will take place

Preference settings
The Draft module has its preferences screen

Scripting
The Draft module features a complete Draft API so you can use its functions in scripts and macros

Tutorials
Draft tutorial
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Module&oldid=84829"

Draft DAT
The common airfoil data format is a simple file containing the optional metadata about the airfoil in the first 1-2 lines and the coordinates of the upper and
lower surface.
There are many different dialects to this format so this import module tries to be as smart as possible to understand almost anyone.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_DAT&oldid=83901"

Draft Arc
Draft Arc

Description

Menu location

The Arc tool creates an arc in the current work plane by entering four points, the center, the radius, the first point
Draft -> Arc
and the last point, or by picking tangents, or any combination of those. It takes the linewidth and color previously
Workbenches
set on the Tasks tab. This tool works the same way as the Draft Circle tool, but adds start and end angles.

Draft, Arch
Default shortcut
AR
See also
Draft Circle

How to use
1.
2.
3.
4.
5.

Press the
Draft Arc button, or press A then R keys
Click a first point on the 3D view, or type a coordinate
Click a second point on the 3D view, or enter a radius value
Click a third point in the 3D view, or enter a start angle
Click a fourth point in the 3D View, or enter an end ange

Options
The primary use of the arc tool is by picking four points: the centre, a point on the circumference, defining the radius, a third point defining the
start of the arc, and a fourth one defining its end.
By pressing ALT , you can select a tangent instead of picking point, to define the base circle of the arc. You can therefore construct several
types of circles by selecting one, two or three tangents.
The direction of the arc depends on the movement you are doing with your mouse. If you start to move clockwise after the third point is entered,
your arc will go clockwise. To go counter-clockwise, simply move your mouse back over the third point, until the arc starts drawing in the other
direction.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Arc tool will restart after you give the fourth
point, allowing you to draw another arc without pressing the Arc button again.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your point horizontally or vertically in relation to the center.
Press ESC or the Cancel button to abort the current Line command.
The arc can be turned into a circle after creation, by setting a same value to its first angle and last angle properties.

Properties
DATA
DATA
DATA

Radius: The radius of the arc


First Angle: The angle of the first point of the arc
Last Angle: The angle of the last point of the arc

Scripting
The Circle tool can also be used to create arcs in macros and from the python console by using the following function, giving it additional arguments:
makeCircle (radius, [placement], [facemode], [startangle], [endangle])
Creates a circle object with given radius.
If a placement is given, it is used. If facemode is False, the circle is shown as a wireframe, otherwise as a face.
If startangle AND endangle are given (in degrees), they are used and the object appears as an arc.
Returns the newly created object.
Example:
import Draft
myArc = Draft.makeCircle(2,startangle=0,endangle=90)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Arc&oldid=70733"

Draft Draft2Sketch
Description
This tool converts Draft objects to Sketcher objects, and vice-versa.

Draft
Draft2Sketch
Menu location
Drafting -> Draft to Sketch
Workbenches
Draft, Arch
Default shortcut
None
See also
None

How to use
1. Select a Draft object or a Sketch
2. Press the
Draft Draft2Sketch button

Options
If you convert a Draft Wire, point constraints will be applied to the nodes
If you convert a Draft Rectangle, point constraints will be applied to the corners, and horizontal and vertical constraints to the edges
Non-Draft objects that are totally planar will also get converted to sketches
The sketcher does support straight lines and circular arcs. The conversion of any element that can not be represented with those will fail.
The conversion of any element that can not be represented with either a straight line or circular curve will just fail, i.e. the item will not appear in the
sketch.

Scripting
Not available, see the Sketcher Module documentation for how to create sketches by scripting
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Draft2Sketch&oldid=70714"

Draft ToggleContinueMode
Description

Draft
ToggleContinueMode

Some tools of the Draft and Arch modules feature a Continue checkbox, which, when checked, restarts the
command after you finish it, so you don't need to press the command button again, and you can quickly create Menu
several objects in a row, one after the other. This command switches on/off this checkbox for the next commands.

How to use
1. Press the
Toggle continue mode button
2. Start a command that has a Continue checkbox, such as Draft Line or Arch Wall
3. Cancel the command or press ESC to leave both the command and the continue mode.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_ToggleContinueMode&oldid=72283"

location
Draft -> Utilities -> Toggle
continue mode
Workbenches
Draft, Arch
Default shortcut
None
See also
None

Draft Linestyle
The line color and line width of Draft objects (and any other FreeCAD object) can easily be changed in the Draft module.

On the Command bar , a series of buttons displayed, including three for lines :

Gives color to the line (edge).

Gives background color (face) to the form.

Gives the thickness line (edge).

Gives all the parameters of style bjects selected.


On the Draft command bar, you will see three buttons: a linewidth setting, a linecolor button, and an "apply" button. If objects are selected when you
change those values, they will receive automatically the new values. If no object is selected, the changes you make will apply to objects you will create
later. At any moment, you can hit the "apply" button to apply current settings to selected objects. You can also do that from the tree's context menu. If
a group is selected, the settings will be applied to all objects in the group.
If you would like to change the face color of filled objects, you can do it via the properties window.
See also Draft Apply

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Linestyle&oldid=64017"

Draft BSpline
Draft BSpline

Description

Menu location

The BSpline tool creates a B-Spline curve from several points in the current work plane. It takes the linewidth Draft -> BSpline
and color previously set on the Tasks tab. The BSpline tool behaves exactly like the Draft Wire tool.

Workbenches
Draft, Arch
Default shortcut
BS
See also
Draft Wire

How to use
1.
2.
3.
4.

Press the
Draft BSpline button, or press B then S keys
Click a first point on the 3D view, or type a coordinate
Click additional point on the 3D view, or type a coordinate
Press F or C , or double-click the last point, or click on the first point to finish or close the spline. If the spline is closed, it will also be a face,
even if it appears as wireframe.

Options
Press F or the
Finish button to finish the spline, leaving it open
Press C or the
Close button or click on the first point to finish the spline, but making it closed by adding a last segment between the last
point and the first one.
Press X , Y or Z after a point to constrain the next point on the given axis.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press R or click the checkbox to check/uncheck the Relative button. If relative mode is on, the coordinates of the next point are relative to
the last one. If not, they are absolute, taken from the (0,0,0) origin point.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the BSpline tool will restart after you finish or
close it, allowing you to draw another one without pressing the BSpline button again.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your next point horizontally or vertically in relation to the last one.
Press W or press the
Wipe button to remove the existing segments and start the spline from the last point.
Press CTRL + Z or press the
Undo button to undo the last point.
Press I or the Filled button to have the spline to appear as a face after it has been closed. This simply sets the View->Property of the Wire
to "Flat lines" or "Wireframe", so it can easily be changed later.
Press ESC or the Cancel button to abort the current BSpline command.
BSplines, when in "Flat Lines" display mode, can display a hatch pattern, by setting their "Pattern" property below.

Properties
DATA
VIEW
VIEW
VIEW

Closed: Specifies if the spline is closed or not


End Arrow: Shows an arrow symbol at the last point of the spline, so it can be used as an annotation leader line
Pattern: Specifies a hatch pattern to fill the wire with
Pattern Size: Specifies the size of the hatch pattern

Scripting
The BSpline tool can by used in macros and from the python console by using the following function:
makeBSpline (pointslist,[closed],[placement])
Creates a B-Spline object from the given list of vectors.
If closed is True or first and last points are identical, the wire is closed.
If face is true (and the bspline is closed), the bspline will appear filled.
Instead of a list of points, you can also pass a Part Wire.
Returns the newly created object.
Example:
import FreeCAD,Draft
p1 = FreeCAD.Vector(0,0,0)
p2 = FreeCAD.Vector(1,1,0)
p3 = FreeCAD.Vector(2,0,0)
Draft.makeBSpline([p1,p2,p3],closed=True)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_BSpline&oldid=66023"

Draft tutorial
The Draft module has changed a lot since this tutorial was written. Several concepts are now
different and might not work the way they are described below.

This tutorial will teach you how to use FreeCAD's 2D drafting module (also called Draft module) to create a simple architecture drawing. For this
purpose, we will be drawing a simple masonry cabin. Let's assume that we received a CAD drawing showing the location of the cabin, and we'll use it to
draw our project on top of it. We'll draw a plan, a section and two elevations.

Before you begin


Keep in mind that FreeCAD is still in an early stage of development, so you might not be as productive as with another CAD application, and you will
certainly encounter bugs, or experience crashes. FreeCAD now has the ability to save backup files. The number of those backup files can be specified in
the preferences dialog. Don't hesitate to allow 2 or 3 backup files until you know well how to deal with FreeCAD.
Save your work often, from time to time save your work under a different name, so you have a "safe" copy to fall back to, and be prepared to the
possibilty that some commands might not give you the expected results.

Setting up your FreeCAD workspace


FreeCAD is a 3D modeler, but in this tutorial we will use it only for working in 2D. So, we will be drawing on the ground plane, and everything we do will
have a Z coordinate of zero. So first, let's put ourselves in top view by pressing the 2 and be sure we are in orthographic projection (key O ) otherwise
we might get fooled by some perspective effects.
Another very important thing to do, is to give custom hotkeys to your Draft commands. So you can do all the commands from the keyboard, which will
drastically improve your speed. Basically you can do about everything from the keyboard, and will need the mouse only to draw points and select
objects. Go to menu Customize -> Keyboard -> Category Python and select shortcuts as you like, a good idea is to make them easy to remember. For
example, I use L for Line, W for Polyline (also called Wire in FreeCAD), A for Arc, C for Circle, M for Move, R for Rotate, F for Offset (O is already taken
by Orthographic), D for Dimension, T for Text, etc...
Now we are set up, we can begin to draw.

Importing CAD drawings


If you are going to import a 2D cad drawing, chances are high that they will be in a proprietary format such as .dwg (from AutoCAD) or .mcd (from
VectorWorks). The specification of those file formats are being kept secret by their vendors, so it is extremely difficult or totally impossible for FreeCAD
to support them. However, One file format that is fairly well documented is the DXF format, and the Draft module supports it partially.
Almost all CAD applications can export to the DXF format, and you also have several free converters such as openDWG's "Teigha file Converter"
utility, that will allow you to convert your file to the DXF format. For example, Doublecad is a free, fully functional CAD program that allows you to export
DXF files:

Open your DXF file simply with the File -> Open dialog. Several import settings can be configured in the Draft Preferences screen. For example, you
can configure if you want the DXF file to be imported with original colors and linewidths, or converted to current Draft color, that you see at the right side
of the Draft command bar. But in FreeCAD you won't need to attribute ugly colors to your objects to determine their linewidth. Objects all have
independent color and linewidth attributes. So, you can very well forget about DXF colors, or convert everything to the colors of your choice.
After importing your drawing in FreeCAD, it will look like this:

Let's begin with doing some cleaning.

In FreeCAD, there are no layers like in AutoCAD. We work with groups instead. Groups are another more flexible way to organize your drawing. You can
create new groups with a right-click on the tree view, rearrange them, move them into other groups, or move objects to/from groups simply by dragging
and dropping things in the tree view. You can also assign current line width and colors to all objects in a group, or turn them on or off by pressing
SPACE .
Let's put all our objects into one new group, and turn off everything we won't use, like vegetation and dimensions, to speed up our work.

Drawing the plan view


Using the drawing tools
The only thing we'll need at the moment is the area that is assigned to our cabin. It lies in a separate group named "projection". So we can basically turn
off everything else with the SPACE key, and start drawing on top of it. We will draw a small cabin with a guard room and a WC, in very simple
structural masonry, so there won't be any need for special concretework in the plan itself. But we'll put a layer of plaster inside, and a layer of ceramics
outside.
So, let's begin with doing the general shape of our walls:

Our DXF drawing was drawn in meters, so unless we have any reason to change that, we'll continue with the same units. FreeCAD currently does not
have a friendly system to work with real-world units, so we simply assume that "one" means "one meter".
Another good thing to remember is to construct temporary geometry whenever you need. You want a point that lies 2 meters away horizontally? Draw a
vertical line, move it 2m away, pass a horizontal line through it, there is your point.
Create a rectangle: Snap its cornerpoints with CTRL to the corners of the assigned area
Offset the rectangle: With the rectangle selected, press Offset, press C to turn on copy mode, move your mouse inside the first rectangle so
offset knows in which direction to go, and type 0.20, Enter

Turn them into a face: Upgrade the first rectangle, upgrade the second rectangle, then select the outer rectangle, CTRL-select the inner
rectangle and press Downgrade
Create the door opening: Make a 1.00 x 0.50 rectangle, move it to the upper corner of our main wall (press C to turn copy mode off).
Move the door opening to the right position: Move it 0.10 to the left. We won't put our opening directly on the corner, because it would make the
door difficult to open.
Subtract the door opening: Select the wall, CTRL-select the door opening, and press downgrade.

A note about upgrade & downgrade


Now, you must be aware that the openCasCade kernel that FreeCAD is built upon, is a 3D kernel. It is made primarily for 3D operations. When it has to
cut or unite planar faces, like we are doing now with upgrade/downgrade operations, it sometimes does strange things, and subsequent operations (like
other upgrades/downgrades) sometimes don't give the expected results. Of course with time those behaviours will end up being corrected by the
FreeCAD developers, but it is wise to know alternative ways to solve immediate problems.
The best way to solve a face that isn't upgrading/downgrading/offsetting correctly, is simply to downgrade it until it is all exploded to single edges, then
upgrade those edges together again up to a new face. In case that doesn't work either, simply redraw a new wire (polyline) on top of the problematic
face, snapping to its endpoints, then delete the old face and upgrade the new wire. Usually a face that you draw yourself is in much better shape than a
face that you obtained by upgrade/downgrade.
Another thing to keep in mind is that when you subtract a shape from another, you can find yourself with one object containing several faces. This might
difficult your further work (they don't offset correctly, etc), so a good thing in that case is always to separate them with the downgrade tool.

Another note about snapping


There are two forms of snapping in the Draft module: passive snap, which occurs when you simply pass your mouse cursor over an object (an open
circle symbol appears), and active snap, which is when you press CTRL . Active snapping allows you to snap to specific points on an object, like its
endpoints, midpoints, centers, or intersections with other objects. If you press SHIFT , which is the key for constraining horizontally and vertically, you
gain even more snapping points. But this has a cost, because FreeCAD must do many calculations in real time. If you have many objects, you'll begin to
feel the difference. So a good trick to speedup your work is to take the habit of working as much as possible with SHIFT and passive snapping only.
You will see quickly that you'll obtain accurate results and work much faster.
So let's go back to work:
Create a 10cm-wide wall between the main room and the WC. Upgrade it, then upgrade it together with the main wall to unite them
Create other rectangles for your other openings. I put a 60cm-wide window in what will become the WC, a 80cm door between the main room and
the WC, and for the big window in the main room I simply left 40cm wall at the left and right side.
Offset all the walls of 1cm, to make a cement/plaster layer, then downgrade the offsetted copies to turn them into simple wires
Create a layer of ceramics on the exterior side, by offsetting our plaster line 2cm, then drawing a 2cm-thick shape between the two lines
Delete the 2cm offset. that we don't need anymore, as well as all construction geometry. If you feel you might need them later, simply put them in
a separate group and turn that group off with SPACE .
This is where we are now (I kept construction geometry there, in blue, for you to see):

Importing and building compound objects


In FreeCAD, compound objects are objects made with the geometry of several other objects. In other softwares, it is called blocks, symbols or
components. It is a very handy way to group geometry under one single object. Any of the objects created with the draft module can be grouped into a
compound. The command to create a compound is the Upgrade command. The use is simple, select everything you want to turn into a compound, and
press Upgrade. If no other more intelligent shape can be created, they will be turned into a compound.
Using compound geometry is specially useful to build a symbol library on your disk, so you can reuse them later. One cool use of this, coupled to the
DXF import function, is that you can very easily use symbol libraries in DXF format (if your symbols are in dwg format, the free "Teigha file Converter"
application can batch-convert all your library at once).
Once you have a library of DXF symbols, just drag one of them and drop it on top of your open FreeCAD window and it will be imported in the current
document. It won't be imported as a compound, but all of the symbol geometry will be placed in a separate group, so it is easy to select it all and simply
press "Upgrade". Beware that AutoCAD users have the bad habit of drawing things very far from the origin point (0,0,0), your inserted symbol can then lie
very far from your drawing zone.
So, back to our drawing:

Import a sanitary block if you have one, or pick one on the Cad Exchange site, and convert it to DXF with the "Teigha file Converter"
Create the geometry for a door, upgrade it to a compound, copy it to the other door location, downgrade it, adjust the elements to the new
size, and upgrade it again
Do the same for the windows

Dimensions and annotations


Now that our plan is more or less ready, we can add dimensions and texts. This is usually pretty straightforward, so there is probably no need to
explain much. Just try to dimension everything, and as a convention, always start the dimension lines from the main wall line, not the finishing layer.
One thing is good to know, sometimes you draw a text or a dimension over a filled area, and the filled area will cover your dimension. There is a simple
way to fix that, it is by downgrading and upgrading again the filled area. It will then be displayed under the other elements.
The dimension and text will by default have the same text height, which can be changed in the Draft Preferences page. You can then edit individually
each text height.
Unfortunately certain non-geometry objects like texts and dimension are still not selectable in the FreeCAD 3D view, you must therefore select them in
the tree, and you won't be able to snap to them, but this will probably be solved in a near future. It is also not possible at the moment to choose a font
style. To align dimensions, at the moment, you need to draw a line first, then snap your dimensions to that line.

Organizing

Finally, we can add a few things to finish our plan, like putting vegetation around the cabin. We can simply copy a few trees from our imported DXF
drawing and scale them down with the scale tool, to for example (0.5,0.5). We can also change the line thickness of a couple of objects, for example
make the walls thicker, and change the color of some things. And we can organize all our elements in groups.
The ability to organize your work in nested groups is surely one of the big advantages of groups over traditional work with layers. In this tutorial, I grouped
my objects by type, inside the Plan group. For example, instead of having one big layer with all dimensions of your drawing, each part of the drawing will
contain their own dimensions group, making it extremely easy to organize your drawing.
You might feel a loss at first if you come from a traditional drawing program like AutoCAD, but you'll quickly see the power that this method brings.
For example, all our construction geometry can go in a separate group, that we'll turn off. Maybe later we'll need to make some changes, and it will be
handy to have that geometry available.
So, now we are ready to draw other parts...

Drawing the elevations

Since in this exercise we are going to stay in pure 2D, we will draw our elevations and sections directly. In more advanced architecture environments
(what FreeCAD will hopefully become in some future), we wouldn't need to draw the elevations. We would model the building in 3D and then generate the
different views automatically. But for the sake of this exercise (and also because all the needed tools are still not implemented in FreeCAD), we'll do it by
hand, like in the old times.
We'll begin with the rear wall elevation, because the way our plan is oriented, it can be drawn directly below it, without the need to rotate the view. We
will simply draw construction lines from the plan, set horizontal lines to the desired heights (I set the 0.00 level, the +0.15 level of the slab, then heights
for the windows, and the roof slab at +2.50. We can then draw our geometry very quickly on top of it.
We can then place a couple of annotations, dimensions, and upgrade some of the objects so they appear filled with a color. Finally, we can make a bit
of cleaning by creating a "South Elevation" group, then subgroups for our construction geometry and annotations, and place all of our new objects in
them.

Rotating the view, and creating macros


Now, we need to draw other elevations of our little building. The simplest way would be to draw them directly under the plan view, as we did with the
south elevation. For this, it would be handy to be able to rotate the view by 90, so we can continue drawing our elevations "on foot". Unfortunately,
FreeCAD has at the moment no "Rotate View" tool. But, fortunately, it has tools for us to easily create our own tools, called Macros. So, this is a good
opportunity for us to try something easy.
Macros, as well as all scripting in FreeCAD, is done in a very simple programming language called python. You can write very complex programs in
FreeCAD in python, but you can also use it to perform very simple operations where there still isn't a proper FreeCAD toolbar icon, such as our Rotate
The View tool. So, first thing to do, open the Report view, if you closed it, and select the python tab. In there, type (or copy/paste) the following code:
import math
from pivy import coin
cam = Gui.ActiveDocument.ActiveView.getCameraNode()
rot = coin.SbRotation()
rot.setValue(coin.SbVec3f(0,0,1),math.pi/2)
cam.orientation = rot
This small script will simply rotate the view by 90 (left). For rotating by -90 (right), you would simply change math.pi/2 by -math.pi/2. If you would like to

learn more about python scripting in FreeCAD, there is an extensive Scripting section on this wiki.
Now, we need to do one more step, which is save our piece of code in a macro, so we can reuse it later. So, instead of pasting our code in the python
interpreter, let's open the macro manager (Tools -> Macros), create a new macro, press the "Edit" button and paste our code in it. Close the macro
editor tab, and the macro will be saved.
The macros can behave like any other FreeCAD tool. With the Tools -> Customize menu, we can add an icon to our macro, a keyboard shortcut, and
add it to a toolbar.

Drawing the rotated views

Now that we can rotate the view at will, we can draw our other elevations. The easiest way is to draw your elevation at the right place under the plan view,
and use a "mirror" (a 45-oriented line) to push the height lines from another elevation. This way, drawing goes pretty fast.
Finally, we draw 2 others elevations, and since the fourth one is the same as the second one (but mirrored), we will skip it. We can then draw a cross
section, and our drawing is complete:

To be continued...
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_tutorial&oldid=84857"

Draft Circle
Description

Draft Circle
Menu location

The Circle tool creates a circle in the current work plane by entering two points, the center and the radius, or by
Draft -> Circle
picking tangents, or any combination of those. It takes the linewidth and color previously set on the Tasks tab.
This tool works the same way as the Draft Arc tool, except that it stops after entering the radius.
Workbenches

Draft, Arch
Default shortcut
CI
See also
Draft Arc

How to use
1. Press the
Draft Circle button, or press C then I keys
2. Click a first point on the 3D view, or type a coordinate
3. Click a second point on the 3D view, or enter a radius value.

Options
The primary use of the circle tool is by picking two points, the centre and a point on the circumference, defining the radius.
By pressing ALT , you can select a tangent instead of picking a point. You can therefore construct several types of circles by selecting one, two
or three tangents.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Circle tool will restart after you give the
second point, allowing you to draw another circle without pressing the Circle button again.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your second point horizontally or vertically in relation to the first one.
Press I or the Filled button to have the circle to appear as a face after it has been closed. This simply sets the View->Property of the Circle
to "Flat lines" or "Wireframe", so it can easily be changed later.
Press ESC or the Cancel button to abort the current Line command.
The circle can be turned into an arc after creation, by setting its first angle and last angle properties to different values.
Circles, when in "Flat Lines" display mode, can display a hatch pattern, by setting their "Pattern" property below.

Properties
DATA
VIEW
VIEW

Radius: The radius of the circle


Pattern: Specifies a hatch pattern to fill the wire with
Pattern Size: Specifies the size of the hatch pattern

Scripting
The Circle tool can by used in macros and from the python console by using the following function:
makeCircle (radius, [placement], [facemode], [startangle], [endangle])
Creates a circle object with given radius.
If a placement is given, it is used.
If facemode is False, the circle is shown as a wireframe, otherwise as a face.
If startangle AND endangle are given (in degrees), they are used and the object appears as an arc.
Returns the newly created object.
Example:
import Draft
myCircle = Draft.makeCircle(2)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Circle&oldid=70734"

Draft Polygon
Draft Polygon

Description

Menu location

The polygon tool creates a regular polygon by picking two points, the center and a second point defining a radius. It
Draft -> Polygon
takes the linewidth and color previously set on the Tasks tab.

Workbenches
Draft, Arch
Default shortcut
PG
See also
None

How to use
1.
2.
3.
4.

Press the
Draft Polygon button, or press P then G keys
Click a first point on the 3D view, or type a coordinate to indicate the center
Adjust the desired number of sides in the options dialog,
Click another point on the 3D view, or type a radius value to define the polygon radius. The polygon will also be a face, even if it appears as
wireframe.

Options
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Polygon tool will restart after you finish or
close it, allowing you to draw another one without pressing the Polygon button again.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your next point horizontally or vertically in relation to the last one.
Press I or the Filled button to have the polygon to appear as a face after it has been closed. This simply sets the View->Property of the
Rectangle to "Flat lines" or "Wireframe", so it can easily be changed later.
Press ESC or the Cancel button to abort the current command.
Polygons, when in "Flat Lines" display mode, can display a hatch pattern, by setting their "Pattern" property below.

Properties
DATA
DATA
DATA
DATA
DATA
VIEW
VIEW

Radius: The radius of the defining circle


Draw Mode: Specifies if the polygon is inscribed or circumscribed around the defining circle
Faces Number: The number of sides of the polygon
Chamfer Size: Specifies the size of chamfered corners
Fillet Radius: Specifies a curvature radius to give to the corners of the rectangle
Pattern: Specifies a hatch pattern to fill the wire with
Pattern Size: Specifies the size of the hatch pattern

Scripting
The Polygon tool can by used in macros and from the python console by using the following function:
makePolygon(nfaces,[radius],[inscribed],[placement],[face])
Creates a polygon object with the given number of faces and the radius.
If inscribed is False, the polygon is circumscribed around a circle with the given radius, otherwise it is inscribed.
If face is True, the resulting shape is displayed as a face, otherwise as a wireframe.
Returns the newly created object.
Example:
import Draft
Draft.makePolygon(5,radius=3)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Polygon&oldid=66022"

Draft FinishLine
Description
This command finishes the drawing of a current wire, leaving it open.

How to use
1. Start drawing a Draft Wire
2. Press the
Finish button or press the F key

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_FinishLine&oldid=70850"

Draft FinishLine
Menu location
Draft -> Utilities -> Finish
Line
Workbenches
Draft, Arch
Default shortcut
F
See also
CloseLine, UndoLine

Draft Preferences
The preferences screen of the Draft module are found in the Preferences window (Menu Edit -> Preferences).
It has General settings, where you can specify the color of the snap symbols, the default width and color for new objects. By checking the "Save
current color and linewidth across sessions" checkbox, any change you make on the draft command bar will be saved here, so you will start your next
FreeCAD session with the color and width you were using on quit.

The DXF settings configure how DXF files must be imported.


The SVG settings configure how SVG files must be imported.
The OCA settings configure how OCA files must be imported.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Preferences&oldid=79771"

Draft ToggleGrid
Description

Draft ToggleGrid

Menu location
Draft -> Utilities -> Toggle
grid
Options
Workbenches
The aspect and spacing of the Draft grid can be adjusted in the Draft preferences (Edit -> Preferences -> Draft ->
Draft, Arch
Visual Settings)
Default shortcut
None
See also
None
This commands toggles the display of the Draft grid on/off.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_ToggleGrid&oldid=70886"

Draft Rotate
Description

Draft Rotate

This tool rotates or copies the selected objects by a given angle around a point on the current work plane. If no Menu location
object is selected, you will be invited to select one.
Draft -> Rotate

Workbenches
Draft, Arch
Default shortcut
RO
See also
None

How to use
1. Select objects you wish to rotate or copy
2.
3.
4.
5.

Press the
Draft Rotate button, or press R then O keys
Click a center point on the 3D view, or type a coordinate
Click a second point on the 3D view, or give a reference angle
Click a third point on the 3D view, or give a rotation angle

Options
Press X , Y or Z after a point to constrain the next point on the given axis.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Rotate tool will restart after you finish or
close it, allowing you to rotate or copy the objects another time without pressing the Rotate button again.
Pressing ALT or C or clicking the Copy button will make a copy of the objects, instead of rotating them. If you keep ALT pressed after
clicking the third point, you will be able to place more copies, until you release the ALT key.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your next point horizontally or vertically in relation to the rotation center.
Press ESC or the Cancel button to abort the current command.

Scripting
The Rotate tool can by used in macros and from the python console by using the following function:
rotate (FreeCAD.Object or list, angle, [center], [axis] ,[copymode])
Rotates the given object or the objects contained in the given list with the given angle around the given center if provided, using axis as a rotation
axis.
If axis is omitted, the rotation will be around the vertical Z axis.
If copymode is True, the actual objects are not moved, but copies are created instead.
Returns the objects (or their copies is copymode was True).
Example:
import FreeCAD,Draft
Draft.rotate(FreeCAD.ActiveDocument.ActiveObject,45)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Rotate&oldid=66480"

Draft ShowSnapBar
Description
This command shows and hides the snapping toolbar.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Show SnapBar&oldid=70893"

Draft
ShowSnapBar
Menu location
Draft -> Utilities -> Show
Snap Bar
Workbenches
Draft, Arch
Default shortcut
None
See also
None

Draft Apply
Description

Draft Apply

Menu location
Draft -> Utilities -> Apply
How to use
style
Workbenches
1. With the Draft or Arch workbench active, set the desired color and linewidth on the Tasks panel (or on the
Draft, Arch
Draft toolbar if you are using the toolbar mode).
2. Select one or several objects
Default shortcut
3. Press the
Apply style button
None
See also
Options
None
This tool applies the current Draft color and linestyle to the selected objects.

If you just change the current Draft color or linewidth, the new setting will be applied to any selected object.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Apply&oldid=70865"

Draft ConstructionMode
(Redirected from Draft ConstructionMode)

Description
The Draft module features a construction mode, which allows to draw certain objects in a special group, with a
defined color, so it is easy to separate them from the other objects and switch it off when you don't need it, or
delete them after you don't need them anymore.

Draft
ToggleConstructionMode
Menu location
Draft -> Utilities -> Toggle
construction mode
Workbenches
Draft, Arch
Default shortcut
None
See also
None

How to use
1. Press the
Toggle construction mode button
2. Draw some objects
3. Press the
Toggle construction mode button again to go back to normal mode

Options
The Construction Mode button is also present on the Task panel or Draft toolbar when the Draft workbench is active
The color and the group name can be changed in the preferences screen.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_ToggleConstructionMode&oldid=68683"

Draft Heal
Description

Draft Heal

Because of the fast evolution of FreeCAD, some object definitions might change over time and between versions, Menu location
causing some Draft objects found in older files to not load properly or contain errors when opened with a more recent Draft -> Utilities
version of FreeCAD. This command tries to fix those bad objects by recreating a new one from scratch, then copying
Workbenches
the contents of the properties from the old one to the new one. It can be run with objects selected, in which case it
will only look at the selected objects, or with no object selected. All the objects of the current document will then be Draft, Arch
scanned for errors. If no error is found, this command will do nothing.
This command can only heal Draft objects.

How to use
1. Select one or more problematic objects to heal, or nothing to scan the whole document
2. Press the
Heal button
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Heal&oldid=70899"

-> Heal

Default shortcut
None
See also
None

Draft DWG
(Redirected from Draft DWG)

Opening
This function opens a DXF file (any version from 12 to 2007) in a new drawing. The following DXF object types are currently supported:
lines
polylines and lwpolylines
circles
arcs
layers (layers containing objects are conveted to FreeCAD Groups)
texts and mtexts
dimensions
blocks (only geometry. texts, dims and attributes inside blocks will be skipped)
points available in version 0.13
leaders

available in version 0.13

Other DXF entities are currently not imported because there is no corresponding FreeCAD object. As new functionality gets implemented, it will be
possible to import more entity types.

Importing
This works the same way as opening, but it will add the contents of the dxf file in the active documento instead of creating a new document.

Exporting
The exported DXF is compatible with Autocad version 12 and up, so it should open in about any application that supports dxf format. Currently the
following FreeCAD objects get exported:
lines and wires (polylines)
arcs and circles
texts
colors are mapped from objects RGB colors to autocad color index (ACI). Black will always be "by layer"
layers are mapped from group names. When groups are nested, the deepest group gives the layer name.
dimensions, which are exported with "Standard" dimstyle

Preferences
The following parameters can be specified in the Draft Preferences tab (menu Edit -> Preferences -> Draft):
Import style: This lets you choose the way objects from the dxf file will be drawn in FreeCAD. You can choose between:
None: this is the faster way, there is no conversion, all objects will be black with 2px width (FreeCAD default)
Use default color and linewidth: All imported dxf objects will take current linewidth/color from the draft command bar
Original color and linewidth: Objects will keep the color and linewidth (if specified) they have in the dxf file
Colors mapped to linewidth: If this option is selected, the mapping file option below is used.
Color mapping file: This allows you to specify a mapping file to be used for translating dxf colors to color and linewidth, the same way as a plot
style works in Autocad. The mapping file must be a tab-separated text file. There is a nice free utility called Plot style viewer that can convert
Autocad CTB or STB (plot styles) files to tab-separated mapping files ready to use in FreeCAD. Alternatively, we have a couple of home-made
mapping files availables here.
Import texts: This allows you to specify if you want to import dxf texts and dimensions or not. Many texts might make your work in FreeCAD very
heavy, so you might want to use this option some time.
Import layout objects: Turn this on if you want to import paper space object. They will be merged in the same document than model space
objects.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_DXF&oldid=68085"

Draft mapping files


The Draft module is able to import files created form any program capable of exporting DXF files. But since FreeCAD is very different from AutoCAD and
other usual 2D CAD programs, you might want to translate automatically the way DXF entities appear in FreeCAD.
For example 2D CAD programs often use a black background, so you make your drawing using bright colors, like yellow, green, etc. Then, when you
want to print your drawing, those ugly colors will be mapped to nice black colors with different linewidths.
Since FreeCAD is not an AutoCAD clone, we don't need to stick to those ugly colors. The concepts of colors, linewidth, or layers are actually very
different in FreeCAD. So, we can take advantage of this new environment and work, for example, with black lines on white background. We can also use
different linewidths, so our drawing will look on the screen pretty much the same way as it will be printed (note that printing your drawing from FreeCAD
is still not supported at the moment, a little bit more patience!).
To use a mapping file, simply navigate to Edit -> Preferences -> Draft -> dxf settings and select those two options:
Import style: Map colors to linewidths
Mapping file: navigate to a .csv file (see below)
These settings will then be your defaults next time you import a DXF file.
The Draft module accepts two types of .csv (comma- or tab-separated file) as mapping file:
converting from autocad plot styles
AutoCAD saves its plot styles as .CTB files. If you open your plot style manager from AutoCAD, you will actually open an explorer window showing the
location where those files are saved. The DXF importer cannot use these files directly because, you will have guessed, they are encoded. Fortunately,
there is a nice free CTB viewer & converter that can convert CTB files to TAB-separated CSV files. The .csv files generated by this program can be
used immediately, they can also be edited with any spreadsheet application.
making your own .csv files
Making your own mapping files is very easy too. It can be made in a spreadsheet application or in any text editor. The rule is simple: you need 3
columns separated by a tabulation (hit the TAB key). First column is the AutoCAD color, second column is the FreeCAD linecolor RGB value formatted
like this: 255,255,255 and the third column is the FreeCAD linewidth in pixels. The first line won't be read. So, you can make one like this, for example:

dxf color freecad color freecad linewidth


1
0,0,0
1
2
0,0,0
2
3
0,0,0
3
4
0,0,0
4
5
0,0,0
5
6
0,0,0
6
7
0,0,0
1
8
80,80,80
1
9
160,160,160 1
The above table would convert color 1 (red) to black (0,0,0)/1 pixel, color 2 (yellow) to black/2 pixels, color 8 (darkgrey) to some dark shade of
grey(80,80,80) and 1 pixel wide, etc, etc. You can specify only the colors that you need. What you didn't specify will receive default color/linewidth.
Don't forget that the first line won't be used, so you can use it for writing column titles for example. If you write a .csv file in a spreadsheet application
(such as OpenOffice), be careful that sometimes your spreadsheet will think that something written 100,100,100 is one number (hundred million one
hundred thousand hundred) and will want to remove the commas. Also, when you save the file as .csv, be sure to specify that it must be TAB-separated
and not COMMA-separated.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_mapping_files&oldid=83917"

Draft Move
Description

Draft Move

The Move tool moves or copies the selected objects from one point to another on the current work plane. If no Menu location
object is selected, you will be invited to select one.
Draft -> Move

Workbenches
Draft, Arch
Default shortcut
MV
See also
None

How to use
1. Select objects you wish to move or copy
2. Press the
Draft Move button, or press M then V keys
3. Click a first point on the 3D view, or type a coordinate
4. Click another point on the 3D view, or type a coordinate

Options
Press X , Y or Z after a point to constrain the next point on the given axis.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press R or click the checkbox to check/uncheck the Relative button. If relative mode is on, the coordinates of the next point are relative to
the last one. If not, they are absolute, taken from the (0,0,0) origin point.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Move tool will restart after you finish or
close it, allowing you to move or copy the objects another time without pressing the Move button again.
Pressing ALT or C or clicking the Copy button will make a copy of the objects, instead of moving them. If you keep ALT pressed after
clicking the second point, you will be able to place more copies, until you release the ALT key.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your next point horizontally or vertically in relation to the last one.
Press ESC or the Cancel button to abort the current command.

Scripting
The Move tool can by used in macros and from the python console by using the following function:
move (FreeCAD.Object or list, Vector, [copymode])
Moves the given object or the objects contained in the given list in the direction and distance indicated by the given vector.
If copymode is True, the actual objects are not moved, but copies are created instead. Returns the object(s) (or their copies if copymode was
True)
A list of the moved object (or the copies) is returned
Example:
import FreeCAD,Draft
Draft.move(FreeCAD.ActiveDocument.ActiveObject,FreeCAD.Vector(2,2,0))

Limitations
When moving (or changing Placement of) a document object (eg: Pad, Revolution, etc) which is based on a Sketch (from Sketcher/Part Design),
you must move the original sketch. If you move the derived object, it will just go back to the position defined by the sketch.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Mov e&oldid=71611"

Draft AddToGroup
Description

Draft
AddToGroup

This tool displays a quick menu that allows you to add the selected objects to an existing group, or remove them
from their current group
Menu

How to use
1. Select object(s)
2. Press the
Add to group button

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_AddToGroup&oldid=70868"

location
Draft -> Utilities -> Add to
group
Workbenches
Draft, Arch
Default shortcut
None
See also
None

Draft Line
Description

Draft Line
Menu location

The Line tool creates a straight, two-points line in the current work plane. It takes the linewidth and color
Draft -> Line
previously set on the Tasks tab. The Line tool behaves exactly like the Draft Wire tool, except that it stops after two
points.
Workbenches

Draft, Arch
Default shortcut
LI
See also
Draft Wire

How to use
1. Press the
Draft Line button, or press L then I keys
2. Click a first point on the 3D view, or type a coordinate
3. Click a second point on the 3D view, or type a coordinate

Options
Press X , Y or Z after the first point to constrain the second point on the given axis.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press R or click the checkbox to check/uncheck the Relative button. If relative mode is on, the coordinates of the second point are relative
to the first one. If not, they are absolute, taken from the (0,0,0) origin point.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Line tool will restart after you give the
second point, allowing you to draw another line segment without pressing the Line button again.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your second point horizontally or vertically in relation to the first one.
Press CTRL + Z or press the
Undo button to undo the last point.
Press ESC or the Cancel button to abort the current Line command.

Properties
DATA
DATA

Start: The start point


End: The end point

Scripting
The Line tool can by used in macros and from the python console by using the following function:
makeLine (Vector, Vector)
Creates a line between the two given vectors. The current draft linewidth and color will be used.
Returns the newly created object.
Example:
import FreeCAD, Draft
Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0))
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Line&oldid=66011"

Draft Upgrade
Draft Upgrade

Description
This tool upgrades selected objects in different ways. If no object is selected, you will be invited to select one.

Menu location
Draft -> Upgrade
Workbenches
Draft, Arch
Default shortcut
UP
See also
Draft Downgrade

How to use
1. Select one or more objects you wish to upgrade
2. Press the

Draft Upgrade button or press U then P keys

Options
The selected objects are modified/upgraded according to the following conditions (in order):
if there are more than one face in the selection, the faces are merged (union)
if there is only one face in the selection, nothing is done
if there is only one open wire in the selection, it gets closed
if there are only edges in the selection, all edges are joined into a wire (closed if possible)
if none of the above is possible, a compound object is created

Scripting
The upgrade tool can be used from python scripts and macros like this:
Draft.upgrade(objects, delete=False, force=None)
Upgrades the given object(s) (can be an object or a list of objects).
If delete is True, old objects are deleted.
The force attribute can be used to force a certain way of upgrading. It can be: makeCompound, closeGroupWires, makeSolid, closeWire,
turnToParts, makeFusion, makeShell, makeFaces, draftify, joinFaces, makeSketchFace, makeWires
Returns a dictionnary containing two lists, a list of new objects and a list of objects to be deleted
Some of the operations of the Upgrade tool can also be made with the Part Fuse or Draft Wire tools.
Example:
import Draft
mycircle = Draft.makeCircle(2)
face1 = Draft.upgrade([mycircle],True)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Upgrade&oldid=66699"

Draft Drawing
Draft Drawing

Description

Menu location
-> Drawing
Workbenches
Draft, Arch
Default shortcut
None
See also
None

This tool allows you to put selected objects on a svg Drawing sheet. If no sheet exists in the document, a default
Drafting
one will be created.

How to use
1. Select the objects you wish to put on a drawing sheet
2. Press the
Draft Drawing button

Options
Select objects you want to put on the drawing sheet. The tool will work best with flat 2D objects from the Draft or Sketcher modules.
If the selected object is an Arch SectionPlane, this tool will create an additional view of that section plane.
In the same selection, add the page object you want to draw your objects to. If there is no existing page, a new one will be created. If you didn't
select a page but there is at least one in the document, the first found one will be used to draw to.
If you selected an existing sheet, and the objects in the selection that are already on that sheet (for ex. for a "Rectangle" object there is already a
"ViewRectangle" object on the sheet), they will be substitued. This allows you to simply select all the objects and send them to an existing page,
which will simply be updated.

Properties
DATA
DATA
DATA

Fill Style: For closed shapes, allows to specify one of the Default Draft fill styles, or use the shape color.
Font Size: Allows you to specify the font size of texts and dimensions.
Line Width: Allows you to specify the line width of viewed objects.

Scripting
The Draft Drawing tool can by used in macros and from the python console by using the following function:
makeDrawingView (object,page)
Adds a view of the given object to the given page.
Returns the created view object.
Example:
import FreeCAD,Draft
obj = FreeCAD.ActiveDocument.ActiveObject
page = FreeCAD.ActiveDocument.Page
Draft.makeDrawingView(obj,page)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Draw ing&oldid=70720"

Draft Offset
Description

Draft Offset

The Offset tool offsets the selected object by a given distance on the current work plane. If no object is selected, Menu location
you will be invited to select one.
Draft -> Offset

Workbenches
Draft, Arch
Default shortcut
OS
See also
None

How to use
1. Select objects you wish to offset
2. Press the
Draft Offset button, or press O then S keys
3. Click a point on the 3D view, or type a distance.

Options
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Offset tool will restart after you finish or
close it, allowing you to offset or copy the objects another time without pressing the Offset button again.
Pressing ALT or C or clicking the Copy button will make a copy of the objects, instead of moving them. If you keep ALT pressed after
clicking the second point, you will be able to place more copies, until you release the ALT key.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Pressing SHIFT will constrain you to the current segment, instead of picking the closest one.
Press ESC or the Cancel button to abort the current command.

Scripting
The Offset tool can by used in macros and from the python console by using the following function:
offset (object,Vector,[copymode],[bind],[sym])
Offsets the given wire by applying the given Vector to its first vertex.
If copymode is True, another object is created, otherwise the same object gets offsetted.
If bind is True, and provided the wire is open, the original and the offsetted wires will be bound by their endpoints, forming a face.
If sym is True, the offset is made on both sides, the total width being the length of the given vector.
Returns the offsetted object (or its copy if copymode as True).
Example:
import FreeCAD,Draft
Draft.offset(FreeCAD.ActiveDocument.ActiveObject,FreeCAD.Vector(2,2,0))
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Offset&oldid=66583"

Draft SVG

Opening
This function imports SVG files as workable 2D objects, as opposed to the built-in drawing module which imports svg files as sheet drawings. The
following SVG objects get imported at the moment:
PATH objects
LINE objects
RECT objects
CIRCLE objects
ELLIPSE objects
POLYGON objects
POLYLINE objects

Importing
Works the same way as opening but creates the objects in the active document instead of creating a new one.

Exporting
The following objects can be exported in an SVG file:
Lines and wires (polylines)
Arcs and circles
Faces
Texts
Dimensions
Keep in mind that SVG is a 2D format, so all Z information will be disregarded (all objects will be flattened).

Preferences
The following parameters can be specified in the Draft Preferences tab (menu Edit -> Preferences -> Draft):
Import/Export -> Import style: This lets you choose the way objects from the svg file will be drawn in FreeCAD. You can choose between:
None: this is the faster way, there is no conversion, all objects will be black with 2px width (FreeCAD default)
Use default color and linewidth: All imported objects will take current linewidth/color from the draft command bar
Original color and linewidth: Objects will keep the color and linewidth (if specified) they have in the svg file
Import/Export -> Export Style:
Translated: All elements are translated that their coordinates are positive. This should aid display and printing. The output coordinate
system is NOT cosistent between individualy exported elements.
Raw: The position of all elements preserved. This intended for CAM usage for example in PyCAM. Layers or Slices exported individualy will
match.
General settings -> Internal precision level:
This value is used to check if a bezier curve segement has to be considered a straight line. If you import detailed paths, like rendered text,
you may want to increase this setting up to 6. If you are working with Inkscape please consider to raise the precision in the SVG file, well.
(Inkscape Menu -> File -> Inkscape Preferences -> SVG Output -> Numeric Precision)

Unit Handling
When exporting, a User Unit (px) equals one millimeter.
When importing, the width, height and viewBox attributes are respected. All elements are scaled to their size in millimeter, which is FreeCAD internal
unit. If the SVG does not contain information on its physical size, it is assumed to have 90 DPI resolution. Using absoulte units in attributes inside the
SVG should be avoided. Relative units like em,ex and % are currently not supported.
The SVG Editor Inkscape currently works only with 90 DPI documents. No matter which unit is selected in Inkscape. All the output has to be considered

converted to 90 DPI and rounded to 6 decimal places. As FreeCAD (and the SVG standard) is agnostic to the precision of rounding done in Inkscape
these values will not be rounded on input. And odd values in millimeter will remain. If you need the SVG import not to be rounded, work on User Units
(px) in Inkscape. Scaling can be done after the import to FreeCAD or by changing the width, height and viewbox attributes.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_SVG&oldid=68148"

Draft PathArray
Description

Draft PathArray

The PathArray tool places copies of a selected shape along a selected path. The path can be a Wire or one or more Menu location
Edges. The shapes can optionally be aligned with the tangent of the path. If required, a translation Vector can be Draft -> PathArray
specified to shift the shapes so the centroid is on the path. If no objects are selected, you will be invited to select
Workbenches
them.

Draft, Arch
Default shortcut
None
See also
Draft Array

How to use
1.
2.
3.
4.

Select a shape object you wish to distribute.


Select a path object along which the shapes will be distributed. -orSelect some edges of a path object.
Press the
Draft PathArray button.

Options
The array starts with shape copies which are not aligned to the path, nor translated to a new position by default. You can then change the count,
alignment and/or translation vector in the properties.

Properties
DATA
DATA
DATA
DATA
DATA
DATA

Base: The shape object


PathObj: The path object
PathSubs: The subelements(edges) of path object to be used as the path
Count: The number of time to copy the shape
Xlate: The translation vector
Align: True to align the shapes to the path, False to leave shapes in their default orientation.

Scripting
The PathArray tool can by used in macros and from the python console by using the following function:
makePathArray(shapeobject,pathobject,count,[translationvector],[alignment],[listofpathsubelements])
Distribute count copies of a document shapeobject along a pathobject or subobjects of a pathobject. Optionally translates each copy by
FreeCAD.Vector xlate direction and distance to adjust for difference in shape centre vs shape reference point. Optionally aligns baseobject to
tangent/normal/binormal of path.
Example:
import FreeCAD,Draft
Draft.makePathArray(base,path,items,centretrans,orient,pathsubs)

Usage Notes
Align + Xlate: When Align is True, the Xlate vector is relative to the local (tangent/normal/binormal) coordinates. When Align is False, the Xlate
vector is relative to the global (XYZ) coordinates.

Limitations
This tool is not available before version 0.14
The PathSubs Property does not yet appear in the properties list.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_PathArray&oldid=79452"

Draft BezCurve
Draft BezCurve

Description

The BezCurve tool creates a Bezier Curve (or a piecewise Bezier Curve) from several points in the current work Menu location
plane. It takes the linewidth and color previously set on the Tasks tab.
Draft -> BezCurve
The object is created as a single Bezier Curve of degree (number_of_points - 1). This can be changed to a piecewise Workbenches
Bezier Curve of a specified degree after creation using the properties editor. Bezier Curves can be edited using
Draft Edit .

Draft, Arch
Default shortcut
BZ
See also
None

How to use
1.
2.
3.
4.

Press the
Draft BezCurve button, or press B then Z keys.
Click a first point on the 3D view, or type a coordinate
Click additional point on the 3D view, or type a coordinate
Press F or C , or double-click the last point, or click on the first point to finish and close the curve.

Options
Press F or the
Finish button to finish the spline, leaving it open
Press C or the
Close button or click on the first point to finish the spline, but making it closed by adding a last segment between the last
point and the first one.
Press X , Y or Z after a point to constrain the next point on the given axis.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press R or click the checkbox to check/uncheck the Relative button. If relative mode is on, the coordinates of the next point are relative to
the last one. If not, they are absolute, taken from the (0,0,0) origin point.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the BezCurve tool will restart after you finish or
close it, allowing you to draw another one without pressing the BezCurve button again.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your next point horizontally or vertically in relation to the last one.
Press W or press the
Wipe button to remove the existing segments and start the spline from the last point.
Press CTRL + Z or press the
Undo button to undo the last point.
Press ESC or the Cancel button to abort the current BezCurve command.

Properties
DATA
DATA

Closed: Specifies if the Bezier Curve is closed or not


Degree: Specifies the degree of the Bezier Curve (or segments)

Scripting
The BezCurve tool can by used in macros and from the python console by using the following function:
makeBezCurve(pointslist,[closed],[placement],[support],[degree])
Create a Bezier Curve object from the given list of vectors. Instead of a pointslist, you can also pass a Part Wire.
Example:
import FreeCAD,Draft
myFeature = Draft.makeBezCurve(Draft.makeBezCurve(points,False)

Contraining Nodes
The segment endpoints in a piecewise Bezier Curve can be constrained such that adjacent control points are tangent or symmetric to the segments at
the endpoint. This is done after object creation using

Draft Edit .

Sharp - remove constraints


Tangent - force adjacent control points to be tangent
Symmetric - force adjacent control points to be tangent and equi-distant

Limitations

This tool is not available before FreeCAD version 0.14


The Points Property does not yet appear in the properties list.
OpenCascade does not support Bezier Curve with degree > 25. This should not be a problem in practice.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_BezCurv e&oldid=71983"

Draft Shape2DView
Description
This tool places in the document a 2D object which is a flattened view of a selected Shape-based object.

Draft
Shape2DView
Menu location
Draft -> Shape 2D View
Workbenches
Draft, Arch
Default shortcut
None
See also
None

How to use
1. Select the object you want to extract a 2D view from
2. Press the
Draft Shape2DView button

Options
If the selected object is an Arch SectionPlane, the 2D projection will be of the contents of the Section plane, and the projection vector will be
taken from the section plane instead of the Projection property below.
The normal operating mode is Solid, which projects the whole shape, but, if you selected some faces of the base object when creating the 2D
view, you can also set the Individual Faces mode, which will project only the faces that were selected.
If the selected object is an Arch SectionPlane, a cutlines projection mode is also available, which projects only the edges being cut by the
section plane.

Properties
DATA
DATA

Projection: The direction of the projection.


Projection Mode: The mode of the projection: solid, individual faces, or cutlines.

Scripting
The Draft Shape2DView tool can by used in macros and from the python console by using the following function:
makeShape2DView (object,[projection],[facenumbers])
Adds a 2D shape to the document, which is a 2D projection of the given object.
A specific projection vector can also be given.
Returns the generated object.
You can also provide a list of face numbers to be considered.
Example:
import FreeCAD,Draft
Draft.makeShape2DView(FreeCAD.ActiveDocument.ActiveObject)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Shape2DView &oldid=70715"

Draft FlipDimension
Description

Draft
FlipDimension

When in 2D mode, the text of the Draft dimensions is displayed aligned to the dimension line. The Dimension tool
always tries to show you the dimension text on the correct side of the dimension line, depending on where you are Menu location
viewing it from. In some cases, though, the viewing direction might not reflect the intent of the viewer, and the
Draft -> Utilities
orientation of the dimension text might be inverted. This tool inverts that orientation on selected dimension objects.

How to use
1. Select one or more dimension objects
2. Press the
Flip Dimension button

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_FlipDimension&oldid=70907"

-> Flip
Dimension
Workbenches
Draft, Arch
Default shortcut
None
See also
Dimension

Draft Trimex
Draft Trimex

Description
This tool trims/cuts and extends lines and polylines, and extrudes faces.

Menu location
Draft -> Trim/Extend
Workbenches
Draft, Arch
Default shortcut
TR
See also
Part Extrude

How to use
1. Select a wire you wish to trim or extend, or select a face you wish to extrude
2. Press the
Draft Trimex button, or press T then R keys
3. Click a point in the 3D view

Options
trimming or extending is decided automatically from the position of your mouse
if you move the mouse cursor over another object, the trim/extend operation will snap to that object or segment
pressing SHIFT will constrain you to the segment currently being trimmed or extended
pressing ALT will invert the direction of the trimming
When the selected object is a face, or a face is selected from an existing object, the trimex tool switches to extrude mode. In extrude mode,
pressing SHIFT frees the extrusion from the face normal and allows to snap elsewhere.

Scripting
Not available. See the Part Extrude tool.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Trimex&oldid=70723"

Draft Edit
Draft Edit

Description

Menu location

This tool allows you to edit graphically certain properties of the selected object, such as the vertices of a Wire, or the
length and width of a Rectangle, or the radius of a Circle. It does nothing more than enter the object's edit mode, so Draft -> Edit
other ways to enter edit mode (such as double-clicking the object in the Tree view) give the same result.
Workbenches

Draft, Arch
Default shortcut
None
See also
None

How to use
1. Select a wire, line, rectangle, bspline or circle
2.
3.
4.
5.

Press the
Draft Edit button, or double-click the object in the Tree panel, or use the
Click on a point you wish to move
Click another point on the 3D view, or type a coordinate
Press ESC or the Finish button

Std Edit tool.

Options
The Edit tool only works on one selected object at a time.
The Edit tool only works on Draft Wires, Rectangles, Circles and Arcs. Other object types must first be converted to Draft objects.
Click on an edit vertex to move it, click again to release it.
Press X , Y or Z after a point to constrain the next point on the given axis.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your next point horizontally or vertically in relation to the last one.
Press ESC or the Cancel button or the
Draft Edit button again to finish editing.
Pressing the
Add point button allows you to add points to Wires and BSplines by clicking on the segments
Pressing the
Del point button allows you to remove points from Wires and BSplines by clicking on the points to remove

Scripting
Not available. Each of the above object can be modified by changing its properties directly.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Edit&oldid=70719"

Draft Downgrade
Description
This tool downgrades selected objects in different ways. If no object is selected, you will be invited to select one.

Draft Downgrade
Menu location
Draft -> Downgrade
Workbenches
Draft, Arch
Default shortcut
DN
See also
Draft Upgrade

How to use
1. Select one or more objects you widh to downgrade
2. Press the
Draft Downgrade button or press D then N keys

Options
The selected objects are modified/downgraded, according to the following conditions (in order):
if only one object is selected and it contains more than one face, each face becomes a separate object
if there are more than one face in the selection, the subsequent objects are subtracted from the first one
if there is only one face in the selection, it gets converted into a wire
otherwise all wires found in the selection are exploded into single edges

Example

Complete shape

Downgraded shape, with disconnected and split faces

Scripting
The Downgrade tool can be used in python scripts and macros by using the following function:
downgrade (objects [delete], [force])
Downgrades the given object(s) (can be an object or a list of objects).
If delete is True, old objects are deleted.
The force attribute can be used to force a certain way of downgrading. It can be: explode, shapify, subtr, splitFaces, cut2, getWire, splitWires.
Returns a dictionnary containing two lists, a list of new objects and a list of objects to be deleted
Example:
import FreeCADGui,Draft
selection = FreeCADGui.Selection.getSelection()
Draft.downgrade(selection)

Draft Coordinates
In all Draft tools, when you are asked for 3d point locations, distances, radiuses, angles or any other numeric data, you can always choose to enter
those values graphically, by picking on the screen with your mouse, or directly by entering numbers with the keyboard. The first method is usually more
intuitive, but when you work with absolute precision, you often need to enter a precise number and be sure the coordinate you entered is exact.
Therefore, the command bar of the Draft module can always accept number input:

The Draft command bar is an "intelligent" toolbar, which means its contents change according to the tool being used and the input required from the
user. When you draw a circle, for example, the command bar will successively ask you for the circle center, then the radius. Those two values can both
be indicated by picking a point on the screen or by entering numbers.
Whenever you see the number input fields appearing on the command bar, you can enter numbers in them You will see that those numbers also reflect
the movements of your mouse cursor. You can TAB through the X,Y and Z fields to set the coordinates. Pressing ENTER in the Z field will record the
point. Repeating the entry of new X, Y and Z coordinates will set the second point for a line and/or subsequent points for a wire.
The following shortcuts can also be used:
SPACE BAR to swap between absolute and relative coordinates
C to swap between original mode and copy mode
L to lock/unlock the Z coordinate
TAB or ENTER switches to the next field (for ex. from X to Y or from Y to Z)
Sometimes, it can be hard to align objects when working in 3D space. You can lock the Z coordinate, so you'll be certain that everything you draw will lie
in the same horizontal plane. When you open FreeCAD, the Z coordinate is locked by default at 0.00, but you can easily change it, just unlock, change
the Z value, and lock again. If Z coordinate is locked, you won't be able to draw in non-horizontal planes.
Most of the Draft commands now work in 3D, just unlock the Z coordinate and switch the view to the appropriate angle, and what you'll draw next will be
aligned to that view.
Impose a decimal
By default, FreeCAD works with two decimal places, to change the number of decimal places, you must:
add a new integer element Decimals in the menu Tools Edit parameters... BaseApp Preferences Units
make right click in the window and select New integer item create name Decimals and enter the number of decimal places you want.
then click Save to disk , to validate your change.
close and return to FreeCAD to activate your changes.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Coordinates&oldid=69348"

Draft AddPoint
Draft AddPoint

Description
This tools allows you to add additional points to Wires and BSplines.

How to use
1. Select a wire or a BSpline
2. Press the
Draft AddPoint button
3. Click a point on the 3D view, or type a coordinate

Options
This functionality is also available inside the

Draft Edit tool

Scripting
Not available, but adding additional points to Wires and BSplines is easy, for example:
import FreeCAD,Draft
points = FreeCAD.ActiveDocument.ActiveObject.Points
points.append(FreeCAD.Vector(2,2,0))
FreeCAD.ActiveDocument.ActiveObjects.Points = points
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_AddPoint&oldid=70717"

Menu location
Draft -> Add Point
Workbenches
Draft, Arch
Default shortcut
None
See also
None

Draft DXF

Opening
This function opens a DXF file (any version from 12 to 2007) in a new drawing. The following DXF object types are currently supported:
lines
polylines and lwpolylines
circles
arcs
layers (layers containing objects are conveted to FreeCAD Groups)
texts and mtexts
dimensions
blocks (only geometry. texts, dims and attributes inside blocks will be skipped)
points available in version 0.13
leaders

available in version 0.13

Other DXF entities are currently not imported because there is no corresponding FreeCAD object. As new functionality gets implemented, it will be
possible to import more entity types.

Importing
This works the same way as opening, but it will add the contents of the dxf file in the active documento instead of creating a new document.

Exporting
The exported DXF is compatible with Autocad version 12 and up, so it should open in about any application that supports dxf format. Currently the
following FreeCAD objects get exported:
lines and wires (polylines)
arcs and circles
texts
colors are mapped from objects RGB colors to autocad color index (ACI). Black will always be "by layer"
layers are mapped from group names. When groups are nested, the deepest group gives the layer name.
dimensions, which are exported with "Standard" dimstyle

Preferences
The following parameters can be specified in the Draft Preferences tab (menu Edit -> Preferences -> Draft):
Import style: This lets you choose the way objects from the dxf file will be drawn in FreeCAD. You can choose between:
None: this is the faster way, there is no conversion, all objects will be black with 2px width (FreeCAD default)
Use default color and linewidth: All imported dxf objects will take current linewidth/color from the draft command bar
Original color and linewidth: Objects will keep the color and linewidth (if specified) they have in the dxf file
Colors mapped to linewidth: If this option is selected, the mapping file option below is used.
Color mapping file: This allows you to specify a mapping file to be used for translating dxf colors to color and linewidth, the same way as a plot
style works in Autocad. The mapping file must be a tab-separated text file. There is a nice free utility called Plot style viewer that can convert
Autocad CTB or STB (plot styles) files to tab-separated mapping files ready to use in FreeCAD. Alternatively, we have a couple of home-made
mapping files availables here.
Import texts: This allows you to specify if you want to import dxf texts and dimensions or not. Many texts might make your work in FreeCAD very
heavy, so you might want to use this option some time.
Import layout objects: Turn this on if you want to import paper space object. They will be merged in the same document than model space
objects.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_DXF&oldid=68085"

Draft Point
Description

Draft Point

The Point tool creates a simple point in the current work plane, handy to serve as reference for placing other Menu location
objects later. It takes the color previously set on the Tasks tab.
Draft -> Point

Workbenches
Draft, Arch
Default shortcut
PT
See also
None

How to use
1. Press the
Draft Point button, or press P then T keys
2. Click a point on the 3D view, or type a coordinate

Options
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press ESC or the Cancel button to abort the current Line command.

Properties
DATA
DATA
DATA

X: The X coordinate of the point


Y: The Y coordinate of the point
Z: The Z coordinate of the point

Scripting
The Point tool can by used in macros and from the python console by using the following function:
makePoint([x],[y],[z])
makes a point at the given coordinates. If no X, Y and Z coordinates are given, the point is created at (0,0,0). Returns the newly created object.
Example:
import Draft
Draft.makePoint(6,4,2)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Point&oldid=66029"

Draft ShapeString
Description

Draft
ShapeString

The ShapeString tool inserts a compound shape representing a text string at a given point in the current document.
Text height, tracking and font can be specified.
Menu

location
Draft -> ShapeString
Workbenches
Draft, Arch
Default shortcut
SS
See also
None

How to use
1.
2.
3.
4.
5.
6.
7.

Press the
Draft ShapeString button, or press S then S keys
Click a point on the 3D view, or type a coordinate
Enter the desired text, press ENTER
Enter the desired size, press ENTER
Enter the desired tracking, press ENTER
Press ENTER to accept the displayed font file, or,
Press ... to select a font file.

Options
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Pressing ESC will cancel the operation.
You can set a default font file in Draft/Prefences.

Properties
DATA
DATA
DATA
DATA
DATA

Position: The base point of the compound shape


String: The contents of the text string
Size: The height of the letters in FC units
Tracking: The inter-character spacing in FC units
Font File: The font definition file used to draw the string

Scripting
The ShapeString tool can by used in macros and from the python console by using the following function:
makeShapeString(String,FontFile,[Size],[Tracking])
Turns a text string into a Compound Shape using a specified font.
Example:
import FreeCAD,Draft
Draft.makeShapeString("This is a sample text",
"/usr/share/fonts/truetype/msttcorefonts/Arial.ttf",
200.0,10)

Selecting A Font

ShapeString uses the internal geometry of a font to make FreeCAD shapes. To do this it must read the actual font file (*.tff, etc). If the Font Selection
box is empty, you must type the full path to the font file or use ... to select a font file.

Limitations
This tool is not yet generally available. It will be included in a future version. (post v0.13)
TrueType(*.ttf), OpenType(*.otf) and Type1(*.pfb) font files are supported.
Very small text heights may result in deformed character glyphs due to loss of detail in scaling.
The current version is limited to left-to-right layouts on a horizontal baseline.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_ShapeString&oldid=72476"

Draft Ellipse
Description

Draft Ellipse
Menu location

The Ellipse tool creates an ellipse in the current work plane by entering two points, defining the corner of a
Draft -> Ellipse
rectangular box in which the ellipse will fit. It takes the linewidth and color previously set on the Tasks tab.

Workbenches
Draft, Arch
Default shortcut
EL
See also
Draft Circle

How to use
1. Press the
Draft Ellipse button, or press E then L keys
2. Click a first point on the 3D view, or type a coordinate
3. Click a second point on the 3D view, or type a coordinate

Options
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Ellipse tool will restart after you give the
second point, allowing you to draw another ellipse without pressing the Ellipse button again.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your second point horizontally or vertically in relation to the first one.
Press I or the Filled button to have the ellipse to appear as a face after it has been closed. This simply sets the View->Property of the ellipse
to "Flat lines" or "Wireframe", so it can easily be changed later.
Press ESC or the Cancel button to abort the command.
Ellipses, when in "Flat Lines" display mode, can display a hatch pattern, by setting their "Pattern" property below.

Properties
DATA
DATA
VIEW
VIEW

Major Radius: The major radius of the ellipse


Minor Radius: The minor radius of the ellipse
Pattern: Specifies a hatch pattern to fill the ellipse with
Pattern Size: Specifies the size of the hatch pattern

Scripting
The Ellipse tool can by used in macros and from the python console by using the following function:
makeEllipse (majorradius, minorradius, [placement], [facemode])
Creates an ellipse object with given major and minor radius.
If a placement is given, it is used.
If facemode is False, the ellipse is shown as a wireframe, otherwise as a face.
Returns the newly created object.
Example:
import Draft
myEllipse = Draft.makeEllipse(4,2)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Ellipse&oldid=70732"

Draft ToggleSnap
Description
This command toggles snapping on/off.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_ToggleSnap&oldid=70880"

Draft ToggleSnap
Menu location
Draft -> Utilities -> Toggle
snap
Workbenches
Draft, Arch
Default shortcut
None
See also
None

Draft Constrain
To use constraining, press SHIFT while drawing.

In all tools that support constraining, you can force the next point to be constrained horizontally or vertically in relation to the last point entered. The
vertical or horizontal constraining depends on where your mouse lies when you press SHIFT . If you are more north or south from the last point, it will
be vertical. If you are more east or west, it will be horizontal. To change, just release SHIFT and press again at another location.
Some tools, like offset and trimex use constraining differently. They do not constrain vertically or horizontally but use a different way more adapted to
the particular tool, like for example constraining the operation to a certain polyline segment.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Constrain&oldid=69277"

Draft DelPoint
Draft DelPoint

Description
This tools allows you to remove points from Wires and BSplines.

How to use
1. Select a wire or a BSpline
2. Press the
Draft DelPoint button
3. Click a point on the wire or BSpline

Options
This functionality is also available inside the

Draft Edit tool

Scripting
Not available, but removing points from Wires and BSplines is easy, for example:
import FreeCAD,Draft
points = FreeCAD.ActiveDocument.ActiveObject.Points
points.pop(0)
FreeCAD.ActiveDocument.ActiveObjects.Points = points
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_DelPoint&oldid=70716"

Menu location
Draft -> Remove Point
Workbenches
Draft, Arch
Default shortcut
None
See also
None

Draft Facebinder
Draft Facebinder

Description

Menu location

The facebinder a very simple object constructed from selected faces of other objects. It is of parametric, you can
modify the original object and the facebinder object updates accordingly. It can then be used for example for making Draft Facebinder
an extrusion out of a collection of faces from other objects. A typical use is in architectural design, to build an object Workbenches
that covers several pieces of walls. You can move and rotate the facebinder around after its creation, everything will
Draft, Arch
stay linked to the original faces.

Default shortcut
FF
See also
None

How to use
1. Select faces on objects (use CTRL to select several faces)
2. Press the
Facebinder , button, or press F , F keys

Scripting
The facebinder tool can be usedin scripts and macros by using the following function:
makeFacebinder ( selectionset )
Creates a facebinder object from the given selection set,
FreeCADGui.Selection.getSelectionEx() method.
Only selected faces are taken into account
Returns the newly created object

which is

Example:
import Draft, FreeCADGui
mySelection = FreeCADGui.Selection.getSelectionEx()
Draft.makeFacebinder(mySelection)

Limitations
Not available before version 0.14
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Facebinder&oldid=70725"

a list

of selection objects

such as

returned by

the

Draft Rectangle
Draft Rectangle

Description

Menu location

The rectangle tool creates a rectangle by picking two opposite points. It takes the linewidth and color previously Draft -> Rectangle
set on the Tasks tab.

Workbenches
Draft, Arch
Default shortcut
RE
See also
Part Box

How to use
1. Press the
Draft Rectangle button, or press R then E keys
2. Click a first corner point on the 3D view, or type a coordinate
3. Click another opposite point on the 3D view, or type a coordinate. The rectangle will also be a face, even if it appears as wireframe.

Options
Press X , Y or Z after a point to constrain the next point on the given axis.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press R or click the checkbox to check/uncheck the Relative button. If relative mode is on, the coordinates of the next point are relative to
the last one. If not, they are absolute, taken from the (0,0,0) origin point.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Rectangle tool will restart after you finish
or close it, allowing you to draw another one without pressing the Rectangle button again.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your next point horizontally or vertically in relation to the last one.
Press I or the Filled button to have the rectangle to appear as a face after it has been closed. This simply sets the View->Property of the
Rectangle to "Flat lines" or "Wireframe", so it can easily be changed later.
Press ESC or the Cancel button to abort the current Line command.
Rectangles, when in "Flat Lines" display mode, can display a hatch pattern, by setting their "Pattern" property.

Properties
Length: Specifies the length of the rectangle
Width: Specifies the width of the rectangle
DATA Chamfer Size: Specifies the size of chamfered corners
DATA Fillet Radius: Specifies a curvature radius to give to the corners of the rectangle
VIEW Texture Image : Allows to give the path to an image file to be mapped on the rectangle. It is up to you to give the rectangle the same
proportion as the image if you want to avoid distortions. Blanking this property will remove the image.
VIEW Pattern: Specifies a hatch pattern to fill the wire with
VIEW Pattern Size: Specifies the size of the hatch pattern
DATA
DATA

Scripting
The Rectangle tool can by used in macros and from the python console by using the following function:
makeRectangle (length, width, [placement], [facemode])
Creates a Rectangle object with length in X direction and height in Y direction.
If a placement is given, it is used.
If facemode is False, the rectangle is shown as a wireframe, otherwise as a face.
The current Draft linewidth and color will be used.
Returns the newly created object.
Example:
import FreeCAD,Draft
Draft.makeRectangle(10,4)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Rectangle&oldid=70731"

Draft SelectGroup
Description
This tool allows you to select the contents of one or more selected groups.

How to use
1. Select one or more groups in the Tree view
2. Press the
Add to group button

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_SelectGroup&oldid=70870"

Draft
SelectGroup
Menu location
Draft -> Utilities -> Select
group
Workbenches
Draft, Arch
Default shortcut
None
See also
None

Draft Array
Description
The Array tool creates an orthogonal (3-axes) or polar array from a selected object. If no object is selected, you will
be invited to select one.

Draft Array
Menu location
Draft -> Array
Workbenches
Draft, Arch
Default shortcut
None
See also
PathArray

How to use
1. Select an object you wish to make an array with
2. Press the
Draft Array button

Options
The array starts as orthogonal by default, you can then change its mode in the properties.

Properties
DATA

Array Type: Specifies the type of the array, ortho or polar

For orthogonal arrays:


DATA
DATA
DATA
DATA
DATA
DATA

Interval X: The interval between each copy on the first axis


Interval Y: The interval between each copy on the second axis
Interval Z: The interval between each copy on the third axis
Number X: The number of copies on the first axis
Number Y: The number of copies on the second axis
Number Z: The number of copies on the third axis

For polar arrays:


DATA
DATA
DATA
DATA

Axis: The normal direction of the array circle


Center: The center point of the array
Angle: The angle to cover with copies
Number Polar: The number of copies

Scripting
The Array tool can by used in macros and from the python console by using one of the following functions, depending if you wish to obtain simple,
standalone copies of your base object, or a parametric array object, that stays linked to the original object.

Simple array
For rectangular array:
array (objectslist,xvector,yvector,xnum,ynum,[zvector,znum])
For polar array:
array (objectslist,center,totalangle,totalnum)
Creates an array of the objects contained in list (that can be an object or a list of objects) with, in case of rectangular array, xnum of iterations in
the x direction at xvector distance between iterations, and same for y direction with yvector and ynum. In case of polar array, center is a vector,
totalangle is the angle to cover (in degrees) and totalnum is the number of objects, including the original.
This function produces standalone copies of the base object(s)

Parametric array
For rectangular array:
makeArray (object,xvector,yvector,xnum,ynum)
For polar array:
makeArray (object,center,totalangle,totalnum)
Creates an array of the given object with, in case of rectangular array, xnum of iterations in the x direction at xvector distance between iterations,
and same for y direction with yvector and ynum. In case of polar array, center is a vector, totalangle is the angle to cover (in degrees) and
totalnum is the number of objects, including the original.

The result of this function is a parametric Draft Array object.


Example:
import FreeCAD,Draft
Draft.array(FreeCAD.ActiveDocument.ActiveObject,FreeCAD.Vector(2,0,0),FreeCAD.Vector(0,2,0),2,2)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Array&oldid=71124"

Draft CloseLine
Description

Draft CloseLine

This command finishes the drawing of a current wire, and closes it by drawing a closing segment between the last Menu location
point and the first one. Closed wires are always also filled faces internally, even if they appear as wireframe.
Draft -> Utilities

How to use
1. Start drawing a Draft Wire
2. Press the
Close button or press the C key

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_CloseLine&oldid=70851"

-> Close
Line
Workbenches
Draft, Arch
Default shortcut
C
See also
FinishLine, UndoLine

Draft WireToBSpline
Description
This tool converts Wires to BSplines, and vice-versa.

How to use
1. Select a wire or a BSpline
2. Press the
Draft WireToBSpline button

Options
The original object will not be deleted after the operation, you must delete it manually if you wish so.

Scripting
Not available, but creating a new object with the points from another one is easy, for example:
If the active object is a wire:
import FreeCAD,Draft
points = FreeCAD.ActiveDocument.ActiveObject.Points
Draft.makeBSpline(points)
if the active object is a bspline
import FreeCAD,Draft
points = FreeCAD.ActiveDocument.ActiveObject.Points
Draft.makeWire(points)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_WireToBSpline&oldid=70718"

Draft
WireToBSpline
Menu location
Drafting -> Wire to BSpline
Workbenches
Draft, Arch
Default shortcut
None
See also
None

Draft Scale
Description

Draft Scale

This tool scales selected object(s) around a base point. If no object is selected, you will be invited to select one. It Menu location
can also be used to mirror objects.
Draft -> Scale

Workbenches
Draft, Arch
Default shortcut
SC
See also
Draft Clone

How to use
1.
2.
3.
4.

Select objects you wish to scale


Press the
Draft Scale button, or press S then C keys
Click a first point on the 3D view, or type a coordinate
Click another point on the 3D view, or type a coordinate

Options
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
The x, y and z components of the second point define the scale factor. For example, (1,1,1) would do nothing, (2,2,2) would scale 2x in all
directions, (-1,1,1) would mirror in x direction.
Pressing ALT or C or clicking the Copy button will make a copy of the objects, instead of scaling the original. If you keep ALT pressed
after clicking the second point, you will be able to place more copies, until you release the ALT key.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Pressing SHIFT will lock x and y values together, so the shape is not deformed.
Press ESC or the Cancel button to abort the current command.
The resulting object is a Draft Clone, which allows you to change the scale values after it has been created.
Mirroring objects works by inverting the sign of one of the directions. For example, (-1,1,1) mirrors horizontally (on the X axis), and (1,-1,1)
vertically (on the Y axis).

Scripting
The Scale tool can by used in macros and from the python console by using the following function:
scale (objects,vector,[center,copy,legacy])
Scales the objects contained in objects (that can be a list of objects or an object) of the given scale factors defined by the given vector (in X, Y
and Z directions) around the given center.
If legacy is True, direct (old) mode is used, otherwise a parametric copy is made.
If copy is True, the actual objects are not moved, but copies are created instead.
The objects (or their copies) are returned.
Example:
import FreeCAD,Draft
Draft.scale(FreeCAD.ActiveDocument.ActiveObject,FreeCAD.Vector(2,2,2))
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Scale&oldid=71688"

Draft Snap
Snapping means "gluing" your next 3d point onto an existing point. Snapping is available with most Draft and Arch tools, and can be enabled and
disabled globally with the Draft ToggleSnap command. Each snap location below can also be enabled or disabled individually by clicking the
corresponding button on the snap toolbar.

Available snap locations


Angle: the special cardinal points of circles and arcs, at 45 and 90
Center: the center point of arcs and circles
Endpoint: the endpoints of line, arc and spline segments
Extension: on an imaginary line that extends beyond the endpoints of line segments. Hover the mouse over the desired object to activate
its extension snap
Grid: the nodes of the Draft grid, if visible.
Intersection: the intersection of 2 line or arc segments. Hover the mouse over the two desired bjects to activate their intersection snaps
Midpoint: the middle point of line and arc segments
Near: the closest point on the nearest object
Ortho: on imaginary lines that cross the last point, and extend at 0, 45 and 90
Parallel: on an imaginary line parallel to a line segment. Hover the mouse over the desired object to activate its parallel snap
Perpendicular: on line and arc segments, perpendicularly to the latest point
Restrict to working plane: always places the snapped point on the current working plane, even if you snap to a point outside that
working plane.

Options
Lock: turns snapping on/off globally
Certain additional snap locations can be obtained by combining 2 snap locations, such as ortho + extension, that will give you a snap point at the
intersection of their imaginary lines.
Other, more complex snap locations can also be obtained by using constraining (by pressing SHIFT or X or Y or Z while drawing).
Pressing L while drawing locks the current angle of the line segment being drawn.
The maximum distance at which a point is snapped a snap location is specified in the preferences, and can also be changed on-the-fly by
pressing [ or ] keys.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Snap&oldid=74652"

Draft ToggleConstructionMode
Description
The Draft module features a construction mode, which allows to draw certain objects in a special group, with a
defined color, so it is easy to separate them from the other objects and switch it off when you don't need it, or
delete them after you don't need them anymore.

Draft
ToggleConstructionMode
Menu location
Draft -> Utilities -> Toggle
construction mode
Workbenches
Draft, Arch
Default shortcut
None
See also
None

How to use
1. Press the
Toggle construction mode button
2. Draw some objects
3. Press the
Toggle construction mode button again to go back to normal mode

Options
The Construction Mode button is also present on the Task panel or Draft toolbar when the Draft workbench is active
The color and the group name can be changed in the preferences screen.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_ToggleConstructionMode&oldid=68683"

Draft Clone
Description

Draft Clone

This tool produces a clone (a copy that is parametrically bound to the original object) of a selected object. If the Menu location
original object changes, the clone changes too, but keeps its position, rotation and scale.
Draft -> Clone

Workbenches
Draft, Arch
Default shortcut
None
See also
Draft Scale

How to use
1. Select objects you wish to clone
2. Press the
Draft Clone button

Properties
Scale: Specifies an optional scale factor for the clone
The result of the Draft Scale tool is also a clone
DATA

Scripting
The Clone tool can by used in macros and from the python console by using the following function:
clone (obj,[delta])
Makes a clone of the given object(s).
The clone is an exact, linked copy of the given object.
If the original object changes, the final object changes too. Optionally, you can give a delta Vector to move the clone away from the original
position.
Example:
import Draft
Draft.clone(FreeCAD.ActiveDocument.ActiveObject)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Clone&oldid=68620"

Draft Workingplane
(Redirected from Draft Workingplane)

Draft SelectPlane

Description

The Draft module features a working plane system, that allows you to specify a custom plane in the 3D space on Menu location
which next Draft command will occur. There are several methods to define the working plane:
Draft -> Utilities

-> Select
Plane
From a selected face
Workbenches
From the current view
From a preset: top, frontal or lateral
Draft, Arch
None, in which case the working plane is adapted automatically to the current view when you start a
Default shortcut
command, or to a face if you start drawing on an existing face.
None
See also
None

How to use
1. Press the

SelectPlane button. If your button doesn't look like this, see this note.

Options
To set the workplane to an existing face: select a face of an existing object in the 3D view, then press the
SelectPlane button
Pressing the VIEW button will set the working plane as the view plane, perpendicular to the camera axis and passing through the (0,0,0) origin
point.
Pressing the NONE will unset any current working plane. The next 2D operations will be view-dependent.
You can also specify an offset value, which will set your working plane at a certain distance from the plane you select.

Scripting
Working plane objects can easily be created and manipulated in scripts and macros. You can create your own, and use them independently of the
current Draft working plane.
Example:
import WorkingPlane
myPlane = WorkingPlane.plane()
You can also access the current Draft working plane:
import FreeCAD
draftPlane = FreeCAD.DraftWorkingPlane
The working plane has a complete scripting API on its own, with convenience functions to position it and convert to/from placements.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_SelectPlane&oldid=70848"

Draft Text
Draft Text

Description

Menu location

The Text tool inserts a piece of text at a given point in the current document. It takes the text size and color Draft -> Text
previously set on the Tasks tab.

Workbenches
Draft, Arch
Default shortcut
TE
See also
None

How to use
1.
2.
3.
4.

Press the
Draft Text button, or press T then E keys
Click a point on the 3D view, or type a coordinate
Enter the desired text, pressing ENTER between each line
Press ENTER twice to finish the operation.

Options
Pressing CTRL will snap your point to available snap locations.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Pressing ESC will cancel the operation.
When editing the text, pressing ENTER or DOWN ARROW allow you to enter or edit a next line of text.
Pressing UP ARROW allows you to edit a previous line of text.
Pressing ENTER twice (thus leaving the last line empty) adds the text to the document and closes the editor.

Properties
Position: The base point of the text block
Label Text: The contents of the text block
VIEW Display Mode: Specifies if the text is aligned to the scene axes or always faces the camera
VIEW Font Size: The size of the letters
VIEW Justification: Specifies if the text is aligned to the left, right or center of the base point.
VIEW Line Spacing: Specifies the space between lines of text
VIEW Rotation: Specifies a rotation to be applied to the text
VIEW Rotation Axis: Specifies the axis to use for the rotation
VIEW Font Name: The font to use to draw the text. It can be a font name, such as "Arial", a default style such as "sans", "serif" or "mono", or a
family such as "Arial,Helvetica,sans" or a name with a style such as "Arial:Bold". If the given font is not found on the system, a generic one is
used instead.
DATA
DATA

Scripting
The Text tool can by used in macros and from the python console by using the following function:
makeText (string or list, [Vector], [screenmode])
Creates a Text object, at the given point if a vector is provided, containing the string or the strings given in the list, one string by line.
The current Draft color and text height and font specified in preferences are used.
If screenmode is True, the text always faces the view direction, otherwise it lies on the XY plane.
Returns the newly created object.
Example:
import FreeCAD,Draft
Draft.makeText("This is a sample text",FreeCAD.Vector(1,1,0))
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Text&oldid=70728"

Draft Wire
Draft Wire

Description

Menu location

The Wire tool creates a polyline (sequence of lines made of several segments) in the current work plane. It takes
the linewidth and color previously set on the Tasks tab. The Wire tool behaves like the Draft Line tool, except Draft -> Wire
that it doesn't stop after two points.

Workbenches
Draft, Arch
Default shortcut
WI
See also
Draft Line, Draft BSpline

How to use
1.
2.
3.
4.

Press the
Draft Wire button, or press W then I keys
Click a first point on the 3D view, or type a coordinate
Click additional point on the 3D view, or type a coordinate
Press F or C , or double-click the last point, or click on the first point to finish or close the wire. If the wire is closed, it will also be a face, even
if it appears as wireframe.

Options
Press F or the
Finish button to finish the wire, leaving it open
Press C or the
Close button or click on the first point to finish the wire, but making it closed by adding a last segment between the last
point and the first one.
Press X , Y or Z after a point to constrain the next point on the given axis.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press R or click the checkbox to check/uncheck the Relative button. If relative mode is on, the coordinates of the next point are relative to
the last one. If not, they are absolute, taken from the (0,0,0) origin point.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Wire tool will restart after you finish or
close it, allowing you to draw another one without pressing the Wire button again.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Press SHIFT while drawing to constrain your next point horizontally or vertically in relation to the last one.
Press W or press the
Wipe button to remove the existing segments and start the wire from the last point.
Press CTRL + Z or press the
Undo button to undo the last point.
Press I or the Filled button to have the wire to appear as a face after it has been closed. This simply sets the View->Property of the Wire to
"Flat lines" or "Wireframe", so it can easily be changed later.
Press ESC or the Cancel button to abort the current Line command.
Closed wires, when in "Flat Lines" display mode, can display a hatch pattern, by setting their "Pattern" property below.

Properties
DATA
DATA
DATA
VIEW
VIEW
VIEW

Closed: Specifies if the wire is closed or not


Chamfer Size: Specifies the size of chamfered corners
Fillet Radius: Specifies a curvature radius to give to the nodes of the wire
End Arrow: Shows an arrow symbol at the last point of the wire, so it can be used as an annotation leader line
Pattern: Specifies a hatch pattern to fill the wire with
Pattern Size: Specifies the size of the hatch pattern

Scripting
The Wire tool can by used in macros and from the python console by using the following function:
makeWire (list or Part.Wire, [closed], [placement], [facemode])
Creates a Wire object from the given list of vectors or from the given wire.
If closed is True or if first and last points are identical, the wire is closed.
If facemode is True (and the wire is closed), the wire will appear filled.
The current Draft linewidth and color will be used.
Returns the newly created object.
Example:
import FreeCAD,Draft
p1 = FreeCAD.Vector(0,0,0)
p2 = FreeCAD.Vector(1,1,0)
p3 = FreeCAD.Vector(2,0,0)
Draft.makeWire([p1,p2,p3],closed=True)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Wire&oldid=70735"

Draft UndoLine
Description
This command undoes the last segment of a Draft Wire being drawn.

How to use
1. Start drawing a Draft Wire
2. Press the
Undo button or press the CTRL + Z keys

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_UndoLine&oldid=70852"

Draft UndoLine
Menu location
Draft -> Utilities -> Undo Line
Workbenches
Draft, Arch
Default shortcut
Ctrl + Z
See also
FinishLine, CloseLine

Draft OCA
Opening
This function imports OCA/GCAD files. The OCA file format is community effort to create a free, simple and open CAD file format. OCA is largely based
on the GCAD file format generated from gCAD3D. Both formats can be imported in FreeCAD, and the OCA files exported by FreeCAD can be opened in
gCAD3D.
The following OCA objects get imported at the moment:
Lines
Arcs and Circles
Closed areas

Importing
Works the same way as opening but creates the objects in the active document instead of creating a new one.

Exporting
Objects that can be exported at the moment:
Lines and wires (polylines)
Arcs and circles
Faces

Preferences
The following parameters can be specified in the Draft Preferences tab (menu Edit -> Preferences -> Draft):
Import closed areas or not
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_OCA&oldid=69114"

Draft ToggleDisplayMode
Description
This tool switches the display of selected object(s) between Wireframe and Flat Lines

Draft
ToggleDisplayMode

Menu location
Draft -> Utilities -> Toggle
display mode
1. Select object(s)
Workbenches
2. Press the
Toggle display mode button or press the SHIFT and SPACEBAR keys
Draft, Arch
Default shortcut
Options
Shift + Space
This as the same effect as changing the Display Mode property of objects between "Wireframe" and "Flat
See also
Lines"
None

How to use

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_ToggleDisplayMode&oldid=70867"

Draft Dimension
Description

Draft Dimension

The dimension tool creates a dimension in the current document with two points defining the distance to measure, Menu location
and a third point specifying where the dimension line passes.
Draft -> Dimension

Workbenches
Draft, Arch
Default shortcut
DI
See also
FlipDimension

How to use
1.
2.
3.
4.

Press the
Draft Dimension button, or press D then I keys
Click a point on the 3D view, or type a coordinate
Click a second point on the 3D view, or type a coordinate
Click a third on the 3D view, or type a coordinate

Available dimension types


Linear dimensions: by picking any 2 points or any straight edge with ALT pressed.
Horizontal/vertical dimensions: by pressing SHIFT after the first point is selected.
Diameter dimensions: by picking a curved edge with ALT pressed.
Radius dimensions: by picking a curved edge with ALT pressed, then pressing SHIFT .
Angular dimensions: by picking 2 straight edges with ALT pressed.

Options
Press X , Y or Z after a point to constrain the next point on the given axis.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
Pressing SHIFT will constrain the dimension horizontally or vertically, or, when working on a circular edge, switches between diameter and
radius modes.
Press R or click the checkbox to check/uncheck the Relative button. If relative mode is on, the coordinates of the next point are relative to
the last one. If not, they are absolute, taken from the (0,0,0) origin point.
Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, you will be able to draw continued dimensions,
one after the other, that share the same baseline.
Press ESC or the Cancel button to abort the current Line command.
By picking an existing edge with ALT , instead of entering measurement points, the dimension will become parametric and remember which
edge it is bound to. If the endpoints of that edge move later on, the dimension will follow them.
The direction of the dimension can be changed afterwards, by modifying its "Direction" property

Properties
Start: The start point of the distance to measure
End: The end point of the distance to measure
DATA Dimline: A point through which the dimension line must pass
VIEW Display Mode: Specifies if the text is aligned to the dimension lines or always faces the camera
VIEW Font Size: The size of the letters
VIEW Ext Lines: The size of the extension lines (between the measurement points and the dimension line)
VIEW Text Position: Can be used to force the text to be displayed at a certain position
VIEW Text Spacing: Specifies the space between the text and the dimension line
VIEW Override: Specifies a text to display instead of the measurement. Use the word "dim", inside that text, to display the measurement
VIEW Font Name: The font to use to draw the text. It can be a font name, such as "Arial", a default style such as "sans", "serif" or "mono", or a
family such as "Arial,Helvetica,sans" or a name with a style such as "Arial:Bold". If the given font is not found on the system, a generic one is
used instead.
VIEW Arrow Type: The type of arrow to use
VIEW Arrow Size: The size of the arrows
VIEW Decimals: The number of decimal places to display on the dimension
VIEW Flip Arrows: Reverse the orientation of arrows
DATA
DATA

Scripting
The Dimension tool can by used in macros and from the python console by using the following functions:
makeDimension (p1,p2,[p3])
or

makeDimension (object,i1,i2,p3)
or
makeDimension (objlist,indices,p3)
Creates a Dimension object with the dimension line passign through p3.
The Dimension object takes the Draft linewidth and color set in the command bar.
There are multiple ways to create a dimension, depending on the arguments you pass to it:
1. (p1,p2,p3): creates a standard dimension from p1 to p2.
2. (object,i1,i2,p3): creates a linked dimension to the given object, measuring the distance between its vertices indexed i1 and i2.
3. (object,i1,mode,p3): creates a linked dimension to the given object, i1 is the index of the (curved) edge to measure, and mode is either "radius" or
"diameter". Returns the newly created object.
makeAngularDimension (center,[angle1,angle2],p3)
creates an angular Dimension from the given center, with the given list of angles, passing through p3.
Returns the newly created object.
Example:
import FreeCAD,Draft
p1 = FreeCAD.Vector(0,0,0)
p2 = FreeCAD.Vector(1,1,0)
p3 = FreeCAD.Vector(2,0,0)
Draft.makeDimension(p1,p2,p3)

Links
Tutorial: Projecting dimensions on a Drawing Page
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Draft_Dimension&oldid=70913"

Arch Module
The Arch workbench provides modern BIM workflow to FreeCAD, with support for features like IFC support, fully parametric architectural entities such as
walls, structural elements or windows, and rich 2D document production. The Arch workbench also feature all the tools from the Draft Workbench.

Tools
Construction tools
These are tools for creating architectural objects.

Wall: Creates a wall from scratch or using a selected object as a base


Structural element: Creates a structural element from scratch or using a selected object as a base
Rebar: Creates a reinforcement bar in a selected structural element
Floor: Creates a floor including selected objects
Building: Creates a building including selected objects
Site: Creates a site including selected objects
Window: Creates a window using a selected object as a base
Section Plane: Adds a section plane object to the document
Axes system: Adds an axes system to the document
Roof: Creates a sloped roof from a selected face
Space: Creates a space object in the document
Stairs: Creates a stairs object in the document
Frame: Creates a frame object from a selected layout

Modification tools
These are tools for modifying architectural objects.

Add: Adds objects to a component


Remove: Subtracts or removes objects from a component
Survey: Enters or leaves surveying mode

Utilities
These are additional tools to help you in specific tasks.

Split Mesh: Splits a selected mesh into separate components


Mesh To Shape: Converts a mesh into a shape, unifying coplanar faces
Remove Shape: Turns cubic shape-based arch object fully parametric
Select non-solid meshes: Selects all non-solid meshes from the current selection or frm the document
CloseHoles: Closes holes in a selected shape-based object
Check: Check if the selected objects are solids and don't contain defects
Ifc Explorer: Browse the contents of an IFC file

File formats
IFC : Industry foundation Classes (import only)
DAE : Collada mesh format
OBJ : Obj mesh format (export only)

API
The Arch module can be used in python scripts and macros using the Arch Python API functions.

Tutorials
Arch tutorial
Arch tutorial in Yorik's blog
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Module&oldid=76655"

Arch Building
Description
The Arch Building is a special type of FreeCAD group object particularly suited for representing a whole building unit.
They are mostly used to organize your model, by containing floor objects.

How to use
1. Optionally, select one or more objects to be included in your new building
2. Press the
Arch Building button, or press the B then U keys

Options

Arch Building
Menu location
Arch -> Building
Workbenches
Arch
Default shortcut
BU
See also
Arch Floor, Arch Site

After creating a building, you can add more objects to it by drag and dropping them in the Tree View or by
using the
Arch Add tool
You can remove objects from a building by drag and dropping them out of it the Tree View or by using the
Arch Remove tool

Scripting
The Building tool can by used in macros and from the python console by using the following function:
makeBuilding ([objectslist])
creates a building including the objects from the given list.
Example:
import Arch
Arch.makeBuilding()
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Building&oldid=44139"

Arch Window
Arch Window

Description

The Window is a base object for all kinds of "embeddable" objects, such as windows, doors, etc... It is designed to Menu location
be either independent, or "hosted" inside another component such as a wall. It has its own geometry, that can be Arch -> Window
made of several components (the window frame, for example), and also defines a volume to be subtracted to host
Workbenches
objects, in order to create an opening.

Arch

Windows are based on closed 2D objects, such as Draft Rectangles or Sketches, that are used to define their
inner components. The base 2D object can therefore contain several closed wires, that can be combined to form Default shortcut
filled panels (one wire) or frames (several wires). If the base 2D object was drawn on a support object, and that W I
support object is a wall, then the window gets automatically included in that wall.

See also
Wall

The window tool also features several presets (available in version 014 ), that allow to create full doors or windows from a list Arch
of parameters, without the need to create the base 2D objects and components manually.

In the above image, a window is constructed on top of a Draft Rectangle, then inserted into a Wall. Adding a window to a wall automatically cuts a
correct opening in the host wall.

The above image shows a more complex window being constructed on top of a sketch. When entering the window's edit mode, you can create different
components, set their thickness, and select and assign wires from the sketch to them.

How to use
Using a preset
1.
2.
3.
4.

Deselect everything. If a face is selected you will enter the "creating from scratch" mode automatically
Press the
Arch Window button, or press W then I keys
Select one of the presets in the list
Fill out the desired parameters

Creating from scratch


1.
2.
3.
4.
5.

If you are going to draw your window directly on a wall, select one face of a wall
Press the
Arch Window button, or press W then I keys
A new sketch will be created (on the selected wall face if applicable). Draw one or more closed wires
Press the CLose button in the task panel to create the window
Enter Edit mode by double-clicking the window in the tree view, to adjust the window components

Presets
The following presets are available (available in version 014 ):

W2

HEIGHT

H1
H2

O2
H3

W1

O1

WIDTH

Glass door

W2

HEIGHT

H1

O2

W1

O1

WIDTH

Simple door

W2

W1

HEIGHT

H1
H2

O2

O1

WIDTH

Double-opening window

HEIGHT

H1

W1

O1

WIDTH

Fixed window

W2

W1

HEIGHT

H1
H2

O2

O1

WIDTH

Single-opening window

W2

W1

O2

HEIGHT

H1
H2

O1

WIDTH

Sash-opening window

Building components
Windows can include 2 types of components: panels and frames. Panels are made from one closed wire, which gets extruded, while frames are made
from 2 or more closed wire, where each one is extrudes, then the smaller ones are subtracted from the biggest one. You can access, create, modify and
delete components of a window in edit mode (double-click the window in the Tree view). The components have the following properties:
Name: A name for the component
Type: The type of component. Can be "Frame", "Glass panel" or "Solid panel"
Wires: A comma-separated list of wires the component is based on
Thickness: The extrusion thickness of the component
Offset: The distance between the component and its base 2D wire(s)

Options
You can also create a closed 2D profile (for example with the Draft Workbench or Sketcher Workbench), then, with that 2D object selected,
press the
Arch Window button.
Add a selected window to a wall by selecting both, then pressing the
Arch Add button.
Remove a selected window from a wall by selecting the window, then pressing the
Arch Remove button.
When using presets, it is often convenient to turn the "Near" Draft Snap on, so you can snap your window to an existing face.

Doors
Doors can be made easily with the window tool, you only need to draw the base of the inner wire touching the exterior wire like in the image below.

Properties
DATA

Window Parts: A list of strings (5 strings per component, setting the component options above)

Scripting
The Window tool can by used in macros and from the python console by using the following function:
makeWindow (obj,[name])
creates a window based on the given object
Example:
import Draft, Arch
rect = Draft.makeRectangle(length=2,height=4)
Arch.makeWindow(rect)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Window &oldid=79448"

Arch IfcExplorer
Description

Arch IfcExplorer

The IFC explorer is a simple utility to explore the contents of an IFC file. IFC files are text files, and are therefore Menu location
readable in a text editor, but the information is condensed and hard to browse. This utility presents you the exact Arch -> Utilities -> Ifc
same content, but displayed in an easier way.
Explorer

Workbenches
Arch
Default shortcut
None
See also
Arch IFC

The purpose of this explorer is simply to allow you to check what is really written in an IFC file, in case you want to verify if the contents were correctly
imported or exported to / from an IFC-aware application such as FreeCAD.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_IfcExplorer&oldid=71046"

Arch OBJ
Additionally to the standard FreeCAD OBJ exporter, the Arch Module features an alternative exporter that exports coplanar faces as whole OBJ faces,
instead of triangulating Shape-based objects, like the standard exporter does.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_OBJ&oldid=44422"

Arch RemoveShape
Description

Arch
RemoveShape

This tool attempts at removing the inner cubic shape of an Arch Wall or Arch Structure, and adjusting its
properties, making it totally parametric. This tool will only work if the underlying shape is cubic (exactly 6 faces, all Menu
corners have only right angles).

How to use
1. Select an Arch Wall or Arch Structure
2. Press the
Remove Shape entry in Arch -> Utilities menu

Scripting
This tool can by used in macros and from the python console by using the following function:

location
Arch -> Utilities -> Remove
Shape
Workbenches
Arch
Default shortcut
None
See also
Arch MeshToShape

removeShape (object)
takes an arch object (wall or structure) built on a cubic shape, and removes the inner shape, keeping its length, width and height as parameters.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Remov eShape&oldid=71583"

Arch MeshToShape
Description

Arch
MeshToShape

This tool converts a selected Mesh object into a Shape object. Note that this tool is optimized for objects with flat
faces (no curves). The corresponding tool from the Part Workbench might be more suited for objects that contain Menu
curved surfaces.

How to use
1. Select a mesh object
2. Press the
Mesh to Shape entry in Arch -> Utilities menu

Scripting
This tool can by used in macros and from the python console by using the following function:
meshToShape (object,[mark])
turns a mesh into a shape, joining coplanar facets.
If mark is True (default), non-solid objects will be marked in red
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_MeshToShape&oldid=71573"

location
Arch -> Utilities -> Mesh to
Shape
Workbenches
Arch
Default shortcut
None
See also
Arch RemoveShape

Arch Structure
Description

Arch_Structure

This tool allows you to build structural elements such as columns or beams, by specifying their width, length and Menu location
height, or by basing them on a 2D profile.
Arch -> Structure

Workbenches
Arch
Default shortcut
ST
See also
Arch Wall

The above image shows a column based on a 2D base profile, a column and a beam based on no profile (defined by their height, length and width
dimensions) and a metallic profile based on a 2D contour (face, wire or sketch). Additionally, a certain number of presets available during object creation,
allow you to quickly build a structural element from a predefined standard profile.

How to use
1. Select a 2D shape (draft object, face or sketch) (optional)
2. Press the
Arch Structure button, or press S then T keys
3. Adjust the desired properties

Options
If no object is selected, a default 3-dimension block is created
The height, width and length of a structure can be adjusted after creation
Press ESC or the Cancel button to abort the current command.
Double-clicking on the structure in the tree view after it is created allows you to enter edit mode and access and modify its additions and
subtractions
In edit mode, it is also possible to add axes systems to the structural element. When adding one axes system, the structural element will be
copied once on each axis of the system. When adding two axes systems, the structural element will be copied once on each intersection of the
two systems.

Properties
Length: The length of the structure (only used if not based on a profile)
Width: The width of the structure (only used if not based on a profile)
DATA Height: The height of the structure (or the extrusion length when based on a profile). If no height is given, and the structure is inside a floor
object with its height defined, the structure will automatically take the value of the floor height.
DATA
DATA

Scripting
The Structure tool can by used in macros and from the python console by using the following function:
makeStructure ([obj],[length],[width],[height],[name])
creates a structure element based on the given profile object and the given extrusion height. If no base object is given, you can also specify length
and width for a cubic object.

Example:
import Arch
Arch.makeStructure(0.5,1,3)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Structure&oldid=70917"

Arch Space
Description

Arch_Space

The Space tool allows you to define an empty volume, either by basing it on a solid shape, or by defining its Menu location
boundaries, or a mix of both. If it is based solely on boundaries, the volume is calculated by starting from the Arch Space
bounding box of all the given boundaries, and subtracting the spaces behind each boundary. The space object
Workbenches
always defines a solid volume. The floor area of a space object, calculated by intersecting a horizontal plane at the
center of mass of the space volume, can also be displayed, by setting the display mode of the space object to Arch
"detailed".

Default shortcut
SP
See also
None

In the above image, a space object is created from an existing solid object, then two wall faces are added as boundaries, and the display mode is set to
"detailed" to show the floor area.

How to use
1. Select an existing solid object, or faces on boundary objects
2. Press the
Arch Space button, or press S , P keys

Properties
DATA
DATA

Base: The base object, if any (must be a solid)


Boundaries: A list of optional boundary elements

Scripting
The space tool can be used in python scripts and macros by using the following function:
makeSpace(objects)
Creates a space object from the given objects.
Objects can be one document object, in which case it becomes the base shape of the space object, or a list of selection objects as returned by
FreeCADGui.Selection.getSelectionEx(), or a list of tuples (object, subobjectname).
Returns the newly created space object.
Example:
import FreeCAD, Arch, Part
b = Part.makeBox(2,2,2)
FreeCAD.ActiveDocument.addObject("Part::Feature","Box").Shape=b
sp = makeSpace([FreeCAD.ActiveDocument.Box])
After a space object is created, selected faces can be added to it with the following function:
import FreeCADGui
Arch.addSpaceBoundaries(sp, FreeCADGui.Selection.getSelectionEx())
Boundaries can also be removed with:
Arch.removeSpaceBoundaries(sp, FreeCADGui.Selection.getSelectionEx())

Limitations
Not available below FreeCAD version 0.14
The boundaries properties is currently not editable via GUI
See the forum announcement
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Space&oldid=71262"

Arch Rebar
Description

Arch_Rebar

The Rebar tool allows you to place reinforcing bars inside Arch Structure objects. Rebar objects are based on 2D Menu location
profiles such as sketches or draft objects, that must be drawn on a face of a structure object. You can then adjust Arch -> Rebar
the configuration of the rebars, such as the number and diameter of the bars, or the offset distance between the two
Workbenches
ends of the structural element.

Arch
Default shortcut
RB
See also
Arch Structure

The above image shows a structural object, where two sketches are drawn, defining two bar diagrams. These two sketches are then turned into rebar
objects.

How to use
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Create a structure element


Switch to the Sketcher Workbench
Select one face of the structural element
Press the
New Sketch button to start a new sketch on the selected face
Draw the diagram of your bar
Press the
Leave Sketch button to finish
Switch back to the Arch Workbench
Select the sketch you just drew
Press the
Arch Rebar button, or press R then B keys
Adjust the desired properties (your rebar might not appear immediately, if some of the properties create an impossible situation, such as the bar
diameter being 0, or the offset distances being bigger than the length of the structural element)

Options
The rounding value is expressed in times the diameter. If your bar has a diameter of 5mm, a rounding value of 3 will create rounding at angles with
a radius of 15mm.
Default values for new rebars can be set in the Arch preferences settings.
If a direction vector is not specified, the direction and distance along which the bars will spread is calculated automatically from the host structural
object, by taking the normal direction of the base sketch, and taking its intersection with the structural object. If you specify a direction vector, the
length of that vector will also be taken into account.
The spacing value is calculated from the current amount of bars, and represents the distance between the axes of each bar. You must therefore
subtract the bar diameter to obtain the size of the free space between bars.

Properties
Amount: The amount of bars.
Diameter: The diameter of the bars.
DATA Direction: The direction (and length) along which the bars must spread. If the value is (0,0,0), the direction is calculated automatically from
the host structural object.
DATA Offset Start: The offset distance between the border of the structural object and the first bar.
DATA Offset End: The offset distance between the border of the structural object and the last bar.
DATA Rounding: A rounding value to be applied to the corners of the bars, expressed in times the diameter.
DATA Spacing: The distance between the axes of each bar.
DATA
DATA

Scripting
The Rebar tool can by used in macros and from the python console by using the following function:

makeRebar (structure,sketch,[diameter],[amount],[offset])
Adds a Reinforcing Bar object to the given structural object, using the given sketch as profile.
If no diameter, amount or offset value is given, the default values from the Arch preferences settings are applied.
Returns the new Rebar object.
Example:
import FreeCAD, Arch, Sketcher, PArt
struct = Arch.makeStructure(1,1,3)
sketch = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Sketch')
sketch.Support = (struct,["Face6"])
sketch.addGeometry(Part.Line(App.Vector(-0.4,0.4,0),App.Vector(0.4,0.4,0)))
Arch.makeRebar(structure,sketch)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Rebar&oldid=70957"

Arch IFC
Warning: IFC files handling is still under development, and should not be relied on for production work.

Importing
The Arch Module features an Industry Foundation Classes (IFC) importer. The IFC format is a more and more widely spread format to interchange
data between BIM applications, used in architecture an d engineering.
The importer is still a work in progress, and can use two different IFC processing engines: a built-in python parser, that is slower but doesn't need any
other piece of software, or IfcOpenShell, which is not bundled with FreeCAD and must be installed on your system. If IfcOpenShell is correctly
installed, it will be detected by FreeCAD and used to import IFC files, unless you force the use of the internal python parser from the Arch preferences
settings.
The use of IfcOpenShell is highly recommended, since it is much faster and more powerful than the internal parser. IfcOpenShell supports all Ifc 2.3
entities that carry geometry information (not all of them can be converted to Arch objects, those that can't will be imported as simple Part shapes. The
internal parser only supports the following types:
Walls
Beams, columns, Footings and Slabs
Doors and Windows
Floors
Buildings
Sites

Exporting
Exporting to IFC files is currently experimental and requires a special development version of IfcOpenShell. If that version is installed, IFC export
becomes available. Be aware that this functionality is still in development and might not produce usable files.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_IFC&oldid=71327"

Arch Check
Arch Check

Description

This tool checks the current document or the selected objects for non-solid Part or Arch objects, that might give Menu location
problems, since most operations of the Arch module require solid objects.
Arch -> Utilities -> Check

How to use
1. Press the

Check entry in Arch -> Utilities menu

Scripting
This tool can by used in macros and from the python console by using the following function:
check (objectslist,includehidden=False)
checks if the given objects contain only solids
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Check&oldid=71549"

Workbenches
Arch
Default shortcut
None
See also
Arch CloseHoles

Arch Floor
Description

Arch Floor

The Arch Floor is a special type of FreeCAD group object that has a couple of additional properties particularly suited Menu location
for building floors. Particularly, they have a height property, that its children objects ( walls and structures) can use Arch -> Floor
to set their own height automatically. They are mostly used to organize your model.

How to use
1. Optionally, select one or more objects to be included in your new floor
2. Press the
Arch Floor button or press the F then L keys

Options

Workbenches
Arch
Default shortcut
FL
See also
Arch Building, Arch Site

After creating a floor, you can add more objects to it by drag and dropping them in the Tree View or by using the
Arch Add tool
You can remove objects from a floor by drag and dropping them out of it the Tree View or by using the
Arch Remove tool

Properties
DATA

Height: The height of the floor, to be used by its child objects

Scripting
The Floor tool can by used in macros and from the python console by using the following function:
makeFloor ([objectslist])
creates a floor including the objects from the given list.
Example:
import Arch
Arch.makeFloor()
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Floor&oldid=44117"

Arch Roof
Description

Arch Roof

The Roof tool allows you to create a sloped roof from a selected face. Any face of any shape-based object can be Menu location
used, and the created roof object is parametric, keeping its relationship with the base object. Please note that this Arch -> Roof
tool is still in development, and might fail with very complex shapes.

Workbenches
Arch
Default shortcut
RF
See also
None

How to use
1. Select an existing face
2. Press the
Arch Roof button, or press R then F keys

Properties
DATA
DATA

Angle: The slope angle of the roof


Face: The face index of the base object to be used

Scripting
The Roof tool can by used in macros and from the python console by using the following function:
makeRoof (baseobj,[facenr],[angle],[name])
Makes a roof based on a face from an existing object. You can provide the number of the face to build the roof on (default = 1), the angle in
degrees (default=45) and a name (default = roof).
Example:
import Arch, Draft
rect = Draft.makeRectangle(2,4)
Arch.makeRoof(rect,angle=30)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Roof&oldid=46524"

Arch Axis
Description

Arch Axis

The Axis tool allows you to places an axes system in the current document. The distance and the angle between Menu location
axes is customizable, as well as the numbering style. The axes serve mainly as references to snap objects onto, but Arch -> Axis
can also be used together with structures to create parametric arrays of beams or columns.

Workbenches
Arch
Default shortcut
AX
See also
None

How to use
1. Press the
Arch Axis button, or press A then X keys
2. Move/rotate the axes system to the desired position
3. Enter edit mode by double-clicking the axes system in the tree view to adjust its settings like number of axes, distances and angles between
axes.

Options
Each axis in an axes system has its own distance and angle in relation to the previous axis. This allows to do very complex systems such as
non-orthogonal systems, polar systems or any kind of non-uniform system.
Axes length, size of the bubbles and numbering styles are customizable directly via the axes system's properties

Structural systems
The main use of axes systems is simply to give you reference lines to snap to, but they can also be used to automatically build structural arrays, such
as columns grids and beam layouts:

To obtain that result, one or more axes systems must be added to a structural element, turning it into an array. If one axes system is added, the

element is copied once on each line of the system, like the beams on the image above. If two systems are added, the element is copied once on each
intersection of the two systems, like the columns on the image above. The same axes systems can of course be used in several structural objects.
1.
2.
3.
4.
5.

Create an Arch Structure object


Create one or more axes systems
Select one or more axes systems, then the structure object
Press the
Arch Add button
By entering the edit mode of the structure object (double-clicking it in the tree view), you can add or remove axes systems from it.

Properties
DATA
VIEW
VIEW

Length: The length of the axes


Bubble Size: The size of the axis bubbles
Numeration style: How the axes are numbered: 1,2,3, A,B,C, etc...

Scripting
The Axis tool can by used in macros and from the python console by using the following function:
makeAxis ([number],[interval])
makes an Axis System based on the given number of axes and interval distance
Example:
import Arch
Arch.makeAxis(5,2)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Axis&oldid=46266"

Arch Add
Description

Arch Add

Menu location
Arch -> Add
Add shape-based objects to an Arch component, such as a wall or structure. These objects make then part
of the Arch component, and allow you to modify its shape but keeping its base properties such as width and Workbenches
height
Arch
Add Arch components, such as a walls or structures, to a group-based arch object such as floors.
Default shortcut
Add axis systems to structural objects
Add objects to section planes
None
See also
Arch Remove

The Add tool allows you to do 4 kinds of operations:

In the above image, a box is being added to a wall.

How to use
1. Select the object(s) to be added, then the "host" object (the host object must be the last one you selected)
2. Press the
Add button

Scripting
The Add tool can by used in macros and from the python console by using the following function:
addComponents (objectsList,hostObject)
Adds the given object or the objects from the given list as components to the given host Object. Use this for example to add windows to a wall, or
to add walls to a floor.
Returns nothing.
Example:
import FreeCAD, Arch, Draft, Part
line = Draft.makeWire([FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,2,0)])
wall = Arch.makeWall(line)
box = Part.makeBox(1,1,1)
Arch.addComponents(box,wall)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Add&oldid=70980"

Arch SplitMesh
Description
This tool splits a selected Mesh object into its separate components

How to use
1. Select a mesh object
2. Press the
Split Mesh entry in Arch -> Utilities menu

Scripting
The Split Mesh tool can by used in macros and from the python console by using the following function:
splitMesh (object,[mark])
splits the given mesh object into separated components.
If mark is False, nothing else is done. If True (default), non-manifold components will be painted in red.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_SplitMesh&oldid=71563"

Arch SplitMesh
Menu location
Arch -> Utilities -> Split Mesh
Workbenches
Arch
Default shortcut
None
See also
Arch
SelectNonSolidMeshes

Arch Cell
NOTE: Starting with version 0.13 this command is deleted. Instead, use the command

group .

Description
The Cell tools allows to group several architectural components into a "group". The similar geometries are joined (walls with walls, structure elements
with structure elements, etc)

In the above example, the 3 walls at the left are joined into a cell, displayed at the right
Usage
Select base objects to be grouped
Press the
Arch Cell button
Individual components can then be added or removed to/from the cell with the Arch Add and Arch Remove tools.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Cell&oldid=83859"

Arch SelectNonSolidMeshes
Description
This tool identifies and selects the non-solid (non-manifold) meshes in a selected group of selected Mesh
objects.

How to use
1. Select a mesh object
2. Press the
Select non solid entry in Arch -> Utilities menu

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_SelectNonSolidMeshes&oldid=71532"

Arch
SelectNonSolidMeshes
Menu location
Arch -> Utilities -> Select non
solid
Workbenches
Arch
Default shortcut
None
See also
Arch MeshToShape

Arch Frame
Arch Frame

Description

The Frame tool is used to build all kinds of frame objects based on a profile and a layout. The profile is extruded Menu location
along the edges of the layout, which can be any 2D object such as a sketch, or a draft object. It is especially Arch -> Frame
useful to create railings, or frame walls. Frame objects can then easily be turned into wall or structure objects.

Workbenches
Arch
Default shortcut
FR
See also
None

In the above image, a line has been turned into an array, and a frame object has been made using the array as layout, and a circle as profile.

How to use
1. Create a layout object and a profile object, for example with the Draft Workbench or the Sketcher Workbench
2. Select the layout object, then, with CTRL pressed, select the profile object
3. Press the
Arch Frame button, or press F then R keys

Options
The frame object can be placed at a certain distance from the layout object, by setting its Offset property
The profile will be copied at the base of each edge of the layout object, then extruded along it. You can control how the profile is placed at the
base of each edge with the Align and Rotation properties.

Properties
DATA
DATA
DATA
DATA
DATA

Base: The layout this frame is based on.


Profile: The profile this frame is based on.
Align: Specifies if the profile must be rotated to have its normal axis aligned with each edge.
Offset: An optional distance between the layout object and the frame object.
Rotation: The rotation of the profile around its extrusion axis.

Scripting
The Frame tool can by used in macros and from the python console by using the following function:
makeFrame ( layout,profile )
Creates a frame object from a base sketch (or any other object containing wires) and a profile object (an extrudable 2D object containing faces or
closed wires)
Returns the new frame object, or None if the operation failed.
Example:
import Draft, Arch
layout = Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0))
profile = Draft.makeCircle(.2)
Arch.makeFrame(layout,profile)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Frame&oldid=72409"

Arch tutorial

Introduction
This tutorial aims at giving you the basics to work with the Arch Workbench. I will try to make it simple enough so you don't need any previous
experience with FreeCAD, but having some experience with 3D or BIM applications will be useful. In any case, you should be prepared to look for
yourself for further information about how FreeCAD works on the FreeCAD documentation wiki. The Getting started page is a must read, if you have
no previous experience with FreeCAD. Also check our tutorials section, and on youtube you will also find a lot more of FreeCAD tutorials.
The purpose of the Arch Workbench is to offer a complete BIM workflow inside FreeCAD. As it is still under development, don't expect to find here the
same tools and level of completion as grown-up commercial alternatives such as Revit or ArchiCAD, but on the other hand, FreeCAD being used in a
much bigger scope than these applications, the Arch Workbench greatly benefits from the other disciplines FreeCAD caters to, and offers some
features rarely seen in traditional BIM applications.
Here are, for example, a couple of interesting features of FreeCAD's Arch Workbench that you'll hardly find in other BIM apps:
Architectural objects are always solids. From FreeCAD's strong mechanical background, we learned the importance of always working with solid
objects. This ensures a much more error-free workflow, and very reliable boolean operations. Since cutting through 3D objects with a 2D plane, in
order to extract sections, is also a boolean operation, you can immediately see the importance of this point.
Architectural objects can always have any shape. No restrictions. Walls don't need to be vertical, slabs don't need to look like slab. Any solid
object can always become any architectural object. Very complex things, usually hard to define in other BIM applications, like a floor slab curving
up and becoming a wall (yes Zaha Hadid, it's you we're talking about), present no particular problem at all in FreeCAD.
The whole power of FreeCAD is at your fingertips. You can design architectural objects with any other tool of FreeCAD, such as the PartDesign
Workbench, and when they are ready, convert them to architectural objects. They will still retain their full modeling history, and continue totally
editable. The Arch Workbench also inherits much of the Draft Workbench functionality, such as snapping and working planes.
The Arch Workbench is very mesh-friendly. You can easily design an architectural model in a mesh-based application such as Blender or
SketchUp and import it in FreeCAD. If you took care of the quality of your model and its objects are non-manifold solid shapes, turning them into
architectural objects only requires the press of a button.
At the time I'm writing this, though, the Arch Workbench, as the rest of FreeCAD, suffers some limitations. Most are being worked on, though, and will
disappear in the future.
FreeCAD is no 2D application. It is made for 3D. There is a reasonable set of tools for drawing and editing 2D objects with the Draft Workbench
and Sketcher Workbench, but it is not made for handling very large (and sometimes badly drawn) 2D CAD files. You can usually successfully
import 2D files, but don't expect very high performance if you want to keep working on them in 2D. You have been warned.
No materials support. FreeCAD will have a complete Material system, able to define very complex materials, with all the goodies you can expect
(custom properties, material families, rendering and visual aspect properties, etc), and the Arch Workbench will of course use it when it is ready.
Very preliminary IFC support. You can already import IFC files, quite reliably, provided IfcOpenShell is installed on your system, but exporting
is still not officially supported. This is worked on both by the FreeCAD and IfcOpenShell developers, and in the future we can expect full-powered
IFC support.
Most Arch tools are still in development. That means that automatic "wizard" tools that create complex geometry automatically, such as Arch
Roof or Arch Stairs can only produce certain types of objects, and other tools that have presets, such as Arch Structure or Arch Window only
have a couple of basic presets. This will of course grow over time.
Relations between objects in FreeCAD are still not officially available. These, for example the relation between a window and its host wall, are
currently implemented in the Arch Workbench with temporary (and therefore somewhat limited) methods. Many new possibilities will arise when
this feature will be fully available.
Units are being implemented in FreeCAD, which will allow you to work with any unit you wish (even imperial units, you guys from the USA can be
eternally grateful for this to Jrgen, FreeCAD's godfather and dictator). But at the moment the implementation is not complete, and the Arch
workbench still doesn't support them. You must consider it "unit-less".

FreeCAD version 0.14 required


This tutorial was written using FreeCAD version 0.14. You will need at least this version number in order to follow it. Earlier versions might not contain
all the needed tools,or they could lack options presented here.

Typical workflows

The Arch Workbench is mainly made for two kinds of workflows:


Build your model with a faster, mesh-based application such as Blender or SketchUp, and import them in FreeCAD in order to extract plans and
section views. FreeCAD being made for precision modeling, at a much higher level than what we usually need in architectural modeling, building
your models directly in FreeCAD can be heavy and slow. For this reason, such a workflow has big advantages. I described it in this article on my
blog. If you care to model correctly and precisely (clean, solid, non-manifold meshes), this workflow gives you the same performance and
precision level as the other.
Build your model directly in FreeCAD. That is what I will showcase in this tutorial. We will use mostly three workbenches: Arch, of course, but
also Draft, whose tools are all included in Arch, so there is no need to switch workbenches, and Sketcher. Conveniently, you can do as I usually
so, which is to create a custom toolbar in your Arch workbench, with Tools -> Customize, and add the tools from the sketcher that you use often.
This is my "customized" Arch workbench:

In this tutorial, we will model the house in 3D, based on the 2D drawings we'll download from the net, and extract from it 2D documents, such as plans,
elevations and sections.

Preparation
Instead of creating a project from scratch, Let's take an example project to model, it will save us time. I chose this wonderful house by the famous
architect Vilanova Artigas (see a series of pictures by Pedro Kok), because it is close to where I live, it is simple, it's a wonderful example of the
amazing modernist architecture of So Paulo (it is even for sale if you have "a few" Reals to spend), and dwg drawings are easily available.
We will use the 2D DWG drawings obtained from the link above (you need to register to download, but it's free) as a base to build our model. So the first
thing you'll want to do is to download the file, unzip it, and open the DWG file inside with a dwg application such as DraftSight. Alternatively, you can
convert it to DXF with a free autility such as the Teigha File Converter. If you have the Teigha converter installed (and its path set in the Arch
preferences settings), FreeCAD is also able to import DWG files directly. But since these files can sometimes being of bad quality and very heavy,
it's usually better open it first with a 2D CAD application and do some cleaning.
Here, I removed all the detail drawings, all the titleblocks and page layouts, did a "clean" ("purge" in AutoCAD slang) to remove all unused entities,
reorganized the sections at a logical location in relation to the plan view, and moved everything to the (0,0) point. After that, our file can be opened quite
efficiently in FreeCAD. Check the different options available in Edit -> Preferences -> Draft -> Import/Export, they can affect how (and how quickly)
DXF/DWG files are imported.
This is how the file looks after being opened in FreeCAD. I also changed the thickness of the walls (the contents of the "muros" group), and flipped a
couple of doors that were imported with wrong X scale, with the Draft Scale tool:

The DXF importer (which also takes care of DWG files, since when importing DWG files, they are simpl converted to DXF first), groups the imported
objects by layer. There is no layer in FreeCAD, but there are groups. Groups offer a similar way to organize the objects of your files, but don't have
specific properties, like AutoCAD layers, that apply to their contents. But they can be placed inside other groups, which is very handy. The first thing we
might want to do here, is to create a new group (in the tree view, right-click on the document icon, add a group, right click on it to rename it as "base
2D plans", and drag and drop all the other objects into it.

Building the walls


Like most Arch objects, walls can be built upon a big variety of other objects: lines, wires (polylines), sketches, faces or solid (or even on nothing at
all, in which case they are defined by height, width and length). The resulting geometry of the wall depends on that base geometry, and the properties
you fill in, such as width and height. As you might guess, a wall based on a line will use that line as its alignment line, while a wall based on a face will
use that face as its base footprint, and a wall based on a solid will simply adopt the shape of that solid. This allows about any shape imaginable to
become a wall.
There are different possible strategies to build walls in FreeCAD. One might want to build a complete "floor plan" with the sketcher, and build one, big,
wall object from it. This technique works, but you can only give one thickness for all the walls of the project. Or, you can build each piece of wall from
separate line segments. Or, this is what we will do here, a mix of both: We will build a couple of wires on top of the imported plan, one for each type of
wall:

As you see, I've drawn in red the lines that will become concrete walls (a pictures search of the house can help you to see the different wall types), the
green ones are the exterior brick walls, and the blue ones will become the inner walls. I passed the lines through the doors, because doors will be
inserted in the walls later, and will create their openings automatically. Walls can also be aligned left, right or centrally on their baseline, so it doesn't
matter which side you draw the baseline. I also took care on avoiding intersections as much as I could, because our model will be cleaner that way. But
we'll take care of intersections later.
When this is done, place all those lines in a new group if you want, select each line one by one, and press the Arch Wall tool to build a wall from each
of them. You can also select several lines at once. After doing that, and correcting widths (exterior walls are 25cm wide, inner walls are 15cm wide) and
some alignments, we have our walls ready:

We could also have built our walls from scratch. If you press the Arch Wall button with no object selected, you will be able to click two points on the
screen to draw a wall. But under the hood, the wall tool will actually draw a line and build a wall on it. In this case, I found it more didactic to show you
how things work.
Did you notice that I took great care not to cross the walls? this will save us some headache later, for example if we export our work to other
applications, that might not like it. I have only one intersection, where I was too lazy to draw two small line segments, and drew one big wire crossing
another. This must be fixed. Fortunately, all Arch objects have a great feature: you can add one to another. Doing that will unite their geometries, but
they are still editable independently after. To add one of our crossing walls to the other, just select one, CTRL + select the other, and press the Arch
Add tool:

On the left is are the two intersecting walls, on the right the result after adding one to the other.
An important note about parametric objects
Something is important to consider already. As you can see, in FreeCAD, everything is parametric: Our new "united" wall is made from two walls, each
based on a baseline. When you expand them in the tree view, you can see all that chain of dependencies. As you can imagine, this little game can
quickly become very complex. Furthermore, if you already know how to work with the sketcher, you might have wanted to draw the baselines with
constrained sketches. This whole complexity has a cost: it raises exponentially the number of calculations that FreeCAD has to perform to keep your
model geometry up to date. So, think about it, don't add unnecessary complexity when you don't need it. Keep a good balance between simple and
complex objects, and keep these for the cases where you really need them.
For example, I could have drawn all my baselines above without caring about what crosses what, and fix things with the Arch Add tool later. But I would
have raised much the complexity of my model, for no gain at all. Better make them correct right from the start, and keeping them as very simple pieces
of geometry.
Now that our walls are okay, we need to raise their height, until they intersect the roof. Then, since the wall object still cannot be cut automatically by
roofs (this will happen some day, though), we will build a "dummy" object, that follows the shape of the roof, to be subtracted from our walls.
First, by looking at our 2D drawings, we can see that the highest point of the roof is 5.6m above the ground. So let's give all our walls a height of 6m, so
we make sure they will be cut by our dummy roof volume. Why 6m and not 5.6m? You may ask. Well, if you already worked with boolean operations
(additions, subtractions, intersections), you must already know that these operations usually don't like much "face-on-face" situations. They prefer
clearly, frankly intersecting objects. So by doing this, we keep on the safe side.
To raise the height of our walls, simply select all of them (don't forget the one we added to the other) in the tree view, and change the value of their
"height" property.
Before making our roof and cutting the walls, let's make the remaining objects that will need to be cut: The walls of the above studio, and the columns.
The walls of the studio are made the same way as we did, on the superior floor plan, but they will be raised up to level 2.6m. So we will give them the
needed height so their top is at 6m too, that is, 3.4m. Once this is done, let's move our walls up by 2.6m: Select them both, put yourself in frontal view
(View -> Standard Views -> Front), press the Draft Move button, select a first point, then enter 0, 2.6, 0 as coordinates, and press enter. Your objects
now have jumped 2.6m high:

About coordinates
The Draft objects, and most Arch objects too, obey to a Draft system called working planes. This system defines a 2D plane where next operations
will take place. If you don't specify any, that working plane adapts itself to the current view. This is why we switched to frontal view, and you see that we
indicated a movement in X of 0 and in Y of 2.6. We could also have forced the working plane to stay on the ground, by using the Draft SelectPlane tool.
Then, we would have entered a movement of X of 0, Y of 0 and Z of 2.6.
Now let's move our walls horizontally, to their correct location. Since we have points to snap to, this is easier: Select both walls, press the Draft Move
tool, and move them from one point to the other:

Finally, I changed the color of some walls to a brick-like color (so it's easier to differentiate), and made a small correction: Some walls don't go up to the
roof, but stop at a height of 2.60m. I corrected the height of those walls.

Raising the structure


Now, since we'll have to cut our walls with a subtraction volume, we might as well see if there aren't other objects that will need to be cut that way. There
are, some of the columns. This is a good opportunity to introduce a second arch object: the Arch Structure. Structure objects behave more or less like
walls, but they aren't made to follow a baseline. Rather, their prefer to work from a profile, that gets extruded (along a profile line or not). Any flat object
can be a profile for a structure, with only one requirement: they must form a closed shape.
For our columns, we will use another strategy than with the walls. Instead of "drawing" on top of the 2D plans, we will directly use objects from it: the
circles that represent the columns in the plan view. In theory, we could just select one of them, and press the Arch Structure button. However, if we do
that, we produce an "empty" structural object. This is because you can never be too sure at how well objects were drawn in the DWG file, and often they
are not closed shapes. So, before turning them into actual columns, let's turn them into faces, by using the Draft Upgrade tool twice on them. The first
time to convert them into closed wires (polylines), the second time to convert those wires into faces. That second step is not mandatory, but, if you have
a face, you are 100% sure that it is closed (otherwise a face cannot be made).
After we have converted all our columns to faces, we can use the Arch Structure tool on them, and adjust the height (some have 6m, other only 2.25m
height):

On the image above, you can see two columns that are still as they were in the DWG file, two that were upgraded to faces, and two that were turned into
structural objects, and their height set to 6m and 2.25m.
Note that those different Arch objects (walls, structures, and all the others we'll discover) all share a lot of things between them (for example all can be
added one to another, like we already saw with walls, and any of them can be converted to another). So it's more a matter of taste, we could have made
our columns with the wall tool too, and converted them if needed. In fact, some of our walls are concrete walls, we might want to convert them to
structures later.

Subtractions
Now it is time to build our subtraction volume. The easiest way will be to draw its profile on top of the section view. Then, we will rotate it and place it at
its correct position. See why I placed the sections and elevations like that before beginning? It will be very handy for drawing stuff there, then moving it to
its correct position on the model.
Let's draw a volume, bigger than the roof, that will be subtracted from our walls. To do that, I drew two lines on top of the base of the roof, then extended
them a bit further with the Draft Trimex tool. Then, I drew a wire, snapping on these lines, and going well above our 6 meters. I also drew a blue line on
the ground level (0.00), that will be or rotation axis.

Now is the tricky part: We will use the Draft Rotate tool to rotate our profile 90 degrees up, in the right position to be extruded. To do that, we must first
change the working plane to the YZ plane. Once this is done, the rotation will happen in that plane. But if we do like we did a bit earlier, and set our
view to side view, it will be hard to see and select our profile, and to know where is the basepoint around which it must rotate, right? Then we must set
the working plane manually: Press the Draft SelectPlane button (it is in the "tasks" tab of the tree view), and set it to YZ (which is the "side" plane).
Once you set the working plane manually, like that, it won't change depending on your view. You can now rotate your view until you have a good view of
all the things you must select. To switch the working plane back to "automatic" mode later, press the Draft SelectPlane button again and set it to
"None".
Now the rotation will be easy to do: Select the profile, press the Draft Rotate button, click on a point of the blue line, enter 0 as start angle, and 90 as
rotation:

Now all we need to do it to move the profile a bit closer to the model (set the working plane to XY if needed), and extrude it. This can be done either with
the Part Extrude tool, or Draft Trimex, which also has the special hidden power to extrude faces. Make sure your extrusion is larger than all the walls
it will be subtracted from, to avoid face-on-face situations:

Now, here comes into action the contrary of the Arch Add tool: Arch Remove. As you might have guessed, it also makes an object a child of another,
but its shape is subtracted from the host object, instead of being united. So now things are simple: Select the volume to subtract (I renamed it as "Roof
volume to subtract" in the tree view so it is easy to spot), CTRL + select a wall, and press the Arch Remove button. You'll see that, after the
subtraction happened, the volume to subtract disappeared from both the 3D view and the tree view. That is because it has been marked as child of the
wall, and "swallowed" by that wall. Select the wall, expand it in the tree view, there is our volume.
Now, select the volume in the tree vieew, CTRL + select the next wall, press Arch Remove. Repeat for the next walls until you have everything properly
cut:

Remember that for both Arch Add and Arch Remove, the order you select the objects is important. The host is always the last one, like in "Remove X
from Y" or "Add X to Y"
A note about additions and subtractions
Arch objects that support such additions and subtractions (all of them except the "visual" helper objects such as the axes) keep track of such objects
by having two properties, respectively "Additions" and "Subtractions", that contains a list of links to other objects to be subtracted or added. A same
object can be in thr lists of several other objects, as it is the case of our subtraction volume here. Each of the fathers will want to swallow it in the tree
view, though, so it will usually "live" in the last one. But you can always edit those lists for any object, by double-clicking it in the tree view, which in
FreeCAD enters edit mode. Pressing the escape key exits edit mode.

Making the roofs


Now, all we have to do to complete the structure, is to make the roof and the smaller inner slabs. Again, the easiest way is to draw their profiles on top
of the section, with the Draft Wire tool. Here I drew 3 profiles on top of each other (I moved them apart in the image below so you see better). The green
one will be used for the lateral borders of the roof slab, then the blue one for the side parts, and the red ones for the central part, that sits above the
bathroom block:

Then, we must repeat the rotation operation above, to rotate the objects in a vertical position, then move them at their correct places, and copy some of
them that will need to be extruded twice, with the Draft Move tool, with the ALT key pressed, which creates copies instead of moving the actual object. I
also added two more profiles for the side walls of the bathroom opening.

When everything is in place, it's just a matter of using the Draft Trimex tool to extrude, then convert them to Arch Structure objects.

After that, we can see some problems arising: two of the columns on the right are too short (they should go up to the roof), and there is a gap between
the slab and the walls of the studio on the far right (the 2.60 level symbol on the section view was obviously wrong). Thanks to the parametric objects, all
this is very easy to solve: For the columns, just change their height to 6m, fish your roof subtraction volume from the tree view, and subtract it to the
columns. For the walls, it's even easier: move them a bit down. Since the subtraction volume continues at the same place, the wall geometry will adapt
automatically.
Now one last thing must be fixed, there is a small slab in the bathroom, that intersects some walls. Let's fix that by creating a new subtraction volume,
and subtract it from those walls. Another feature of the Draft Trimex tool, that we use to extrude stuff, is that it can also extrude one single face of an
existing object. This creates a new, separate object, so there is no risk to "harm" the other object. So we can select the base face of the small slab
(look at it from beneath the model, you'll see it), then press the Draft Trimex button, and extrude it up to well above the roofs. Then, subtract it from the
two inner bathroom walls with the Arch Remove tool:

Floors, stairs and chimney


Now, our structure is complete, we just have a couple of smaller objects to do.

The chimney
Let's start with the chimney. Now you already know how it works, right? Draw a couple of closed wires, move them up at their correct height with the
Draft Move tool, extrude them with the Draft Trimex tool, turn the bigger one into a structure, and subtract the smaller ones. Notice how the chimney
tube wasn't drawn on the plan view, but I found its position by dragging blue lines from the section views.

The floors
The floors are not well represented in the base drawings. When looking at the sections, you cannot know where and how thick the floor slabs are. So I
will suppose that the walls are sitting on top of foundation blocks, at level 0.00, and that there are floor slabs, also sitting on those blocks, 15cm thick.
So the floor slabs don't run under the walls, but around them. We could do that by creating a big rectangular slab then subtracting the walls, but
remember, subtraction operations cost us. Better do it in smaller pieces, it will be "cheaper" in terms of calculation, and also if we do it intelligently,
room by room, these will also be useful to calculate floor areas later:

Once the wires are drawn, just turn them into structures, and give them a height of 0.15:

The stairs
Now the stairs. Met the next of the Arch tools, the Arch Stairs. This tool is still in a very early stage of development, at the time I'm writing, so don't
expect too much of it. But it is already pretty useful to make simple, straight stairs. One concept is important to know, the stairs tool is thought to build
stairs from a flat floor up to a wall. In other words, when viewed from the top, the stairs object occupies exactly the space that it occupies on the plan
view, so the last riser is not drawn (but it is of course taken into account when calculating heights).
In this case, I preferred to build the stairs on the section view, because we'll need many measurements that are easier to get from that view. Here, I drew
a couple of red guidelines, then two blue lines that will be the base of our two pieces of stairs, and two green closed wires, that will form the missing
parts. Now select the first blue line, press the Arch Stairs tool, set the number of steps to 5, the height to 0.875,the width to 1.30, the structure type to
"massive" and the structure thickness to 0.12. Repeat for the other piece.
Then, extrude both green wires by 1.30, and rotate and move them to the right position:

On the elevation view, draw (then rotate) the border:

Then move everything into place:

Don't forget also to cut the column that crosses the stairs, because in BIM it's always bad to have intersecting objects. We are building like in the real
world, remember, where solid objects cannot intersect. Here, I didn't want to subtract the column directly from the stairs (otherwise the column object
would be swallowed by the stairs object in the tree view, and I didn't like that), so I took the face on which the column was built, and extruded it again.
This new extrusion was then subtracted from the stairs.
Right! All the hard work is now done, let's go on with the very hard work!

Doors and windows


Arch Windows are pretty complex objects. They are used to make all kinds of "inserted" objects, such as windows or doors. Yes, in FreeCAD, doors
are just a special kind of window. In real life too, if you think of it, no? The Arch Window tool can still be a bit hard to use today, but consider this as a
tradeoff, as it was built for maximum power. Almost any kind of window your imagination can produce can be done with it. But as the tool will gain more
presets, this situation will certainly become better in the future.
The Arch Window object works like this: It is based on a 2D layout (any 2D object, but preferably a sketch, that contains closed wires (polylines).
These wires define the different parts of the window: outer frames, inner frames, glass panels, solid panels, etc. The window objects then has a property
that stores what to do with each of these wires: extrude it, place it at a certain offset, etc. Finally, a window can be inserted into a host object such as a
wall or structure, and it will automatically create a hole in it. That hole will be calculated by extruding the biggest wire found in the 2D layout.
There are two ways to create such objects in FreeCAD: By using a preset, or drawing the window layout from scratch. We'll look at both methods here.
But remember that the preset method does nothing else than creating the layout object and defining the necessary extrusions for you.

Using presets
When pressing the Arch Window tool with no object selected, you are invited either to pick a 2D layout, or to use one of the presets. Let's use the
"Simple Door" preset to place the main entrance door of our model. Give it a width of 1m, a height of 2.45m, a W1 size of 0.15m, and leave the other
parameters to 0.05m. Then click the lower left corner of the wall, and your new door is created:

You will notice that your new door won't appear in the tree view. That is because, by snapping to a wall, we indicated that wall as its host object.
Consequently, it has been "swallowed" by the wall. But a right click on it -> Go to selection will find it in the tree.
In this case, as our window is not inserted in any wall (the opening was there already), we might as well detach our window from its host wall. This is
done by double-clicking the host wall in the tree view to enter its edit mode. There, you will see the window in its "Subtractions" group. Simply select the
window there, press the "remove element" button, then "OK". Our window has now been removed from its host wall, and lies at the bottom of the tree
view.
We have a second door, exactly the same as this one, a bit on the left. Instead of creating a new door from scratch, we have two ways to make a copy
of the previous one: By using the Draft Move tool, with the ALT key pressed, which, as you already know, copies an object instead of moving it. Or,
even better, we can use the Draft Clone tool. The clone tool produces a "clone" of a selected object, that you can move around, but that retains the
shape of the original object. If the original object changes, the clone changes too.
So all we need to do now is select the door, press the Draft Clone tool, then move the clone to its correct position with the Draft Move tool.

Organizing your model

Now would be a good time to do a bit of housecleaning. Since we already have two windows, it is a good moment to do some cleaning in the tree view:
Create a new group, rename it to "windows", and drop the 2 windows in it. I also recommend you to separate other elements that way, such as the walls
and structures. Since you can also create groups inside groups, you can organize further, for example by placing all elements that form the roof into a
separate group, so it is easy to turn on and off (turning a group visible or invisible does the same with all objects inside).
The Arch Workbench has some additional tools to organize your model: the Arch Site, Arch Building and Arch Floor. Those 3 objects are based on
the standard FreeCAD group, so they behave exactly like groups, but they have a couple of additional properties. For example, floors have the ability to
set and manage the height of the contained walls and structure, and when they are moved, all their contents are moved too.
But here, since we have only one building with only one (and a half) floor, there is no real need to use such objects, so let's stick with simple groups.
Now, let's get back to work. Turn off the roof group, so we can see better inside, and switch the Display Mode of the floor objects to Wireframe (or use
t he Draft ToggleDisplayMode tool) so we can still snap to them, but we can see the plan view underneath. But you can also turn off the floors
completely, then place your doors at level 0, then raise them of 15cm with the Draft Move tool.
Let's place the interior doors. Use the "Simple Door" preset again, make doors of 1.00m and 0.70m wide x 2.10m high, with W1 size of 0.1m. Make sure
you snap to the correct wall when you place them, so they automatically create a hole in that wall. If it is hard to place them correctly, you can place
them at an easier location (at the corner of the wall, for example, then move them. The "hole" will move together.
If by mistake you hosted a window in the wrong wall, it is easy to fix: Remove the window from the "Subtraction" group of the host wall in edit mode, as
we saw above, then add it to the "Subtraction" group of the correct wall, by the same method, or, simply, using the Arch Remove tool.
A little work later, all our doors are there:

After a closer look at the elevation view, I now detected another error: The top of the brick walls is not as 2.60m, but 17.5cm lower, that is, 2.425m.
Fortunately, windows based on presets have a facility: You can alter their general dimensions (width and height) from their properties. So let's change
their height to 2.425 - 0.15, that is, 2.275. The second window, as it is a clone of the first one, will adapt too. This is basically where the true magic of
parametric design appears.
Now we can look at the really interesting stuff: How to design your own custom windows.

Creating custom windows


As I explained above, Arch Window objects are created from 2D layouts, made of closed elements (wires (polylines), circles, rectangles, anything).
Since Draft objects cannot hold more than one of these elements, the preferred tool to draw window layouts is the Sketcher. Unfortunately, with the
sketcher, it is not possible to snap to external objects like with the Draft workbench, which would be useful here, since our elevations are drawn already.
Fortunately, a tool exists to convert Draft objects to a sketch: The Draft To Sketch tool.
So, let's start by building our first window layout. I drew it on the elevation, using several rectangles: One for the outer line, and 4 for the inner lines. I
stopped before the door, because, remember, our door already has a frame there:

Then, select all the rectangles, and press the Draft To Sketch button (and delete the rectangles, because this tool doesn't delete the original objects, in
case something goes wrong). Then, with the new sketch selected, press the Arch Window tool:

The tool will detect that the layout has one outer wire and several inner wires, and automatically proposes you a default configuration: One frame, made
by subtracting the inner wires from the outer one, extruded by 1m. Let's change that, by entering the window's edit mode, by double-clicking on it in the
tree view:
You will see a "Default" component, that has been created automatically by the Window tool, that uses the 5 wires (always subtracting the other ones
from the biggest one), and has an extrusion value of 1. Let's change its extrusion value to 0.1, to match what we used in the doors.
Then, let's add 4 new glass panels, each using a single wire, and give them an extrusion of 0.01, and an offset of 0.05, so they are placed at the middle
of the frame. This will be how your window looks like when you are finished:

I suppose now you must have understood the power of this system: Any combination of frames and panels of any shape is possible. If you can draw it in
2D, it can exist as a full valid 3D object.
Now, let's draw the other pieces, then we'll move everything into place together. But first. we'll need to do some corrections to the base 2D drawing,
because some lines are clearly missing, where the windows meet the stairs. We can fix that by offsetting the stairs line by 2.5cm with the Draft Offset
tool (with ALT pressed of course, to copy our lines instead of moving them). Now we can draw our layout, with wires, then convert them to a sketch,
then making a window of it.
After doing that a couple of times (I made it in 4 separate pieces, but it's up to you to decide), we have our facade complete:

Now, as before, it's just a matter of rotating the pieces, and moving them to their correct position:

Last missing piece, there is a segment of wall that didn't appear on the plan view, that we need to add. We have several options for that, I chose to draw
a line on the ground plane, then move it up to the correct height, then create a wall from it. Then, we also need to fish up our roof subtraction volume (it
must have stayed in the last column), then subtract it. Now this side of the building is ready:

Ready? Not quite. Look at the image above, we did our doors with a 5cm frame, remember (it was the default from the preset). But the other windows
have 2.5cm frames. This needs to be fixed.

Editing windows
We already saw how to build and update window components, via the window's edit mode, but we can also edit the underlying sketch. Preset windows
are not different than custom windows, the Arch Window tool only created the underlying sketch fo you. Select our door object (the original, not the
copy, remember, we made a clone), and expand it in the tree view. There is our sketch. Double-click it to enter edit mode.
the Sketcher Workbench is an extremely powerful tool. It doesn't have some of the Draft conveniences, such as snapping or working planes, but it has
many other advantages. In FreeCAD you will frequently use one or another depending on the need. The most important feature of the sketcher is
constraints. Constraints allow you to automatically fix the position of some elements relative to others. For example, you can force a segment to always
be vertical, or to always be at a certain distance to another.
When we edit our door sketch, we can see that it is made on a fully constrained sketch:

Now all we need to do is edit the 5cm distances between the outer line and the inner line, by double-clicking them, and changing their value to 2.5cm
(Remember, the units are still not fully functional at the time I'm writing this). After clicking the "OK" button, our door (and its clone) have been updated.

Working without 2D support


Until now our work has been relatively easy, because we had the underlying 2D drawings to base our work upon. But now, we must do the opposite
facade and the glass atrium, and things are getting more complicated: The opposite facade drawing has a lot of wrong things, doesn't represent the
atrium at all, and we have simply no drawing for the inner walls of the atrium. So we will need to invent a couple of things ourselves. Be sure to have a
look at reference pictures to figure out how things are made. Or do it as you wish!
One thing we can already do: duplicate the complicated stairs window with the Draft Move tool, because it is equal on both sides:

Note that here, I preferred to duplicate with the Draft Move tool instead of using a clone, because the clone currently doesn't support different colors
inside objects. The difference is that the clone is a copy of the final shape of the original object, while if you copy an object, you create a new object and
give it all the same properties as the original one (therefore, also its base sketch and its window components definition, which are both stored as
properties).
Now we must attack the parts that are not drawn anywhere. Let's start with the glass wall between the sitting room and the atrium. It'll be easier to draw
it on the elevation view, because we'll get the correct height of the roof. Once you are in plan view, you can rotate the view from the menu View ->
Standard Views -> Rotate left or right, until you get a comfortable view to work, like this:

Note how on the image above, I made a line from the model to the left section, to get the exact width of the window. Then, I reproduced that width on the
elevation view and divided it into 4 pieces. Then I built one main window piece, plus 4 additional windows for the sliding doors. The sketcher sometimes
has difficulties with overlapping wires, that's why I preferred to keep them separated like this:

After the necessary rotations, everything clicks perfectly into place:

We still need some corner piece there. A little useful trick with the Draft SelectPlane tool, if you have a face selected when you press the button, the
working plane matches this face (at least its position, and if the face is rectangular, it also tries to match its axes). This is useful to draw 2D objects
directly on the model, such as here, we can draw a rectangle to be extruded directly at its correct position:

Then let's do the two remaining pieces. One is easy, it is a copy of what's on the other side, so we can simply use the 2D drawing:

The other one is a bit tricky, by looking at the pictures, we see that it has many vertical divisions, like the stairs windows. By chance (or very good
design from Vilanova Artigas), the width of our window, of 4.50m, is exactly the same as the stairs window, so we can use the exact same division: 15
pieces of 30cm. Here I used the Draft Array tool to copy over the two lines 15 times,and drew rectangles on top of them:

Once this is done, we can create our window with the same method we already know. Another small useful trick, in case you haven't found it yourself
already: When editing a window, if you change the name of a component, it actually creates a duplicate of it. So to create the 15 inner glass panels,
instead of clicking 15 times the "add" button and fill 15 times the data, you can just keep editing one, and change its name and wire, it will create a copy
each time.
After the window is rotated and moved into place, the atrium is complete:

Edits and fixes


Now when we look at our back elevation, and compare it with the plan, we see that there are some differences that need to be fixed. Namely, the
bedroom windows are smaller than I first thought, and we'll need to add some more walls. In order to do that properly, some floors need to be cut:

We have of course several ways to do that, making a subtraction volume would be an easy way, but it would add unnecessary complexity to the model.
Better to edit the base wire of each floors. This is where the Draft Edit mode comes into action. By expanding these floors in the tree view, then making
their base wire visible, we can then double-click them to enter edit mode. There, we can move their points, or add or remove points. With this,editing
our floor plates becomes easy.

After some more sweat (the person who made those drawings obviously became pretty lazy when did this last elevation, much is drawn wrong), we
finally have our complete house:

Note the chimney tube, which is made from a circle I used to make a hole in the chimney block, that I extruded, then converted into a tube with the Part
Offset tool.
Problems in objects
Sometimes an object you made can have problems. For example, the object it was based onto has been deleted, and the object can therefore not
recalculate its shape. These are usually shown to you by a little red sign on their icon, and/or a warning in the output window. There is no generic recipe
to fix these problems, because they can have many origins. But, the easiest way to solve them is often to delete them, and, if you didn't delete their
base objects, recreate them.

Output
Now, after all the hard work we passed through to build this model, comes the reward: What can we do with it? Basically, this is the big advantage of
working with BIM, all our traditional architectural needs, such as 2d drawings (plans, sections, etc), renderings, and calculations (bills of quantities, etc)
can all be extracted from the model. And, even better, regenerated every time the model changes. I'll show you here how to obtain these different
documents.

Preparations
Before starting to export stuff, one consideration is interesting to do: As you saw, our model is becoming increasingly complex, with a lot of relationships
between objects. This can make subsequent calculation operations, such as cutting through the model, heavy. One quick way to magically "simplify"
drastically your model, is to remove all of this complexity, by exporting it to the STEP format. That format will preserve all your geometry, but will discard
all the relationships and parametric constructions, keeping only the final shape. When reimporting that STEP file into FreeCAD, you will get a model that
has no relationship, and a much smaller file size. Think of it as an "output" file, that you can regenerate anytime from your "master" file:

Exporting to IFC and other applications

One of the very fundamental things you need when working with BIM is to be able to import and export IFC files. This is still a work in progress in
FreeCAD. IFC format is already supported, and importing IFC files into FreeCAD is already pretty reliable. Exporting is still experimental, though, and
has currently many limitations. However, things are bettering and we should get proper IFC export very soon.
IFC export requires very little setup, once the necessary software libraries are installed. You only need to recreate the building structure, which is
needed in all IFC files, by adding an Arch Building to your file, then an Arch Floor, then moving all the groups of objects that compose your model in it.
Make sure you leave your construction geometry (all the 2D stuff we've been drawing) out of it to avoid making your IFC file unnecessarily heavy.
Another thing to set, is to check the "Role" property of structural elements. Since IFC has no "generic" structural element, like FreeCAD, we need to
assign them roles (column, beam, etc...) so the exporter knows what element to create in the IFC file.
In this case, we need our whole architectural system, so the IFC exporter can know if an object must be exported as a wall or a column, so we are using
our "master" model, not our "output" model.
Once this is done, simply select your building object, and choose the "Industry Foundation Classes" format. Exporting to non-BIM applications, such as
Sketchup is also easy, you have several export formats at your disposal, such as Collada, STEP, IGES ou OBJ.

Rendering
FreeCAD also features a rendering module, the Raytracing Workbench. That workbench currently supports two render engines, PovRay and
LuxRender. Since FreeCAD is not designed for image rendering, the features that the Raytracing workbench offer to you are somewhat limited. The
best course of action when you want to do proper rendering, is to export your model to a mesh-based format such as OBJ or STL, and open it in an
application more suited to rendering, such as blender. The image below has been rendered with blender's cycles engine:

But, for a quick rendering, the Raytracing workbench can already do a good job, with the advantage of being very easy to setup, thanks to its templates
system. This is a rendering of our model fully made within FreeCAD, with the Luxrender engine, using the "indoor" template.

The Raytracing workbench still offers you very limited control over materials, but lighting and environments are defined in templates, so they can be fully
customized.

2D drawings
Certainly the most important use of BIM is to produce 2D drawings automatically. This is done in FreeCAD with the Arch SectionPlane tool. This tool
allows you to place a section plane object in the 3D view, that you can orient to produce plans, sections and elevations. Section planes must know what
objects they must consider, so once you have created one, you must add objects to it with the Arch Add tool. You can add individual objects, or, more
conveniently, a group, a floor or a whole building. This allows you to easily change the scope of a certain section plane later, by adding or removing
objects to/from that group. Any change to these objects gets reflected in the views produced by the section plane.
The section plane automatically produces cut views of the objects it intersects. In other words, to produce views instead of sections, you just need to
place the section plane outside of your objects.

The section planes can produce two different outputs: shape objects, that live in the same document as your 3D model, or drawing views, that are
made to use on a drawing sheet produced by the Drawing workbench. Each of these behave differently, and has its own advantages.
Shape views
This output is produced by using the Draft Shape2DView tool with a section plane selected. You produce a 2D view of the model directly in the 3D
space, like on the image above. The main advantage here is that you can work on them using the Draft tools (or any other standard tool of FreeCAD), so
you can add texts, dimensions, symbols, etc:

On the image above, two Shape2D views have been produced for each section, one showing everything, the other showing only the cut lines. This
allows us to give it a different line weight, and turn hatching on. Then, dimensions, texts and symbols have been added, and a couple of DXF blocks have
been imported to represent the furniture. These views are then easy to export to DXF or DWG, and open in your favorite 2D CAD application, such as
LibreCAD or DraftSight, where you can work further on them:

Note that some features are still not supported by the DXF/DWG exporter so the result in your 2D application might differ a bit. For example, in the
image above, I had to redo the hatching, and correct the position of some dimension texts. If you place your objects in different groups in FreeCAD,
these become layers in your 2D CAD application.
Drawing views
The other kind of output that can be produced from section planes is a Drawing view. These are produced by using the Draft Drawing tool with a
section plane selected. This method has one big limitation compared to the previous one: you have limited possibilities to edit the results, and at the
moment, things like dimensioning or hatching are still not natively supported.
On the other hand, the final output being easier to manipulate, and the graphical possibilities of the SVG format being huge, in the future, undoubtedly
this will be the preferred method. At the moment, though, you'll get better results using the previous one.

On the image above, the geometry is the direct output of the section plane, but some other Draft objects have been added, such as dimensions and

such operations will be done directly on the Drawing page, leaving your model totally clean.

Quantities extraction
This is another very important task to be performed on BIM models. In FreeCAD, things look good right from the start, since the OpenCasCade kernel of
FreeCAD already takes care of calculating lengths, areas and volumes for all the shapes it produces. Since all Arch objects are solids, you are always
guaranteed to be able to obtain a volume from them.
Using spreadsheets
There is a brand-new workbench in FreeCAD, the Spreadsheet Workbench, that is the perfect tool for collecting such information about our model. It
can count objects of a certain name or a certain type, or display a specific properties of those objects. The spreadsheet workbench features two objects:
The spreadsheet object is a simple spreadsheet container, that you can edit, and place values inside the cells, but has no automation. The cell
controller, on the other hand, is an object that you must insert in a spreadsheet, that controls a series of cells of its host spreadsheet, filling them
according to what you specify. This, provided that you organized your model well, allows you to easily retrieve individual values:

Note that the spreadsheet workbench is still very new, and like everything very new, still contains many bugs and limitations. But for simple summaries
like this, it already works well. The resulting spreadsheet can then be exported to a CSV file, which can be imported in any spreadsheet application.
The survey mode
Another way to survey your model and extract values, is to use the Arch Survey mode. In this mode, you can click on points, edges, faces or doubleclick to select whole objects, and you get altitude, length, area or volume values, shown on the model, printed on the FreeCAD output window, and
copied to the clipboard, so you can easily pick and paste values in another opened application

Conclusion
I hope this gives you a good overview of the available tools, be sure to refer to the Arch Workbench and Draft Workbench documentation for more
(there are more tools that I didn't mention here), and, more generally, to the rest of the FreeCAD documentation. Pay a visit to the forum too, many
problems can usually be solved there in no time, and follow my blog for news about he Arch workbench development.
The file created during this tutorial can be found here
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_tutorial&oldid=75132"

Arch DAE
The Collada (DAE) format is a standard file format for exchange of Mesh data. The Arch Module can import meshes from .dae files, and export Arch
and other Shape-based objects to the .dae format.
Note that imported objects will be Mesh objects, and will need to be turned into Shapes or Arch objects for optimal use. The Arch Module has several
tools to help you in performing that operation.
The Collada import functionality in the Arch module depends on pycollada. If it is not installed on your system, Collada import/export will be disabled.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_DAE&oldid=44411"

Arch Stairs
Description

Arch Stairs

The stairs tool allows you to build automatically several types of stairs. At the moment, only straight stairs (with or Menu location
without a central landing) are supported. Stairs can be built from scratch, or from a straight line, in which case the Arch Stairs
stairs follow the line. If the line is not horizontal but has a vertical inclination, the stairs will also follow its slope.
See the Stairs entry in wikipedia for a definition of the different terms used to describe parts of stairs.

Workbenches
Arch
Default shortcut
SR
See also
None

On the above image, two stairs were created, one with a massive structure and a landing, and another one with a single stringer.

How to use
1. Press the
Arch Stairs button, or press S , R keys
2. Adjust the desired properties. Some parts of the stairs, such as the structure, might not appear immediately, if any of the properties makes it
impossible, such as a structure thickness of 0.

Properties
Base
DATA
DATA
DATA
DATA
DATA

Align: The alignment of these stairs on their baseline, if applicable.


Base: The baseline of these stairs, if any.
Height: The total height of these stairs, if not based on a baseline, or the baseline is horizontal.
Length: The total length of these stairs if no baseline is defined.
Width: The width of these stairs.

Steps
DATA
DATA
DATA
DATA
DATA

Nosing: The size of the nosing.


Number of Steps: The numbers of steps (risers) in these stairs.
Riser Height: The height of the risers.
Tread Depth: The depth of the treads.
Tread Thickness: The thickness of the treads.

Structure
DATA
DATA
DATA
DATA
DATA
DATA

Landings: The type of landings.


Stringer Offset: The offset between the border of the stairs and the structure.
Stringer Width: The width of the stringers.
Structure: The type of structure of these stairs.
Structure Thickness: The thickness of the structure.
Winders: The type of winders.

Scripting
Stairs can be created from python scripts and macros by using the following function:
makeStairs([base], [length], [width], [height], [steps])
Creates a stairs object with the given attributes.
Returns the new stairs object.
Example:

import Arch
makeStairs(length=5, width=1.2, height=3, steps=14)

Limitations
Not available before FreeCAD version 0.14
Only straight stairs are available at the moment
See the forum entry for circle stairs.
See the forum announcement.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Stairs&oldid=85297"

Arch Wall
Description

Arch Wall

This tool builds a Wall object from scratch or on top of any other shape-based or mesh-based object. A wall can be Menu location
built without any base object, in which case it behaves as a cubic volume, using length, width and height properties. Arch -> Wall
When built on top of an existing shape, a wall can be based on:

Workbenches

A linear 2D object, such as lines, wires, arcs or sketches, in which case you can change thickness, Arch
alignment(right, left or centered) and height. The length property has no effect.
A flat face, in which case you can only change the height. Length and width properties have no effect. If the Default shortcut
base face is vertical, however, the wall will use the width property instead of height, allowing you to build walls W A
from space-like objects or mass studies.
See also
A solid, in which case length, width and height properties have no effect. The wall simply uses the underlying
solid as its shape.
Arch Structure
A mesh, in which case the underlying mesh must be a closed, non-manifold solid.

Example

of

walls built from a line, a wire, a face, a solid and a sk etch


Walls can also have additions or subtractions. Additions are other objects whose shapes are joined in this Wall's shape, while subtractions are
subtracted. Additions and subtractions can be added with the Arch Add and Arch Remove tools. Additions and subtractions have no influence over wall
parameters such as height and width, which can still be changed. Walls can also have their height automatic, if they are included into a higher-level
object such as floors. The height must be kept at 0, then the wall will adopt the height specified in the parent object.
When several walls should intersect, you need to place them into a floor to have their geometry intersected.

How to use
Drawing a wall from scratch
1. Press the
Arch Wall button, or press W then A keys
2. Click a first point on the 3D view, or type a coordinate
3. Click a second point on the 3D view, or type a coordinate

Drawing a wall on top of a selected object


1. Select one or more base geometry objects (Draft object, sketch, etc)
2. Press the
Arch Wall button, or press the W then A keys
3. Adjust needed properties such as height or width.

Options
The height, width and alignment of a wall can be set during drawing, via the task panel
When snapping a wall to an existing wall, both walls will be joined into one. The way the two walls are joined depends on their properties: If they
have the same width, height and alignment, and if the option "join base sketches" is enabled in the Arch preferences, the resulting wall will be one
object based on a sketch made of several segments. Otherwise, the latter wall will be added to the first one as addition.
Press X , Y or Z after the first point to constrain the second point on the given axis.
To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
Press R or click the checkbox to check/uncheck the Relative button. If relative mode is on, the coordinates of the second point are relative to
the first one. If not, they are absolute, taken from the (0,0,0) origin point.
Press SHIFT while drawing to constrain your second point horizontally or vertically in relation to the first one.
Press ESC or the Cancel button to abort the current command.
Double-clicking on the wall in the tree view after it is created allows you to enter edit mode and access and modify its additions and subtractions
Multi-layer walls can be easily created by building several walls from the same baseline. By setting their Align property to either left or right, and
specifying an Offset value, you can effectively construct several wall layers. Placing a window in such a wall layer will propagate the opening to
the other wall layers based on the same baseline.

Snapping
Snapping works a bit differently with Arch walls than other Arch and Draft objects. If a wall has a baseline object, snapping will anchor to the base
object, instead of the wall geometry, allowing to easily align walls by their baseline. If, however, you specifically want to snap to the wall geometry,

pressing CTRL will switch snapping to the wall object.

Properties
Wall objects inherit the properties of Part objects, and also have the following extra properties:
Align: The alignment of the wall on its baseline: Left, right or center
Base: The base object this wall is built on
DATA Face: The index of the face from the base object to use. If the vaue is not set or 0, the whole object is used
DATA Force Wire: If True, and the wall is based on a face, only the border wire of the face is used, resulting in a wall bordering the face
DATA Length: The length of the wall (not used when the wall is based on an object)
DATA Width: The width of the wall (not used when the wall is based on a face)
DATA Height: The height of the wall (not used when the wall is based on a solid). If no height is given, and the wall is inside a floor object with its
height defined, the wall will automatically take the value of the floor height.
DATA Normal: An extrusion direction for the wall. If set to (0,0,0), the extrusion direction is automatic.
DATA Offset: This specifies the distance between the wall and its baseline. Works only if the Align property is set to Right or Left.
DATA
DATA

Scripting
The Wall tool can by used in macros and from the python console by using the following function:
makeWall ( [obj],[length],[width],[height],[align],[face],[name] )
Creates a wall based on the given object, which can be a sketch, a draft object, a face or a solid. align can be "Center","Left" or "Right". If you
provide no base object, then you can use numeric values for length, width and height. Face can be used to give the index of a face from the
underlying object, to build this wall on, instead of using the whole object.
Returns the created wall, or None if the operation failed.
Example:
import FreeCAD, Draft, Arch
baseline = Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0))
Arch.makeWall(baseline,None,0.1,2)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Wall&oldid=71054"

Arch CloseHoles
Description

Arch CloseHoles

This tool identifies holes (circular sequence of open edges) in a Shape object and attempts to close it by adding it a Menu location
new face made from that edges sequence. You must still verify yourself that the result is a solid, though.
Arch -> Utilities -> Close

How to use
1. Select a Shape object
2. Press the
Close Holes entry in Arch -> Utilities menu

Scripting
This tool can by used in macros and from the python console by using the following function:
closeHole (shape)
closes a hole in an open shape
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_CloseHoles&oldid=71593"

Holes
Workbenches
Arch
Default shortcut
None
See also
Arch Check

Arch Remove
Description

Arch Remove

Menu location
Arch -> Remove
Remove a subcomponent from an Arch object, for example remove a box that has been added to a wall, like
Workbenches
in the Arch Add example
Subtract a shape-based object from an Arch component such as a wall or structure
Arch
Default shortcut
None
See also
Arch Add

The Remove tools allows you to do 2 kinds of operations:

In the above image, a box is being subtracted from a wall

How to use
1. Select a subcomponent inside an Arch object, or:
2. Select object(s) to be subtracted, then the Arch component from which they must be subtracted (the arch component must be the last thing you
selected)
3. Press the
Remove button

Scripting
The Remove tool can by used in macros and from the python console by using the following function:
removeComponents (objectsList,[hostObject])
removes the given component or the components from the given list from their parents. If a host object is specified, this function will try adding the
components as holes to the host object instead.
Example:
import FreeCAD, Arch, Draft, Part
line = Draft.makeWire([FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,2,0)])
wall = Arch.makeWall(line)
box = Part.makeBox(1,1,1)
Arch.addComponents(box,wall)
Arch.removeComponents(box)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Remov e&oldid=44023"

Arch SectionPlane
Description

Arch
SectionPlane

This tool places in the current Document a section plane gizmo, which defines a section or view plane. The gizmo
can be relocated and reoriented by moving and rotating it, until it describes the 2D view you want to obtain. The Menu location
Section plane object will only consider objects that were selected when it got created. Objects can later be added or
Arch -> Section Plane
removed from a SectionPlane object with the Arch Add and Arch Remove tools.

Workbenches

Upon creation, SectionPlane objects also insert a view of themselves into the active Drawing page, or create a
new page if none exist. You can also add views of Section planes directly in the document, by using the Draft Arch
Shape2DView tool with a section plane selected.
Default shortcut

SP
See also
None

How to use
1.
2.
3.
4.

Select objects you want to be included in your section view


Press the
SectionPlane button or press S then P keys
Move/rotate the Section Plane into correct position
Press the
Recompute button to update the view

Options
With a section plane object selected, use the Draft Shape2DView tool to create a shape object representing the section view in the document

Create additional views of a section plane by selecting it, then using the Draft Drawing tool

Properties
VIEW

Display Size: The size of the section plane gizmo in the 3D view

Scripting
The Section Plane tool can by used in macros and from the python console by using the following function:
makeSectionPlane ([objectslist])
Creates a Section plane objects including the given objects.
Example:
import FreeCAD, Draft, Arch
trace = Part.Line(FreeCAD.Vector (0, 0, 0),FreeCAD.Vector (2, 2, 0))
wall = Arch.makeWall(trace,width=0.1,height=1,align="Center")
Arch.makeSectionPlane([wall])
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_SectionPlane&oldid=46223"

Arch Site
Description

Arch Site

The Arch Site is a special type of FreeCAD group object particularly suited for representing a whole project site, or Menu location
terrain. They are mostly used to organize your model, by containing building objects.
Arch -> Site

How to use
1. Optionally, select one or more objects to be included in your new site
2. Press the
Arch Site button, or press the S then I keys

Options

Workbenches
Arch
Default shortcut
SI
See also
Arch Floor, Arch Building

After creating a site, you can add more objects to it by drag and dropping them in the Tree View or by using
the
Arch Add tool
You can remove objects from a site by drag and dropping them out of it the Tree View or by using the
Arch Remove tool

Scripting
The Site tool can by used in macros and from the python console by using the following function:
makeSite ([objectslist])
creates a site including the objects from the given list.
Example:
import Arch
Arch.makeSite()
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Site&oldid=45057"

Arch Survey
Description

Arch Survey
Menu location

The survey tool enters a special surveying mode, which allows you to quickly grab measures and information from a
model, and transfer that information to other applications. Once you are in Survey mode, clicking on different Arch -> Survey
subelements of 3D objects gathers the following information, depending on what you click:
Workbenches
If you click on an edge, you get its length
If you click on a vertex, you get its height (coordinate on the Z axis)
If you click on a face, you get its area
If you double-click anything, therefore select the whole object, you get its volume
When such a piece of information is gathered, three things happen:

Arch
Default shortcut
None
See also
FCInfo (macro)

A label is placed on top of the element you clicked, that displays the value (with "a" for area, "l" for length, "z"
for height, or "v" for volume)
The numeric value is copied to the clipboard, so you can paste it in another application
A line is printed on the FreeCAD output window. After you exit the survey mode, those lines can be copied and pasted in another application (the
values are comma-separated, making it easy to convert to spreadsheet data)

The above image shows what happens when running the survey mode.

How to use
1. Press the
Arch Survey button
2. Click on vertices, edges, faces or double-click to select whole objects
3. Press ESC or the Cancel button to exit survey mode and remove all the labels.

Scripting
The Survey mode cannot be used directly from python scripts, but gathering the same information from any selected Part-based object is easy
reproduced with the following script:
import FreeCADGui
selection = FreeCADGui.Selection.getSelectionEx()
for obj in selection:
for element in obj.SubObjects:
print "Area: ", element.Area
print "Length: ", element.Length
print "Volume: ", element.Volume
print "Center of Mass: ", element.CenterOfMass
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Arch_Surv ey&oldid=72510"

Robot Module
(Redirected from Robot Module)

The robot workbench is a tool to simulate industrial grade 6-Axis Robots, like e.g. Kuka. You can do following tasks:
set up a simulation environment with a robot and work pieces
create and fill up trajectories
decompose features of an CAD part to a trajectory
simulate the robot movement and reachability
export the trajectory to a robot program file
An examples you can find here: Example files or try the Robot tutorial.

Tools
Here the principal commands you can use to create a robot set-up.

Robots
The tools to create and manage the 6-Axis robots
Create a robot: Insert a new robot into the scene
Simulate a trajectory: Opens the simulation dialog and let you simulate
Export a trajectory: Export a robot program file
Set home positon: Set the home position of an robot
Restore home positon: move the robot to its home position

Trajectories
Tools to creat and manipulate trajectories. There are two kinds, the parametric and non parametric ones.
non parametric

Create a trajectory: Insert a new robot into the scene


Set the default orientation: Set the orientation way-points gets created by default
Set the default speed parameter: set the defaults for way-point creation
Insert a waypoint: Insert a way-point from the current robot position into a trajectory
Insert a waypoint: Insert a way-point from the current mouse position into a trajectory
parametric

Create a trajectory out of edges: Insert a new object which decompose edges to a trajectory
Dress-up a trajectory: Let you override one or more properties of a trajectory
Trajectory compound: create a compound out of some single trajectories

Scripting
This section is generated out of: http://sourceforge.net/p/free-cad/code/ci/master/tree/src/Mod/Robot/RobotExample.py You can use this file
directly if you want.
Example how to use the basic robot class Robot6Axis which represents a 6-axis industrial robot. The Robot module is dependent on Part but not on
other modules. It works mostly with the basic types Placement, Vector and Matrix. So we need only:
from Robot import *
from Part import *
from FreeCAD import *

Basic robot stuff


create the robot. If you do not specify another kinematic it becomes a Puma 560
rob = Robot6Axis()
print rob

accessing the axis and the Tcp. Axes go from 1-6 and are in degree:
Start = rob.Tcp
print Start
print rob.Axis1

move the first axis of the robot:


rob.Axis1 = 5.0
the Tcp has changed (forward kinematic)
print rob.Tcp

move the robot back to start position (reverse kinematic):


rob.Tcp = Start
print rob.Axis1

the same with axis 2:


rob.Axis2 = 5.0
print rob.Tcp
rob.Tcp = Start
print rob.Axis2

Waypoints:
w = Waypoint(Placement(),name="Pt",type="LIN")
print w.Name,w.Type,w.Pos,w.Cont,w.Velocity,w.Base,w.Tool

generate more. The trajectory always finds automatically a unique name for the waypoints
l = [w]
for i in range(5):
l.append(Waypoint(Placement(Vector(0,0,i*100),Vector(1,0,0),0),"LIN","Pt"))

create a trajectory
t = Trajectory(l)
print t
for i in range(7):
t.insertWaypoints(Waypoint(Placement(Vector(0,0,i*100+500),Vector(1,0,0),0),"LIN","Pt"))

see a list of all waypoints:


print t.Waypoints
del rob,Start,t,l,w

working with the document


Working with the robot document objects: first create a robot in the active document
if(App.activeDocument() == None):App.newDocument()
App.activeDocument().addObject("Robot::RobotObject","Robot")
Define the visual representation and the kinematic definition (see 6-Axis Robot and VRML Preparation for Robot Simulation for details about that)
App.activeDocument().Robot.RobotVrmlFile = App.getResourceDir()+"Mod/Robot/Lib/Kuka/kr500_1.wrl"
App.activeDocument().Robot.RobotKinematicFile = App.getResourceDir()+"Mod/Robot/Lib/Kuka/kr500_1.csv"
start positon of the Axis (only that which differ from 0)
App.activeDocument().Robot.Axis2 = -90
App.activeDocument().Robot.Axis3 = 90

retrieve the Tcp position

pos = FreeCAD.getDocument("Unnamed").getObject("Robot").Tcp
move the robot
pos.move(App.Vector(-10,0,0))
FreeCAD.getDocument("Unnamed").getObject("Robot").Tcp = pos

create an empty Trajectory object in the active document


App.activeDocument().addObject("Robot::TrajectoryObject","Trajectory")
get the Trajectory
t = App.activeDocument().Trajectory.Trajectory
add the actual TCP position of the robot to the trajectory
StartTcp = App.activeDocument().Robot.Tcp
t.insertWaypoints(StartTcp)
App.activeDocument().Trajectory.Trajectory = t
print App.activeDocument().Trajectory.Trajectory

insert some more Waypoints and the start point at the end again:
for i in range(7):
t.insertWaypoints(Waypoint(Placement(Vector(0,1000,i*100+500),Vector(1,0,0),i),"LIN","Pt"))
t.insertWaypoints(StartTcp) # end point of the trajectory
App.activeDocument().Trajectory.Trajectory = t
print App.activeDocument().Trajectory.Trajectory

Simulation
To be done..... ;-)

Exporting the trajectory


The trajectory is exported by Python. That means for every control cabinet type there is a post-processor Python module. Here is in detail the Kuka
post-processor described
from KukaExporter import ExportCompactSub
ExportCompactSub(App.activeDocument().Robot,App.activeDocument().Trajectory,'D:/Temp/TestOut.src')

and that's kind of how it's done:


for w in App.activeDocument().Trajectory.Trajectory.Waypoints:
(A,B,C) = (w.Pos.Rotation.toEuler())
print ("LIN {X %.3f,Y %.3f,Z %.3f,A %.3f,B %.3f,C %.3f} ; %s"%(w.Pos.Base.x,w.Pos.Base.y,w.Pos.Base.z,A,B,C,w.Name))
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Robot_Workbench&oldid=84488"

Robot project
This is the project article for the Robot project. It follows the rules of the Getting things done process. The projects are collected in the Development
roadmap.

Purpose and principles


This project should lay down the principal technologies for a realistic robot simulation in FreeCAD. In the first step it targets the standard 6-axis industrial
robot.

Outcome
Robot simulation

Brainstorming
Libs in field
OROCOSlibs for inverse kinematic
ROBOOP targets directly to robot simulation, but seems inactive.
Beremiz a OpenSource PLC.

Standards for communication


OPC UA to communicate with PLCs
RRS-II German standard for robot simulation communication

Middleware for comunication


D-Bus
CORBA

Commercial products in that field


Visual Components
Delmia
KUKA Sim

Knowledge
Kinematic definition
Roboter VRML modele

Organizing
Visual representation of 6-Axis robots (done)
Forward and inverse kinematic calculation of arbitrary robots (done)
RobotLib, dynamic readably robot types (work in progress)
Trajectory simulation (work in progress)
collision simulation
detection of configuration changes and singularities

time estimation
used volume (planed)
Post processor for Kuka robots (work in progress)
Process and work cell control (planed)
Movie making out of simulation (planed)

Next actions
Trajectory and Waypoint management.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Robot_proj ect&oldid=58303"

Robot tutorial
This tutorial is here to teach you how to use the Robot Workbench to simulate a robot cell set-up.

before you begin


This tutorial is written for FreeCAD Version 0.11 R3977 or higher. So if you don't have FreeCAD on your computer go to the Download page and do the
installation.
This tutorial targeting on the use of industrial robots and not mobile or service robots (see here).
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Robot_tutorial&oldid=84505"

List of Commands
(Redirected from List of Commands)
This category contains the help pages of each of FreeCAD command.

Pages in category "Command Reference"


The following 200 pages are in this category, out of 396 total.
(previous 200) (next 200)

D cont.
Arch Add
Arch Axis
Arch Building
Arch Cell
Arch Check
Arch CloseHoles
Arch Floor
Arch Frame
Arch IfcExplorer
Arch MeshToShape
Arch Rebar
Arch Remove
Arch RemoveShape
Arch Roof
Arch SectionPlane
Arch SelectNonSolidMeshes
Arch Site
Arch Space
Arch SplitMesh
Arch Stairs
Arch Stairs/en
Arch Stairs/es
Arch Stairs/fr
Arch Structure
Arch Survey
Arch Wall
Arch Window

Draft Line
Draft Move
Draft Offset
Draft PathArray
Draft Point
Draft Polygon
Draft Rectangle
Draft Rotate
Draft Scale
Draft SelectGroup
Draft SelectPlane
Draft Shape2DView
Draft ShapeString
Draft ShowSnapBar
Draft Text
Draft ToggleConstructionMode
Draft ToggleContinueMode
Draft ToggleDisplayMode
Draft ToggleGrid
Draft ToggleSnap
Draft Trimex
Draft UndoLine
Draft Upgrade
Draft Wire
Draft WireToBSpline
Drawing Annotation
Drawing Clip
Drawing Landscape A3
Drawing Open SVG
Drawing Openbrowser
Drawing Orthoviews
Drawing Save
Drawing Symbol
Drawing View

C
Clipping plane
Clipping plane/en
Constraint EqualLength
Constraint Horizontal
Constraint HorizontalDistance
Constraint InternalAngle
Constraint Length
Constraint Lock
Constraint Parallel
Constraint Perpendicular
Constraint PointOnObject
Constraint PointOnPoint
Constraint Radius
Constraint Symmetric
Constraint Tangent
Constraint Vertical
Constraint VerticalDistance

D
Draft AddPoint
Draft AddPoint/en
Draft AddToGroup
Draft Apply
Draft Arc
Draft Array
Draft Array/cs
Draft BezCurve
Draft BSpline
Draft Circle
Draft Clone
Draft CloseLine

F
File Format FCStd
File Format FCStd/en

G
Gui Command
Template:GuiCommand
GuiCommand model

M
Manual03/fr
Mesh BoundingBox
Mesh BuildRegularSolid
Mesh CurvatureInfo
Mesh Demolding
Mesh Difference
Mesh EvaluateFacet
Mesh EvaluateSolid
Mesh Evaluation
Mesh ExMakeMesh
Mesh ExMakeTool
Mesh ExMakeUnion
Mesh FillInteractiveHole
Mesh FillupHoles

M cont.
Mesh ToolMesh
Mesh Transform
Mesh Union
Mesh VertexCurvature
MIBA
MIBA/en

O
OpenSCAD
AddOpenSCADElement

P
Part Booleans
Part Booleans/de
Part Booleans/en
Part Booleans/es
Part Booleans/fr
Part Booleans/sv
Part Box
Part Box/en
Part Chamfer
Part Chamfer/en
Part Circle
Part Circle/en
Part Common
Part Common/en
Part Common/se
Part Cone
Part Cone/en
Part Cone/se
Part CreatePrimitives
Part CreatePrimitives/en
Part Cut
Part Cut/en
Part Cut/se
Part Cylinder
Part Cylinder/en
Part Cylinder/se
Part Ellipse
Part Ellipse/en
Part Ellipsoid
Part Ellipsoid/en
Part Extrude
Part Extrude/en
Part Extrude/se
Part Fillet
Part Fillet/en
Part Fillet/se
Part Fuse
Part Fuse/en
Part Fuse/se
Part Helix
Part Helix/en
Part Line
Part Line/en
Part Loft
Part Mirror
Part Mirror/en
Part Offset
Part Plane

Draft DelPoint
Draft Dimension
Draft Downgrade
Draft Draft2Sketch
Draft Drawing
Draft Edit
Draft Ellipse
Draft Facebinder
Draft FinishLine
Draft FlipDimension
Draft Heal

Mesh FixDegenerations
Mesh FixDuplicateFaces
Mesh FixDuplicatePoints
Mesh FixIndices
Mesh FlipNormals
Mesh FromGeometry
Mesh HarmonizeNormals
Mesh Import
Mesh Intersection
Mesh PolyCut
Mesh PolySegm
Mesh PolySplit
Mesh RemoveCompByHand
Mesh RemoveComponents

(previous 200) (next 200)


Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Category:Command_Reference&oldid=2362"

Part Plane/en
Part Point
Part Point/en
Part Prism
Part Prism/en
Part RefineShape
Part RefineShape/en
Part RegularPolygon
Part RegularPolygon/en
Part Revolve
Part Revolve/en

Tutorials
(Redirected from Tutorials)
FreeCAD tutorials. Please help us adding more!
Special pages are Offsite tutorials and Video tutorials that hierarchically contain links to tutorials hosted on external sites. A useful source of video
tutorials is of course also a FreeCAD keyword search on YouTube.

Pages in category "Tutorials"


The following 34 pages are in this category, out of 34 total.

E cont.
Aeroplane
Aeroplane/en
Arch tutorial
Assembly Basic Tutorial

P cont.

Engine tutorial

Python scripting tutorial

R
FreeCAD-Ship s60 tutorial
FreeCAD-Ship s60 tutorial (II)

B
Basic modeling tutorial

S
Macros recipes
Macros recipes/en
Manual
Manual/se

Code snippets
Code snippets/en
Code snippets/se

Robot tutorial
Robot tutorial/en

Sketcher Tutorial
Sketcher Tutorial/en

Topological data scripting


Offsite tutorials

Draft tutorial
Draft tutorial/en
Drawing Template HowTo

E
Engine Block Tutorial

P
PartDesign Bearingholder
Tutorial I
PartDesign Bearingholder
Tutorial II
Plot Basic tutorial
Plot MultiAxes tutorial

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Category:Tutorials&oldid=40916"

V
Video tutorials
Video tutorials/en
VRML Preparation for Robot
Simulation
VRML Preparation for Robot
Simulation/en

Macros
Macros are a convenient way to create complex actions in FreeCAD. You simply record actions as you do them, then save that under a name, and
replay them whenever you want. Since macros are in reality a list of python commands, you can also edit them, and create very complex scripts.

How it works
If you enable console output (Menu Edit -> Preferences -> General -> Macros -> Show scripts commands in python console), you will see that in
FreeCAD, every action you do, such as pressing a button, outputs a python command. Thos commands are what can be recorded in a macro. The main
tool for making macros is the macros toolbar:
macro.

. On it you have 4 buttons: Record, stop recording, edit and play the current

It is very simple to use: Press the record button, you will be asked to give a name to your macro, then perform some actions. When you are done, click
the stop recording button, and your actions will be saved. You can now access the macro dialog with the edit button:

There you can manage your macros, delete, edit or create new ones from scratch. If you edit a macro, it will be opened in an editor window where you
can make changes to its code.

Example
Press the record button, give a name, let's say "cylinder 10x10", then, in the Part Workbench, create a cylinder with radius = 10 and height = 10. Then,
press the "stop recording" button. In the edit macros dialog, you can see the python code that has been recorded, and, if you want, make alterations to
it. To execute your macro, simply press the execute button on the toolbar while your macro is in the editor. You macro is always saved to disk, so any
change you make, or any new macro you create, will always be available next time you start FreeCAD.

Customizing
Of course it is not practical to load a macro in the editor in order to use it. FreeCAD provides much better ways to use your macro, such as assigning a
keyboard shortcut to it or putting an entry in the menu. Once your macro is created, all this can be done via the Tools -> Customize menu:

This way you can make your macro become a real tool, just like any standard FreeCAD tool. This, added to the power of python scripting within
FreeCAD, makes it possible to easily add your own tools to the interface. Read on to the Scripting page if you want to know more about python
scripting...

Creating macros without recording


You can also directly copy/paste python code into a macro, without recording GUI action. Simply create a new macro, edit it, and paste your code. You
can then save your macro the same way as you save a FreeCAD document. Next time you start FreeCAD, the macro will appear under the "Installed
Macros" item of the Macro menu.

Macros repository
Visit the Macros recipes page to pick some useful macros to add to your FreeCAD installation.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Macros&oldid=69628"

Introduction to python
(Redirected from Introduction to python)
This is a short tutorial made for who is totally new to Python. Python is an open-source, multiplatform programming language. Python has several
features that make it very different than other common programming languages, and very accessible to new users like yourself:
It has been designed specially to be easy to read by human beings, and so it is very easy to learn and understand.
It is interpreted, that is, unlike compiled languages like C, your program doesn't need to be compiled before it is executed. The code you write
can be immediately executed, line by line if you want so. This makes it extremely easy to learn and to find errors in your code, because you go
slowly, step-by-step.
It can be embedded in other programs to be used as scripting language. FreeCAD has an embedded Python interpreter, so you can write Python
code in FreeCAD, that will manipulate parts of FreeCAD, for example to create geometry. This is extremely powerful, because instead of just
clicking a button labeled "create sphere", that a programmer has placed there for you, you have the freedom to create easily your own tool to
create exactly the geometry you want.
It is extensible, you can easily plug new modules in your Python installation and extend its functionality. For example, you have modules that
allow Python to read and write jpg images, to communicate with twitter, to schedule tasks to be performed by your operating system, etc.
So, hands on! Be aware that what will come next is a very simple introduction, by no means a complete tutorial. But my hope is that after that you'll get
enough basics to explore deeper into the FreeCAD mechanisms.

The interpreter
Usually, when writing computer programs, you simply open a text editor or your special programming environment which is in most case a text editor
with several tools around it, write your program, then compile it and execute it. Most of the time you made errors while writing, so your program won't
work, and you will get an error message telling you what went wrong. Then you go back to your text editor, correct the mistakes, run again, and so on
until your program works fine.
That whole process, in Python, can be done transparently inside the Python interpreter. The interpreter is a Python window with a command prompt,
where you can simply type Python code. If you install Python on your computer (download it from the Python website if you are on Windows or Mac,
install it from your package repository if you are on GNU/Linux), you will have a Python interpreter in your start menu. But FreeCAD also has a Python
interpreter in its bottom part:

(If you don't have it, click on View Views Python console.)
The interpreter shows the Python version, then a >>> symbol, which is the command prompt, that is, where you enter Python code. Writing code in the
interpreter is simple: one line is one instruction. When you press Enter, your line of code will be executed (after being instantly and invisibly compiled).
For example, try writing this:
print "hello"
print is a special Python keyword that means, obviously, to print something on the screen. When you press Enter, the operation is executed, and the
message "hello" is printed. If you make an error, for example let's write:
print hello
Python will tell us that it doesn't know what hello is. The " characters specify that the content is a string, which is simply, in programming jargon, a
piece of text. Without the ", the print command believed hello was not a piece of text but a special Python keyword. The important thing is, you
immediately get notified that you made an error. By pressing the up arrow (or, in the FreeCAD interpreter, CTRL+up arrow), you can go back to the last
command you wrote and correct it.
The Python interpreter also has a built-in help system. Try typing:
help
or, for example, let's say we don't understand what went wrong with our print hello command above, we want specific information about the "print"
command:
help("print")
You'll get a long and complete description of everything the print command can do.
Now we dominate totally our interpreter, we can begin with serious stuff.

Variables
Of course, printing "hello" is not very interesting. More interesting is printing stuff you don't know before, or let Python find for you. That's where the
concept of variable comes in. A variable is simply a value that you store under a name. For example, type this:
a = "hello"

print a
I guess you understood what happened, we "saved" the string "hello" under the name a. Now, a is not an unknown name anymore! We can use it
anywhere, for example in the print command. We can use any name we want, just respecting simple rules, like not using spaces or punctuation. For
example, we could very well write:
hello = "my own version of hello"
print hello
See? now hello is not an undefined word anymore. What if, by terrible bad luck, we choosed a name that already exists in Python? Let's say we want to
store our string under the name "print":
print = "hello"
Python is very intelligent and will tell us that this is not possible. It has some "reserved" keywords that cannot be modified. But our own variables can be
modified anytime, that's exactly why they are called variables, the contents can vary. For example:
myVariable = "hello"
print myVariable
myVariable = "good bye"
print myVariable
We changed the value of myVariable. We can also copy variables:
var1 = "hello"
var2 = var1
print var2
Note that it is interesting to give good names to your variables, because when you'll write long programs, after a while you won't remember what your
variable named "a" is for. But if you named it for example myWelcomeMessage, you'll remember easily what it is used for when you'll see it.

Numbers
Of course you must know that programming is useful to treat all kind of data, and especially numbers, not only text strings. One thing is important,
Python must know what kind of data it is dealing with. We saw in our print hello example, that the print command recognized our "hello" string. That is
because by using the ", we told specifically the print command that what it would come next is a text string.
We can always check what data type is the contents of a variable with the special Python keyword type:
myVar = "hello"
type(myVar)
It will tell us the contents of myVar is 'str', or string in Python jargon. We have also other basic types of data, such as integer and float numbers:
firstNumber = 10
secondNumber = 20
print firstNumber + secondNumber
type(firstNumber)
This is already much more interesting, isn't it? Now we already have a powerful calculator! Look well at how it worked, Python knows that 10 and 20 are
integer numbers. So they are stored as "int", and Python can do with them everything it can do with integers. Look at the results of this:
firstNumber = "10"
secondNumber = "20"
print firstNumber + secondNumber
See? We forced Python to consider that our two variables are not numbers but mere pieces of text. Python can add two pieces of text together, but it
won't try to find out any sum. But we were talking about integer numbers. There are also float numbers. The difference is that integer numbers don't have
decimal part, while foat numbers can have a decimal part:
var1 = 13
var2 = 15.65
print "var1 is of type ", type(var1)
print "var2 is of type ", type(var2)
Int and Floats can be mixed together without problem:
total = var1 + var2
print total
print type(total)
Of course the total has decimals, right? Then Python automatically decided that the result is a float. In several cases such as this one, Python
automatically decides what type to give to something. In other cases it doesn't. For example:
varA = "hello 123"
varB = 456
print varA + varB
This will give us an error, varA is a string and varB is an int, and Python doesn't know what to do. But we can force Python to convert between types:
varA = "hello"
varB = 123
print varA + str(varB)
Now both are strings, the operation works! Note that we "stringified" varB at the time of printing, but we didn't change varB itself. If we wanted to turn varB
permanently into a string, we would need to do this:

varB = str(varB)
We can also use int() and float() to convert to int and float if we want:
varA = "123"
print int(varA)
print float(varA)
Note on Python commands
You must have noticed that in this section we used the print command in several ways. We printed variables, sums, several things separated by
commas, and even the result of other Python command such as type(). Maybe you also saw that doing those two commands:
type(varA)
print type(varA)
have exactly the same result. That is because we are in the interpreter, and everything is automatically printed on screen. When we'll write more
complex programs that run outside the interpreter, they won't print automatically everything on screen, so we'll need to use the print command. But from
now on, let's stop using it here, it'll go faster. So we can simply write:
myVar = "hello friends"
myVar
You must also have seen that most of the Python commands (or keywords) we already know have parenthesis used to tell them on what contents the
command must work: type(), int(), str(), etc. Only exception is the print command, which in fact is not an exception, it also works normally like this:
print("hello"), but, since it is used often, the Python programmers made a simplified version.

Lists
Another interesting data type is lists. A list is simply a list of other data. The same way as we define a text string by using " ", we define lists by using [
]:
myList = [1,2,3]
type(myList)
myOtherList = ["Bart", "Frank", "Bob"]
myMixedList = ["hello", 345, 34.567]
You see that it can contain any type of data. Lists are very useful because you can group variables together. You can then do all kind of things within
that groups, for example counting them:
len(myOtherList)
or retrieving one item of a list:
myName = myOtherList[0]
myFriendsName = myOtherList[1]
You see that while the len() command returns the total number of items in a list, their "position" in the list begins with 0. The first item in a list is always
at position 0, so in our myOtherList, "Bob" will be at position 2. We can do much more stuff with lists such as you can read here, such as sorting
contents, removing or adding elements.
A funny and interesting thing for you: a text string is very similar to a list of characters! Try doing this:
myvar = "hello"
len(myvar)
myvar[2]
Usually all you can do with lists can also be done with strings. In fact both lists and strings are sequences.
Outside strings, ints, floats and lists, there are more built-in data types, such as dictionnaries, or you can even create your own data types with
classes.

Indentation
One big cool use of lists is also browsing through them and do something with each item. For example look at this:
alldaltons = ["Joe", "William", "Jack", "Averell"]
for dalton in alldaltons:
print dalton + " Dalton"
We iterated (programming jargon again!) through our list with the "for ... in ..." command and did something with each of the items. Note the special
syntax: the for command terminates with : which indicates that what will comes after will be a block of one of more commands. Immediately after you
enter the command line ending with :, the command prompt will change to ... which means Python knows that a :-ended line has happened and that
what will come next will be part of it.
How will Python know how many of the next lines will be to be executed inside the for...in operation? For that, Python uses indentation. That is, your
next lines won't begin immediately. You will begin them with a blank space, or several blank spaces, or a tab, or several tabs. Other programming
languages use other methods, like putting everythin inside parenthesis, etc. As long as you write your next lines with the same indentation, they will be
considered part of the for-in block. If you begin one line with 2 spaces and the next one with 4, there will be an error. When you finished, just write
another line without indentation, or simply press Enter to come back from the for-in block
Indentation is cool because if you make big ones (for example use tabs instead of spaces because it's larger), when you write a big program you'll have
a clear view of what is executed inside what. We'll see that many other commands than for-in can have indented blocks of code too.
For-in commands can be used for many things that must be done more than once. It can for example be combined with the range() command:

serie = range(1,11)
total = 0
print "sum"
for number in serie:
print number
total = total + number
print "----"
print total
Or more complex things like this:
alldaltons = ["Joe", "William", "Jack", "Averell"]
for n in range(4):
print alldaltons[n], " is Dalton number ", n
You see that the range() command also has that strange particularity that it begins with 0 (if you don't specify the starting number) and that its last
number will be one less than the ending number you specify. That is, of course, so it works well with other Python commands. For example:
alldaltons = ["Joe", "William", "Jack", "Averell"]
total = len(alldaltons)
for n in range(total):
print alldaltons[n]
Another interesting use of indented blocks is with the if command. If executes a code block only if a certain condition is met, for example:
alldaltons = ["Joe", "William", "Jack", "Averell"]
if "Joe" in alldaltons:
print "We found that Dalton!!!"
Of course this will always print the first sentence, but try replacing the second line by:
if "Lucky" in alldaltons:
Then nothing is printed. We can also specify an else: statement:
alldaltons = ["Joe", "William", "Jack", "Averell"]
if "Lucky" in alldaltons:
print "We found that Dalton!!!"
else:
print "Such Dalton doesn't exist!"

Functions
The standard Python commands are not many. In current version of Python there are about 30, and we already know several of them. But imagine if
we could invent our own commands? Well, we can, and it's extremely easy. In fact, most the additional modules that you can plug into your Python
installation do just that, they add commands that you can use. A custom command in Python is called a function and is made like this:
def printsqm(myValue):
print str(myValue)+" square meters"
printsqm(45)
Extremely simple: the def() command defines a new function. You give it a name, and inside the parenthesis you define arguments that we'll use in our
function. Arguments are data that will be passed to the function. For example, look at the len() command. If you just write len() alone, Python will tell you
it needs an argument. That is, you want len() of something, right? Then, for example, you'll write len(myList) and you'll get the length of myList. Well,
myList is an argument that you pass to the len() function. The len() function is defined in such a way that it knows what to do with what is passed to it.
Same as we did here.
The "myValue" name can be anything, and it will be used only inside the function. It is just a name you give to the argument so you can do something
with it, but it also serves so the function knows how many arguments to expect. For example, if you do this:
printsqm(45,34)
There will be an error. Our function was programmed to receive just one argument, but it received two, 45 and 34. We could instead do something like
this:
def sum(val1,val2):
total = val1 + val2
return total
sum(45,34)
myTotal = sum(45,34)
We made a function that receives two arguments, sums them, and returns that value. Returning something is very useful, because we can do something
with the result, such as store it in the myTotal variable. Of course, since we are in the interpreter and everything is printed, doing:
sum(45,34)
will print the result on the screen, but outside the interpreter, since there is no more print command inside the function, nothing would appear on the
screen. You would need to do:
print sum(45,34)
to have something printed. Read more about functions here.

Modules
Now that we have a good idea of how Python works, we'll need one last thing: How to work with files and modules.
Until now, we wrote Python instructions line by line in the interpreter, right? What if we could write several lines together, and have them executed all at
once? It would certainly be handier for doing more complex things. And we could save our work too. Well, that too, is extremely easy. Simply open a
text editor (such as the windows notepad), and write all your Python lines, the same way as you write them in the interpreter, with indentations, etc.
Then, save that file somewhere, preferably with a .py extension. That's it, you have a complete Python program. Of course, there are much better editors
than notepad, but it is just to show you that a Python program is nothing else than a text file.
To make Python execute that program, there are hundreds of ways. In windows, simply right-click your file, open it with Python, and execute it. But you
can also execute it from the Python interpreter itself. For this, the interpreter must know where your .py program is. In FreeCAD, the easiest way is to
place your program in a place that FreeCAD's Python interpreter knows by default, such as FreeCAD's bin folder, or any of the Mod folders. Suppose we
write a file like this:
def sum(a,b):
return a + b
print "test.py succesfully loaded"
and we save it as test.py in our FreeCAD/bin directory. Now, let's start FreeCAD, and in the interpreter window, write:
import test
without the .py extension. This will simply execute the contents of the file, line by line, just as if we had written it in the interpreter. The sum function will
be created, and the message will be printed. There is one big difference: the import command is made not only to execute programs written in files, like
ours, but also to load the functions inside, so they become available in the interpreter. Files containing functions, like ours, are called modules.
Normally when we write a sum() function in the interpreter, we execute it simply like that:
sum(14,45)
Like we did earlier. When we import a module containing our sum() function, the syntax is a bit different. We do:
test.sum(14,45)
That is, the module is imported as a "container", and all its functions are inside. This is extremely useful, because we can import a lot of modules, and
keep everything well organized. So, basically, everywhere you see something.somethingElse, with a dot in between, that means somethingElse is inside
something.
We can also throw out the test part, and import our sum() function directly into the main interpreter space, like this:
from test import *
sum(12,54)
Basically all modules behave like that. You import a module, then you can use its functions like that: module.function(argument). Almost all modules do
that: they define functions, new data types and classes that you can use in the interpreter or in your own Python modules, because nothing prevents
you to import modules inside your module!
One last extremely useful thing. How do we know what modules we have, what functions are inside and how to use them (that is, what kind of
arguments they need)? We saw already that Python has a help() function. Doing:
help()
modules
Will give us a list of all available modules. We can now type q to get out of the interactive help, and import any of them. We can even browse their
content with the dir() command
import math
dir(math)
We'll see all the functions contained in the math module, as well as strange stuff named __doc__, __file__, __name__. The __doc__ is extremely useful,
it is a documentation text. Every function of (well-made) modules has a __doc__ that explains how to use it. For example, we see that there is a sin
function in side the math module. Want to know how to use it?
print math.sin.__doc__
And finally one last little goodie: When we work on programming a new module, we often want to test it. So once we wrote a little piece of module, in a
python interpreter, we do something like this, to test our new code:
import myModule
myModule.myTestFunction()
But what if we see that myTestFunction() doesn't work correctly? We go back to our editor and modifiy it. Then, instead of closing and reopening the
python interpreter, we can simply update the module like this:
reload(myModule)

Starting with FreeCAD


Well, I think you must know have a good idea of how Python works, and you can start exploring what FreeCAD has to offer. FreeCAD's Python functions
are all well organized in different modules. Some of them are already loaded (imported) when you start FreeCAD. So, just do
dir()

and read on to FreeCAD Scripting Basics...


Of course, we saw here only a very small part of the Python world. There are many important concepts that we didn't mention here. There are three very
important Python reference documents on the net:
the official Python tutorial with way more information than this one
the official Python reference
the Dive into Python wikibook/ book.
Be sure to bookmark them!

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Introduction_to_Python&oldid=16730"

Python scripting tutorial


Python is a programming language, very simple to use and very fast to learn. It is open-source, multi-platform, and can be used alone for a wide array of
things, from programming simple shell scripts to very complex programs. But one of its most widespread uses is as a scripting language, since it is
easy to embed in other applications. That's exactly how it is used inside FreeCAD. From the python console, or from your custom scripts, you can pilot
FreeCAD, and make it perform very complex actions for which there is still no graphical user interface tool.
For example, from a python script, you can:
create new objects
modify existing objects
modify the 3D representation of those objects
modify the FreeCAD interface
There are also several different ways to use python in FreeCAD:
From the FreeCAD python interpreter, where you can issue simple commands like in a "command line"-style interface
From macros, which are a convenient way to quickly add a missing tool to the FreeCAD interface
From external scripts, which can be used to program much more complex things. like entire Workbenches.
In this tutorial, we'll work on a couple of simple examples to get you started, but there is also much more documentation about python scripting
available on this wiki. If you are totally new to python and want to understand how it works, we also have a basic introduction to python.
Important! Before proceeding with Python scripting, go to Edit->Prefences->General->Output window and check 2 boxes:
Redirect internal Python output to report view
Redirect internal Python errors to report view
Then go to View->Views and check:
Report view
This will save you a lot of aggravation!

Writing python code


There are two easy ways to write python code in FreeCAD: From the python console (available from the View -> Views -> Python console menu) or from
the Macro editor (Tools -> Macros). In the console, you write python commands one by one, which are executed when you press return, while the
macros can contain a more complex script made of several lines, which is executed only when the macro is executed.

The FreeCAD python console


In this tutorial, you will be able to use both methods, either by copying/pasting each line one by one in the python console and pressing Return after
each line, or by copying/pasting the entire code in a new Macro window.

Exploring FreeCAD
Let's start by creating a new empty document:
doc = FreeCAD.newDocument()
If you type this in the FreeCAD python console, you will notice that as soon as you type "FreeCAD.", a windows pops up, allowing to quickly
autocomplete the rest of your line. Even better, each entry in the autocomplete list has a tooltip explaining what it does. This makes it very easy to
explore the functionality available. Before choosing "newDocument", have a look at the other options available.

The autocomplete mechanism of the FreeCAD python console


Now our new document will be created. This is similar to pressing the "new document" button on the toolbar. In fact, most buttons in FreeCAD do
nothing else than executing a line or two of python code. Even better, you can set an option in Edit->Preferences->General->Macro to "show script

commands in python console". This will print in the console all python code executed when you press buttons. Very useful to learn how to reproduce
actions in python.
Now let's get back to our document. Let's see what we can do with it:
doc.
Explore the available options. Usually names that begin with a capital letter are attributes, they contain a value, while names that begin with small letter
are functions (also called methods), they "do something". Names that begin with an underscore are usually there for the internal working of the module,
and you shouldn't care about them. Let's use one of the methods to add a new object to our document:
box = doc.addObject("Part::Box","myBox")
Nothing happens. Why? Because FreeCAD is made for the big picture. One day, it will work with hundreds of complex objects, all depending one from
another. Making a small change somewhere could have a big impact, you may need to recalculate the whole document, which could take a long time...
For that reason, almost no command updates the scene automatically. You must do it manually:
doc.recompute()
See? Now our box appeared! Many of the buttons that add objects in FreeCAD actually do 2 things: add the object, and recompute. If you turned on the
"show script commands in python console" option above, try now adding a sphere with the GUI button, you'll see the two lines of python code being
executed one after the other.
What about the "Part::Box" will you ask? How can I know what other kind of objects can be added? It's all here:
doc.supportedTypes()
Now let's explore the contents of our box:
box.
You'll immediately see a couple of very interesting things such as:
box.Height
This will print the current height of our box. Now let's try to change that:
box.Height = 5
If you select your box with the mouse, you'll see that in the properties panel, in the "Data" tab, our "Height" property appears. All properties of a
FreeCAD object that appear there (and also in the "View" tab, more about that later), are directly accessible by python too, by their names, like we did
with the "Height" property. Try changing the other dimensions of that box.

Vectors and Placements


Vectors are a very fundamental concept in any 3D application. It is a list of 3 numbers (x, y and z), describing a point or position in the 3D space. A lot
of things can be done with vectors, such as additions, subtractions, projections and much more. In FreeCAD vectors work like this:
myvec = FreeCAD.Vector(2,0,0)
myvec
myvec.x
myvec.y
othervec = FreeCAD.Vector(0,3,0)
sumvec = myvec.add(othervec)
Another common feature of FreeCAD objects is their placement. Each object has a Placement attributes, which contains the position (Base) and
orientation (Rotation) of the object. It is easy to manipulate, for example to move our object:
box.Placement.
box.Placement.Base
box.Placement.Base = sumvec
otherpla = FreeCAD.Placement()
box.Placement = otherpla
Now you must understand a couple of important concepts before we get further.

App and Gui


FreeCAD is made from the beginning to work as a command-line application, without its user interface. As a result, almost everything is separated
between a "geometry" component and a "visual" component. When you work in command-line mode, the geometry part is present, but all the visual part
is simply disabled. Almost any object in FreeCAD therefore is made of two parts, an Object and a ViewObject.
To illustrate the concept, see our cube object, the geometric properties of the cube, such as its dimensions, position, etc... are stored in the object,
while its visual properties, such as its color, line thickness, etc... are stored in the viewobject. This corresponds to the "Data" and "View" tabs in the
property window. The view object of an object is accessed like this:
vo = box.ViewObject
Now you can also change the properties of the "View" tab:
vo.Transparency = 80
vo.hide()
vo.show()
When you start FreeCAD, the python console already loads 2 base modules: FreeCAD and FreeCADGui (which can also be accessed by their
shortcuts App and Gui). They contain all kinds of generic functionality to work with documents and their objects. To illustrate our concept, see that both
FreeCAD and FreeCADGui contain an ActiveDocument attribute, which is the currently opened document. FreeCAD.ActiveDocument and
FreeCADGui.ActiveDocument are not the same object. They are the two components of a FreeCAD document, and they contain different attributes and
methods. For example, FreeCADGui.ActiveDocument contains ActiveView, which is the currently opened 3D view

Modules
Now you must surely wonder, what else than "Part::Box" can I do? The FreeCAD base application is more or less an empty container. Without its

modules, it can do little more than creating new, empty documents. The true power of FreeCAD is in its faithful modules. Each of them adds not only
new workbenches to the interface, but also new python commands and new object types. As a result, several different or even totally incompatible object
types can coexist in the same document. The most important modules in FreeCAD, that we'll look at in this tutorial, are Part, Mesh, Sketcher or Draft.
Sketcher and Draft both use the Part module to create and handle their geometry, which are BRep while Mesh is totally independent, and handles its
own objects. More about that below.
You can check all the available base object types for the current document like this:
doc.supportedTypes()
The different FreeCAD modules, although they added their object types to FreeCAD, are not automatically loaded in the python console. This is to avoid
having a very slow startup. Modules are loaded only when you need them. So, for example, to explore what's inside the Part module:
import Part
Part.
But we'll talk more about the Part module below.
By now, you know a bit more about the different modules of FreeCAD: The core modules (FreeCAD, FreeCADGui), and the workbenches modules (Part,
Mesh, Sketcher). The other important modules are the 3d scene module (pivy) and the interface module (pyqt), we'll talk about them too below.
Now it's time to explore a bit deeper the important ones, which are the workbench modules.

Mesh
Meshes are a very simple kind of 3D objects, used for example by Sketchup, Blender or 3D studio Max. They are composed of 3 elements: points
(also called vertices), lines (also called edges) and faces. In many applications, FreeCAD included, faces can have only 3 vertices. But of course nothing
prevents you from having a bigger plane face made of several coplanar triangles.
Meshes are simple, this can be a bad thing, but for many applications such as those above, it turns to be an advantage, because they are so simple
that you can easily have millions of them in a single document. In FreeCAD, though, they have less use, and are mostly there so you can import objects
in mesh formats (.stl, .obj) from other applications. It was also extensively used as the main test module in the first month of life of FreeCAD.
Mesh objects and FreeCAD objects are different things. You can see the FreeCAD object as a container for a Mesh object (like, we'll see below, for Part
objects too). So in order to add a mesh object to FreeCAD, we must first create a FreeCAD object and a Mesh object, then add the Mesh object to the
FreeCAD object:
import Mesh
mymesh = Mesh.createSphere()
mymesh.
mymesh.Facets
mymesh.Points
meshobj = doc.addObject("Mesh::Feature","MyMesh")
meshobj.Mesh = mymesh
doc.recompute()
This is a standard example, that uses the createSphere() method to automatically create a sphere, but you can very well create custom meshes from
scratch, by defining their vertices and faces.
Read more about mesh scripting...

Part
The Part Module is the most powerful module of the whole FreeCAD. It allows to create and manipulate BRep objects. This kind of object, unlike
meshes, can have a wide variety of components. To resume a bit, Brep means Boundary Representation. which means that they are defined by their
surfaces, which enclose and define an inner volume. These surface can be a variety of things, such as plane faces or very complex NURBS surfaces.
They also carry the concept of volume.
The Part module is based on the powerful OpenCasCade library, which allows a wide range of complex operations to be easily performed on those
objects, such as boolean operations, filleting, lofts, etc...
The Part module works the same way as the Mesh module: You create a FreeCAD object, a Part object, then add the Part object to the FreeCAD
object:
import Part
myshape = Part.makeSphere(10)
myshape.
myshape.Volume
myshape.Area
shapeobj = doc.addObject("Part::Feature","MyShape")
shapeobj.Shape = myshape
doc.recompute()
The Part module (like the Mesh module) also has a shortcut that automatically creates a FreeCAD object and add a shape to it, so you can skip the 3
last lines above:
Part.show(myshape)
By exploring the contents of myshape, you will notice many interesting available subcomponents such as Faces, Edges, Vertexes, Solids or Shells,
and a wide range of geometry operations such as cut (subtraction), common (intersection) or fuse (union). The Topological data scripting page
explains all that in detail.
Read more about part scripting...

Draft
FreeCAD features many more modules, such as Sketcher or Draft, which also create Part objects, but add parameters to it, or even carry a whole new
way to handle the Part geometry in them. Our box example above, is a perfect example of parametric object. All you need, to define the box, is to
specify a couple of parameters, such as height, width and length. Based on those, the object will automatically calculate its Part shape. FreeCAD
allows you to create such objects in python.

The Draft Module adds a couple of 2D parametric objects types (which are all Part objects) such as lines and circles, and also provides some generic
functions that work not only on Draft-made objects, but on any Part object. To explore what is available, simply do:
import Draft
Draft.
rec = Draft.makeRectangle(5,2)
mvec = FreeCAD.Vector(4,4,0)
Draft.move(rec,mvec)
Draft.move(box,mvec)

Interface
The FreeCAD user interface is made with Qt, a powerful graphical interface system, responsible for drawing and handling all the controls, menus,
toolbars, buttons around the 3D view. Qt provides a module, called PyQt, which allows python to access and modify Qt interfaces, such as FreeCAD.
Let's try to fiddle with the Qt interface and produce a simple dialog:
from PyQt4 import QtGui
QtGui.QMessageBox.information(None,"Apollo program","Houston, we have a problem")
See that the dialog that appears has the FreeCAD icon in its toolbar, meaning that Qt knows that the order has been issued from inside the FreeCAD
application. We can therefore easily directly manipulate any part of the FreeCAD interface.
Qt is a very powerful interface system, that allows you to do very complex things, but also has a couple of very easy-to use tools such as the Qt
Designer with which you can design dialogs graphically and then add them to the FreeCAD interface with a couple of lines of python.
Read more about pyqt here...

Macros
Now that you have a good understanding of the basics, where are we going to keep our python scripts, and how are we going to launch them easily from
FreeCAD? There is an easy mechanism for that, called Macros. A macro is simply a python script, that can then be added to a toolbar and be launched
from a simple mouse click. FreeCAD provides you with a simple text editor (Macro -> Macros -> Create) where you can write or paste scripts. Once it is
done, the Tools -> Customize -> Macros allow you to define a button for it, that can be added to toolbars.
Now you are ready for more in-depth FreeCAD scripting. Head on to the Power users hub!
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Python_scripting_tutorial&oldid=69838"

FreeCAD Scripting Basics


Python scripting in FreeCAD
FreeCAD is built from scratch to be totally controlled by Python scripts. Almost all parts of FreeCAD, such as the interface, the scene contents, and
even the representation of this content in the 3D views, are accessible from the built-in Python interpreter or from your own scripts. As a result, FreeCAD
is probably one of the most deeply customizable engineering applications available today.
In its current state however, FreeCAD has very few 'native' commands to interact with your 3D objects, mainly because it is still in the early stages of
development, but also because the philosophy behind it is more to provide a platform for CAD development than a specific use application. But the ease
of Python scripting inside FreeCAD is a quick way to see new functionality being developed by 'power users', typically users who know a bit of Python
programming. Python is one of the most popular interpreted languages, and because it is generally regarded as easy to learn, you too can soon be
making your own FreeCAD 'power user' scripts.
If you are not familiar with Python, we recommend you search for tutorials on the internet and have a quick look at its structure. Python is a very easy
language to learn, especially because it can be run inside an interpreter, where simple commands, right up to complete programs, can be executed on
the fly without the need to compile anything. FreeCAD has a built-in Python interpreter. If you don't see the window labeled 'Python console' as shown
below, you can activate it under the View -> Views -> Python console to bring-up the interpreter.

The interpreter
From the interpreter, you can access all your system-installed Python modules, as well as the built-in FreeCAD modules, and all additional FreeCAD
modules you installed later. The screenshot below shows the Python interpreter:

From the interpreter, you can execute Python code and browse through the available classes and functions. FreeCAD provides a very handy class
browser for exploration of your new FreeCAD world: When you type the name of a known class followed by a period (meaning you want to add
something from that class), a class browser window opens, where you can navigate between available subclasses and methods. When you select
something, an associated help text (if it exists) is displayed:

So, start here by typing App. or Gui. and see what happens. Another more generic Python way of exploring the content of modules and classes is to
use the 'print dir()' command. For example, typing print dir() will list all modules currently loaded in FreeCAD. print dir(App) will show you everything
inside the App module, etc.
Another useful feature of the interpreter is the possibility to go back through the command history and retrieve a line of code that you already typed
earlier. To navigate through the command history, just use CTRL+UP or CTRL+DOWN.
By right-clicking in the interpreter window, you also have several other options, such as copy the entire history (useful when you want to experiment with
things before making a full script of them), or insert a filename with complete path.

Python Help
In the FreeCAD Help menu, you'll find an entry labeled 'Python help', which will open a browser window containing a complete, realtime-generated
documentation of all Python modules available to the FreeCAD interpreter, including Python and FreeCAD built-in modules, system-installed modules,
and FreeCAD additional modules. The documentation available there depends on how much effort each module developer put into documenting his code,
but usually Python modules have a reputation for being fairly well documented. Your FreeCAD window must stay open for this documentation system to
work.

Built-in modules
Since FreeCAD is designed to be run without a Graphical User Interface (GUI), almost all its functionality is separated into two groups: Core
functionality, named 'App', and GUI functionality, named 'Gui'. So, our two main FreeCAD built-in modules are called App and Gui. These two modules
can also be accessed from scripts outside of the interpreter, by the names 'FreeCAD' and 'FreeCADGui' respectively.
In the App module, you'll find everything related to the application itself, like methods for opening or closing files, and to the documents, like
setting the active document or listing their contents.

In the Gui module, you'll find tools for accessing and managing Gui elements, like the workbenches and their toolbars, and, more interestingly,
the graphical representation of all FreeCAD content.
Listing all the content of those modules is a bit counter-productive task, since they grow quite fast with FreeCAD development. But the two browsing
tools provided (the class browser and the Python help) should give you, at any moment, complete and up-to-date documentation of these modules.

The App and Gui objects


As we said, in FreeCAD, everything is separated between core and representation. This includes the 3D objects too. You can access defining properties
of objects (called features in FreeCAD) via the App module, and change the way they are represented on screen via the Gui module. For example, a
cube has properties that define it, (like width, length, height) that are stored in an App object, and representation properties, (like faces color, drawing
mode) that are stored in a corresponding Gui object.
This way of doing things allows a very wide range of uses, like having algorithms work only on the definition part of features, without the need to care
about any visual part, or even redirect the content of the document to non-graphical application, such as lists, spreadsheets, or element analysis.
For every App object in your document, there exists a corresponding Gui object. Infact the document itself has both App and a Gui objects. This, of
course, is only valid when you run FreeCAD with its full interface. In the command-line version no GUI exists, so only App objects are availible. Note that
the Gui part of objects is re-generated every time an App object is marked as 'to be recomputed' (for example when one of its parameters changes), so
changes you might have made directly to the Gui object may be lost.
To access the App part of something, you type:
myObject = App.ActiveDocument.getObject("ObjectName")
where "ObjectName" is the name of your object. You can also type:
myObject = App.ActiveDocument.ObjectName
To access the Gui part of the same object, you type:
myViewObject = Gui.ActiveDocument.getObject("ObjectName")
where "ObjectName" is the name of your object. You can also type:
myViewObject = App.ActiveDocument.ObjectName.ViewObject
If we have no GUI (for example we are in command-line mode), the last line will return 'None'.

The Document objects


In FreeCAD all your work resides inside Documents. A document contains your geometry and can be saved to a file. Several documents can be opened
at the same time. The document, like the geometry contained inside, has App and Gui objects. App object contains your actual geometry definitions,
while the Gui object contains the different views of your document. You can open several windows, each one viewing your work with a different zoom
factor or point of view. These views are all part of your document's Gui object.
To access the App part the currently open (active) document, you type:
myDocument = App.ActiveDocument
To create a new document, type:
myDocument = App.newDocument("Document Name")
To access the Gui part the currently open (active) document, you type:
myGuiDocument = Gui.ActiveDocument
To access the current view, you type:
myView = Gui.ActiveDocument.ActiveView

Using additional modules


The FreeCAD and FreeCADGui modules are solely responsibles for creating and managing objects in the FreeCAD document. They don't actually do
anything such as creating or modifying geometry. That is because that geometry can be of several types, and so it is managed by additional modules,
each responsible for managing a certain geometry type. For example, the Part Module uses the OpenCascade kernel, and therefore is able to create
and manipulate B-rep type geometry, which is what OpenCascade is built for. The Mesh Module is able to build and modify mesh objects. That way,
FreeCAD is able to handle a wide variety of object types, that can all coexist in the same document, and new types could be added easily in the future.

Creating objects
Each module has its own way to treat its geometry, but one thing they usually all can do is create objects in the document. But the FreeCAD document
is also aware of the available object types provided by the modules:
FreeCAD.ActiveDocument.supportedTypes()
will list you all the possible objects you can create. For example, let's create a mesh (treated by the mesh module) and a part (treated by the part
module):
myMesh = FreeCAD.ActiveDocument.addObject("Mesh::Feature","myMeshName")
myPart = FreeCAD.ActiveDocument.addObject("Part::Feature","myPartName")
The first argument is the object type, the second the name of the object. Our two objects look almost the same: They don't contain any geometry yet,
and most of their properties are the same when you inspect them with dir(myMesh) and dir(myPart). Except for one, myMesh has a "Mesh" property and
"Part" has a "Shape" property. That is where the Mesh and Part data are stored. For example, let's create a Part cube and store it in our myPart object:

import Part
cube = Part.makeBox(2,2,2)
myPart.Shape = cube
You could try storing the cube inside the Mesh property of the myMesh object, it will return an error complaining of the wrong type. That is because
those properties are made to store only a certain type. In the myMesh's Mesh property, you can only save stuff created with the Mesh module. Note that
most modules also have a shortcut to add their geometry to the document:
import Part
cube = Part.makeBox(2,2,2)
Part.show(cube)

Modifying objects
Modifying an object is done the same way:
import Part
cube = Part.makeBox(2,2,2)
myPart.Shape = cube
Now let's change the shape by a bigger one:
biggercube = Part.makeBox(5,5,5)
myPart.Shape = biggercube

Querying objects
You can always look at the type of an object like this:
myObj = FreeCAD.ActiveDocument.getObject("myObjectName")
print myObj.Type
or know if an object is derived from one of the basic ones (Part Feature, Mesh Feature, etc):
print myObj.isDerivedFrom("Part::Feature")
Now you can really start playing with FreeCAD! To look at what you can do with the Part Module, read the Part scripting page, or the Mesh Scripting
page for working with the Mesh Module. Note that, although the Part and Mesh modules are the most complete and widely used, other modules such
as the Draft Module also have scripting APIs that can be useful to you. For a complete list of each modules and their available tools, visit the
Category:API section.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=FreeCAD_Scripting_Basics&oldid=16220"

Mesh Scripting
Introduction
First of all you have to import the Mesh module:
import Mesh
After that you have access to the Mesh module and the Mesh class which facilitate the functions of the FreeCAD C++ Mesh-Kernel.

Creation and Loading


To create an empty mesh object just use the standard constructor:
mesh = Mesh.Mesh()
You can also create an object from a file
mesh = Mesh.Mesh('D:/temp/Something.stl')
(A list of compatible filetypes can be found under 'Meshes' here.)
Or create it out of a set of triangles described by their corner points:
planarMesh = [
# triangle 1
[-0.5000,-0.5000,0.0000],[0.5000,0.5000,0.0000],[-0.5000,0.5000,0.0000],
#triangle 2
[-0.5000,-0.5000,0.0000],[0.5000,-0.5000,0.0000],[0.5000,0.5000,0.0000],
]
planarMeshObject = Mesh.Mesh(planarMesh)
The Mesh-Kernel takes care about creating a topological correct data structure by sorting coincident points and edges together.
Later on you will see how you can test and examine mesh data.

Modeling
To create regular geometries you can use the Python script BuildRegularGeoms.py.
import BuildRegularGeoms
This script provides methods to define simple rotation bodies like spheres, ellipsoids, cylinders, toroids and cones. And it also has a method to create a
simple cube. To create a toroid, for instance, can be done as follows:
t = BuildRegularGeoms.Toroid(8.0, 2.0, 50) # list with several thousands triangles
m = Mesh.Mesh(t)
The first two parameters define the radiuses of the toroid and the third parameter is a sub-sampling factor for how many triangles are created. The higher
this value the smoother and the lower the coarser the body is. The Mesh class provides a set of boolean functions that can be used for modeling
purposes. It provides union, intersection and difference of two mesh objects.
m1, m2
# are the input mesh objects
m3 = Mesh.Mesh(m1) # create a copy of m1
m3.unite(m2)
# union of m1 and m2, the result is stored in m3
m4 = Mesh.Mesh(m1)
m4.intersect(m2)
# intersection of m1 and m2
m5 = Mesh.Mesh(m1)
m5.difference(m2)
# the difference of m1 and m2
m6 = Mesh.Mesh(m2)
m6.difference(m1)
# the difference of m2 and m1, usually the result is different to m5
Finally, a full example that computes the intersection between a sphere and a cylinder that intersects the sphere.
import Mesh, BuildRegularGeoms
sphere = Mesh.Mesh( BuildRegularGeoms.Sphere(5.0, 50) )
cylinder = Mesh.Mesh( BuildRegularGeoms.Cylinder(2.0, 10.0, True, 1.0, 50) )
diff = sphere
diff.difference(cylinder)
d = FreeCAD.newDocument()
d.addObject("Mesh::Feature","Diff_Sphere_Cylinder").Mesh=diff
d.recompute()

Examining and Testing


Write your own Algorithms
Exporting
You can even write the mesh to a python module:
m.write("D:/Develop/Projekte/FreeCAD/FreeCAD_0.7/Mod/Mesh/SavedMesh.py")
import SavedMesh
m2 = Mesh.Mesh(SavedMesh.faces)

Gui related stuff


Odds and Ends

An extensive (though hard to use) source of Mesh related scripting are the unit test scripts of the Mesh-Module. In this unit tests literally all methods are
called and all properties/attributes are tweaked. So if you are bold enough, take a look at the Unit Test module.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Mesh_Scripting&oldid=50944"

Topological data scripting


This page describes several methods for creating and modifying Part shapes from python. Before reading this page, if you are new to python, it is a
good idea to read about python scripting and how python scripting works in FreeCAD.

Introduction
We will here explain you how to control the Part Module directly from the FreeCAD python interpreter, or from any external script. Be sure to browse
the Scripting section and the FreeCAD Scripting Basics pages if you need more information about how python scripting works in FreeCAD.

Class Diagram
This is a Unified Modeling Language (UML) overview of the most important classes of the Part module:

Geometry
The geometric objects are the building block of all topological objects:
Geom Base class of the geometric objects
Line A straight line in 3D, defined by starting point and and point
Circle Circle or circle segment defined by a center point and start and end point
...... And soon some more ;-)

Topology
The following topological data types are available:
Compound A group of any type of topological object.
Compsolid A composite solid is a set of solids connected by their faces. It expands the notions of WIRE and SHELL to solids.
Solid A part of space limited by shells. It is three dimensional.
Shell A set of faces connected by their edges. A shell can be open or closed.
Face In 2D it is part of a plane; in 3D it is part of a surface. Its geometry is constrained (trimmed) by contours. It is two dimensional.
Wire A set of edges connected by their vertices. It can be an open or closed contour depending on whether the edges are linked or not.
Edge A topological element corresponding to a restrained curve. An edge is generally limited by vertices. It has one dimension.
Vertex A topological element corresponding to a point. It has zero dimension.
Shape A generic term covering all of the above.

Quick example : Creating simple topology

We will now create a topology by constructing it out of simpler geometry. As a case study we use a part as seen in the picture which consists of four
vertexes, two circles and two lines.

Creating Geometry
First we have to create the distinct geometric parts of this wire. And we have to take care that the vertexes of the geometric parts are at the same
position. Otherwise later on we might not be able to connect the geometric parts to a topology!
So we create first the points:
from
V1 =
V2 =
V3 =
V4 =

FreeCAD import Base


Base.Vector(0,10,0)
Base.Vector(30,10,0)
Base.Vector(30,-10,0)
Base.Vector(0,-10,0)

Arc

To create an arc of circle we make a helper point and create the arc of circle through three points:
VC1 = Base.Vector(-10,0,0)
C1 = Part.Arc(V1,VC1,V4)
# and the second one
VC2 = Base.Vector(40,0,0)
C2 = Part.Arc(V2,VC2,V3)
Line

The line can be created very simple out of the points:


L1 = Part.Line(V1,V2)
# and the second one
L2 = Part.Line(V4,V3)
Putting all together
The last step is to put the geometric base elements together and bake a topological shape:
S1 = Part.Shape([C1,C2,L1,L2])
Make a prism
Now extrude the wire in a direction and make an actual 3D shape:
W = Part.Wire(S1.Edges)
P = W.extrude(Base.Vector(0,0,10))
Show it all
Part.show(P)

Creating basic shapes


You can easily create basic topological objects with the "make...()" methods from the Part Module:
b = Part.makeBox(100,100,100)
Part.show(b)
A couple of other make...() methods available:
makeBox(l,w,h): Makes a box located in p and pointing into the direction d with the dimensions (l,w,h)
makeCircle(radius): Makes a circle with a given radius
makeCone(radius1,radius2,height): Makes a cone with a given radii and height
makeCylinder(radius,height): Makes a cylinder with a given radius and height.
makeLine((x1,y1,z1),(x2,y2,z2)): Makes a line of two points
makePlane(length,width): Makes a plane with length and width
makePolygon(list): Makes a polygon of a list of points
makeSphere(radius): Make a sphere with a given radius
makeTorus(radius1,radius2): Makes a torus with a given radii
See the Part API page for a complete list of available methods of the Part module.
Importing the needed modules

First we need to import the Part module so we can use its contents in python. We'll also import the Base module from inside the FreeCAD module:
import Part
from FreeCAD import Base
Creating a Vector
Vectors are one of the most important pieces of information when building shapes. They contain a 3 numbers usually (but not necessarily always) the x,
y and z cartesian coordinates. You create a vector like this:
myVector = Base.Vector(3,2,0)
We just created a vector at coordinates x=3, y=2, z=0. In the Part module, vectors are used everywhere. Part shapes also use another kind of point
representation, called Vertex, which is acually nothing else than a container for a vector. You access the vector of a vertex like this:
myVertex = myShape.Vertexes[0]
print myVertex.Point
> Vector (3, 2, 0)
Creating an Edge
An edge is nothing but a line with two vertexes:
edge = Part.makeLine((0,0,0), (10,0,0))
edge.Vertexes
> [<Vertex object at 01877430>, <Vertex object at 014888E0>]
Note: You can also create an edge by passing two vectors:
vec1
vec2
line
edge

=
=
=
=

Base.Vector(0,0,0)
Base.Vector(10,0,0)
Part.Line(vec1,vec2)
line.toShape()

You can find the length and center of an edge like this:
edge.Length
> 10.0
edge.CenterOfMass
> Vector (5, 0, 0)
Putting the shape on screen
So far we created an edge object, but it doesn't appear anywhere on screen. This is because we just manipulated python objects here. The FreeCAD 3D
scene only displays what you tell it to display. To do that, we use this simple method:
Part.show(edge)
An object will be created in our FreeCAD document, and our "edge" shape will be attributed to it. Use this whenever it's time to display your creation on
screen.
Creating a Wire
A wire is a multi-edge line and can be created from a list of edges or even a list of wires:
edge1 = Part.makeLine((0,0,0), (10,0,0))
edge2 = Part.makeLine((10,0,0), (10,10,0))
wire1 = Part.Wire([edge1,edge2])
edge3 = Part.makeLine((10,10,0), (0,10,0))
edge4 = Part.makeLine((0,10,0), (0,0,0))
wire2 = Part.Wire([edge3,edge4])
wire3 = Part.Wire([wire1,wire2])
wire3.Edges
> [<Edge object at 016695F8>, <Edge object at 0197AED8>, <Edge object at 01828B20>, <Edge object at 0190A788>]
Part.show(wire3)
Part.show(wire3) will display the 4 edges that compose our wire. Other useful information can be easily retrieved:
wire3.Length
> 40.0
wire3.CenterOfMass
> Vector (5, 5, 0)
wire3.isClosed()
> True
wire2.isClosed()
> False
Creating a Face
Only faces created from closed wires will be valid. In this example, wire3 is a closed wire but wire2 is not a closed wire (see above)
face = Part.Face(wire3)
face.Area
> 99.999999999999972

face.CenterOfMass
> Vector (5, 5, 0)
face.Length
> 40.0
face.isValid()
> True
sface = Part.Face(wire2)
face.isValid()
> False
Only faces will have an area, not wires nor edges.
Creating a Circle
A circle can be created as simply as this:
circle = Part.makeCircle(10)
circle.Curve
> Circle (Radius : 10, Position : (0, 0, 0), Direction : (0, 0, 1))
If you want to create it at certain position and with certain direction:
ccircle = Part.makeCircle(10, Base.Vector(10,0,0), Base.Vector(1,0,0))
ccircle.Curve
> Circle (Radius : 10, Position : (10, 0, 0), Direction : (1, 0, 0))
ccircle will be created at distance 10 from origin on x and will be facing towards x axis. Note: makeCircle only accepts Base.Vector() for position and
normal but not tuples. You can also create part of the circle by giving start angle and end angle as:
from math import pi
arc1 = Part.makeCircle(10, Base.Vector(0,0,0), Base.Vector(0,0,1), 0, 180)
arc2 = Part.makeCircle(10, Base.Vector(0,0,0), Base.Vector(0,0,1), 180, 360)
Both arc1 and arc2 jointly will make a circle. Angles should be provided in degrees, if you have radians simply convert them using formula: degrees =
radians * 180/PI or using python's math module (after doing import math, of course):
degrees = math.degrees(radians)
Creating an Arc along points
Unfortunately there is no makeArc function but we have Part.Arc function to create an arc along three points. Basically it can be supposed as an arc
joining start point and end point along the middle point. Part.Arc creates an arc object on which .toShape() has to be called to get the edge object, the
same way as when using Part.Line instead of Part.makeLine.
arc = Part.Arc(Base.Vector(0,0,0),Base.Vector(0,5,0),Base.Vector(5,5,0))
arc
> <Arc object>
arc_edge = arc.toShape()
Arc only accepts Base.Vector() for points but not tuples. arc_edge is what we want which we can display using Part.show(arc_edge). You can also
obtain an arc by using a portion of a circle:
from math import pi
circle = Part.Circle(Base.Vector(0,0,0),Base.Vector(0,0,1),10)
arc = Part.Arc(c,0,pi)
Arcs are valid edges, like lines. So they can be used in wires too.
Creating a polygon
A polygon is simply a wire with multiple straight edges. The makePolygon function takes a list of points and creates a wire along those points:
lshape_wire = Part.makePolygon([Base.Vector(0,5,0),Base.Vector(0,0,0),Base.Vector(5,0,0)])
Creating a Bezier curve
Bzier curves are used to model smooth curves using a series of poles (points) and optional weights. The function below makes a Part.BezierCurve from
a series of FreeCAD.Vector points. (Note: pole and weight indices start at 1, not 0.)
def makeBCurve(Points):
c = Part.BezierCurve()
c.setPoles(Points)
return(c)
Creating a Plane
A Plane is simply a flat rectangular surface. The method used to create one is this: makePlane(length,width,[start_pnt,dir_normal]). By default
start_pnt = Vector(0,0,0) and dir_normal = Vector(0,0,1). Using dir_normal = Vector(0,0,1) will create the plane facing z axis, while dir_normal =
Vector(1,0,0) will create the plane facing x axis:
plane = Part.makePlane(2,2)
plane
><Face object at 028AF990>
plane = Part.makePlane(2,2, Base.Vector(3,0,0), Base.Vector(0,1,0))
plane.BoundBox
> BoundBox (3, 0, 0, 5, 0, 2)

BoundBox is a cuboid enclosing the plane with a diagonal starting at (3,0,0) and ending at (5,0,2). Here the BoundBox thickness in y axis is zero, since
our shape is totally flat.
Note: makePlane only accepts Base.Vector() for start_pnt and dir_normal but not tuples
Creating an ellipse
To create an ellipse there are several ways:
Part.Ellipse()
Creates an ellipse with major radius 2 and minor radius 1 with the center in (0,0,0)
Part.Ellipse(Ellipse)
Create a copy of the given ellipse
Part.Ellipse(S1,S2,Center)
Creates an ellipse centered on the point Center, where the plane of the ellipse is defined by Center, S1 and S2, its major axis is defined by Center and
S1, its major radius is the distance between Center and S1, and its minor radius is the distance between S2 and the major axis.
Part.Ellipse(Center,MajorRadius,MinorRadius)
Creates an ellipse with major and minor radii MajorRadius and MinorRadius, and located in the plane defined by Center and the normal (0,0,1)
eli = Part.Ellipse(Base.Vector(10,0,0),Base.Vector(0,5,0),Base.Vector(0,0,0))
Part.show(eli.toShape())
In the above code we have passed S1, S2 and center. Similarly to Arc, Ellipse also creates an ellipse object but not edge, so we need to convert it into
edge using toShape() to display.
Note: Arc only accepts Base.Vector() for points but not tuples
eli = Part.Ellipse(Base.Vector(0,0,0),10,5)
Part.show(eli.toShape())
for the above Ellipse constructor we have passed center, MajorRadius and MinorRadius
Creating a Torus
Using the method makeTorus(radius1,radius2,[pnt,dir,angle1,angle2,angle]). By default pnt=Vector(0,0,0),dir=Vector(0,0,1),angle1=0,angle2=360
and angle=360. Consider a torus as small circle sweeping along a big circle. Radius1 is the radius of big cirlce, radius2 is the radius of small circle, pnt
is the center of torus and dir is the normal direction. angle1 and angle2 are angles in radians for the small circle, the last parameter angle is to make a
section of the torus:
torus = Part.makeTorus(10, 2)
The above code will create a torus with diameter 20(radius 10) and thickness 4 (small cirlce radius 2)
tor=Part.makeTorus(10,5,Base.Vector(0,0,0),Base.Vector(0,0,1),0,180)
The above code will create a slice of the torus
tor=Part.makeTorus(10,5,Base.Vector(0,0,0),Base.Vector(0,0,1),0,360,180)
The above code will create a semi torus, only the last parameter is changed i.e the angle and remaining angles are defaults. Giving the angle 180 will
create the torus from 0 to 180, that is, a half torus.
Creating a box or cuboid
Using makeBox(length,width,height,[pnt,dir]). By default pnt=Vector(0,0,0) and dir=Vector(0,0,1)
box = Part.makeBox(10,10,10)
len(box.Vertexes)
> 8
Creating a Sphere
U s i n g makeSphere(radius,[pnt, dir, angle1,angle2,angle3]). By default pnt=Vector(0,0,0), dir=Vector(0,0,1), angle1=-90, angle2=90 and
angle3=360. angle1 and angle2 are the vertical minimum and maximum of the sphere, angle3 is the sphere diameter itself.
sphere = Part.makeSphere(10)
hemisphere = Part.makeSphere(10,Base.Vector(0,0,0),Base.Vector(0,0,1),-90,90,180)
Creating a Cylinder
Using makeCylinder(radius,height,[pnt,dir,angle]). By default pnt=Vector(0,0,0),dir=Vector(0,0,1) and angle=360
cylinder = Part.makeCylinder(5,20)
partCylinder = Part.makeCylinder(5,20,Base.Vector(20,0,0),Base.Vector(0,0,1),180)
Creating a Cone

Using makeCone(radius1,radius2,height,[pnt,dir,angle]). By default pnt=Vector(0,0,0), dir=Vector(0,0,1) and angle=360


cone = Part.makeCone(10,0,20)
semicone = Part.makeCone(10,0,20,Base.Vector(20,0,0),Base.Vector(0,0,1),180)

Modifying shapes
There are several ways to modify shapes. Some are simple transformation operations such as moving or rotating shapes, other are more complex, such
as unioning and subtracting one shape from another. Be aware that

Transform operations
Translating a shape
Translating is the act of moving a shape from one place to another. Any shape (edge, face, cube, etc...) can be translated the same way:
myShape = Part.makeBox(2,2,2)
myShape.translate(Base.Vector(2,0,0))
This will move our shape "myShape" 2 units in the x direction.
Rotating a shape
To rotate a shape, you need to specify the rotation center, the axis, and the rotation angle:
myShape.rotate(Vector(0,0,0),Vector(0,0,1),180)
The above code will rotate the shape 180 degrees around the Z Axis.
Generic transformations with matrixes
A matrix is a very convenient way to store transformations in the 3D world. In a single matrix, you can set translation, rotation and scaling values to be
applied to an object. For example:
myMat = Base.Matrix()
myMat.move(Base.Vector(2,0,0))
myMat.rotateZ(math.pi/2)
Note: FreeCAD matrixes work in radians. Also, almost all matrix operations that take a vector can also take 3 numbers, so those 2 lines do the same
thing:
myMat.move(2,0,0)
myMat.move(Base.Vector(2,0,0))
When our matrix is set, we can apply it to our shape. FreeCAD provides 2 methods to do that: transformShape() and transformGeometry(). The
difference is that with the first one, you are sure that no deformations will occur (see "scaling a shape" below). So we can apply our transformation like
this:
myShape.trasformShape(myMat)
or
myShape.transformGeometry(myMat)
Scaling a shape
Scaling a shape is a more dangerous operation because, unlike translation or rotation, scaling non-uniformly (with different values for x, y and z) can
modify the structure of the shape. For example, scaling a circle with a higher value horizontally than vertically will transform it into an ellipse, which
behaves mathematically very differenty. For scaling, we can't use the transformShape, we must use transformGeometry():
myMat = Base.Matrix()
myMat.scale(2,1,1)
myShape=myShape.transformGeometry(myMat)

Boolean Operations
Subtraction
Subtracting a shape from another one is called "cut" in OCC/FreeCAD jargon and is done like this:
cylinder = Part.makeCylinder(3,10,Base.Vector(0,0,0),Base.Vector(1,0,0))
sphere = Part.makeSphere(5,Base.Vector(5,0,0))
diff = cylinder.cut(sphere)
Intersection
The same way, the intersection between 2 shapes is called "common" and is done this way:
cylinder1 = Part.makeCylinder(3,10,Base.Vector(0,0,0),Base.Vector(1,0,0))
cylinder2 = Part.makeCylinder(3,10,Base.Vector(5,0,-5),Base.Vector(0,0,1))
common = cylinder1.common(cylinder2)

Union
Union is called "fuse" and works the same way:
cylinder1 = Part.makeCylinder(3,10,Base.Vector(0,0,0),Base.Vector(1,0,0))
cylinder2 = Part.makeCylinder(3,10,Base.Vector(5,0,-5),Base.Vector(0,0,1))
fuse = cylinder1.fuse(cylinder2)
Section
A Section is the intersection between a solid shape and a plane shape. It will return an intersection curve, a compound with edges
cylinder1 = Part.makeCylinder(3,10,Base.Vector(0,0,0),Base.Vector(1,0,0))
cylinder2 = Part.makeCylinder(3,10,Base.Vector(5,0,-5),Base.Vector(0,0,1))
section = cylinder1.section(cylinder2)
section.Wires
> []
section.Edges
> [<Edge object at 0D87CFE8>, <Edge object at 019564F8>, <Edge object at 0D998458>,
<Edge object at 0D86DE18>, <Edge object at 0D9B8E80>, <Edge object at 012A3640>,
<Edge object at 0D8F4BB0>]
Extrusion
Extrusion is the act of "pushing" a flat shape in a certain direction resulting in a solid body. Think of a circle becoming a tube by "pushing it out":
circle = Part.makeCircle(10)
tube = circle.extrude(Base.Vector(0,0,2))
If your circle is hollow, you will obtain a hollow tube. If your circle is actually a disc, with a filled face, you will obtain a solid cylinder:
wire = Part.Wire(circle)
disc = Part.makeFace(wire)
cylinder = disc.extrude(Base.Vector(0,0,2))

Exploring shapes
You can easily explore the topological data structure:
import Part
b = Part.makeBox(100,100,100)
b.Wires
w = b.Wires[0]
w
w.Wires
w.Vertexes
Part.show(w)
w.Edges
e = w.Edges[0]
e.Vertexes
v = e.Vertexes[0]
v.Point
By typing the lines above in the python interpreter, you will gain a good understanding of the structure of Part objects. Here, our makeBox() command
created a solid shape. This solid, like all Part solids, contains faces. Faces always contain wires, which are lists of edges that border the face. Each
face has at least one closed wire (it can have more if the face has a hole). In the wire, we can look at each edge separately, and inside each edge, we
can see the vertexes. Straight edges have only two vertexes, obviously.

Edge analysis
In case of an edge, which is an arbitrary curve, it's most likely you want to do a discretization. In FreeCAD the edges are parametrized by their lengths.
That means you can walk an edge/curve by its length:
import Part
box = Part.makeBox(100,100,100)
anEdge = box.Edges[0]
print anEdge.Length
Now you can access a lot of properties of the edge by using the length as a position. That means if the edge is 100mm long the start position is 0 and
the end position 100.
anEdge.tangentAt(0.0)
# tangent direction at the beginning
anEdge.valueAt(0.0)
# Point at the beginning
anEdge.valueAt(100.0)
# Point at the end of the edge
anEdge.derivative1At(50.0) # first derivative of the curve in the middle
anEdge.derivative2At(50.0) # second derivative of the curve in the middle
anEdge.derivative3At(50.0) # third derivative of the curve in the middle
anEdge.centerOfCurvatureAt(50) # center of the curvature for that position
anEdge.curvatureAt(50.0)
# the curvature
anEdge.normalAt(50)
# normal vector at that position (if defined)

Using the selection


Here we see now how we can use the selection the user did in the viewer. First of all we create a box and shows it in the viewer
import Part
Part.show(Part.makeBox(100,100,100))

Gui.SendMsgToActiveView("ViewFit")
Select now some faces or edges. With this script you can iterate all selected objects and their sub elements:
for o
print
for s
print
for s
print

in Gui.Selection.getSelectionEx():
o.ObjectName
in o.SubElementNames:
"name: ",s
in o.SubObjects:
"object: ",s

Select some edges and this script will calculate the length:
length = 0.0
for o in Gui.Selection.getSelectionEx():
for s in o.SubObjects:
length += s.Length
print "Length of the selected edges:" ,length

Complete example: The OCC bottle


A typical example found on the OpenCasCade Getting Started Page is how to build a bottle. This is a good exercise for FreeCAD too. In fact, you can
follow our example below and the OCC page simultaneously, you will understand well how OCC structures are implemented in FreeCAD. The complete
script below is also included in FreeCAD installation (inside the Mod/Part folder) and can be called from the python interpreter by typing:
import Part
import MakeBottle
bottle = MakeBottle.makeBottle()
Part.show(bottle)

The complete script


Here is the complete MakeBottle script:
import Part, FreeCAD, math
from FreeCAD import Base
def makeBottle(myWidth=50.0, myHeight=70.0, myThickness=30.0):
aPnt1=Base.Vector(-myWidth/2.,0,0)
aPnt2=Base.Vector(-myWidth/2.,-myThickness/4.,0)
aPnt3=Base.Vector(0,-myThickness/2.,0)
aPnt4=Base.Vector(myWidth/2.,-myThickness/4.,0)
aPnt5=Base.Vector(myWidth/2.,0,0)
aArcOfCircle = Part.Arc(aPnt2,aPnt3,aPnt4)
aSegment1=Part.Line(aPnt1,aPnt2)
aSegment2=Part.Line(aPnt4,aPnt5)
aEdge1=aSegment1.toShape()
aEdge2=aArcOfCircle.toShape()
aEdge3=aSegment2.toShape()
aWire=Part.Wire([aEdge1,aEdge2,aEdge3])
aTrsf=Base.Matrix()
aTrsf.rotateZ(math.pi) # rotate around the z-axis
aMirroredWire=aWire.transformGeometry(aTrsf)
myWireProfile=Part.Wire([aWire,aMirroredWire])
myFaceProfile=Part.Face(myWireProfile)
aPrismVec=Base.Vector(0,0,myHeight)
myBody=myFaceProfile.extrude(aPrismVec)
myBody=myBody.makeFillet(myThickness/12.0,myBody.Edges)
neckLocation=Base.Vector(0,0,myHeight)
neckNormal=Base.Vector(0,0,1)
myNeckRadius = myThickness / 4.
myNeckHeight = myHeight / 10
myNeck = Part.makeCylinder(myNeckRadius,myNeckHeight,neckLocation,neckNormal)
myBody = myBody.fuse(myNeck)
faceToRemove = 0
zMax = -1.0
for xp in myBody.Faces:
try:
surf = xp.Surface
if type(surf) == Part.Plane:
z = surf.Position.z
if z > zMax:
zMax = z
faceToRemove = xp
except:
continue
myBody = myBody.makeThickness([faceToRemove],-myThickness/50 , 1.e-3)
return myBody

Detailed explanation

import Part, FreeCAD, math


from FreeCAD import Base
We will need,of course, the Part module, but also the FreeCAD.Base module, which contains basic FreeCAD structures like vectors and matrixes.
def makeBottle(myWidth=50.0, myHeight=70.0, myThickness=30.0):
aPnt1=Base.Vector(-myWidth/2.,0,0)
aPnt2=Base.Vector(-myWidth/2.,-myThickness/4.,0)
aPnt3=Base.Vector(0,-myThickness/2.,0)
aPnt4=Base.Vector(myWidth/2.,-myThickness/4.,0)
aPnt5=Base.Vector(myWidth/2.,0,0)
Here we define our makeBottle function. This function can be called without arguments, like we did above, in which case default values for width, height,
and thickness will be used. Then, we define a couple of points that will be used for building our base profile.
aArcOfCircle = Part.Arc(aPnt2,aPnt3,aPnt4)
aSegment1=Part.Line(aPnt1,aPnt2)
aSegment2=Part.Line(aPnt4,aPnt5)
Here we actually define the geometry: an arc, made of 3 points, and two line segments, made of 2 points.
aEdge1=aSegment1.toShape()
aEdge2=aArcOfCircle.toShape()
aEdge3=aSegment2.toShape()
aWire=Part.Wire([aEdge1,aEdge2,aEdge3])
Remember the difference between geometry and shapes? Here we build shapes out of our construction geometry. 3 edges (edges can be straight or
curved), then a wire made of those three edges.
aTrsf=Base.Matrix()
aTrsf.rotateZ(math.pi) # rotate around the z-axis
aMirroredWire=aWire.transformGeometry(aTrsf)
myWireProfile=Part.Wire([aWire,aMirroredWire])
Until now we built only a half profile. Easier than building the whole profile the same way, we can just mirror what we did, and glue both halfs together.
So we first create a matrix. A matrix is a very common way to apply transformations to objects in the 3D world, since it can contain in one structure all
basic transformations that 3D objects can suffer (move, rotate and scale). Here, after we create the matrix, we mirror it, and we create a copy of our wire
with that transformation matrix applied to it. We now have two wires, and we can make a third wire out of them, since wires are actually lists of edges.
myFaceProfile=Part.Face(myWireProfile)
aPrismVec=Base.Vector(0,0,myHeight)
myBody=myFaceProfile.extrude(aPrismVec)
myBody=myBody.makeFillet(myThickness/12.0,myBody.Edges)
Now that we have a closed wire, it can be turned into a face. Once we have a face, we can extrude it. Doing so, we actually made a solid. Then we apply
a nice little fillet to our object because we care about good design, don't we?
neckLocation=Base.Vector(0,0,myHeight)
neckNormal=Base.Vector(0,0,1)
myNeckRadius = myThickness / 4.
myNeckHeight = myHeight / 10
myNeck = Part.makeCylinder(myNeckRadius,myNeckHeight,neckLocation,neckNormal)
Then, the body of our bottle is made, we still need to create a neck. So we make a new solid, with a cylinder.
myBody = myBody.fuse(myNeck)
The fuse operation, which in other apps is sometimes called union, is very powerful. It will take care of gluing what needs to be glued and remove parts
that need to be removed.
return myBody
Then, we return our Part solid as the result of our function. That Part solid, like any other Part shape, can be attributed to an object in a FreeCAD
document, with:
myObject = FreeCAD.ActiveDocument.addObject("Part::Feature","myObject")
myObject.Shape = bottle
or, more simple:
Part.show(bottle)

Box pierced
Here a complete example of building a box pierced.
The construction is done side by side and when the cube is finished, it is hollowed out of a cylinder through.
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, PyQt4
from math import sqrt, pi, sin, cos, asin
from FreeCAD import Base
size = 10
poly = Part.makePolygon( [ (0,0,0), (size, 0, 0), (size, 0, size), (0, 0, size), (0, 0, 0)])

face1
face2
face3
face4
face5
face6

=
=
=
=
=
=

Part.Face(poly)
Part.Face(poly)
Part.Face(poly)
Part.Face(poly)
Part.Face(poly)
Part.Face(poly)

myMat = FreeCAD.Matrix()
myMat.rotateZ(math.pi/2)
face2.transformShape(myMat)
face2.translate(FreeCAD.Vector(size, 0, 0))
myMat.rotateZ(math.pi/2)
face3.transformShape(myMat)
face3.translate(FreeCAD.Vector(size, size, 0))
myMat.rotateZ(math.pi/2)
face4.transformShape(myMat)
face4.translate(FreeCAD.Vector(0, size, 0))
myMat = FreeCAD.Matrix()
myMat.rotateX(-math.pi/2)
face5.transformShape(myMat)
face6.transformShape(myMat)
face6.translate(FreeCAD.Vector(0,0,size))
myShell = Part.makeShell([face1,face2,face3,face4,face5,face6])
mySolid = Part.makeSolid(myShell)
mySolidRev = mySolid.copy()
mySolidRev.reverse()
myCyl = Part.makeCylinder(2,20)
myCyl.translate(FreeCAD.Vector(size/2, size/2, 0))
cut_part = mySolidRev.cut(myCyl)
Part.show(cut_part)

Loading and Saving


There are several ways to save your work in the Part module. You can of course save your FreeCAD document, but you can also save Part objects
directly to common CAD formats, such as BREP, IGS, STEP and STL.
Saving a shape to a file is easy. There are exportBrep(), exportIges(), exportStl() and exportStep() methods availables for all shape objects. So, doing:
import Part
s = Part.makeBox(0,0,0,10,10,10)
s.exportStep("test.stp")
this will save our box into a STEP file. To load a BREP, IGES or STEP file, simply do the contrary:
import Part
s = Part.Shape()
s.read("test.stp")
To convert an .stp in .igs file simply :
import Part
s = Part.Shape()
s.read("file.stp")
# incoming file igs, stp, stl, brep
s.exportIges("file.igs") # outbound file igs
Note that importing or opening BREP, IGES or STEP files can also be done directly from the File -> Open or File -> Import menu, while exporting is with
File -> Export
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Topological_data_scripting&oldid=42021"

Mesh to Part
Converting Part objects to Meshes
Converting higher-level objects such as Part shapes into simpler objects such as meshes is a pretty simple operation, where all faces of a Part object
get triangulated. The result of that triangulation (tessellation) is then used to construct a mesh:
#let's assume our document contains one part object
import Mesh
faces = []
shape = FreeCAD.ActiveDocument.ActiveObject.Shape
triangles = shape.tessellate(1) # the number represents the precision of the tessellation)
for tri in triangles[1]:
face = []
for i in range(3):
vindex = tri[i]
face.append(triangles[0][vindex])
faces.append(face)
m = Mesh.Mesh(faces)
Mesh.show(m)
Sometimes the triangulation of certain faces offered by OpenCascade is quite ugly. If the face has a rectangular parameter space and doesn't contain
any holes or other trimming curves you can also create a mesh on your own:
import Mesh
def makeMeshFromFace(u,v,face):
(a,b,c,d)=face.ParameterRange
pts=[]
for j in range(v):
for i in range(u):
s=1.0/(u-1)*(i*b+(u-1-i)*a)
t=1.0/(v-1)*(j*d+(v-1-j)*c)
pts.append(face.valueAt(s,t))
mesh=Mesh.Mesh()
for j in range(v-1):
for i in range(u-1):
mesh.addFacet(pts[u*j+i],pts[u*j+i+1],pts[u*(j+1)+i])
mesh.addFacet(pts[u*(j+1)+i],pts[u*j+i+1],pts[u*(j+1)+i+1])
return mesh

Converting Meshes to Part objects


Converting Meshes to Part objects is an extremely important operation in CAD work, because very often you receive 3D data in mesh format from other
people or outputted from other applications. Meshes are very practical to represent free-form geometry and big visual scenes, as it is very lightweight, but
for CAD we generally prefer higher-level objects that carry much more information, such as the idea of solid, or faces made of curves instead of triangles.
Converting meshes to those higher-level objects (handled by the Part Module in FreeCAD) is not an easy operation. Meshes can be made of thousands
of triangles (for example when generated by a 3D scanner), and having solids made of the same number of faces would be extremely heavy to
manipulate. So you generally want to optimize the object when converting.
FreeCAD currently offers two methods to convert Meshes to Part objects. The first method is a simple, direct conversion, without any optimization:
import Mesh,Part
mesh = Mesh.createTorus()
shape = Part.Shape()
shape.makeShapeFromMesh(mesh.Topology,0.05) # the second arg is the tolerance for sewing
solid = Part.makeSolid(shape)
Part.show(solid)
The second method offers the possibility to consider mesh facets coplanar when the angle between them is under a certain value. This allows to build
much simpler shapes:
# let's assume our document contains one Mesh object
import Mesh,Part,MeshPart
faces = []
mesh = App.ActiveDocument.ActiveObject.Mesh
segments = mesh.getPlanes(0.00001) # use rather strict tolerance here
for i in segments:
if len(i) > 0:
# a segment can have inner holes
wires = MeshPart.wireFromSegment(mesh, i)
# we assume that the exterior boundary is that one with the biggest bounding box
if len(wires) > 0:
ext=None
max_length=0
for i in wires:
if i.BoundBox.DiagonalLength > max_length:
max_length = i.BoundBox.DiagonalLength
ext = i
wires.remove(ext)
# all interior wires mark a hole and must reverse their orientation, otherwise Part.Face fails
for i in wires:

i.reverse()
# make sure that the exterior wires comes as first in the lsit
wires.insert(0, ext)
faces.append(Part.Face(wires))
shell=Part.Compound(faces)
Part.show(shell)
#solid = Part.Solid(Part.Shell(faces))
#Part.show(solid)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Mesh_to_Part&oldid=16733"

Scenegraph
FreeCAD is basically a collage of different powerful libraries, the most important being openCascade, for managing and constructing geometry, Coin3d
to display that geometry, and Qt to put all this in a nice Graphical User Interface.
The geometry that appears in the 3D views of FreeCAD are rendered by the Coin3D library. Coin3D is an implementation of the OpenInventor standard.
The openCascade software also provides the same functionality, but it was decided, at the very beginnings of FreeCAD, not to use the built-in
openCascade viewer and rather switch to the more performant coin3D software. A good way to learn about that library is the book Open Inventor
Mentor.
OpenInventor is actually a 3D scene description language. The scene described in openInventor is then rendered in OpenGL on your screen. Coin3D
takes care of doing this, so the programmer doesn't need to deal with complex openGL calls, he just has to provide it with valid OpenInventor code. The
big advantage is that openInventor is a very well-known and well documented standard.
One of the big jobs FreeCAD does for you is basically to translate openCascade geometry information into openInventor language.
OpenInventor describes a 3D scene in the form of a scenegraph, like the one below:

image from Inventor mentor


An openInventor scenegraph describes everything that makes part of a 3D scene, such as geometry, colors, materials, lights, etc, and organizes all that
data in a convenient and clear structure. Everything can be grouped into sub-structures, allowing you to organize your scene contents pretty much the
way you like. Here is an example of an openInventor file:
#Inventor V2.0 ascii
Separator {
RotationXYZ {
axis Z
angle 0
}
Transform {
translation 0 0 0.5
}
Separator {
Material {
diffuseColor 0.05 0.05 0.05
}
Transform {
rotation 1 0 0 1.5708
scaleFactor 0.2 0.5 0.2
}
Cylinder {
}
}
}
As you can see, the structure is very simple. You use separators to organize your data into blocks, a bit like you would organize your files into folders.
Each statement affects what comes next, for example the first two items of our root separator are a rotation and a translation, both will affect the next
item, which is a separator. In that separator, a material is defined, and another transformation. Our cylinder will therefore be affected by both
transformations, the one who was applied directly to it and the one that was applied to its parent separator.
We also have many other types of elements to organize our scene, such as groups, switches or annotations. We can define very complex materials for
our objects, with color, textures, shading modes and transparency. We can also define lights, cameras, and even movement. It is even possible to
embed pieces of scripting in openInventor files, to define more complex behaviours.
If you are interested in learning more about openInventor, head directly to its most famous reference, the Inventor mentor.

In FreeCAD, normally, we don't need to interact directly with the openInventor scenegraph. Every object in a FreeCAD document, being a mesh, a part
shape or anything else, gets automatically converted to openInventor code and inserted in the main scenegraph that you see in a 3D view. That
scenegraph gets updated continuously when you do modifications, add or remove objects to the document. In fact, every object (in App space) has a
view provider (a corresponding object in Gui space), responsible for issuing openInventor code.
But there are many advantages to be able to access the scenegraph directly. For example, we can temporarily change the appearence of an object, or
we can add objects to the scene that have no real existence in the FreeCAD document, such as construction geometry, helpers, graphical hints or tools
such as manipulators or on-screen information.
FreeCAD itself features several tools to see or modify openInventor code. For example, the following python code will show the openInventor
representation of a selected object:
obj = FreeCAD.ActiveDocument.ActiveObject
viewprovider = obj.ViewObject
print viewprovider.toString()
But we also have a python module that allows complete access to anything managed by Coin3D, such as our FreeCAD scenegraph. So, read on to
Pivy.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Scenegraph&oldid=16734"

Pivy
Pivy is a python binding library for Coin3d, the 3D-rendering library used FreeCAD. When imported in a running python interpreter, it allows to dialog
directly with any running Coin3d scenegraphs, such as the FreeCAD 3D views, or even to create new ones. Pivy is bundled in standard FreeCAD
installation.
The coin library is divided into several pieces, coin itself, for manipulating scenegraphs and bindings for several GUI systems, such as windows or, like in
our case, qt. Those modules are available to pivy too, depending if they are present on the system. The coin module is always present, and it is what we
will use anyway, since we won't need to care about anchoring our 3D display in any interface, it is already done by FreeCAD itself. All we need to do is
this:
from pivy import coin

Accessing and modifying the scenegraph


We saw in the Scenegraph page how a typical Coin scene is organized. Everything that appears in a FreeCAD 3D view is a coin scenegraph,
organized the same way. We have one root node, and all objects on the screen are its children.
FreeCAD has an easy way to access the root node of a 3D view scenegraph:
sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
print sg
This will return the root node:
<pivy.coin.SoSelection; proxy of <Swig Object of type 'SoSelection *' at 0x360cb60> >
We can inspect the immediate children of our scene:
for node in sg.getChildren():
print node
Some of those nodes, such as SoSeparators or SoGroups, can have children themselves. The complete list of the available coin objects can be found in
the official coin documentation.
Let's try to add something to our scenegraph now. We'll add a nice red cube:
col = coin.SoBaseColor()
col.rgb=(1,0,0)
cub = coin.SoCube()
myCustomNode = coin.SoSeparator()
myCustomNode.addChild(col)
myCustomNode.addChild(cub)
sg.addChild(myCustomNode)
and here is our (nice) red cube. Now, let's try this:
col.rgb=(1,1,0)
See? everything is still accessible and modifiable on-the-fly. No need to recompute or redraw anything, coin takes care of everything. You can add stuff
to your scenegraph, change properties, hide stuff, show temporary objects, anything. Of course, this only concerns the display in the 3D view. That
display gets recomputed by FreeCAD on file open, and when an object needs recomputing. So, if you change the aspect of an existing FreeCAD object,
those changes will be lost if the object gets recomputed or when you reopen the file.
A key to work with scenegraphs in your scripts is to be able to access certain properties of the nodes you added when needed. For example, if we
wanted to move our cube, we would have added a SoTranslation node to our custom node, and it would have looked like this:
col = coin.SoBaseColor()
col.rgb=(1,0,0)
trans = coin.SoTranslation()
trans.translation.setValue([0,0,0])
cub = coin.SoCube()
myCustomNode = coin.SoSeparator()
myCustomNode.addChild(col)
mtCustomNode.addChild(trans)
myCustomNode.addChild(cub)
sg.addChild(myCustomNode)
Remember that in an openInventor scenegraph, the order is important. A node affects what comes next, so you can say something like: color red, cube,
color yellow, sphere, and you will get a red cube and a yellow sphere. If we added the translation now to our existing custom node, it would come after
the cube, and not affect it. If we had inserted it when creating it, like here above, we could now do:
trans.translation.setValue([2,0,0])
And our cube would jump 2 units to the right. Finally, removing something is done with:
sg.removeChild(myCustomNode)

Using callback mechanisms


A callback mechanism is a system that permits a library that you are using, such as our coin library, to call you back, that is, to call a certain function
from your currently running python object. This is extremely useful, because that way coin can notify you if some specific event occurs in the scene.
Coin can watch very different things, such as mouse position, clicks of a mouse button, keyboard keys being pressed, and many other things.

FreeCAD features an easy way to use such callbacks:


class ButtonTest:
def __init__(self):
self.view = FreeCADGui.ActiveDocument.ActiveView
self.callback = self.view.addEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),self.getMouseClick)
def getMouseClick(self,event_cb):
event = event_cb.getEvent()
if event.getState() == SoMouseButtonEvent.DOWN:
print "Alert!!! A mouse button has been improperly clicked!!!"
self.view.removeEventCallbackSWIG(SoMouseButtonEvent.getClassTypeId(),self.callback)
ButtonTest()
The callback has to be initiated from an object, because that object must still be running when the callback will occur. See also a complete list of
possible events and their parameters, or the official coin documentation.

Documentation
Unfortunately pivy itself still doesn't have a proper documentation, but since it is an accurate translation of coin, you can safely use the coin
documentation as reference, and use python style instead of c++ style (for example SoFile::getClassTypeId() would in pivy be SoFile.getClassId())
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Piv y&oldid=16735"

PyQt
PySide
Recently, FreeCAD has switched internally to use PySide instead of PyQt. That change was mainly done because of the licenses, PySide having an
LGPL license which is more compatible with FreeeCAD. Other than that, PySide works exactly the same way as PyQt, and in FreeCAD you can
usually use any of them, as you prefer. If you choose to use PySide, just replace all "PyQt" in the example code below with "PySide".
PyQt is a python module that allows python applications to create, access and modify Qt applications. You can use it for example to create your own
Qt programs in python, or to access and modify the interface of a running qt application, like FreeCAD.
By using the PyQt module from inside FreeCAD, you have therefore full control over its interface. You can for example:
Add your own panels, widgets and toolbars
Add or hide elements to existing panels
Change, redirect or add connections between all those elements
PyQt has an extensive API documentation, and there are many tutorials on the net to teach you how it works.
If you want to work on the FreeCAD interface, the very first thing to do is create a reference to the FreeCAD main window:
import sys
from PyQt4 import QtGui
app = QtGui.qApp
mw = app.activeWindow()
Then, you can for example browse through all the widgets of the interface:
for child in mw.children():
print 'widget name = ', child.objectName(), ', widget type = ', child
The widgets in a Qt interface are usually nested into "containers" widgets, so the children of our main window can themselves contain other children.
Depending on the widget type, there are a lot of things you can do. Check the API documentation to see what is possible.
Adding a new widget, for example a dockWidget (which can be placed in one of FreeCAD's side panels) is easy:
myWidget = QtGui.QDockWidget()
mw.addDockWidget(QtCore.Qt.RightDockWidgetArea,myWidget)
You could then add stuff directly to your widget:
myWidget.setObjectName("my Nice New Widget")
myWidget.resize(QtCore.QSize(300,100)) # sets size of the widget
label = QtGui.QLabel("Hello World", myWidget) # creates a label
label.setGeometry(QtCore.QRect(50,50,200,24)) # sets its size
label.setObjectName("myLabel") # sets its name, so it can be found by name
But a preferred method is to create a UI object which will do all of the setup of your widget at once. The big advantage is that such an UI object can be
created graphically with the Qt Designer program. A typical object generated by Qt Designer is like this:
class myWidget_Ui(object):
def setupUi(self, myWidget):
myWidget.setObjectName("my Nice New Widget")
myWidget.resize(QtCore.QSize(300,100).expandedTo(myWidget.minimumSizeHint())) # sets size of the widget
self.label = QtGui.QLabel(myWidget) # creates a label
self.label.setGeometry(QtCore.QRect(50,50,200,24)) # sets its size
self.label.setObjectName("label") # sets its name, so it can be found by name
def retranslateUi(self, draftToolbar): # built-in QT function that manages translations of widgets
myWidget.setWindowTitle(QtGui.QApplication.translate("myWidget", "My Widget", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("myWidget", "Welcome to my new widget!", None, QtGui.QApplication.UnicodeUTF8))
To use it, you just need to apply it to your freshly created widget like this:
myNewFreeCADWidget = QtGui.QDockWidget() # create a new dckwidget
myNewFreeCADWidget.ui = myWidget_Ui() # load the Ui script
myNewFreeCADWidget.ui.setupUi(myNewFreeCADWidget) # setup the ui
FCmw.addDockWidget(QtCore.Qt.RightDockWidgetArea,myNewFreeCADWidget) # add the widget to the main window
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=PyQt&oldid=78935"

Scripted objects
Besides the standard object types such as annotations, meshes and parts objects, FreeCAD also offers the amazing possibility to build 100% pythonscripted objects, called Python Features. Those objects will behave exactly as any other FreeCAD object, and are saved and restored automatically on
file save/load.
One particularity must be understood, those objects are saved in FreeCAD FcStd files with python's json module. That module turns a python object as
a string, allowing it to be added to the saved file. On load, the json module uses that string to recreate the original object, provided it has access to the
source code that created the object. This means that if you save such a custom object and open it on a machine where the python code that generated
the object is not present, the object won't be recreated. If you distribute such objects to others, you will need to distribute the python script that created
it together.
Python Features follow the same rule as all FreeCAD features: they are separated into App and GUI parts. The app part, the Document Object, defines
the geometry of our object, while its GUI part, the View Provider Object, defines how the object will be drawn on screen. The View Provider Object, as
any other FreeCAD feature, is only available when you run FreeCAD in its own GUI. There are several properties and methods available to build your
object. Properties must be of any of the predefined properties types that FreeCAD offers, and will appear in the property view window, so they can be
edited by the user. This way, FeaturePython objects are truly and totally parametric. you can define properties for the Object and its ViewObject
separately.
Hint: In former versions we used Python's cPickle module. However, this module executes arbitrary code and thus causes a security problem. Thus, we
moved to Python's json module.

Basic example
The following sample can be found in the src/Mod/TemplatePyMod/FeaturePython.py file, together with several other examples:
"Examples for a feature class and its view provider."
import FreeCAD, FreeCADGui
from pivy import coin
class Box:
def __init__(self, obj):
"'''Add some custom properties to our box feature'''"
obj.addProperty("App::PropertyLength","Length","Box","Length of the box").Length=1.0
obj.addProperty("App::PropertyLength","Width","Box","Width of the box").Width=1.0
obj.addProperty("App::PropertyLength","Height","Box", "Height of the box").Height=1.0
obj.Proxy = self
def onChanged(self, fp, prop):
"'''Do something when a property has changed'''"
FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n")
def execute(self, fp):
"'''Do something when doing a recomputation, this method is mandatory'''"
FreeCAD.Console.PrintMessage("Recompute Python Box feature\n")
class ViewProviderBox:
def __init__(self, obj):
"'''Set this object to the proxy object of the actual view provider'''"
obj.addProperty("App::PropertyColor","Color","Box","Color of the box").Color=(1.0,0.0,0.0)
obj.Proxy = self
def attach(self, obj):
"'''Setup the scene sub-graph of the view provider, this method is mandatory'''"
self.shaded = coin.SoGroup()
self.wireframe = coin.SoGroup()
self.scale = coin.SoScale()
self.color = coin.SoBaseColor()
data=coin.SoCube()
self.shaded.addChild(self.scale)
self.shaded.addChild(self.color)
self.shaded.addChild(data)
obj.addDisplayMode(self.shaded,"Shaded");
style=coin.SoDrawStyle()
style.style = coin.SoDrawStyle.LINES
self.wireframe.addChild(style)
self.wireframe.addChild(self.scale)
self.wireframe.addChild(self.color)
self.wireframe.addChild(data)
obj.addDisplayMode(self.wireframe,"Wireframe");
self.onChanged(obj,"Color")
def updateData(self, fp, prop):
"'''If a property of the handled feature has changed we have the chance to handle this here'''"
# fp is the handled feature, prop is the name of the property that has changed
l = fp.getPropertyByName("Length")
w = fp.getPropertyByName("Width")
h = fp.getPropertyByName("Height")
self.scale.scaleFactor.setValue(l,w,h)
pass
def getDisplayModes(self,obj):
"'''Return a list of display modes.'''"
modes=[]
modes.append("Shaded")
modes.append("Wireframe")
return modes
def getDefaultDisplayMode(self):
"'''Return the name of the default display mode. It must be defined in getDisplayModes.'''"
return "Shaded"
def setDisplayMode(self,mode):
"'''Map the display mode defined in attach with those defined in getDisplayModes.\'''
'''Since they have the same names nothing needs to be done. This method is optional'''"
return mode
def onChanged(self, vp, prop):
"'''Here we can do something when a single property got changed'''"
FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n")
if prop == "Color":

c = vp.getPropertyByName("Color")
self.color.rgb.setValue(c[0],c[1],c[2])
def getIcon(self):
"'''Return the icon in XPM format which will appear in the tree view. This method is\'''
'''optional and if not defined a default icon is shown.'''"
return """
/* XPM */
static const char * ViewProviderBox_xpm[] = {
"16 16 6 1",
" c None",
".c #141010",
"+c #615BD2",
"@c #C39D55",
"#c #000000",
"$c #57C355",
"
........",
"
......++..+..",
"
.@@@@.++..++.",
"
.@@@@.++..++.",
"
.@@ .++++++.",
" ..@@ .++..++.",
"###@@@@ .++..++.",
"##$.@@$#.++++++.",
"#$#$.$$$........",
"#$$#######
",
"#$$#$$$$$#
",
"#$$#$$$$$#
",
"#$$#$$$$$#
",
" #$#$$$$$#
",
" ##$$$$$#
",
"
#######
"};
"""
def __getstate__(self):
"'''When saving the document this object gets stored using Python's json module.\'''
'''Since we have some un-serializable parts here -- the Coin stuff -- we must define this method\'''
'''to return a tuple of all serializable objects or None.'''"
return None
def __setstate__(self,state):
"'''When restoring the serialized object from document we have the chance to set some internals here.\'''
'''Since no data were serialized nothing needs to be done here.'''"
return None
def makeBox():
FreeCAD.newDocument()
a=FreeCAD.ActiveDocument.addObject("App::FeaturePython","Box")
Box(a)
ViewProviderBox(a.ViewObject)

Available properties
Properties are the true building stones of FeaturePython objects. Through them, the user will be able to interact and modify your object. After creating a
new FeaturePython object in your document ( obj=FreeCAD.ActiveDocument.addObject("App::FeaturePython","Box") ), you can get a list of the
available properties by issuing:
obj.supportedProperties()
You will get a list of available properties:
App::PropertyBool
App::PropertyFloat
App::PropertyFloatList
App::PropertyFloatConstraint
App::PropertyAngle
App::PropertyDistance
App::PropertyInteger
App::PropertyIntegerConstraint
App::PropertyPercent
App::PropertyEnumeration
App::PropertyIntegerList
App::PropertyString
App::PropertyStringList
App::PropertyLink
App::PropertyLinkList
App::PropertyMatrix
App::PropertyVector
App::PropertyVectorList
App::PropertyPlacement
App::PropertyPlacementLink
App::PropertyColor
App::PropertyColorList
App::PropertyMaterial
App::PropertyPath
App::PropertyFile
App::PropertyFileIncluded
Part::PropertyPartShape
Part::PropertyFilletContour
Part::PropertyCircle
When adding properties to your custom objects, take care of this:
Do not use characters "<" or ">" in the properties descriptions (that would break the xml pieces in the .fcstd file)
Properties are stored alphabetically in a .fcstd file. If you have a shape in your properties, any property whose name comes after "Shape" in
alphabetic order, will be loaded AFTER the shape, which can cause strange behaviours.

Property Type
By default the properties can be updated. It is possible to make the properties read-only, for instance in the case one wants to show the result of a
method. It is also possible to hide the property. The property type can be set using

obj.setEditorMode("MyPropertyName", mode)
where mode is a short int that can be set to:
0 -- default mode, read and write
1 -- read-only
2 -- hidden

Other more complex example


This example makes use of the Part Module to create an octahedron, then creates its coin representation with pivy.
First is the Document object itself:
import FreeCAD, FreeCADGui, Part
class Octahedron:
def __init__(self, obj):
"Add some custom properties to our box feature"
obj.addProperty("App::PropertyLength","Length","Octahedron","Length of the octahedron").Length=1.0
obj.addProperty("App::PropertyLength","Width","Octahedron","Width of the octahedron").Width=1.0
obj.addProperty("App::PropertyLength","Height","Octahedron", "Height of the octahedron").Height=1.0
obj.addProperty("Part::PropertyPartShape","Shape","Octahedron", "Shape of the octahedron")
obj.Proxy = self
def execute(self, fp):
# Define six vetices for the shape
v1 = FreeCAD.Vector(0,0,0)
v2 = FreeCAD.Vector(fp.Length,0,0)
v3 = FreeCAD.Vector(0,fp.Width,0)
v4 = FreeCAD.Vector(fp.Length,fp.Width,0)
v5 = FreeCAD.Vector(fp.Length/2,fp.Width/2,fp.Height/2)
v6 = FreeCAD.Vector(fp.Length/2,fp.Width/2,-fp.Height/2)
# Make the wires/faces
f1 = self.make_face(v1,v2,v5)
f2 = self.make_face(v2,v4,v5)
f3 = self.make_face(v4,v3,v5)
f4 = self.make_face(v3,v1,v5)
f5 = self.make_face(v2,v1,v6)
f6 = self.make_face(v4,v2,v6)
f7 = self.make_face(v3,v4,v6)
f8 = self.make_face(v1,v3,v6)
shell=Part.makeShell([f1,f2,f3,f4,f5,f6,f7,f8])
solid=Part.makeSolid(shell)
fp.Shape = solid
# helper mehod to create the faces
def make_face(self,v1,v2,v3):
wire = Part.makePolygon([v1,v2,v3,v1])
face = Part.Face(wire)
return face
Then, we have the view provider object, responsible for showing the object in the 3D scene:
class ViewProviderOctahedron:
def __init__(self, obj):
"Set this object to the proxy object of the actual view provider"
obj.addProperty("App::PropertyColor","Color","Octahedron","Color of the octahedron").Color=(1.0,0.0,0.0)
obj.Proxy = self
def attach(self, obj):
"Setup the scene sub-graph of the view provider, this method is mandatory"
self.shaded = coin.SoGroup()
self.wireframe = coin.SoGroup()
self.scale = coin.SoScale()
self.color = coin.SoBaseColor()
self.data=coin.SoCoordinate3()
self.face=coin.SoIndexedLineSet()
self.shaded.addChild(self.scale)
self.shaded.addChild(self.color)
self.shaded.addChild(self.data)
self.shaded.addChild(self.face)
obj.addDisplayMode(self.shaded,"Shaded");
style=coin.SoDrawStyle()
style.style = coin.SoDrawStyle.LINES
self.wireframe.addChild(style)
self.wireframe.addChild(self.scale)
self.wireframe.addChild(self.color)
self.wireframe.addChild(self.data)
self.wireframe.addChild(self.face)
obj.addDisplayMode(self.wireframe,"Wireframe");
self.onChanged(obj,"Color")
def updateData(self, fp, prop):
"If a property of the handled feature has changed we have the chance to handle this here"
# fp is the handled feature, prop is the name of the property that has changed
if prop == "Shape":
s = fp.getPropertyByName("Shape")
self.data.point.setNum(6)
cnt=0
for i in s.Vertexes:
self.data.point.set1Value(cnt,i.X,i.Y,i.Z)
cnt=cnt+1
self.face.coordIndex.set1Value(0,0)
self.face.coordIndex.set1Value(1,1)
self.face.coordIndex.set1Value(2,2)
self.face.coordIndex.set1Value(3,-1)
self.face.coordIndex.set1Value(4,1)
self.face.coordIndex.set1Value(5,3)

self.face.coordIndex.set1Value(6,2)
self.face.coordIndex.set1Value(7,-1)
self.face.coordIndex.set1Value(8,3)
self.face.coordIndex.set1Value(9,4)
self.face.coordIndex.set1Value(10,2)
self.face.coordIndex.set1Value(11,-1)
self.face.coordIndex.set1Value(12,4)
self.face.coordIndex.set1Value(13,0)
self.face.coordIndex.set1Value(14,2)
self.face.coordIndex.set1Value(15,-1)
self.face.coordIndex.set1Value(16,1)
self.face.coordIndex.set1Value(17,0)
self.face.coordIndex.set1Value(18,5)
self.face.coordIndex.set1Value(19,-1)
self.face.coordIndex.set1Value(20,3)
self.face.coordIndex.set1Value(21,1)
self.face.coordIndex.set1Value(22,5)
self.face.coordIndex.set1Value(23,-1)
self.face.coordIndex.set1Value(24,4)
self.face.coordIndex.set1Value(25,3)
self.face.coordIndex.set1Value(26,5)
self.face.coordIndex.set1Value(27,-1)
self.face.coordIndex.set1Value(28,0)
self.face.coordIndex.set1Value(29,4)
self.face.coordIndex.set1Value(30,5)
self.face.coordIndex.set1Value(31,-1)
def getDisplayModes(self,obj):
"Return a list of display modes."
modes=[]
modes.append("Shaded")
modes.append("Wireframe")
return modes
def getDefaultDisplayMode(self):
"Return the name of the default display mode. It must be defined in getDisplayModes."
return "Shaded"
def setDisplayMode(self,mode):
return mode
def onChanged(self, vp, prop):
"Here we can do something when a single property got changed"
FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n")
if prop == "Color":
c = vp.getPropertyByName("Color")
self.color.rgb.setValue(c[0],c[1],c[2])
def getIcon(self):
return """
/* XPM */
static const char * ViewProviderBox_xpm[] = {
"16 16 6 1",
"
c None",
".
c #141010",
"+
c #615BD2",
"@
c #C39D55",
"#
c #000000",
"$
c #57C355",
"
........",
"
......++..+..",
"
.@@@@.++..++.",
"
.@@@@.++..++.",
"
.@@ .++++++.",
" ..@@ .++..++.",
"###@@@@ .++..++.",
"##$.@@$#.++++++.",
"#$#$.$$$........",
"#$$#######
",
"#$$#$$$$$#
",
"#$$#$$$$$#
",
"#$$#$$$$$#
",
" #$#$$$$$#
",
" ##$$$$$#
",
"
#######
"};
"""
def __getstate__(self):
return None
def __setstate__(self,state):
return None
Finally, once our object and its viewobject are defined, we just need to call them:
FreeCAD.newDocument()
a=FreeCAD.ActiveDocument.addObject("App::FeaturePython","Octahedron")
Octahedron(a)
ViewProviderOctahedron(a.ViewObject)

Making objects selectable


If you want to make your object selectable, or at least part of it, by clicking on it in the viewport, you must include its coin geometry inside a
SoFCSelection node. If your object has complex representation, with widgets, annotations, etc, you might want to include only a part of it in a
SoFCSelection. Everything that is a SoFCSelection is constantly scanned by FreeCAD to detect selection/preselection, so it makes sense try not to
overload it with unneeded scanning. This is what you would do to include a self.face from the example above:
selectionNode = coin.SoType.fromName("SoFCSelection").createInstance()
selectionNode.documentName.setValue(FreeCAD.ActiveDocument.Name)

selectionNode.objectName.setValue(obj.Object.Name) # here obj is the ViewObject, we need its associated App Object
selectionNode.subElementName.setValue("Face")
selectNode.addChild(self.face)
...
self.shaded.addChild(selectionNode)
self.wireframe.addChild(selectionNode)
Simply, you create a SoFCSelection node, then you add your geometry nodes to it, then you add it to your main node, instead of adding your geometry
nodes directly.

Working with simple shapes


If your parametric object simply outputs a shape, you don't need to use a view provider object. The shape will be displayed using FreeCAD's standard
shape representation:
class Line:
def __init__(self, obj):
'''"App two point properties" '''
obj.addProperty("App::PropertyVector","p1","Line","Start point")
obj.addProperty("App::PropertyVector","p2","Line","End point").p2=FreeCAD.Vector(1,0,0)
obj.Proxy = self
def execute(self, fp):
'''"Print a short message when doing a recomputation, this method is mandatory" '''
fp.Shape = Part.makeLine(fp.p1,fp.p2)
a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Line")
Line(a)
a.ViewObject.Proxy=0 # just set it to something different from None (this assignment is needed to run an internal notification)
FreeCAD.ActiveDocument.recompute()
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Scripted_obj ects&oldid=70551"

Embedding FreeCAD
FreeCAD has the amazing ability to be importable as a python module in other programs or in a standalone python console, together with all its modules
and components. It's even possible to import the FreeCAD GUI as python module -- with some restrictions, however.

Using FreeCAD without GUI


One first, direct, easy and useful application you can make of this is to import FreeCAD documents into your program. In the following example, we'll
import the Part geometry of a FreeCAD document into blender. Here is the complete script. I hope you'll be impressed by its simplicity:
FREECADPATH = '/opt/FreeCAD/lib' # path to your FreeCAD.so or FreeCAD.dll file
import Blender, sys
sys.path.append(FREECADPATH)
def import_fcstd(filename):
try:
import FreeCAD
except ValueError:
Blender.Draw.PupMenu('Error%t|FreeCAD library not found. Please check the FREECADPATH variable in the import script is correct')
else:
scene = Blender.Scene.GetCurrent()
import Part
doc = FreeCAD.open(filename)
objects = doc.Objects
for ob in objects:
if ob.Type[:4] == 'Part':
shape = ob.Shape
if shape.Faces:
mesh = Blender.Mesh.New()
rawdata = shape.tessellate(1)
for v in rawdata[0]:
mesh.verts.append((v.x,v.y,v.z))
for f in rawdata[1]:
mesh.faces.append.append(f)
scene.objects.new(mesh,ob.Name)
Blender.Redraw()
def main():
Blender.Window.FileSelector(import_fcstd, 'IMPORT FCSTD',
Blender.sys.makename(ext='.fcstd'))
# This lets you import the script without running it
if __name__=='__main__':
main()
The first, important part is to make sure python will find our FreeCAD library. Once it finds it, all FreeCAD modules such as Part, that we'll use too, will
be available automatically. So we simply take the sys.path variable, which is where python searches for modules, and we append the FreeCAD lib path.
This modification is only temporary, and will be lost when we'll close our python interpreter. Another way could be making a link to your FreeCAD library
in one of the python search paths. I kept the path in a constant (FREECADPATH) so it'll be easier for another user of the script to configure it to his own
system.
Once we are sure the library is loaded (the try/except sequence), we can now work with FreeCAD, the same way as we would inside FreeCAD's own
python interpreter. We open the FreeCAD document that is passed to us by the main() function, and we make a list of its objects. Then, as we choosed
only to care about Part geometry, we check if the Type property of each object contains "Part", then we tesselate it.
The tesselation produce a list of vertices and a list of faces defined by vertices indexes. This is perfect, since it is exactly the same way as blender
defines meshes. So, our task is ridiculously simple, we just add both lists contents to the verts and faces of a blender mesh. When everything is done,
we just redraw the screen, and that's it!
Of course this script is very simple (in fact I made a more advanced here), you might want to extend it, for example importing mesh objects too, or
importing Part geometry that has no faces, or import other file formats that FreeCAD can read. You might also want to export geometry to a FreeCAD
document, which can be done the same way. You might also want to build a dialog, so the user can choose what to import, etc... The beauty of all this
actually lies in the fact that you let FreeCAD do the ground work while presenting its results in the program of your choice.

Using FreeCAD with GUI


From version 4.2 on Qt has the intriguing ability to embed Qt-GUI-dependent plugins into non-Qt host applications and share the host's event loop.
Especially, for FreeCAD this means that it can be imported from within another application with its whole user interface where the host application has
full control over FreeCAD, then.
The whole python code to achieve that has only two lines
import FreeCADGui
FreeCADGui.showMainWindow()
If the host application is based on Qt then this solution should work on all platforms which Qt supports. However, the host should link the same Qt
version as FreeCAD because otherwise you could run into unexpected runtime errors.
For non-Qt applications, however, there are a few limitations you must be aware of. This solution probably doesn't work together with all other toolkits.
For Windows it works as long as the host application is directly based on Win32 or any other toolkit that internally uses the Win32 API such as
wxWidgets, MFC or WinForms. In order to get it working under X11 the host application must link the "glib" library.
Note, for any console application this solution of course doesn't work because there is no event loop running.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Embedding_FreeCAD&oldid=16738"

API documentation
(Redirected from API documentation)
This category gathers article that list objects and methods available to the python programmer.
Note: This section contains obsolete data,
http://www.freecadweb.org/api

and is

in the process

of being transferred to autogenerated API documentation on

Pages in category "API"


The following 15 pages are in this category, out of 15 total.

F cont.
Base API
Builtin modules

FreeCADGui API

Placement API

S
Matrix API
Mesh API

Console API

P cont.

Selection API

TopoShape API
Draft API

Object API

P
FreeCAD API

Part API

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Category:API&oldid=64328"

Vector API
ViewObject API

Code snippets
This page contains examples, pieces, chunks of FreeCAD python code collected from users experiences and discussions on the forums. Read and use
it as a start for your own scripts...

A typical InitGui.py file


Every module must contain, besides your main module file, an InitGui.py file, responsible for inserting the module in the main Gui. This is an example of
a simple one.
class ScriptWorkbench (Workbench):
MenuText = "Scripts"
def Initialize(self):
import Scripts # assuming Scripts.py is your module
list = ["Script_Cmd"] # That list must contain command names, that can be defined in Scripts.py
self.appendToolbar("My Scripts",list)
Gui.addWorkbench(ScriptWorkbench())

A typical module file


This is an example of a main module file, containing everything your module does. It is the Scripts.py file invoked by the previous example. You can have
all your custom commands here.
import FreeCAD, FreeCADGui
class ScriptCmd:
def Activated(self):
# Here your write what your ScriptCmd does...
FreeCAD.Console.PrintMessage('Hello, World!')
def GetResources(self):
return {'Pixmap' : 'path_to_an_icon/myicon.png', 'MenuText': 'Short text', 'ToolTip': 'More detailed text'}
FreeCADGui.addCommand('Script_Cmd', ScriptCmd())

Import a new filetype


Making an importer for a new filetype in FreeCAD is easy. FreeCAD doesn't consider that you import data in an opened document, but rather that you
simply can directly open the new filetype. So what you need to do is to add the new file extension to FreeCAD's list of known extensions, and write the
code that will read the file and create the FreeCAD objects you want:
This line must be added to the InitGui.py file to add the new file extension to the list:
# Assumes Import_Ext.py is the file that has the code for opening and reading .ext files
FreeCAD.addImportType("Your new File Type (*.ext)","Import_Ext")
Then in the Import_Ext.py file:
def open(filename):
doc=App.newDocument()
# here you do all what is needed with filename, read, classify data, create corresponding FreeCAD objects
doc.recompute()
To export your document to some new filetype works the same way, except that you use:
FreeCAD.addExportType("Your new File Type (*.ext)","Export_Ext")

Adding a line
A line simply has 2 points.
import Part,PartGui
doc=App.activeDocument()
# add a line element to the document and set its points
l=Part.Line()
l.StartPoint=(0.0,0.0,0.0)
l.EndPoint=(1.0,1.0,1.0)
doc.addObject("Part::Feature","Line").Shape=l.toShape()
doc.recompute()

Adding a polygon
A polygon is simply a set of connected line segments (a polyline in AutoCAD). It doesn't need to be closed.
import Part,PartGui
doc=App.activeDocument()
n=list()
# create a 3D vector, set its coordinates and add it to the list
v=App.Vector(0,0,0)
n.append(v)
v=App.Vector(10,0,0)
n.append(v)
#... repeat for all nodes
# Create a polygon object and set its nodes
p=doc.addObject("Part::Polygon","Polygon")
p.Nodes=n
doc.recompute()

Adding and removing an object to a group


doc=App.activeDocument()
grp=doc.addObject("App::DocumentObjectGroup", "Group")
lin=doc.addObject("Part::Feature", "Line")
grp.addObject(lin) # adds the lin object to the group grp
grp.removeObject(lin) # removes the lin object from the group grp
Note: You can even add other groups to a group...

Adding a Mesh

import Mesh
doc=App.activeDocument()
# create a new empty mesh
m = Mesh.Mesh()
# build up box out of 12 facets
m.addFacet(0.0,0.0,0.0, 0.0,0.0,1.0, 0.0,1.0,1.0)
m.addFacet(0.0,0.0,0.0, 0.0,1.0,1.0, 0.0,1.0,0.0)
m.addFacet(0.0,0.0,0.0, 1.0,0.0,0.0, 1.0,0.0,1.0)
m.addFacet(0.0,0.0,0.0, 1.0,0.0,1.0, 0.0,0.0,1.0)
m.addFacet(0.0,0.0,0.0, 0.0,1.0,0.0, 1.0,1.0,0.0)
m.addFacet(0.0,0.0,0.0, 1.0,1.0,0.0, 1.0,0.0,0.0)
m.addFacet(0.0,1.0,0.0, 0.0,1.0,1.0, 1.0,1.0,1.0)
m.addFacet(0.0,1.0,0.0, 1.0,1.0,1.0, 1.0,1.0,0.0)
m.addFacet(0.0,1.0,1.0, 0.0,0.0,1.0, 1.0,0.0,1.0)
m.addFacet(0.0,1.0,1.0, 1.0,0.0,1.0, 1.0,1.0,1.0)
m.addFacet(1.0,1.0,0.0, 1.0,1.0,1.0, 1.0,0.0,1.0)
m.addFacet(1.0,1.0,0.0, 1.0,0.0,1.0, 1.0,0.0,0.0)
# scale to a edge langth of 100
m.scale(100.0)
# add the mesh to the active document
me=doc.addObject("Mesh::Feature","Cube")
me.Mesh=m

Adding an arc or a circle


import Part
doc = App.activeDocument()
c = Part.Circle()
c.Radius=10.0
f = doc.addObject("Part::Feature", "Circle") # create a document with a circle feature
f.Shape = c.toShape() # Assign the circle shape to the shape property
doc.recompute()

Accessing and changing representation of an object


Each object in a FreeCAD document has an associated view representation object that stores all the parameters that define how the object appear, like
color, linewidth, etc...
gad=Gui.activeDocument()

# access the active document containing all


# view representations of the features in the
# corresponding App document

v=gad.getObject("Cube")
# access the view representation to the Mesh feature 'Cube'
v.ShapeColor
# prints the color to the console
v.ShapeColor=(1.0,1.0,1.0) # sets the shape color to white

Observing mouse events in the 3D viewer via Python


The Inventor framework allows to add one or more callback nodes to the scenegraph of the viewer. By default in FreeCAD one callback node is installed
per viewer which allows to add global or static C++ functions. In the appropriate Python binding some methods are provided to make use of this
technique from within Python code.
App.newDocument()
v=Gui.activeDocument().activeView()
#This class logs any mouse button events. As the registered callback function fires twice for 'down' and
#'up' events we need a boolean flag to handle this.
class ViewObserver:
def logPosition(self, info):
down = (info["State"] == "DOWN")
pos = info["Position"]
if (down):
FreeCAD.Console.PrintMessage("Clicked on position: ("+str(pos[0])+", "+str(pos[1])+")\n")
o = ViewObserver()
c = v.addEventCallback("SoMouseButtonEvent",o.logPosition)
Now, pick somewhere on the area in the 3D viewer and observe the messages in the output window. To finish the observation just call
v.removeEventCallback("SoMouseButtonEvent",c)
The following event types are supported
SoEvent -- all kind of events
SoButtonEvent -- all mouse button and key events
SoLocation2Event -- 2D movement events (normally mouse movements)
SoMotion3Event -- 3D movement events (normally spaceball)
SoKeyboardEvent -- key down and up events
SoMouseButtonEvent -- mouse button down and up events
SoSpaceballButtonEvent -- spaceball button down and up events
The Python function that can be registered with addEventCallback() expects a dictionary. Depending on the watched event the dictionary can contain
different keys.
For all events it has the keys:
Type -- the name of the event type i.e. SoMouseEvent, SoLocation2Event, ...
Time -- the current time as string
Position -- a tuple of two integers, mouse position
ShiftDown -- a boolean, true if Shift was pressed otherwise false
CtrlDown -- a boolean, true if Ctrl was pressed otherwise false
AltDown -- a boolean, true if Alt was pressed otherwise false
For all button events, i.e. keyboard, mouse or spaceball events
State -- A string 'UP' if the button was up, 'DOWN' if it was down or 'UNKNOWN' for all other cases
For keyboard events:
Key -- a character of the pressed key
For mouse button event
Button -- The pressed button, could be BUTTON1, ..., BUTTON5 or ANY
For spaceball events:

Button -- The pressed button, could be BUTTON1, ..., BUTTON7 or ANY


And finally motion events:
Translation -- a tuple of three floats
Rotation -- a quaternion for the rotation, i.e. a tuple of four floats

Manipulate the scenegraph in Python


It is also possible to get and change the scenegraph in Python, with the 'pivy' module -- a Python binding for Coin.
from pivy.coin import *
view = Gui.ActiveDocument.ActiveView
root = view.getSceneGraph()
root.addChild(SoCube())
view.fitAll()

# load the pivy module


# get the active viewer
# the root is an SoSeparator node

The Python API of pivy is created by using the tool SWIG. As we use in FreeCAD some self-written nodes you cannot create them directly in Python.
However, it is possible to create a node by its internal name. An instance of the type 'SoFCSelection' can be created with
type = SoType.fromName("SoFCSelection")
node = type.createInstance()

Adding and removing objects to/from the scenegraph


Adding new nodes to the scenegraph can be done this way. Take care of always adding a SoSeparator to contain the geometry, coordinates and
material info of a same object. The following example adds a red line from (0,0,0) to (10,0,0):
from pivy import coin
sg = Gui.ActiveDocument.ActiveView.getSceneGraph()
co = coin.SoCoordinate3()
pts = [[0,0,0],[10,0,0]]
co.point.setValues(0,len(pts),pts)
ma = coin.SoBaseColor()
ma.rgb = (1,0,0)
li = coin.SoLineSet()
li.numVertices.setValue(2)
no = coin.SoSeparator()
no.addChild(co)
no.addChild(ma)
no.addChild(li)
sg.addChild(no)
To remove it, simply issue:
sg.removeChild(no)

Adding custom widgets to the interface


You can create custom widgets with Qt designer, transform them into a python script, and then load them into the FreeCAD interface with PyQt4.
The python code produced by the Ui python compiler (the tool that converts qt-designer .ui files into python code) generally looks like this (it is simple,
you can also code it directly in python):
class myWidget_Ui(object):
def setupUi(self, myWidget):
myWidget.setObjectName("my Nice New Widget")
myWidget.resize(QtCore.QSize(QtCore.QRect(0,0,300,100).size()).expandedTo(myWidget.minimumSizeHint())) # sets size of the widget
self.label = QtGui.QLabel(myWidget) # creates a label
self.label.setGeometry(QtCore.QRect(50,50,200,24)) # sets its size
self.label.setObjectName("label") # sets its name, so it can be found by name
def retranslateUi(self, draftToolbar): # built-in QT function that manages translations of widgets
myWidget.setWindowTitle(QtGui.QApplication.translate("myWidget", "My Widget", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("myWidget", "Welcome to my new widget!", None, QtGui.QApplication.UnicodeUTF8))
Then, all you need to do is to create a reference to the FreeCAD Qt window, insert a custom widget into it, and "transform" this widget into yours with
the Ui code we just made:
app = QtGui.qApp
FCmw = app.activeWindow() # the active qt window, = the freecad window since we are inside it
myNewFreeCADWidget = QtGui.QDockWidget() # create a new dckwidget
myNewFreeCADWidget.ui = myWidget_Ui() # load the Ui script
myNewFreeCADWidget.ui.setupUi(myNewFreeCADWidget) # setup the ui
FCmw.addDockWidget(QtCore.Qt.RightDockWidgetArea,myNewFreeCADWidget) # add the widget to the main window

Adding a Tab to the Combo View


The following code allows you to add a tab to the FreeCAD ComboView, besides the "Project" and "Tasks" tabs. It also uses the uic module to load an
ui file directly in that tab.
from PyQt4 import QtGui,QtCore
from PyQt4 import uic
#from PySide import QtGui,QtCore
def getMainWindow():
"returns the main window"
# using QtGui.qApp.activeWindow() isn't very reliable because if another
# widget than the mainwindow is active (e.g. a dialog) the wrong widget is
# returned
toplevel = QtGui.qApp.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
def getComboView(mw):
dw=mw.findChildren(QtGui.QDockWidget)
for i in dw:
if str(i.objectName()) == "Combo View":
return i.findChild(QtGui.QTabWidget)
raise Exception("No tab widget found")
mw = getMainWindow()
tab = getComboView(getMainWindow())

tab2=QtGui.QDialog()
tab.addTab(tab2,"A Special Tab")
uic.loadUi("/myTaskPanelforTabs.ui",tab2)
tab2.show()
#tab.removeTab(2)

Opening a custom webpage


import WebGui
WebGui.openBrowser("http://www.example.com")

Getting the HTML contents of an opened webpage


from PyQt4 import QtGui,QtWebKit
a = QtGui.qApp
mw = a.activeWindow()
v = mw.findChild(QtWebKit.QWebFrame)
html = unicode(v.toHtml())
print html

Retrieve and use the coordinates of 3 selected points or objects


# -*- coding: utf-8 -*# the line above to put the accentuated in the remarks
# If this line is missing, an error will be returned
# extract and use the coordinates of 3 objects selected
import Part, FreeCAD, math, PartGui, FreeCADGui
from FreeCAD import Base, Console
sel = FreeCADGui.Selection.getSelection() # " sel " contains the items selected
if len(sel)!=3 :
# If there are no 3 objects selected, an error is displayed in the report view
# The \r and \n at the end of line mean return and the newline CR + LF.
Console.PrintError("Select 3 points exactly\r\n")
else :
points=[]
for obj in sel:
points.append(obj.Shape.BoundBox.Center)
for pt in points:
# display of the coordinates in the report view
Console.PrintMessage(str(pt.x)+"\r\n")
Console.PrintMessage(str(pt.y)+"\r\n")
Console.PrintMessage(str(pt.z)+"\r\n")
Console.PrintMessage(str(pt[1]) + "\r\n")

List all objects


# -*- coding: utf-8 -*import FreeCAD,Draft
# List all objects of the document
doc = FreeCAD.ActiveDocument
objs = FreeCAD.ActiveDocument.Objects
#App.Console.PrintMessage(str(objs) + "\n")
#App.Console.PrintMessage(str(len(FreeCAD.ActiveDocument.Objects)) + " Objects"

+ "\n")

for obj in objs:


a = obj.Name
# list the Name of the object (not modifiable)
b = obj.Label
# list the Label of the object (modifiable)
try:
c = obj.LabelText
# list the LabeText of the text (modifiable)
App.Console.PrintMessage(str(a) +" "+ str(b) +" "+ str(c) + "\n") # Displays the Name the Label and the text
except:
App.Console.PrintMessage(str(a) +" "+ str(b) + "\n") # Displays the Name and the Label of the object
#doc.removeObject("Box") # Clears the designated object

Function resident with the mouse click action


# -*- coding: utf-8 -*# causes an action to the mouse click on an object
# This function remains resident (in memory) with the function "addObserver(s)"
# "removeObserver(s) # Uninstalls the resident function
class SelObserver:
def addSelection(self,doc,obj,sub,pnt):
# Selection
App.Console.PrintMessage("addSelection"+ "\n")
App.Console.PrintMessage(str(doc)+ "\n")
# Name of the document
App.Console.PrintMessage(str(obj)+ "\n")
# Name of the object
App.Console.PrintMessage(str(sub)+ "\n")
# The part of the object name
App.Console.PrintMessage(str(pnt)+ "\n")
# Coordinates of the object
App.Console.PrintMessage("______"+ "\n")
def removeSelection(self,doc,obj,sub):
App.Console.PrintMessage("removeSelection"+ "\n")
def setSelection(self,doc):
App.Console.PrintMessage("setSelection"+ "\n")
def clearSelection(self,doc):
App.Console.PrintMessage("clearSelection"+ "\n")
s =SelObserver()
FreeCADGui.Selection.addObserver(s)
#FreeCADGui.Selection.removeObserver(s)

# Delete the selected object


# Selection in ComboView
# If click on the screen, clear the selection
# If click on another object, clear the previous object
# install the function mode resident
# Uninstall the resident function

List the components of an object


#
#
#
#
#
#
#

-*- coding: utf-8 -*This function list the components of an object


and extract this object its XYZ coordinates,
its edges and their lengths center of mass and coordinates
its faces and their center of mass
its faces and their surfaces and coordinates
8/05/2014

import Draft,Part
def detail():

sel = FreeCADGui.Selection.getSelection()
if len(sel) != 0:
Vertx=[]
Edges=[]
Faces=[]
compt_V=0
compt_E=0
compt_F=0
pas
=0
perimetre = 0.0
EdgesLong = []

# Select an object
# If there is a selection then

# Displays the "Name" and the "Label" of the selection


App.Console.PrintMessage("Selection > " + str(sel[0].Name) + "

" + str(sel[0].Label) +"\n"+"\n")

for j in enumerate(sel[0].Shape.Edges):
compt_E+=1
Edges.append("Edge%d" % (j[0]+1))
EdgesLong.append(str(sel[0].Shape.Edges[compt_E-1].Length))
perimetre += (sel[0].Shape.Edges[compt_E-1].Length)

# Search the "Edges" and their lengths

# calculates the perimeter

# Displays the "Edge" and its length


App.Console.PrintMessage("Edge"+str(compt_E)+" Length > "+str(sel[0].Shape.Edges[compt_E-1].Length)+"\n")
# Displays the "Edge" and its center mass
App.Console.PrintMessage("Edge"+str(compt_E)+" Center > "+str(sel[0].Shape.Edges[compt_E-1].CenterOfMass)+"\n")
num = sel[0].Shape.Edges[compt_E-1].Vertexes[0]
Vertx.append("X1: "+str(num.Point.x))
Vertx.append("Y1: "+str(num.Point.y))
Vertx.append("Z1: "+str(num.Point.z))
# Displays the coordinates 1
App.Console.PrintMessage("X1: "+str(num.Point[0])+" Y1: "+str(num.Point[1])+" Z1: "+str(num.Point[2])+"\n")
try:
num = sel[0].Shape.Edges[compt_E-1].Vertexes[1]
Vertx.append("X2: "+str(num.Point.x))
Vertx.append("Y2: "+str(num.Point.y))
Vertx.append("Z2: "+str(num.Point.z))
except:
Vertx.append("-")
Vertx.append("-")
Vertx.append("-")
# Displays the coordinates 2
App.Console.PrintMessage("X2: "+str(num.Point[0])+" Y2: "+str(num.Point[1])+" Z2: "+str(num.Point[2])+"\n")
App.Console.PrintMessage("\n")
App.Console.PrintMessage("Perimeter of the form

: "+str(perimetre)+"\n")

App.Console.PrintMessage("\n")
FacesSurf = []
for j in enumerate(sel[0].Shape.Faces):
compt_F+=1
Faces.append("Face%d" % (j[0]+1))
FacesSurf.append(str(sel[0].Shape.Faces[compt_F-1].Area))

# Search the "Faces" and their surface

# Displays 'Face' and its surface


App.Console.PrintMessage("Face"+str(compt_F)+" >

Surface "+str(sel[0].Shape.Faces[compt_F-1].Area)+"\n")

# Displays 'Face' and its CenterOfMass


App.Console.PrintMessage("Face"+str(compt_F)+" >

Center

# Displays 'Face' and its Coordinates


FacesCoor = []
fco = 0
for f0 in sel[0].Shape.Faces[compt_F-1].Vertexes:
fco += 1
FacesCoor.append("X"+str(fco)+": "+str(f0.Point.x))
FacesCoor.append("Y"+str(fco)+": "+str(f0.Point.y))
FacesCoor.append("Z"+str(fco)+": "+str(f0.Point.z))
# Displays 'Face' and its Coordinates
App.Console.PrintMessage("Face"+str(compt_F)+" >
# Displays 'Face' and its Volume
App.Console.PrintMessage("Face"+str(compt_F)+" >
App.Console.PrintMessage("\n")

"+str(sel[0].Shape.Faces[compt_F-1].CenterOfMass)+"\n")

# Search the Vertexes of the face

Coordinate"+str(FacesCoor)+"\n")
Volume

"+str(sel[0].Shape.Faces[compt_F-1].Volume)+"\n")

# Displays the total surface of the form


App.Console.PrintMessage("Surface of the form

: "+str(sel[0].Shape.Area)+"\n")

# Displays the total Volume of the form


App.Console.PrintMessage("Volume of the form

: "+str(sel[0].Shape.Volume)+"\n")

detail()

List the PropertiesList


o = App.ActiveDocument.ActiveObject
op = o.PropertiesList
for p in op:
print "Property: ", p, " Value: ", o.getPropertyByName (p)
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Code_snippets&oldid=83485"

Line drawing function


This page shows how advanced functionality can easily be built in Python. In this exercise, we will be building a new tool that draws a line. This tool can
then be linked to a FreeCAD command, and that command can be called by any element of the interface, like a menu item or a toolbar button.

The main script


First we will write a script containing all our functionality. Then, we will save this in a file, and import it in FreeCAD, so all classes and functions we write
will be availible to FreeCAD. So, launch your favorite text editor, and type the following lines:
import FreeCADGui, Part
from pivy.coin import *
class line:
"this class will create a line after the user clicked 2 points on the screen"
def __init__(self):
self.view = FreeCADGui.ActiveDocument.ActiveView
self.stack = []
self.callback = self.view.addEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),self.getpoint)
def getpoint(self,event_cb):
event = event_cb.getEvent()
if event.getState() == SoMouseButtonEvent.DOWN:
pos = event.getPosition()
point = self.view.getPoint(pos[0],pos[1])
self.stack.append(point)
if len(self.stack) == 2:
l = Part.Line(self.stack[0],self.stack[1])
shape = l.toShape()
Part.show(shape)
self.view.removeEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),self.callback)

Detailed explanation
import Part, FreeCADGui
from pivy.coin import *
In Python, when you want to use functions from another module, you need to import it. In our case, we will need functions from the Part Module, for
creating the line, and from the Gui module (FreeCADGui), for accessing the 3D view. We also need the complete contents of the coin library, so we can
use directly all coin objects like SoMouseButtonEvent, etc...
class line:
Here we define our main class. Why do we use a class and not a function? The reason is that we need our tool to stay "alive" while we are waiting for
the user to click on the screen. A function ends when its task has been done, but an object (a class defines an object) stays alive until it is destroyed.
"this class will create a line after the user clicked 2 points on the screen"
In Python, every class or function can have a description string. This is particularly useful in FreeCAD, because when you'll call that class in the
interpreter, the description string will be displayed as a tooltip.
def __init__(self):
Python classes can always contain an __init__ function, which is executed when the class is called to create an object. So, we will put here everything
we want to happen when our line tool begins.
self.view = FreeCADGui.ActiveDocument.ActiveView
In a class, you usually want to append self. before a variable name, so it will be easily accessible to all functions inside and outside that class. Here, we
will use self.view to access and manipulate the active 3D view.
self.stack = []
Here we create an empty list that will contain the 3D points sent by the getpoint function.
self.callback = self.view.addEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),self.getpoint)
This is the important part: Since it is actually a coin3D scene, the FreeCAD uses coin callback mechanism, that allows a function to be called
everytime a certain scene event happens. In our case, we are creating a callback for SoMouseButtonEvent events, and we bind it to the getpoint
function. Now, everytime a mouse button is pressed or released, the getpoint function will be executed.
Note that there is also an alternative to addEventCallbackPivy() called addEventCallback() which dispenses the use of pivy. But since pivy is a very
efficient and natural way to access any part of the coin scene, it is much better to use it as much as you can!
def getpoint(self,event_cb):
Now we define the getpoint function, that will be executed when a mouse button is pressed in a 3D view. This function will receive an argument, that we
will call event_cb. From this event callback we can access the event object, which contains several pieces of information (mode info here).
if event.getState() == SoMouseButtonEvent.DOWN:
The getpoint function will be called when a mouse button is pressed or released. But we want to pick a 3D point only when pressed (otherwise we would
get two 3D points very close to each other). So we must check for that here.
pos = event.getPosition()
Here we get the screen coordinates of the mouse cursor
point = self.view.getPoint(pos[0],pos[1])
This function gives us a FreeCAD vector (x,y,z) containing the 3D point that lies on the focal plane, just under our mouse cursor. If you are in camera
view, imagine a ray coming from the camera, passing through the mouse cursor, and hitting the focal plane. There is our 3D point. If we are in orthogonal
view, the ray is parallel to the view direction.
self.stack.append(point)
We add our new point to the stack
if len(self.stack) == 2:
Do we have enough points already? if yes, then let's draw the line!
l = Part.Line(self.stack[0],self.stack[1])
Here we use the function Line() from the Part Module that creates a line from two FreeCAD vectors. Everything we create and modify inside the Part

module, stays in the Part module. So, until now, we created a Line Part. It is not bound to any object of our active document, so nothing appears on the
screen.
shape = l.toShape()
The FreeCAD document can only accept shapes from the Part module. Shapes are the most generic type of the Part module. So, we must convert our
line to a shape before adding it to the document.
Part.show(shape)
The Part module has a very handy show() function that creates a new object in the document and binds a shape to it. We could also have created a new
object in the document first, then bound the shape to it manually.
self.view.removeEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),self.callback)
Since we are done with our line, let's remove the callback mechanism, that consumes precious CPU cycles.

Testing & Using the script


Now, let's save our script to some place where the FreeCAD python interpreter will find it. When importing modules, the interpreter will look in the
following places: the python installation paths, the FreeCAD bin directory, and all FreeCAD modules directories. So, the best solution is to create a new
directory in one of the FreeCAD Mod directories, and to save our script in it. For example, let's make a "MyScripts" directory, and save our script as
"exercise.py".
Now, everything is ready, let's start FreeCAD, create a new document, and, in the python interpreter, issue:
import exercise
If no error message appear, that means our exercise script has been loaded. We can now check its contents with:
dir(exercise)
The command dir() is a built-in python command that lists the contents of a module. We can see that our line() class is there, waiting for us. Now let's
test it:
exercise.line()
Then, click two times in the 3D view, and bingo, here is our line! To do it again, just type exercise.line() again, and again, and again... Feels great, no?

Registering the script in the FreeCAD interface


Now, for our new line tool to be really cool, it should have a button on the interface, so we don't need to type all that stuff everytime. The easiest way is
to transform our new MyScripts directory into a full FreeCAD workbench. It is easy, all that is needed is to put a file called InitGui.py inside your
MyScripts directory. The InitGui.py will contain the instructions to create a new workbench, and add our new tool to it. Besides that we will also need to
transform a bit our exercise code, so the line() tool is recognized as an official FreeCAD command. Let's start by making an InitGui.py file, and write the
following code in it:
class MyWorkbench (Workbench):
MenuText = "MyScripts"
def Initialize(self):
import exercise
commandslist = ["line"]
self.appendToolbar("My Scripts",commandslist)
Gui.addWorkbench(MyWorkbench())
By now, you should already understand the above script by yourself, I think: We create a new class that we call MyWorkbench, we give it a title
(MenuText), and we define an Initialize() function that will be executed when the workbench is loaded into FreeCAD. In that function, we load in the
contents of our exercise file, and append the FreeCAD commands found inside to a command list. Then, we make a toolbar called "My Scripts" and we
assign our commands list to it. Currently, of course, we have only one tool, so our command list contains only one element. Then, once our workbench
is ready, we add it to the main interface.
But this still won't work, because a FreeCAD command must be formatted in a certain way to work. So we will need to transform a bit our line() tool. Our
new exercise.py script will now look like this:
import FreeCADGui, Part
from pivy.coin import *
class line:
"this class will create a line after the user clicked 2 points on the screen"
def Activated(self):
self.view = FreeCADGui.ActiveDocument.ActiveView
self.stack = []
self.callback = self.view.addEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),self.getpoint)
def getpoint(self,event_cb):
event = event_cb.getEvent()
if event.getState() == SoMouseButtonEvent.DOWN:
pos = event.getPosition()
point = self.view.getPoint(pos[0],pos[1])
self.stack.append(point)
if len(self.stack) == 2:
l = Part.Line(self.stack[0],self.stack[1])
shape = l.toShape()
Part.show(shape)
self.view.removeEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),self.callback)
def GetResources(self):
return {'Pixmap' : 'path_to_an_icon/line_icon.png', 'MenuText': 'Line', 'ToolTip': 'Creates a line by clicking 2 points on the screen'}
FreeCADGui.addCommand('line', line())
What we did here is transform our __init__() function into an Activated() function, because when FreeCAD commands are run, they automatically
execute the Activated() function. We also added a GetResources() function, that informs FreeCAD where it can find an icon for the tool, and what will be
the name and tooltip of our tool. Any jpg, png or svg image will work as an icon, it can be any size, but it is best to use a size that is close to the final
aspect, like 16x16, 24x24 or 32x32. Then, we add the line() class as an official FreeCAD command with the addCommand() method.
That's it, we now just need to restart FreeCAD and we'll have a nice new workbench with our brand new line tool!

So you want more?


If you liked this exercise, why not try to improve this little tool? There are many things that can be done, like for example:
Add user feedback: until now we did a very bare tool, the user might be a bit lost when using it. So we could add some feedback, telling him what
to do next. For example, you could issue messages to the FreeCAD console. Have a look in the FreeCAD.Console module
Add a possibility to type the 3D points coordinates manually. Look at the python input() function, for example
Add the possibility to add more than 2 points
Add events for other things: Now we just check for Mouse button events, what if we would also do something when the mouse is moved, like
displaying current coordinates?
Give a name to the created object
Don't hesitate to write your questions or ideas on the talk page!
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Line_draw ing_function&oldid=16740"

Dialog creation
In this page we will show how to build a simple Qt Dialog with Qt Designer, Qt's official tool for designing interfaces, then convert it to python code, then
use it inside FreeCAD. I'll assume in the example that you know how to edit and run python scripts already, and that you can do simple things in a
terminal window such as navigate, etc. You must also have, of course, pyqt installed.

Designing the dialog


In CAD applications, designing a good UI (User Interface) is very important. About everything the user will do will be through some piece of interface:
reading dialog boxes, pressing buttons, choosing between icons, etc. So it is very important to think carefully to what you want to do, how you want the
user to behave, and how will be the workflow of your action.
There are a couple of concepts to know when designing interface:
Modal/non-modal dialogs: A modal dialog appears in front of your screen, stopping the action of the main window, forcing the user to respond
to the dialog, while a non-modal dialog doesn't stop you from working on the main window. In some case the first is better, in other cases not.
Identifying what is required and what is optional: Make sure the user knows what he must do. Label everything with proper description, use
tooltips, etc.
Separating commands from parameters: This is usually done with buttons and text input fields. The user knows that clicking a button will produce
an action while changing a value inside a text field will change a parameter somewhere. Nowadays, though, users usually know well what is a
button, what is an input field, etc. The interface toolkit we are using, Qt, is a state-of-the-art toolkit, and we won't have to worry much about
making things clear, since they will already be very clear by themselves.
So, now that we have well defined what we will do, it's time to open the qt designer. Let's design a very simple dialog, like this:

We will then use this dialog in FreeCAD to produce a nice rectangular plane. You might find it not very useful to produce nice rectangular planes, but it
will be easy to change it later to do more complex things. When you open it, Qt Designer looks like this:

It is very simple to use. On the left bar you have elements that can be dragged on your widget. On the right side you have properties panels displaying all
kinds of editable properties of selected elements. So, begin with creating a new widget. Select "Dialog without buttons", since we don't want the default
Ok/Cancel buttons. Then, drag on your widget 3 labels, one for the title, one for writing "Height" and one for writing "Width". Labels are simple texts that
appear on your widget, just to inform the user. If you select a label, on the right side will appear several properties that you can change if you want, such
as font style, height, etc.
Then, add 2 LineEdits, which are text fields that the user can fill in, one for the height and one for the width. Here too, we can edit properties. For
example, why not set a default value? For example 1.00 for each. This way, when the user will see the dialog, both values will be filled already and if he
is satisfied he can directly press the button, saving precious time. Then, add a PushButton, which is the button the user will need to press after he filled
the 2 fields.
Note that I choosed here very simple controls, but Qt has many more options, for example you could use Spinboxes instead of LineEdits, etc... Have a
look at what is available, you will surely have other ideas.
That's about all we need to do in Qt Designer. One last thing, though, let's rename all our elements with easier names, so it will be easier to identify
them in our scripts:

Converting our dialog to python


Now, let's save our widget somewhere. It will be saved as an .ui file, that we will easily convert to python script with pyuic. On windows, the pyuic
program is bundled with pyqt (to be verified), on linux you probably will need to install it separately from your package manager (on debian-based
systems, it is part of the pyqt4-dev-tools package). To do the conversion, you'll need to open a terminal window (or a command prompt window on
windows), navigate to where you saved your .ui file, and issue:
pyuic mywidget.ui > mywidget.py
On some systems the program is called pyuic4 instead of pyuic. This will simply convert the .ui file into a python script. If we open the mywidget.py file,
its contents are very easy to understand:
from PyQt4 import QtCore, QtGui
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(187, 178)
self.title = QtGui.QLabel(Dialog)
self.title.setGeometry(QtCore.QRect(10, 10, 271, 16))
self.title.setObjectName("title")
self.label_width = QtGui.QLabel(Dialog)
...
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
self.title.setText(QtGui.QApplication.translate("Dialog", "Plane-O-Matic", None, QtGui.QApplication.UnicodeUTF8))
...
As you see it has a very simple structure: a class named Ui_Dialog is created, that stores the interface elements of our widget. That class has two
methods, one for setting up the widget, and one for translating its contents, that is part of the general Qt mechanism for translating interface elements.
The setup method simply creates, one by one, the widgets as we defined them in Qt Designer, and sets their options as we decided earlier. Then, the
whole interface gets translated, and finally, the slots get connected (we'll talk about that later).
We can now create a new widget, and use this class to create its interface. We can already see our widget in action, by putting our mywidget.py file in a
place where FreeCAD will find it (in the FreeCAD bin directory, or in any of the Mod subdirectories), and, in the FreeCAD python interpreter, issue:
from PyQt4 import QtGui
import mywidget
d = QtGui.QWidget()
d.ui = mywidget.Ui_Dialog()
d.ui.setupUi(d)
d.show()
And our dialog will appear! Note that our python interpreter is still working, we have a non-modal dialog. So, to close it, we can (apart from clicking its
close icon, of course) issue:
d.hide()

Making our dialog do something


Now that we can show and hide our dialog, we just need to add one last part: To make it do something! If you play a bit with Qt designer, you'll quickly
discover a whole section called "signals and slots". Basically, it works like this: elements on your widgets (in Qt terminology, those elements are
themselves widgets) can send signals. Those signals differ according to the widget type. For example, a button can send a signal when it is pressed and
when it is released. Those signals can be connected to slots, which can be special functionality of other widgets (for example a dialog has a "close" slot
to which you can connect the signal from a close button), or can be custom functions. The PyQt Reference Documentation lists all the qt widgets,
what they can do, what signals they can send, etc...
What we will do here, is to create a new function that will create a plane based on height and width, and to connect that function to the pressed signal
emitted by our "Create!" button. So, let's begin with importing our FreeCAD modules, by putting the following line at the top of the script, where we
already import QtCore and QtGui:
import FreeCAD, Part
Then, let's add a new function to our Ui_Dialog class:
def createPlane(self):
try:
# first we check if valid numbers have been entered
w = float(self.width.text())
h = float(self.height.text())
except ValueError:
print "Error! Width and Height values must be valid numbers!"
else:
# create a face from 4 points
p1 = FreeCAD.Vector(0,0,0)
p2 = FreeCAD.Vector(w,0,0)
p3 = FreeCAD.Vector(w,h,0)
p4 = FreeCAD.Vector(0,h,0)
pointslist = [p1,p2,p3,p4,p1]
mywire = Part.makePolygon(pointslist)
myface = Part.Face(mywire)
Part.show(myface)
self.hide()
Then, we need to inform Qt to connect
QtCore.QMetaObject.connectSlotsByName(Dialog):

the

button

to

the

function,

by

placing

QtCore.QObject.connect(self.create,QtCore.SIGNAL("pressed()"),self.createPlane)

the

following

line

just

before

This, as you see, connects the pressed() signal of our create object (the "Create!" button), to a slot named createPlane, which we just defined. That's it!
Now, as a final touch, we can add a little function to create the dialog, it will be easier to call. Outside the Ui_Dialog class, let's add this code:
class plane():
def __init__(self):
self.d = QtGui.QWidget()
self.ui = Ui_Dialog()
self.ui.setupUi(self.d)
self.d.show()
(Python reminder: the __init__ method of a class is automatically executed whenever a new object is created!) Then, from FreeCAD, we only need to do:
import mywidget
myDialog = mywidget.plane()
That's all Folks... Now you can try all kinds of things, like for example inserting your widget in the FreeCAD interface (see the Code snippets page), or
making much more advanced custom tools, by using other elements on your widget.

The complete script


This is the complete script, for reference:
# -*- coding: utf-8 -*# Form implementation generated from reading ui file 'mywidget.ui'
#
# Created: Mon Jun 1 19:09:10 2009
#
by: PyQt4 UI code generator 4.4.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
import FreeCAD, Part
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(187, 178)
self.title = QtGui.QLabel(Dialog)
self.title.setGeometry(QtCore.QRect(10, 10, 271, 16))
self.title.setObjectName("title")
self.label_width = QtGui.QLabel(Dialog)
self.label_width.setGeometry(QtCore.QRect(10, 50, 57, 16))
self.label_width.setObjectName("label_width")
self.label_height = QtGui.QLabel(Dialog)
self.label_height.setGeometry(QtCore.QRect(10, 90, 57, 16))
self.label_height.setObjectName("label_height")
self.width = QtGui.QLineEdit(Dialog)
self.width.setGeometry(QtCore.QRect(60, 40, 111, 26))
self.width.setObjectName("width")
self.height = QtGui.QLineEdit(Dialog)
self.height.setGeometry(QtCore.QRect(60, 80, 111, 26))
self.height.setObjectName("height")
self.create = QtGui.QPushButton(Dialog)
self.create.setGeometry(QtCore.QRect(50, 140, 83, 26))
self.create.setObjectName("create")
self.retranslateUi(Dialog)
QtCore.QObject.connect(self.create,QtCore.SIGNAL("pressed()"),self.createPlane)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
self.title.setText(QtGui.QApplication.translate("Dialog", "Plane-O-Matic", None, QtGui.QApplication.UnicodeUTF8))
self.label_width.setText(QtGui.QApplication.translate("Dialog", "Width", None, QtGui.QApplication.UnicodeUTF8))
self.label_height.setText(QtGui.QApplication.translate("Dialog", "Height", None, QtGui.QApplication.UnicodeUTF8))
self.create.setText(QtGui.QApplication.translate("Dialog", "Create!", None, QtGui.QApplication.UnicodeUTF8))
def createPlane(self):
try:
# first we check if valid numbers have been entered
w = float(self.width.text())
h = float(self.height.text())
except ValueError:
print "Error! Width and Height values must be valid numbers!"
else:
# create a face from 4 points
p1 = FreeCAD.Vector(0,0,0)
p2 = FreeCAD.Vector(w,0,0)
p3 = FreeCAD.Vector(w,h,0)
p4 = FreeCAD.Vector(0,h,0)
pointslist = [p1,p2,p3,p4,p1]
mywire = Part.makePolygon(pointslist)
myface = Part.Face(mywire)
Part.show(myface)
class plane():
def __init__(self):
self.d = QtGui.QWidget()
self.ui = Ui_Dialog()
self.ui.setupUi(self.d)
self.d.show()

Creation of a dialog with buttons


Method 1
An example of a dialog box complete with its connections.
# -*- coding: utf-8 -*# Create by flachyjoe
from PyQt4 import QtCore, QtGui

try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):
def __init__(self, MainWindow):
self.window = MainWindow
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(400, 300)
self.centralWidget = QtGui.QWidget(MainWindow)
self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
self.pushButton = QtGui.QPushButton(self.centralWidget)
self.pushButton.setGeometry(QtCore.QRect(30, 170, 93, 28))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.pushButton.clicked.connect(self.on_pushButton_clicked) #connection pushButton
self.lineEdit = QtGui.QLineEdit(self.centralWidget)
self.lineEdit.setGeometry(QtCore.QRect(30, 40, 211, 22))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.lineEdit.returnPressed.connect(self.on_lineEdit_clicked) #connection lineEdit
self.checkBox = QtGui.QCheckBox(self.centralWidget)
self.checkBox.setGeometry(QtCore.QRect(30, 90, 81, 20))
self.checkBox.setChecked(True)
self.checkBox.setObjectName(_fromUtf8("checkBoxON"))
self.checkBox.clicked.connect(self.on_checkBox_clicked) #connection checkBox
self.radioButton = QtGui.QRadioButton(self.centralWidget)
self.radioButton.setGeometry(QtCore.QRect(30, 130, 95, 20))
self.radioButton.setObjectName(_fromUtf8("radioButton"))
self.radioButton.clicked.connect(self.on_radioButton_clicked) #connection radioButton
MainWindow.setCentralWidget(self.centralWidget)
self.menuBar = QtGui.QMenuBar(MainWindow)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 400, 26))
self.menuBar.setObjectName(_fromUtf8("menuBar"))
MainWindow.setMenuBar(self.menuBar)
self.mainToolBar = QtGui.QToolBar(MainWindow)
self.mainToolBar.setObjectName(_fromUtf8("mainToolBar"))
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
self.statusBar = QtGui.QStatusBar(MainWindow)
self.statusBar.setObjectName(_fromUtf8("statusBar"))
MainWindow.setStatusBar(self.statusBar)
self.retranslateUi(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.pushButton.setText(_translate("MainWindow", "OK", None))
self.lineEdit.setText(_translate("MainWindow", "tyty", None))
self.checkBox.setText(_translate("MainWindow", "CheckBox", None))
self.radioButton.setText(_translate("MainWindow", "RadioButton", None))

#
#

def on_checkBox_clicked(self):
if self.checkBox.checkState()==0:
App.Console.PrintMessage(str(self.checkBox.checkState())+" CheckBox KO\r\n")
else:
App.Console.PrintMessage(str(self.checkBox.checkState())+" CheckBox OK\r\n")
App.Console.PrintMessage(str(self.lineEdit.setText("tititi"))+" LineEdit\r\n") #write text to the lineEdit window !
str(self.lineEdit.setText("tititi")) #crit le texte dans la fentre lineEdit
App.Console.PrintMessage(str(self.lineEdit.displayText())+" LineEdit\r\n")
def on_radioButton_clicked(self):
if self.radioButton.isChecked():
App.Console.PrintMessage(str(self.radioButton.isChecked())+" Radio OK\r\n")
else:
App.Console.PrintMessage(str(self.radioButton.isChecked())+" Radio KO\r\n")

def on_lineEdit_clicked(self):
if self.lineEdit.textChanged():
App.Console.PrintMessage(str(self.lineEdit.displayText())+" LineEdit Display\r\n")
def on_pushButton_clicked(self):
App.Console.PrintMessage("Termin\r\n")
self.window.hide()

MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow(MainWindow)
MainWindow.show()

Here the same window but with an icon on each button.


# -*- coding: utf-8 -*from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8

except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):

def __init__(self, MainWindow):


self.window = MainWindow
path = FreeCAD.ConfigGet("UserAppData")
path = FreeCAD.ConfigGet("AppHomePath")
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(400, 300)
self.centralWidget = QtGui.QWidget(MainWindow)
self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
self.pushButton = QtGui.QPushButton(self.centralWidget)
self.pushButton.setGeometry(QtCore.QRect(30, 170, 93, 28))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.pushButton.clicked.connect(self.on_pushButton_clicked) #connection pushButton
self.lineEdit = QtGui.QLineEdit(self.centralWidget)
self.lineEdit.setGeometry(QtCore.QRect(30, 40, 211, 22))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.lineEdit.returnPressed.connect(self.on_lineEdit_clicked) #connection lineEdit
self.checkBox = QtGui.QCheckBox(self.centralWidget)
self.checkBox.setGeometry(QtCore.QRect(30, 90, 100, 20))
self.checkBox.setChecked(True)
self.checkBox.setObjectName(_fromUtf8("checkBoxON"))
self.checkBox.clicked.connect(self.on_checkBox_clicked) #connection checkBox
self.radioButton = QtGui.QRadioButton(self.centralWidget)
self.radioButton.setGeometry(QtCore.QRect(30, 130, 95, 20))
self.radioButton.setObjectName(_fromUtf8("radioButton"))
self.radioButton.clicked.connect(self.on_radioButton_clicked) #connection radioButton
MainWindow.setCentralWidget(self.centralWidget)
self.menuBar = QtGui.QMenuBar(MainWindow)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 400, 26))
self.menuBar.setObjectName(_fromUtf8("menuBar"))
MainWindow.setMenuBar(self.menuBar)
self.mainToolBar = QtGui.QToolBar(MainWindow)
self.mainToolBar.setObjectName(_fromUtf8("mainToolBar"))
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
self.statusBar = QtGui.QStatusBar(MainWindow)
self.statusBar.setObjectName(_fromUtf8("statusBar"))
MainWindow.setStatusBar(self.statusBar)
self.retranslateUi(MainWindow)
# Affiche un icne sur le bouton PushButton
# self.image_01 = "C:\Program Files\FreeCAD0.13\icone01.png" # adapt the icon name
self.image_01 = path+"icone01.png" # adapt the name of the icon
icon01 = QtGui.QIcon()
icon01.addPixmap(QtGui.QPixmap(self.image_01),QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton.setIcon(icon01)
self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) # This command reverses the direction of the button
# Affiche un icne sur le bouton RadioButton
# self.image_02 = "C:\Program Files\FreeCAD0.13\icone02.png" # adapt the name of the icon
self.image_02 = path+"icone02.png" # adapter le nom de l'icne
icon02 = QtGui.QIcon()
icon02.addPixmap(QtGui.QPixmap(self.image_02),QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.radioButton.setIcon(icon02)
# self.radioButton.setLayoutDirection(QtCore.Qt.RightToLeft) # This command reverses the direction of the button
# Affiche un icne sur le bouton CheckBox
# self.image_03 = "C:\Program Files\FreeCAD0.13\icone03.png" # the name of the icon
self.image_03 = path+"icone03.png" # adapter le nom de l'icne
icon03 = QtGui.QIcon()
icon03.addPixmap(QtGui.QPixmap(self.image_03),QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.checkBox.setIcon(icon03)
# self.checkBox.setLayoutDirection(QtCore.Qt.RightToLeft) # This command reverses the direction of the button
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "FreeCAD", None))
self.pushButton.setText(_translate("MainWindow", "OK", None))
self.lineEdit.setText(_translate("MainWindow", "tyty", None))
self.checkBox.setText(_translate("MainWindow", "CheckBox", None))
self.radioButton.setText(_translate("MainWindow", "RadioButton", None))
def on_checkBox_clicked(self):
if self.checkBox.checkState()==0:
App.Console.PrintMessage(str(self.checkBox.checkState())+" CheckBox KO\r\n")
else:
App.Console.PrintMessage(str(self.checkBox.checkState())+" CheckBox OK\r\n")
# App.Console.PrintMessage(str(self.lineEdit.setText("tititi"))+" LineEdit\r\n") # write text to the lineEdit window !
# str(self.lineEdit.setText("tititi")) #crit le texte dans la fentre lineEdit
App.Console.PrintMessage(str(self.lineEdit.displayText())+" LineEdit\r\n")
def on_radioButton_clicked(self):
if self.radioButton.isChecked():
App.Console.PrintMessage(str(self.radioButton.isChecked())+" Radio OK\r\n")
else:

App.Console.PrintMessage(str(self.radioButton.isChecked())+"

Radio KO\r\n")

def on_lineEdit_clicked(self):
# if self.lineEdit.textChanged():
App.Console.PrintMessage(str(self.lineEdit.displayText())+" LineEdit Display\r\n")
def on_pushButton_clicked(self):
App.Console.PrintMessage("Termin\r\n")
self.window.hide()
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow(MainWindow)
MainWindow.show()
Here the code to display the icon on the pushButton, change the name for another button, (radioButton, checkBox) and the path to the icon.
# Affiche un icne sur le bouton PushButton
# self.image_01 = "C:\Program Files\FreeCAD0.13\icone01.png" # the name of the icon
self.image_01 = path+"icone01.png" # the name of the icon
icon01 = QtGui.QIcon()
icon01.addPixmap(QtGui.QPixmap(self.image_01),QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton.setIcon(icon01)
self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) # This command reverses the direction of the button
The command UserAppData gives the user path AppHomePath gives the installation path of FreeCAD
#

path = FreeCAD.ConfigGet("UserAppData")
path = FreeCAD.ConfigGet("AppHomePath")

This command reverses the horizontal button, right to left.


self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) # This command reverses the direction of the button

Method 2
Another method to display a window, here by creating a file QtForm.py which contains the header program (module called with import QtForm), and a
second module that contains the code window all these accessories, and your code (the calling module).
This method requires two separate files, but allows to shorten your program using the file ' ' QtForm.py ' ' import. Then distribute the two files together,
they are inseparable.
The file QtForm.py

# -*- coding: utf-8 -*# Create by flachyjoe


from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Form(object):
def __init__(self, title, width, height):
self.window = QtGui.QMainWindow()
self.title=title
self.window.setObjectName(_fromUtf8(title))
self.window.setWindowTitle(_translate(self.title, self.title, None))
self.window.resize(width, height)
def show(self):
self.createUI()
self.retranslateUI()
self.window.show()
def setText(self, control, text):
control.setText(_translate(self.title, text, None))
The appellant, file that contains the window and your code.
The file my_file.py
The connections are to do, a good exercise.

# -*- coding: utf-8 -*# Create by flachyjoe


from PyQt4 import QtCore, QtGui
import QtForm
class myForm(QtForm.Form):
def createUI(self):
self.centralWidget = QtGui.QWidget(self.window)
self.window.setCentralWidget(self.centralWidget)
self.pushButton = QtGui.QPushButton(self.centralWidget)
self.pushButton.setGeometry(QtCore.QRect(30, 170, 93, 28))
self.pushButton.clicked.connect(self.on_pushButton_clicked)
self.lineEdit = QtGui.QLineEdit(self.centralWidget)
self.lineEdit.setGeometry(QtCore.QRect(30, 40, 211, 22))
self.checkBox = QtGui.QCheckBox(self.centralWidget)
self.checkBox.setGeometry(QtCore.QRect(30, 90, 81, 20))
self.checkBox.setChecked(True)

self.radioButton = QtGui.QRadioButton(self.centralWidget)
self.radioButton.setGeometry(QtCore.QRect(30, 130, 95, 20))
def retranslateUI(self):
self.setText(self.pushButton, "Fermer")
self.setText(self.lineEdit, "essai de texte")
self.setText(self.checkBox, "CheckBox")
self.setText(self.radioButton, "RadioButton")
def on_pushButton_clicked(self):
self.window.hide()
myWindow=myForm("Fentre de test",400,300)
myWindow.show()

Some useful commands


# Here the code to display the icon on the pushButton,
# change the name to another button, (radioButton, checkBox) as well as the path to the icon,
# Displays an icon on the button PushButton
# self.image_01 = "C:\Program Files\FreeCAD0.13\icone01.png" # he name of the icon
self.image_01 = path+"icone01.png" # the name of the icon
icon01 = QtGui.QIcon()
icon01.addPixmap(QtGui.QPixmap(self.image_01),QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton.setIcon(icon01)
self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) # This command reverses the direction of the button

# path = FreeCAD.ConfigGet("UserAppData") # gives the user path


path = FreeCAD.ConfigGet("AppHomePath") # gives the installation path of FreeCAD
# This command reverses the horizontal button, right to left
self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) # This command reverses the horizontal button
# Displays an info button
self.pushButton.setToolTip(_translate("MainWindow", "Quitter la fonction", None)) # Displays an info button
# This function gives a color button
self.pushButton.setStyleSheet("background-color: red") # This function gives a color button
# This function gives a color to the text of the button
self.pushButton.setStyleSheet("color : #ff0000") # This function gives a color to the text of the button
# combinaison des deux, bouton et texte
self.pushButton.setStyleSheet("color : #ff0000; background-color : #0000ff;" ) #

combination of the two, button, and text

# replace the icon in the main window


MainWindow.setWindowIcon(QtGui.QIcon('C:\Program Files\FreeCAD0.13\View-C3P.png'))
# connects a lineEdit on execute
self.lineEdit.returnPressed.connect(self.execute) # connects a lineEdit on "def execute" after validation on enter
# self.lineEdit.textChanged.connect(self.execute) # connects a lineEdit on "def execute" with each keystroke on the keyboard
# display text in a lineEdit
self.lineEdit.setText(str(val_X)) # Displays the value in the lineEdit (convert to string)
# extract the string contained in a lineEdit
val_X = self.lineEdit.text() # extract the (string) string contained in lineEdit
val_X = float(val_X0)
# converted the string to an floating
val_X = int(val_X0)
# convert the string to an integer
# This code allows you to change the font and its attributes
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(10)
font.setWeight(10)
font.setBold(True) # same result with tags "your text" (in quotes)
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.label_6.setStyleSheet("color : #ff0000") # This function gives a color to the text
self.label_6.setText(_translate("MainWindow", "Select a view", None))
By using the characters with accents, where you get the error :
Several solutions are possible.
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-2: invalid data
# conversion from a lineEdit
App.activeDocument().CopyRight.Text = str(unicode(self.lineEdit_20.text() , 'ISO-8859-1').encode('UTF-8'))
DESIGNED_BY = unicode(self.lineEdit_01.text(), 'ISO-8859-1').encode('UTF-8')
or with the procedure
def utf8(unio):
return unicode(unio).encode('UTF8')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 9: ordinal not in range(128)
# conversion
a = u"Nom de l'lment : "
f.write(a.encode('iso-8859-1')+str(element_)+"\n")
or with the procedure

def iso8859(encoder):
return unicode(encoder).encode('iso-8859-1')
or
iso8859(unichr(176))
or
unichr(ord(176))
or
uniteSs = "mm"+iso8859(unichr(178))
print unicode(uniteSs, 'iso8859')

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Dialog_creation&oldid=69836"

Licence
Statement of the maintainer
I know that the discussion on the "right" licence for open source occupied a significant portion of internet bandwidth and so is here the reason why, in
my opinion, FreeCAD should have this one.
I chose the LGPL for the project and I know the pro and cons about the LGPL and will give you some reasons for that decision.
FreeCAD is a mixture of a library and an application, so the GPL would be a little bit strong for that. It would prevent writing commercial modules for
FreeCAD because it would prevent linking with the FreeCAD base libs. You may ask why commercial modules at all? Therefore Linux is good example.
Would Linux be so successful when the GNU C Library would be GPL and therefore prevent linking against non-GPL applications? And although I love
the freedom of Linux, I also want to be able to use the very good NVIDIA 3D graphic driver. I understand and accept the reason NVIDIA does not wish to
give away driver code. We all work for companies and need payment or at least food. So for me, a coexistence of open source and closed source
software is not a bad thing, when it obeys the rules of the LGPL. I would like to see someone writing a Catia import/export processor for FreeCAD and
distribute it for free or for some money. I don't like to force him to give away more than he wants to. That wouldn't be good neither for him nor for
FreeCAD.
Nevertheless this decision is made only for the core system of FreeCAD. Every writer of an application module may make his own decision.

Used Licences
Here the two licences under which FreeCAD is published:
Lesser General Public Licence (LGPL2+)
For the core libs as stated in the .h and .cpp files in src/App src/Gui src/Base and most modules in src/Mod and for the executable as stated in
the .h and .cpp files in src/main. The icons and other graphic parts are also LGPL.
Open Publication Licence
For the documentation on http://free-cad.sourceforge.net/ as not marked differently by the author
See FreeCAD's debian copyright file for more details about the licenses used in FreeCAD

License side effects


Up to Version 0.13 FreeCAD is delivered as GPL2+, although the source itself is under LGPL2+. Thats because of linkage of Coin3D (GPL2) and
PyQt(GPL). Starting with 0.14 we will be completely GPL free. PyQt will be replaced by PySide, and Coin3D was re-licensed under BSD. One problem,
we still have to face, license-wise, the OCTPL (Open CASCADE Technology Public License). Its a License mostly LGPL similar, with certain
changes. On of the originators, Roman Lygin, elaborated on the License on his Blog. The home-brew OCTPL license leads to all kind of side effects for
FreeCAD, which where widely discussed on different forums and mailing lists, e.g. on OpenCasCade forum itself. I will link here some articles for the
biggest problems.

GPL2/GPL3/OCTLP incompatibility
We first discovered the problem by a discussion on the FSF high priority project discussion list. It was about a library we look at, which was licensed
with GPL3. Since we linked back then with Coin3D, with GPL2 only, we was not able to adopt that lib. Also the OCTPL is considered GPL
incompatible. This Libre Graphics World article "LibreDWG drama: the end or the new beginning?" shows up the drama of LibreDWG project not
acceptably in FreeCAD or LibreCAD.
Debian
The incompatibility of the OCTPL was discussed on the debian legal list and lead to a bug report on the FreeCAD package which prevent (ignortag) the transition from debian-testing to the main distribution. But its also mentioned thats a FreeCAD, which is free of GPL code and libs, would be
acceptably. With a re-licensed Coin3D V4 and a substituted PyQt we will hopefully reach GPL free with the 0.14 release.
Fedora/RedHat non-free
In the Fedora project OpenCasCade is listed "non-free". This means basically it won't make it into Fedora or RedHat. This means also FreeCAD won't
make it into Fedora/RedHat until OCC is changing its license. Here the links to the license evaluation:
Discussion on the Fedora-legal-list
License review entry in the RedHat bug tracker
The main problem they have AFIK is that the OCC license demand non discriminatory support fees if you want to do paid support. It has nothing to do
with "free" or OpenSource, its all about RedHat's business model!

Impact of the licences


Private users
Private users can use FreeCAD free of charge and can do basically whatever they want to do with it....
Professional users
Can use FreeCAD freely, for any kind of private or professional work. They can customize the application as they wish. They can write open or closed
source extensions to FreeCAD. They are always master of their data, they are not forced to update FreeCAD, change their usage of FreeCAD. Using
FreeCAD doesn't bind them to any kind of contract or obligation.
Open Source developers
Can use FreeCAD as the groundwork for own extension modules for special purposes. They can choose either the GPL or the LGPL to allow the use of
their work in proprietary software or not.
Commercial developers
Commercial developers can use FreeCAD as the groundwork for their own extension modules for special purposes and are not forced to make their

modules open source. They can use all modules which use the LGPL. They are allowed to distribute FreeCAD along with their proprietary software. They
will get the support of the author(s) as long as it is not a one way street.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Licence&oldid=30991"

Tracker
The adress of our bug tracker is:
http://www.freecadweb.org/tracker
There you can report bugs, submit feature requests, patches, or request to merge your branch if you developed something using git. The tracker is
divided into modules, so please be specific and file your request in the appropriate subsection. In cas of doubt, leave it in the "FreeCAD" section.

Reporting bugs
If you think you might have found a bug, you are welcome to report it there. But before reporting a bug, please check the following items:
Make sure your bug is really a bug, that is, something that should be working and that is not working. If you are not sure, don't hesitate to explain
your problem on the forum and ask what to do.
Before submitting anything, read the frequently asked questions, do a search on the forum, and make sure the same bug hasn't been reported
before, by doing a search on the bug tracker.
Describe as clearly as possible the problem, and how it can be reproduced. If we can not verify the bug, we might not be able to fix it.
Join the following information: Your operating system, if it is 32 or 64 bits, and the version of FreeCAD you are running.
Please file one separate report for each bug.
If you are on a linux system and your bug causes a crash in FreeCAD, you can try running a debug backtrace: From a terminal run gdb freecad
(assuming package gdb is installed), then, inside gdb, type run . FreeCAD will then run. After the crash happens, type bt , to get the full
backtrace. Include that backtrace in your bug report.

Requesting features
If you want something to appear in FreeCAD that is not implemented yet, it is not a bug but a feature request. You can also submit it on the same
tracker (file it as feature request instead of bug), but keep in mind there are no guarantees that your wish will be fulfilled.

Submitting patches
In case you have programmed a bug fix, an extension or something else that can be of public use in FreeCAD, create a patch using the Git diff tool and
submit it on the same tracker (file it as patch).

Requesting merge
If you have created a git branch containing changes that you would like to see merged into the FreeCAD code, you can ask there to have your branch
reviewed and merged if the FreeCAD developers are OK with it. You must first publish your branch to a public git repository (github,bitbucket,
sourceforge...) and then give the URL of your branch in your merge request.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Tracker&oldid=43057"

CompileOnWindows
This article explains step by step how to compile FreeCAD on Windows.

Prerequisites
What you need is mainly the compiler. On Windows we use the M$ Visual Studio 9 Compiler 2008 (or VC++ Express 2008) with the highest service
pack. Although it's probably possible to use Cygwin or MinGW gcc it's not tested or ported so far. You need to download the Windows Platform SDK to
get e.g. the Windows.h, although this should not be needed with M$ compilers (either full or express).
Also you need all the Third Party Libraries to successfully compile FreeCAD. If you use the M$ compilers you want most likely to download the
FreeCAD LibPack which provides you with all needed libs to build FreeCAD on Windows.
Other prerequisites (and helpful programs) are:
CMake
TortoiseGit
Python 2.6
NSIS Windows installer (note: formerly, WiX installer was used - now under transition to NSIS) - if you want to make msi installer
It is also necessary to have, in your system path, paths to:
Libpack
git (not tortoiseGit, but git.exe)
python

Building with CMake


First of all, you have to download CMake and install it on your build machine.

The switch to CMake


Since version 0.9 we use the CMake build system to generate the build/make files for various compilers. We do not longer deliver .vcproj files. If you
want build former versions of FreeCAD (0.8 and older) see Building older versions later in this article.
We switched because it became more and more painful to maintain project files for 30+ build targets and x compilers. CMake gives us the possibility to
support alternative IDEs, like Code::Blocks, Qt Creator and Eclipse CDT. The main compiler we use is still M$ VC9 Express, though. But we plan for the
future a build process on Windows without proprietary compiler software.

CMake dependencies
The first step to build FreeCAD with CMake is to configure the environment. There are basically two ways to go:
Using the LibPack
Installing all needed libs and let CMake find them
We will be using LibPack here. The second option may be discussed in Options for the Build Process.
Add libpack to the system path:
Start menu -> Right click on Computer -> Properties -> Advanced system settings
Advanced tab -> Environment Variables...
Add the libpack folder location to the PATH
It should be separated from the others with a semicolon `;`
If you are building with Qt Creator, jump to Building with Qt Creator, otherwise proceed to Building with Visual Studio 9 2008.

Building with Visual Studio 9 2008


Configure CMake using GUI

Open CMake GUI


Specify source folder
Specify build folder
Click Configure
Specify the generator as Visual Studio 9 2008
This will begin configuration and should fail because the location of FREECAD_LIBPACK_DIR is unset.
Expand the FREECAD category and set FREECAD_LIBPACK_DIR to the correct location
Click Configure again
There should be no errors
Click Generate
Close CMake
Copy libpack\bin folder into the new build folder CMake created
Building
Open Visual Studio 9 2008 or Visual C++ Express 2008<ref>Visual C++ Express 2008 does not support 64-bit compilation. There is a
workaround here</ref>
File -> Open -> Project/Solution

Open FreeCAD_Trunk.sln from the build folder CMake created


Switch the Solutions Configuration dropdown at the top to Release
Build -> Build Solution to build
This will take a long time...
After it is built:
Debug -> Start without Debugging
Click popup menu under Executable File Name and choose Browse
Go to the build\bin folder and choose FreeCAD.exe
You are done!

Building with Qt Creator


Installation and configuration of Qt Creator
Download and install Qt Creator
Tools -> Options -> Text Editor -> Behavior tab:
File Encodings -> Default Encodings:
Set to: ISO-8859-1 /...csISOLatin1<ref>Certain characters create errors/warnings with Qt Creator if left set to UTF-8. This seems to fix it.
</ref>
Tools -> Options -> Build & Run:
CMake tab
Fill Executable box with path to cmake.exe
Kits tab
Name: MSVC 2008
Compiler: Microsoft Visual C++ Compiler 9.0 (x86)
Debugger: Auto detected...
Qt version: None
General tab
Uncheck: Always build project before deploying it
Uncheck: Always deploy project before running it
Import project and Build
File -> Open File or Project
Open CMakeLists.txt which is in the top level of the source
This will start CMake
Choose build directory and click next
Set generator to NMake Generator (MSVC 2008)
Click Run CMake
CMake will error because it doesn't know where libpack is
Browse to the new build directory and open CMakeCache.txt
Find: FREECAD_LIBPACK_DIR:PATH=
Set the right side to libpack's location
Save and Close the file
Return to CMake and click Run CMake
This will configure and generate before completing
Click Finish
Copy libpack\bin folder into the new build folder CMake created
Now FreeCAD can be built
Build -> Build All
This will take a long time...
Once complete, it can be run: There are 2 green triangles at the bottom left. One is debug. The other is run. Pick whichever you want.

Options for the Build Process


The CMake build system gives us a lot more flexibility over the build process. That means we can switch on and off some features or modules. It's in a
way like the Linux kernel build. You have a lot switches to determine the build process.
Here is the description of these switches. They will most likely change a lot in the future because we want to increase the build flexibility a lot more.

Link table
Variable name
Description
Default
FREECAD_LIBPACK_USE
Switch the usage of the FreeCAD LibPack on or off
On Win32 on, otherwishe off
FREECAD_LIBPACK_DIR
Directory where the LibPack is
FreeCAD SOURCE dir
FREECAD_BUILD_GUI
Build FreeCAD with all Gui related modules
ON
FREECAD_BUILD_CAM
Build the CAM module, experimental!
OFF
FREECAD_BUILD_INSTALLER
Create the project files for the Windows installer.
OFF
FREECAD_BUILD_DOXYGEN_DOCU Create the project files for source code documentation. OFF
FREECAD_MAINTAINERS_BUILD
Switch on stuff needed only when you do a Release build. OFF
Command line build
Here an example how to build FreeCAD from the Command line:
rem @echo off
rem
Build script, uses vcbuild to completetly build FreeCAD
rem update trunc
d:
cd "D:\_Projekte\FreeCAD\FreeCAD_0.9"
"C:\Program Files (x86)\Subversion\bin\svn.exe" update
rem

set the aprobiated Variables here or outside in the system

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
set INCLUDE=
set LIB=
rem Register VS Build programms
call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
rem Set Standard include paths
set INCLUDE=%INCLUDE%;%FrameworkSDKDir%\include
set INCLUDE=%INCLUDE%;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include
rem Set lib Pathes
set LIB=%LIB%;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
set LIB=%LIB%;%PROGRAMFILES%\Microsoft Visual Studio\VC98\Lib
rem Start the Visuall Studio build process
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe" "D:\_Projekte\FreeCAD FreeCAD_0.9_build\FreeCAD_trunk.sln" /useenv

Building older versions


Using LibPack

To make it easier to get FreeCAD compiled, we provide a collection of all needed libraries. It's called the LibPack. You can find it on the download
page on sourceforge.
You need to set the following environment variables:
FREECADLIB = "D:\Wherever\LIBPACK"
QTDIR = "%FREECADLIB%"
Add "%FREECADLIB%\bin" and "%FREECADLIB%\dll" to the system PATH variable. Keep in mind that you have to replace "%FREECADLIB%" with
the path name, since Windows does not recursively replace environment variables.
Directory setup in Visual Studio
Some search path of Visual Studio need to be set. To change them, use the menu ToolsOptionsDirectory
Includes

Add the following search path to the include path search list:
%FREECADLIB%\include
%FREECADLIB%\include\Python
%FREECADLIB%\include\boost
%FREECADLIB%\include\xercesc
%FREECADLIB%\include\OpenCascade
%FREECADLIB%\include\OpenCV
%FREECADLIB%\include\Coin
%FREECADLIB%\include\SoQt
%FREECADLIB%\include\QT
%FREECADLIB%\include\QT\Qt3Support
%FREECADLIB%\include\QT\QtCore
%FREECADLIB%\include\QT\QtGui
%FREECADLIB%\include\QT\QtNetwork
%FREECADLIB%\include\QT\QtOpenGL
%FREECADLIB%\include\QT\QtSvg
%FREECADLIB%\include\QT\QtUiTools
%FREECADLIB%\include\QT\QtXml
%FREECADLIB%\include\Gts
%FREECADLIB%\include\zlib
Libs

Add the following search path to the lib path search list:
%FREECADLIB%\lib
Executables

Add the following search path to the executable path search list:
%FREECADLIB%\bin
TortoiseSVN binary installation directory, usually "C:\Programm Files\TortoiseSVN\bin", this is needed for a distribution build when
SubWVRev.exe is used to extract the version number from Subversion.
Python needed
During the compilation some Python scripts get executed. So the Python interpreter has to function on the OS. Use a command box to check it. If the
Python library is not properly installed you will get an error message like Cannot find python.exe. If you use the LibPack you can also use the
python.exe in the bin directory.
Special for VC8
When building the project with VC8, you have to change the link information for the WildMagic library, since you need a different version for VC6 and
VC8. Both versions are supplied in LIBPACK/dll. In the project properties for AppMesh change the library name for the wm.dll to the VC8 version. Take
care to change it in Debug and Release configuration.

Compile
After you conform to all prerequisites the compilation is - hopefully - only a mouse click in VC ;-)

After Compiling
To get FreeCAD up and running from the compiler environment you need to copy a few files from the LibPack to the bin folder where FreeCAD.exe is
installed after a successful build:
python.exe and python_d.exe from LIBPACK/bin
python25.dll and python25_d.dll from LIBPACK/bin
python25.zip from LIBPACK/bin
make a copy of Python25.zip and rename it to Python25_d.zip
QtCore4.dll from LIBPACK/bin
QtGui4.dll from LIBPACK/bin
boost_signals-vc80-mt-1_34_1.dll from LIBPACK/bin
boost_program_options-vc80-mt-1_34_1.dll from LIBPACK/bin
xerces-c_2_8.dll from LIBPACK/bin
zlib1.dll from LIBPACK/bin
coin2.dll from LIBPACK/bin
soqt1.dll from LIBPACK/bin
QtOpenGL4.dll from LIBPACK/bin
QtNetwork 4.dll from LIBPACK/bin
QtSvg4.dll from LIBPACK/bin
QtXml4.dll from LIBPACK/bin
When using a LibPack with a Python version older than 2.5 you have to copy two further files:
zlib.pyd and zlib_d.pyd from LIBPACK/bin/lib. This is needed by python to open the zipped python library.
_sre.pyd and _sre_d.pyd from LIBPACK/bin/lib. This is needed by python for the built in help system.
If you don't get it running due to a Python error it is very likely that one of the zlib*.pyd files is missing.

Additional stuff
If you whant to build the source code documentation you need DoxyGen.
To create an intstaller package you need WIX.
During the compilation some Python scripts get executed. So the Python interpreter has to work properly.
For more details have also a look to README.Linux in your sources.
First of all you should build the Qt plugin that provides all custom widgets of FreeCAD we need for the Qt Designer. The sources are located under
//src/Tools/plugins/widget//.
So far we don't provide a makefile -- but calling
qmake plugin.pro
creates it. Once that's done, calling mak e will create the library

//libFreeCAD_widgets.so//.
To make this library known to your Qt Designer you have to copy the file to
//$QTDIR/plugin/designer//.

References
Template:Reflist

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=CompileOnWindow s&oldid=81689"

CompileOnUnix
On recent linux distributions, FreeCAD is generally easy to build, since all dependencies are usually provided by the package manager. It basically
involves 3 steps:
1. Getting the FreeCAD source code
2. Getting the dependencies (packages FreeCAD depends upon)
3. Compiling with "cmake . && make"
Below, you'll find detailed explanations of the whole process and particularities you might encounter. If you find anything wrong or out-of-date in the text
below (Linux distributions change often), or if you use a distribution which is not listed, please help us correcting it.

Getting the source


Before you can compile FreeCAD, you need the source code. There are 3 ways to get it:

Git
The quickest and best way to get the code is to clone the read-only git repository (you need the git package installed):
git clone git://git.code.sf.net/p/free-cad/code free-cad-code
This will place a copy of the latest version of the FreeCAD source code in a new directory called "free-cad-code". The first time you try connecting to the
free-cad.git.sourceforge.net host, you will receive a message asking to authenticate the sourceforge SSH key, which is normally safe to accept (you can
check their SSH keys on the sourceforge website if you are not sure)

Github
There is an always up to date FreeCAD repository on Github: github.com/FreeCAD/FreeCAD_sf_master

Source package
Alternatively you can download a source package, but they could be already quite old so it's always better to get the latest sources via git or github.
Depending on your distribution, there are several ways to obtain a source package:
Official FreeCAD source packages (distribution-independent): https://sourceforge.net/projects/free-cad/files/FreeCAD%20Source/
Debian: http://packages.debian.org/source/sid/freecad
Ubuntu: http://packages.ubuntu.com/source/precise/freecad

Getting the dependencies


To compile FreeCAD under Linux you have to install all libraries mentioned in Third Party Libraries first. On recent distributions, this is generally just a
matter of installing a couple of packages:

Debian and Ubuntu


On Debian-based systems (Debian, Ubuntu, Mint, etc...) it is quite easy to get all needed dependencies installed. Most of the libraries are available via
apt-get or synaptic package manager. Below are listed all packgages you need to install. Note that if you don't use the most recent version of your
distribution, some of the packages below might be missing from your repositories. In that case, look in the Older and non-conventional distributions
section below.
build-essential
cmake
python
python-matplotlib
libtool
either:
libcoin60-dev (Debian Wheezy, Ubuntu 13.04 and before)
or:
libcoin80-dev (Debian wheezy-backports, unstable, testing, Ubuntu 13.10 and forward, See Additional instruction below])
libsoqt4-dev
libxerces-c-dev
libboost-dev
libboost-filesystem-dev
libboost-regex-dev
libboost-program-options-dev
libboost-signals-dev
libboost-thread-dev
libqt4-dev
libqt4-opengl-dev
qt4-dev-tools
python-dev
python-pyside
either:
libopencascade-dev (official opencascade version)
or:
liboce*-dev (opencascade community edition)
oce-draw
gfortran
libeigen3-dev
libqtwebkit-dev
libshiboken-dev
libpyside-dev
libode-dev
swig
libzipios++-dev
libfreetype6
libfreetype6-dev
Additional instruction for libcoin80-dev (Debian wheezy-backports, unstable, testing, Ubuntu 13.10 and forward
Optionally you can also install these extra packages:
libsimage-dev (to make Coin to support additional image file formats)
checkinstall (to register your installed files into your system's package manager, so yo can easily uninstall later)
python-pivy (needed for the 2D Drafting module)
python-qt4 (needed for the 2D Drafting module)
doxygen and libcoin60-doc (if you intend to generate source code documentation)
libspnav-dev (for 3Dconnexion devices support like the Space Navigator or Space Pilot)

Fedora
You need the following packages:
cmake
doxygen
swig
gcc-gfortran
gettext
dos2unix
desktop-file-utils
libXmu-devel
freeimage-devel
mesa-libGLU-devel
OCE-devel
python python-devel
boost-devel
tbb-devel
eigen3-devel
qt-devel
qt-webkit-devel
ode-devel
xerces-c
xerces-c-devel
opencv-devel
smesh-devel
coin2-devel
soqt-devel
freetype
freetype-devel
And optionally:
libspnav-devel (for 3Dconnexion devices support like the Space Navigator or Space Pilot)
pivy ( https://bugzilla.redhat.com/show_bug.cgi?id=458975 Pivy is not mandatory but needed for the Draft module )
Building FreeCAD with coin3 is still more hassle on Fedora, since only coin2 is provided in the official repos, but if you wish so anyway, you can avoid to

rebuild all the coin3 / soqt / pivy suite by installing coin3-ready packages from http://www.zultron.com/rpm-repo/
Fedora 20
Install the "free" and "nonfree" Fedora repositories:

$ su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusio

Now, install the required packages:

$ sudo yum install cmake doxygen swig gcc-gfortran gettext dos2unix desktop-file-utils libXmu-devel freeimage-devel mesa-libGLU-devel OCE-devel python python-devel boost-devel tbb-devel ei

Create a symbolic link so that cmake will find the Coin/Inventor files:

$ sudo ln -s /usr/include/Coin2/Inventor /usr/include/Inventor

Download the tarball for SoQt-1.5.0-10:

$ cd ~/Downloads/
$ wget http://pkgs.fedoraproject.org/repo/pkgs/SoQt/SoQt-1.5.0.tar.gz/9f1e582373d66f556b1db113a93ac68e/SoQt-1.5.0.tar.gz
$ tar -xvf SoQt-1.5.0.tar.gz

Compile SoQt:

$
$
$
$

cd SoQt-1.5.0/
./configure
make
sudo make install

Download, build and install pivy:

$
$
$
$
$

cd ~/Downloads/
hg clone https://bitbucket.org/Coin3D/pivy pivy-code
cd pivy-code
python setup.py build
sudo python setup.py install

Skip to Compile FreeCAD

Gentoo
You need the following packages to build FreeCAD:
dev-cpp/eigen
dev-games/ode
dev-libs/boost
dev-libs/xerces-c
dev-python/pivy
dev-python/PyQt4
media-libs/coin
media-libs/SoQt
sci-libs/opencascade-6.5
sys-libs/zlib
virtual/fortran
x11-libs/qt-gui
x11-libs/qt-opengl
x11-libs/qt-svg
x11-libs/qt-webkit
x11-libs/qt-xmlpatterns
dev-lang/swig-2.0.4-r1
app-admin/eselect-python-20091230
dev-lang/python-2.7.2-r3
dev-util/cmake-2.8.4
sys-apps/findutils-4.4.0
freetype
Since latest opencascade is not available, you might want to compile opencascade too, hence the following additional libaries are needed:
media-libs/ftgl
virtual/opengl
x11-libs/libXmu
dev-lang/tcl-8.5.9
dev-lang/tk-8.5.9-r1
dev-tcltk/itcl-3.4_beta1
dev-tcltk/itk-3.4_pre20090417
dev-tcltk/tix-8.4.3
x11-libs/gl2ps
sys-devel/automake-1.11
sys-devel/autoconf-2.68
sys-devel/libtool
dev-java/java-config-2.1.11-r3

OpenSUSE
You need the following packages:
gcc
cmake
OpenCASCADE-devel
libXerces-c-devel
python-devel
libqt4-devel
python-qt4
Coin-devel
SoQt-devel
boost-devel
libode-devel
libQtWebKit-devel
libeigen3-devel
gcc-fortran
freetype2
freetype2-devel
For FreeCAD 0.13 unstable you need to add Eigen3 and swig libraries, that don't seem to be in standard repos. You can get them with one-click install
here:
Eigen3: http://software.opensuse.org/search?q=eigen3&baseproject=openSUSE%3A12.1&lang=en&exclude_debug=true
swig: http://software.opensuse.org/search?q=swig&baseproject=openSUSE%3A12.1&lang=en&exclude_debug=true
Also, note that Eigen3 Library from Factory Education was causing problems sometimes, so use the one from KDE 4.8 Extra repo

Older and non-conventional distributions


On other distributions, we have very few feedback from users, so it might be harder to find the required packages. Try first locating the required libraries
mentioned in Third Party Libraries. Beware that some of them might have a slightly different package name in your distribution (such as name,
libname, name-dev, name-devel, etc...).
You also need the GNU gcc compiler version equal or above 3.0.0. g++ is also needed because FreeCAD is completely written in C++. During the
compilation some Python scripts get executed. So the Python interpreter has to work properly. To avoid any linker problems during the build process it
is also a good idea to have the library paths either in your LD_LIBRARY_PATH variable or in your ld.so.conf file. This is normally already the case in
recent distributions.
For more details have also a look to README.Linux in your sources.
Below is additional help for a couple of libraries that might not be present in your distribution repositories
Eigen 3

The Eigen3 library is now required by the Sketcher module. This library is only available starting from Ubuntu 11.10 repositories. For prior Ubuntu
releases, you can either download it from here and install it manually, or add the FreeCAD Daily Builds PPA to your software sources before installing
it through one of the means listed below.
OpenCASCADE community edition (OCE)
OpenCasCade has recently been forked into a Community edition, which is much, much easier to build. FreeCAD can use any version installed on
your system, either the "official" edition or the community edition. The OCE website contains detailed build instructions.
OpenCASCADE official version
Note: You are advised to use the OpenCasCade community edition above, which is easier to build, but this one works too.
Not all Linux distributions have an official OpenCASCADE package in their repositories. You have to check yourself for your distribution if one is
available. At least from Debian Lenny and Ubuntu Intrepid on an official .deb package is provided. For older Debian or Ubuntu releases you may get
unofficial packages from here. To build your own private .deb packages follow these steps:
wget http://lyre.mit.edu/~powell/opencascade/opencascade_6.2.0.orig.tar.gz
wget http://lyre.mit.edu/~powell/opencascade/opencascade_6.2.0-7.dsc
wget http://lyre.mit.edu/~powell/opencascade/opencascade_6.2.0-7.diff.gz
dpkg-source -x opencascade_6.2.0-7.dsc
# Install OCC build-deps
sudo apt-get install build-essential devscripts debhelper autoconf
automake libtool bison libx11-dev tcl8.4-dev tk8.4-dev libgl1-mesa-dev
libglu1-mesa-dev java-gcj-compat-dev libxmu-dev
#Build Opencascade packages. This takes hours and requires
# at least 8 GB of free disk space
cd opencascade-6.2.0 ; debuild
# Install the resulting library debs
sudo dpkg -i libopencascade6.2-0_6.2.0-7_i386.deb
libopencascade6.2-dev_6.2.0-7_i386.deb
Alternatively, you can download and compile the latest version from opencascade.org:
Install the package normally, be aware that the installer is a java program that requires the official java runtime edition from Sun (package name: sunjava6-jre), not the open-source java (gij) that is bundled with Ubuntu. Install it if needed:
sudo apt-get remove gij
sudo apt-get install sun-java6-jre
Be careful, if you use gij java with other things like a browser plugin, they won't work anymore. If the installer doesn't work, try:
java -cp path_to_file_setup.jar <-Dtemp.dir=path_to_tmp_directory> run
Once the package is installed, go into the "ros" directory inside the opencascade dir, and do
./configure --with-tcl=/usr/lib/tcl8.4 --with-tk=/usr/lib/tk8.4
Now you can build. Go back to the ros folder and do:
make
It will take a long time, maybe several hours.
When it is done, just install by doing
sudo make install
The library files will be copied into /usr/local/lib which is fine because there they will be found automatically by any program. Alternatively, you can also
do
sudo checkinstall
which will do the same as make install but create an entry in your package management system so you can easily uninstall later. Now clean up the
enormous temporary compilation files by doing
make clean
Possible error 1: If you are using OCC version 6.2, it is likely that the compiler will stop right after the beginning of the "make" operation. If it happens,
edit the "configure" script, locate the CXXFLAGS="$CXXFLAGS " statement, and replace it by CXXFLAGS="$CXXFLAGS -ffriend-injection -fpermissive".
Then do the configure step again.
Possible error 2: Possibly several modules (WOKSH, WOKLibs, TKWOKTcl, TKViewerTest and TKDraw) will complain that they couldn't find the tcl/tk
headers. In that case, since the option is not offered in the configure script, you will have to edit manually the makefile of each of those modules: Go into
adm/make and into each of the bad modules folders. Edit the Makefile, and locate the lines CSF_TclLibs_INCLUDES = -I/usr/include and
CSF_TclTkLibs_INCLUDES = -I/usr/include and add /tcl8.4 and /tk8.4 to it so they read: CSF_TclLibs_INCLUDES = -I/usr/include/tcl8.4 and
CSF_TclTkLibs_INCLUDES = -I/usr/include/tk8.4
SoQt
The SoQt library must be compiled against Qt4, which is the case in most recent distributions. But at the time of writing this article there were only
SoQt4 packages for Debian itself available but not for all Ubuntu versions. To get the packages built do the following steps:
wget http://ftp.de.debian.org/debian/pool/main/s/soqt/soqt_1.4.1.orig.tar.gz
wget http://ftp.de.debian.org/debian/pool/main/s/soqt/soqt_1.4.1-6.dsc
wget http://ftp.de.debian.org/debian/pool/main/s/soqt/soqt_1.4.1-6.diff.gz
dpkg-source -x soqt_1.4.1-6.dsc
sudo apt-get install doxygen devscripts fakeroot debhelper libqt3-mt-dev qt3-dev-tools libqt4-opengl-dev
cd soqt-1.4.1
debuild
sudo dpkg -i libsoqt4-20_1.4.1-6_i386.deb libsoqt4-dev_1.4.1-6_i386.deb libsoqt-dev-common_1.4.1-6_i386.deb
If you are on a 64bit system, you will probably need to change i386 by amd64.
Pivy
Pivy is not needed to build FreeCAD or to run it, but it is needed for the 2D Drafting module to work. If you are not going to use that module, you won't
need pivy. At the time of writing, Pivy is very new and might not have made its way into your distribution repository. If you cannot find Pivy in your
distribution's packages repository, you can grab debian/ubuntu packages on the FreeCAD download page:
http://sourceforge.net/projects/free-cad/files/FreeCAD%20Linux/
or compile pivy yourself:
Pivy compilation instructions

Compile FreeCAD
Using cMake
cMake is a newer build system which has the big advantage of being common for different target systems (Linux, Windows, MacOSX, etc). FreeCAD is
now using the cMake system as its main building system. Compiling with cMake is usually very simple and happens in 2 steps. In the first step, cMake
checks that every needed programs and libraries are present on your system and sets up all that's necessary for the subsequent compilation. You are
given a few alternatives detailed below, but FreeCAD comes with sensible defaults. The second step is the compiling itself, which produces the FreeCAD
executable.
Since FreeCAD is a heavy application, compiling can take a bit of time (about 10 minutes on a fast machine, 30 minutes on a slow one)
In-souce building
FreeCAD can be built in-source, which means that all the files resulting from the compilation stay in the same folder as the source code. This is fine if
you are just looking at FreeCAD, and want to be able to remove it easily by just deleting that folder. But in case you are planning to compile it often, you
are advised to make an out-of-source build, which offers many more advantages. The following commands will compile freecad:

$ cd freecad (the folder where you cloned the freecad source)

If you installed pivy from source, set the compiler flag to use the correct pivy (via FREECAD_USE_EXTERNAL_PIVY=1). Also, set the build type to
debug. (NOTE: the "." and space after the cmake flags are CRITICAL!):

$ cmake -DFREECAD_USE_EXTERNAL_PIVY=1 -DCMAKE_BUILD_TYPE=Debug .


$ make

$ ./bin/FreeCAD

Out-of-source build
If you intend to follow the fast evolution of FreeCAD, building in a separate folder is much more convenient. Everytime you update the source code,
cMake will then intelligently distinguish which files have changed, and recompile only what is needed. Out-of-source builds are specially handy when
using the Git system, because you can easily try other branches without confusing the build system. To build out-of-source, simply create a build
directory, distinct from your freecad source folder, and, from the build folder, point cMake to the source folder:
mkdir freecad-build
cd freecad-build
cmake ../freecad (or whatever the path is to your FreeCAD source folder)
make
The FreeCAD executable will then reside in the "bin" directory (within your freecad-build directory).
Configuration options
There are a number of experimental or unfinished modules you may have to build if you want to work on them. To do so, you need to set the proper
options for the configuration phase. Do it either on the command line, passing -D <var>:<type>=<value> options to cMake or using one of the availables
gui-frontends (eg for Debian, packages cmake-qt-gui or cmake-curses-gui).
As an example, to configure on the command line with the Assembly module built, issue:
cmake -D FREECAD_BUILD_ASSEMBLY:BOOL=ON ''path-to-freecad-root''
Possible options are listed in FreeCAD's root CmakeLists.txt file.

Using autotools
Autotools is in the process of being deprecated in favor of cMake, but at the moment it is still available to build FreeCAD. You must have automake and
libtool installed on your system; on Debian/Ubuntu:
aptitude install automake libtool
If you got the sources with git or subversion, then the very first step must be
./autogen.sh
that creates the configure script and more. For the build process itself we provide a configure script. Just type
./configure
To get everything configured. If you want an overview of all options you can specify, you can type
./configure --help
Normally you need none of them - unless you have one of your libraries installed in a really uncommon directory. After configuration has finished,
compiling FreeCAD is as simple as
make
If any error occurs while building from sources, please double-check this page and README.Linux file, then you could jump to the Bug Tracker on
SourceForge, choose Any for status and click the Browse button to see previous reports on compile problems. After having built FreeCAD successfully,
do
make install
to install it onto your machine. The default install directory is
~/FreeCAD
It will be installed in a FreeCAD folder in your home folder, so you don't need root privileges. Instead of make install, you can also do
checkinstall
In this way FreeCAD will be installed by your package management system, so you can uninstall it easily later. But since all of FreeCAD installation
resides into one single directory, just removing the FreeCAD directory is a valid way to uninstall too.
Qt designer plugin
If you want to develop Qt stuff for FreeCAD, you'll need the Qt Designer plugin that provides all custom widgets of FreeCAD. Go to
freecad/src/Tools/plugins/widget
So far we don't provide a makefile -- but calling
qmake plugin.pro
creates it. Once that's done, calling
make
will create the library libFreeCAD_widgets.so. To make this library known to Qt Designer you have to copy the file to $QTDIR/plugin/designer
Doxygen
If you feel bold enough to dive in the code, you could take advantage to build and consult Doxygen generated FreeCAD's Source documentation

Making a debian package


If you plan to build a Debian package out of the sources you need to install those packages first:
dh-make
devscripts
lintian (optional, used for checking if packages are standard-compliant)
To build a package open a console, simply go to the FreeCAD directory and call
debuild
Once the package is built, you can use lintian to check if the package contains errors
lintian your-fresh-new-freecad-package.deb (replace by the name of the package you just created)

Troubleshooting
Note for 64bit systems
When building FreeCAD for 64-bit there is a known issue with the OpenCASCADE 64-bit package. To get FreeCAD running properly you might need to
run the ./configure script with the additional define _OCC64 set:
./configure CXXFLAGS="-D_OCC64"
For Debian based systems this workaround is not needed when using the prebuilt package because there the OpenCASCADE package is built to set
internally this define. Now you just need to compile FreeCAD the same way as described above.

Automake macros
The configure script of FreeCAD makes use of several automake macros that are sometimes not installed with their packages: bnv_have_qt.m4,
coin.m4, and soqt.m4. If needed (error while configuring), google for them and you will find them easily. They are just simple scripts that you need to put
in your /usr/share/aclocal folder.

Fedora 13
To build & install FreeCAD on Fedora 13, a few tips and tricks are needed:
Install a bunch of required packages, most are available from the Fedora 13 repositories
Download and build xerces
Download and build OpenCascade. Need to point it to xmu: ./configure --with-xmu-include=/usr/include/X11/Xmu --with-xmu-library=/usr/lib
Download and build Pivy. You have to remove 2 references to non existent "SoQtSpaceball.h" from pivy/interfaces/soqt.i Commenting out those
two lines allow the build & install to work.

Configure Freecad. You will need to point it to a few things: ./configure --with-qt4-include=/usr/include --with-qt4-bin=/usr/lib/qt4/bin --with-occlib=/usr/local/lib --with-occ-include=/usr/local/inc --with-xercesc-lib=/usr/local/lib
make - hits a problem where the build is breaking because the ldflags for soqt are set to "-LNONE" which made libtool barf. My hackish
workaround was to modify /usr/lib/Coin2/conf/soqt-default.cfg so that the ldflags are "" instead of "-LNONE". After this -> success !
make install

Ubuntu Lucid
In Ubuntu Lucid, you don't need the qtwebkit-dev, since it is included into qt4-dev.

Automatic build scripts


Here is all what you need for a complete build of FreeCAD. It's a one-script-approach and works on a fresh installed distro. The commands will ask for
root password (for installation of packages) and sometime to acknowledge a fingerprint for an external repository server or https-subversion repository.
This scripts should run on 32 and 64 bit versions. They are written for distinct version, but are also likely to run on a later version with or without minor
changes.
If you have such a script for your preferred distro, please send it! We will incorporate it into this article.
Note that this script starts by adding the FreeCAD Daily Builds PPA repository so it can proceed with the Eigen3 library (libeigen3-dev) installation. If
you already have this library installed on your system, you can remove the first line.

Ubuntu 10.04 LTS - Lucid Lynx / Ubuntu 10.10 Maverick Meerkat / Ubuntu 11.04 Natty Narwhal
sudo add-apt-repository ppa:freecad-maintainers/freecad-daily && sudo apt-get update
sudo apt-get install build-essential python libcoin60-dev libsoqt4-dev \
libxerces-c2-dev libboost-dev libboost-date-time-dev libboost-filesystem-dev \
libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev \
libboost-serialization-dev libboost-signals-dev libboost-regex-dev libboost-thread-dev \
libqt4-dev qt4-dev-tools python2.7-dev libopencascade-dev libsoqt4-dev \
libode-dev subversion cmake libeigen2-dev libsimage-dev python-qt4 \
libtool autotools-dev automake bison flex gfortran libeigen3-dev libqtwebkit-dev git
# checkout the latest source
git clone git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad freecad
# go to source dir
cd freecad
# build configuration
cmake .
# build FreeCAD
make
# test FreeCAD
cd bin
./FreeCAD -t 0
# use FreeCAD
./FreeCAD
# Update latest version
# go to source dir
cd freecad
# Update source
git pull
# build configuration
cmake .
# build FreeCAD
make

OpenSUSE 12.2
No external Repositories are needed to compile FreeCAD 0.13 with this release. However, there is an imcompatability with python3-devel which needs to
be removed. FreeCAD can be compiled from GIT similar to in OpenSUSE 12.2
# install needed packages for development
sudo zypper install gcc cmake OpenCASCADE-devel libXerces-c-devel \
python-devel libqt4-devel python-qt4 Coin-devel SoQt-devel boost-devel \
libode-devel libQtWebKit-devel libeigen3-devel gcc-fortran git swig
# create new dir, and go into it
mkdir FreeCAD-Compiled
cd FreeCAD-Compiled
# get the source
git clone git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
# Now you will have subfolder in this location called free-cad. It contains the source
# make another dir for compilation, and go into it
mkdir FreeCAD-Build1
cd FreeCAD-Build1
# build configuration
cmake ../free-cad
# build FreeCAD
make
# test FreeCAD
cd bin
./FreeCAD -t 0
Since you are using git, next time you wish to compile you do not have to clone everything, just pull from git and compile once more
# go into free-cad dir created earlier
cd free-cad
# pull
git pull
# get back to previous dir
cd ..
# Now repeat last few steps from before.
# make another dir for compilation, and go into it
mkdir FreeCAD-Build2
cd FreeCAD-Build2
# build configuration
cmake ../free-cad
# build FreeCAD
make
# test FreeCAD
cd bin
./FreeCAD -t 0

OpenSUSE 12.1
For FreeCAD 0.13 unstable you need to add Eigen3 and swig libraries, that don't seem to be in standard repos. You can get them with one-click install
here:
Eigen3: http://software.opensuse.org/search?q=eigen3&baseproject=openSUSE%3A12.1&lang=en&exclude_debug=true
swig: http://software.opensuse.org/search?q=swig&baseproject=openSUSE%3A12.1&lang=en&exclude_debug=true
# install needed packages for development
sudo zypper install gcc cmake OpenCASCADE-devel libXerces-c-devel \
python-devel libqt4-devel python-qt4 Coin-devel SoQt-devel boost-devel \
libode-devel libQtWebKit-devel libeigen3-devel gcc-fortran git
# create new dir, and go into it

mkdir FreeCAD-Compiled
cd FreeCAD-Compiled
# get the source
git clone git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
# Now you will have subfolder in this location called free-cad. It contains the source
# make another dir for compilation, and go into it
mkdir FreeCAD-Build1
cd FreeCAD-Build1
# build configuration
cmake ../free-cad
# build FreeCAD
make
# test FreeCAD
cd bin
./FreeCAD -t 0
Since you are using git, next time you wish to compile you do not have to clone everything, just pull from git and compile once more
# go into free-cad dir created earlier
cd free-cad
# pull
git pull
# get back to previous dir
cd ..
# Now repeat last few steps from before.
# make another dir for compilation, and go into it
mkdir FreeCAD-Build2
cd FreeCAD-Build2
# build configuration
cmake ../free-cad
# build FreeCAD
make
# test FreeCAD
cd bin
./FreeCAD -t 0

OpenSuse 11.2
This script is not working at the moment because:
libXerces-c-devel seams to be disappeared ....

# install needed packages for development


sudo zypper install gcc cmake subversion OpenCASCADE-devel \
libXerces-c-devel python-devel libqt4-devel python-qt4 \
Coin-devel SoQt-devel boost-devel libode-devel libQtWebKit-devel \
libeigen2-devel gcc-fortran
# get the source
git clone git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad freecad
# go to source dir
cd freecad
# build configuration
cmake .
# build FreeCAD
nice make
# test FreeCAD
cd bin
./FreeCAD -t 0

OpenSuse 11.1
# additional repository (for OpenCascade)
sudo zypper -p http://packman.unixheads.com/suse/11.1/
# install needed packages for development
sudo zypper install gcc cmake subversion OpenCASCADE-devel \
libXerces-c-devel python-devel libqt4-devel python-qt4 \
Coin-devel SoQt-devel boost-devel libode-devel libQtWebKit-devel \
libeigen2-devel
# get the source
git clone git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad freecad
# go to source dir
cd freecad
# build configuration
cmake .
# build FreeCAD
nice make
# test FreeCAD
cd bin
./FreeCAD -t 0

Debian Squeeze
# get the needed tools and libs
sudo apt-get install build-essential python libcoin60-dev libsoqt4-dev \
libxerces-c2-dev libboost-dev libboost-date-time-dev libboost-filesystem-dev \
libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev \
libboost-serialization-dev libboost-signals-dev libboost-regex-dev \
libqt4-dev qt4-dev-tools python2.5-dev \
libsimage-dev libopencascade-dev \
libsoqt4-dev libode-dev subversion cmake libeigen2-dev python-pivy \
libtool autotools-dev automake gfortran
# checkout the latest source
git clone git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad freecad
# go to source dir
cd freecad
# build configuration
cmake .
# build FreeCAD
make
# test FreeCAD
cd bin
./FreeCAD -t 0

Updating the source code


FreeCAD development happens fast, everyday or so there are bug fixes or new features. The cmake systems allows you to intelligently update the
source code, and only recompile what has changed, making subsequent compilations very fast. Updating the source code with git or subversion is very
easy:

cd freecad (or where you cloned the source code the first time)
git pull (if you are using git)
Move into the appropriate build directory and run cmake again (as cmake updates the version number data for the Help menu, ...about FreeCAD),
however you do not need to add the path to source code after "cmake", just a space and a dot:
cd ../freecad-build (or wherever your build directory is located)
cmake .
make
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=CompileOnUnix&oldid=84577"

CompileOnMac
Since Mac OS X is BSD (UNIX) based, compiling FreeCAD on a Mac isn't much different from CompileOnUnix, however there are a number of Macspecific details critical to getting everything working properly. These instructions have been tested on Lion (10.7), but should work on Intel Macs running
(Snow) Leopard as well.

Getting the source


Before you can compile FreeCAD, you need the source code. There are 3 ways to get it:

Git
The quickest and best way to get the code is to clone the read-only git repository (you need the git package installed):
git clone git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad freecad
This will place a copy of the latest version of the FreeCAD source code in a new directory called "freecad". The first time you try connecting to the freecad.git.sourceforge.net host, you will receive a message asking to authenticate the sourceforge SSH key, which is normally safe to accept (you can
check their SSH keys on the sourceforge website if you are not sure)

Github
There is an always up to date FreeCAD repository on Gihub: github.com/FreeCAD/FreeCAD_sf_master

Source package
Alternatively you can download a source package, but they could be already quite old so it's always better to get the latest sources. Depending on your
distribution, there are several ways to obtain a source package:
Official FreeCAD source packages (distribution-independent): https://sourceforge.net/projects/free-cad/files/FreeCAD%20Source/
Debian: http://packages.debian.org/source/sid/freecad
Ubuntu: http://packages.ubuntu.com/source/precise/freecad

Install Dependencies
On Mac OS X 10.7, the following dependencies are NOT bundled with the operating and thus must be installed before building FreeCAD:
sip
fortran
xerces-c
boost
eigen
ftgl
coin3d
OpenCASCADE
Qt
pyqt
soqt

Option 1: Homebrew
Note: this section is still a work in progress! See the help forum post for the latest.
https://forum.freecadweb.org/viewtopic.php?f=4&t=2064&p=15405
Download and install the package manager Homebrew:
http://mxcl.github.com/homebrew/
Then compile and install most of FreeCAD's dependencies:
brew install sip gfortran xerces-c boost eigen coin qt pyqt soqt ftgl
Go on to CompileOnMac#Build OpenCASCADE.
Option 2: MacPorts/Fink
Note: this section is in need of updates.
Install MacPorts )if you don't already have it). MacPorts is a system that allows you to download, compile, and install many common open-source
applications with a single command. Similar applications from the UNIX/Linux world are PKGSRC and APT. To install, just download the disk image from
the MacPorts site and follow the directions:
http://www.macports.org/install.php
Whether or not you just installed MacPorts, you'll probably want to make sure it's up to date. Run:
sudo port selfupdate
Now that MacPorts is installed and up to date, you can start installing some of FreeCAD's required packages:
xercesc
boost
py-sip
ftlg
f2c
eigen3
py-pyqt4
Coin
The following command will compile/install the above libraries. If MacPorts produces errors, you may want to try installing them one at a time.
sudo port install xercesc boost ftgl f2c eigen3 py-sip py-pyqt4 Coin
Note that for python packages like py-sip and py-pyqt4, there are multiple packages, one for each MacPorts version of Python.
Note that boost is a large package, and py-pyqt4 depends on qt4-mac, which is a large package. You may want to run port -v install so that you have

more of an idea what's going on during these long builds.


Qt4 is also available for Mac as a binary installer from the Qt web site. I'm not sure how nicely this approach plays with FreeCAD compiling.
It is also possible to choose the version of the gcc compiler to use, some recent versions might sometimes cause problems:
sudo port -v install gcc_select
sudo port select --list gcc
sudo port select --set gcc mp-gcc46
Install Fortran Compiler
You also need a FORTRAN compiler. Apple's fork of gcc on OSX does not come with FORTRAN.
An installer for GFortran can be found here, and will do the trick:
http://gcc.gnu.org/wiki/GFortranBinaries#MacOS
If you are using fink, another method is to use the following commands (attempted by Shaneyfelt 2100.Nov.14)
sudo fink selfupdate
sudo fink install gcc46
This installs another gcc compiler collection with the name gcc-4 to avoid a name conflict with the apple one.
MacPorts gcc4x packages also include FORTRAN compilers, so this should also work:
sudo port install gcc46
Another possible MacPorts package is g95. This seems to be a valid FORTRAN90 compiler and will pass FreeCAD's cmake configuration tests, but the
actual build seems to ask for gcc-specific options, so probably easier to stick to gcc4x.
Install Eigen3
Download and unzip the latest eigen3 library here:
http://eigen.tuxfamily.org/index.php?title=Main_Page
These are needed for solver functionality. Once unzipped, the folder named 'Eigen' can be dropped into
/usr/local/include/eigen3/

Build OpenCASCADE
Currently, the easiest way to build OpenCASCADE on OS X is from the community edition (oce). Download the source or check out the Git repository
from:
https://github.com/tpaviot/oce
Then, in terminal:
mkdir build
cd build
cmake ..
cd ..
make
make install/strip
You may need cmake:
sudo port install cmake

Download and 'install' the FreeCAD.app template


The following archive contains an application bundle template for FreeCAD. This is not strictly necessary, but it makes working with FreeCAD more
convenient than the default installation configuration. The recommended install location for the bundle is the /Applications folder, but you should be able
to put it anywhere you want -- just remember that the bundle can't be moved after FreeCAD is complied and installed without further modifications.
Running make install using the configuration in the next step will install into this bundle.
http://dl.getdropbox.com/u/103808/FreeCAD/FreeCAD_bundle_template_20091128.tar.gz

Compile
Configure, compile, and install FreeCAD using the following commands from within the root FreeCAD folder. If you put your FreeCAD.app bundle
somewhere other than /Applications (or aren't using the bundle), change the 'PREFIX' argument accordingly.
./autogen.sh
PREFIX=/Applications/FreeCAD.app/Contents
If you installed dependencies using Option 1 (Homebrew):
Note: this config line has not been verified and may contain errors!
./configure --with-xercesc-lib=/usr/local/lib --with-xercesc-include=/usr/local/include \
--with-boost-lib=/usr/local/lib --with-boost-include=/usr/local/include \
--with-qt4-dir=/usr/local--with-qt4-lib=/usr/local/lib --with-qt4-include=/usr/local/include \
--with-qt4-framework=/usr/local/lib --with-qt4-bin=/usr/local/bin --with-occ-lib=/usr/local/lib \
--with-occ-include=/usr/local/include/oce --with-coin=/usr/local/lib --with-soqt=/usr/local/lib \
--prefix=/Applications/FreeCAD.app/Contents --bindir=/Applications/FreeCAD.app/Contents/MacOS \
--libdir=/Applications/FreeCAD.app/Contents/Frameworks/FreeCAD \
--includedir=/Applications/FreeCAD.app/Contents/Resources/include \
--datarootdir=/Applications/FreeCAD.app/Contents/Resources/share --enable-debug=no \
--with-python-include=/System/Library/Frameworks/Python.framework/Versions/2.5/Headers
Or if you installed dependencies using Option 2 (MacPorts/Fink):
./configure --with-xercesc-lib=/opt/local/lib --with-xercesc-include=/opt/local/include \
--with-boost-lib=/opt/local/lib --with-boost-include=/opt/local/include \
--with-qt4-dir=/usr/local/Trolltech/Qt-4.8.0 --with-qt4-lib=/usr/local/Trolltech/Qt-4.8.0/lib \
--with-qt4-include=/usr/local/Trolltech/Qt-4.8.0/include --with-qt4-framework=/Library/Frameworks \
--with-qt4-bin=/usr/local/Trolltech/Qt-4.8.0/bin --with-occ-lib=/usr/local/lib \

--with-occ-include=/usr/local/include/oce --with-coin=/Library/Frameworks \
--with-soqt=/Library/Frameworks --prefix=/Applications/FreeCAD.app/Contents \
--bindir=/Applications/FreeCAD.app/Contents/MacOS --libdir=/Applications/FreeCAD.app/Contents/Frameworks/FreeCAD \
--includedir=/Applications/FreeCAD.app/Contents/Resources/include \
--datarootdir=/Applications/FreeCAD.app/Contents/Resources/share --enable-debug=no \
--with-python-include=/System/Library/Frameworks/Python.framework/Versions/2.5/Headers
Then:
make
make install
Depending on your machine's processing power, the make step can take quite a while.

Run
If everything went OK, double-clicking the .app bundle should start FreeCAD. If you have any issues, post the details on the help forum.

PyQt4
Some users reported facing a "No Module named PyQt4" message on FreeCAD startup. This is a workaround to correct it:
cd /Library/Python/2.6/site-packages
sudo ln -s /contrib/lib/python2.6/site-packages/PyQt4 .
sudo ln -s /contrib/lib/python2.6/site-packages/sip* .
cd /volatile/FreeCAD-r5443-ser/bin/pivy
cp _coin.dylib _coin.so
cd /volatile/FreeCAD-r5443-ser/lib
for i in *.dylib; do j=`basename $i .dylib`; cp $i $j.so; done

Pivy
Some FreeCAD components won't work without Pivy. See here for partial build instructions.

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=CompileOnMac&oldid=43013"

Third Party Libraries


Overview
These are libraries which are not changed in the FreeCAD project. They are basically used unchanged as a dynamic link library (*.so or *.dll). If there is
a change necessary or a wrapper class is needed, then the code of the wrapper or the changed library code have to be moved to the FreeCAD base
package. The used libraries are:
Consider using LibPack instead of downloading and installing all the stuff on your own.

Links

Link table
Lib name
Version needed Link to get it
Python
>= 2.5.x
http://www.python.org/
OpenCasCade >= 5.2
http://www.opencascade.org
Qt
>= 4.1.x
http://www.qtsoftware.com
Coin3D
>= 2.x
http://www.coin3d.org
ODE
>= 0.10.x
http://www.ode.org
SoQt
>= 1.2
http://www.coin3d.org
Xerces-C++
>= 2.7.x < 3.0
http://xml.apache.org/xerces-c/
GTS
>= 0.7.x
http://gts.sourceforge.net/
Zlib
>= 1.x.x
http://www.zlib.net/
Boost
>= 1.33.x
http://www.boost.org/
Eigen3
>= 3.0.1
http://eigen.tuxfamily.org/index.php?title=Main_Page
Details
Python
Version: 2.5 or higher
License: Python 2.5 license
You can use the source or binary from http://www.python.org/ or use alternetivly ActiveState Python from http://www.activestate.com/ though it is a
little bit hard to get the debug libs from ActiveState.
Description

Python is the primary scripting language and is used throughout the application. For example:
Implement test scripts for testing on:
memory leaks
ensure presents of functionality after changes
post build checks
test coverage tests
Macros and macro recording
Implement application logic for standard packages
Implementation of whole workbenches
Dynamic loading of packages
Implementing rules for design (Knowledge engineering)
Doing some fancy Internet stuff like work groups and PDM
And so on ...
Especially the dynamic package loading of Python is used to load at run time additional functionality and workbenches needed for the actual tasks. For
a closer look to Python see: www.python.org Why Python you may ask. There are some reasons: So far I used different scripting languages in my
professional life:
Perl
Tcl/Tk
VB
Java
Python is more OO then Perl and Tcl, the code is not a mess like in Perl and VB. Java isn't a script language in the first place and hard (or impossible)
to embed. Python is well documented and easy to embed and extend. It is also well tested and has a strong back hold in the open source community.
Credits

Goes to Guido van Rossum and a lot of people made Python such a success!
OpenCasCade
Version: 5.2 or higher
License: OCTPL
OCC is a full-featured CAD Kernel. Originally, it's developed by Matra Datavision in France for the Strim (Styler) and Euclid Quantum applications and
later on made Open Source. It's a really huge library and makes a free CAD application possible in the first place, by providing some packages which
would be hard or impossible to implement in an Open Source project:
A complete STEP compliant geometry kernel
A topological data model and all needed functions to work on (cut, fuse, extrude, and so on. . . )
Standard Import- / Export processors like STEP, IGES, VRML

3D and 2D viewer with selection support


A document and project data structure with support for save and restore, external linking of documents, recalculation of design history (parametric
modeling) and a facility to load new data types as an extension package dynamically
To learn more about OpenCasCade take a look at the OpenCasCade page or http://www.opencascade.org.
Qt
Version: 4.1.x or higher
License: GPL v2.0/v3.0 or Commercial (from version 4.5 on also LPGL v2.1)
I don't think I need to tell a lot about Qt. It's one of the most often used GUI toolkits in Open Source projects. For me the most important point to use Qt
is the Qt Designer and the possibility to load whole dialog boxes as a (XML) resource and incorporate specialized widgets. In a CAX application the user
interaction and dialog boxes are by far the biggest part of the code and a good dialog designer is very important to easily extend FreeCAD with new
functionality. Further information and a very good online documentation you'll find on http://www.qtsoftware.com.
Coin3D
Version: 2.0 or higer
License: GPL v2.0 or Commercial
Coin is a high-level 3D graphics library with a C++ Application Programming Interface. Coin uses scenegraph data structures to render real-time graphics
suitable for mostly all kinds of scientific and engineering visualization applications.
Coin is portable over a wide range of platforms: any UNIX / Linux / *BSD platform, all Microsoft Windows operating system, and Mac OS X.
Coin is built on the industry-standard OpenGL immediate mode rendering library, and adds abstractions for higher-level primitives, provides 3D
interactivity, immensely increases programmer convenience and productivity, and contains many complex optimization features for fast rendering that
are transparent for the application programmer.
Coin is based on the SGI Open Inventor API. Open Inventor, for those who are not familiar with it, has long since become the de facto standard graphics
library for 3D visualization and visual simulation software in the scientific and engineering community. It has proved it's worth over a period of more than
10 years, its maturity contributing to its success as a major building block in thousands of large-scale engineering applications around the world.
We will use OpenInventor as 3D viewer in FreeCAD because the OpenCasCade viewer (AIS and Graphics3D) has serios limitations and performace
bottlenecks, especially when it goes in large-scale engineering rendering. Other things like textures or volumetric rendering are not really supported, and
so on ....
Since Version 2.0 Coin uses a different licence model. It's not longer LGPL. They use GPL for open source and a commercial licence for closed source.
That means if you want to sell your work based on FreeCAD (extension modules) you need to purchase a Coin licence!
ODE (Open dynamic engine)
Version: 0.10.0 or higher
License: LGPL v2.1 or later or BSD
ODE is an open source, high performance library for simulating rigid body dynamics. It is fully featured, stable, mature and platform independent with an
easy to use C/C++ API. It has advanced joint types and integrated collision detection with friction. ODE is useful for simulating vehicles, objects in virtual
reality environments and virtual creatures. It is currently used in many computer games, 3D authoring tools and simulation tools.
Credits

Russell Smith is the primary author of ODE.

SoQt
Version: 1.2.0 or higher
License: GPL v2.0 or Commercial
SoQt is the Inventor binding to the Qt Gui Toolkit. Unfortunately, it's not longer LGPL so we have to remove it from the code base of FreeCAD and link it
as a library. It has the same licence model like Coin. And you have to compile it with your version of Qt.
Xerces-C++
Version: 2.7.0 or higher
License: Apache Software License Version 2.0
Xerces-C++ is a validating XML parser written in a portable subset of C++. Xerces-C++ makes it easy to give your application the ability to read and write
XML data. A shared library is provided for parsing, generating, manipulating, and validating XML documents.
Xerces-C++ is faithful to the XML 1.0 recommendation and many associated standards (see Features below).
The parser provides high performance, modularity, and scalability. Source code, samples and API documentation are provided with the parser. For
portability, care has been taken to make minimal use of templates, no RTTI, and minimal use of #ifdefs.
The parser is used for saving and restoring parameters in FreeCAD.
GTS
Version: 0.7.x
License: LGPL v2.0 or later
GTS stands for the GNU Triangulated Surface Library. It is an Open Source Free Software Library intended to provide a set of useful functions to deal
with 3D surfaces meshed with interconnected triangles. The source code is available free of charge under the Free Software LGPL license.

Actually not needed to compile FreeCAD. You can switch on the usage with a proprocessor switch in FCConfig.h.
Zlib
Version: 1.x.x
License: zlib License
zlib is designed to be a free, general-purpose, legally unencumbered -- that is, not covered by any patents -- lossless data-compression library for use on
virtually any computer hardware and operating system. The zlib data format is itself portable across platforms. Unlike the LZW compression method
used in Unix compress(1) and in the GIF image format, the compression method currently used in zlib essentially never expands the data. (LZW can
double or triple the file size in extreme cases.) zlib's memory footprint is also independent of the input data and can be reduced, if necessary, at some
cost in compression.

Boost
Version: 1.33.x
License: Boost Software License - Version 1.0
The Boost C++ libraries are a collection of peer-reviewed, open source libraries that extend the functionality of C++. The libraries are licensed under the
Boost Software License, designed to allow Boost to be used with both open and closed source projects. Many of Boost's founders are on the C++
standard committee and several Boost libraries have been accepted for incorporation into the Technical Report 1 of C++0x.
The libraries are aimed at a wide range of C++ users and application domains. They range from general-purpose libraries like SmartPtr, to OS
Abstractions like FileSystem, to libraries primarily aimed at other library developers and advanced C++ users, like MPL.
In order to ensure efficiency and flexibility, Boost makes extensive use of templates. Boost has been a source of extensive work and research into
generic programming and meta-programming in C++.
See: http://www.boost.org/ for details.

LibPack
LibPack is a convenient package with all the above libraries packed together. It is currently available for the Windows platform on the Download page! If
you're working under Linux you don't need a LibPack, instead of you should make use of the package repositories of your Linux distribution.
FreeCADLibs7.x Changelog
Using QT 4.5.x and Coin 3.1.x
Eigen template lib for Robot added
SMESH experimental

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Third_Party_Libraries&oldid=16748"

Third Party Tools


Tool Page
For every serious software development you need tools. Here is a list of tools we use to develop FreeCAD:

Platform independend tools


Qt-Toolkit
The Qt-toolkit is a state of the art, plattform independend user interface design tool. It is contained in the LibPack of FreeCAD, but can also be
downloaded at Qt project.
InkScape
Great vector drawing programm. Adhers to the SVG standard and is used to draw Icons and Pictures. Get it at www.inkscape.org.
Doxygen
A very good and stable tool to generate source documentation from the .h and .cpp files.
The Gimp
Not much to say about the Gnu Image Manipulation Program. Besides it can handle .xpm files which is a very convenient way to handle Icons in QT
Programms. XPM is basicly C-Code which can be compiled into a programme.
Get the GIMP here: www.gimp.org

Tools on Windows
Visual Studio 8 Express
Although VC8 is for C++ development not really a step forward since VisualStudio 6 (IMO a big step back), its a free development system on Windows.
For native Win32 applications you need to download the PlatformSDK from M$.
So the Express edition is hard to find. But you might try this link
CamStudio
Is a Open Source tool to record Screencasts (Webcasts). Its a very good tool to create tutorials by recording them. Its far not so boring as writing
documentation.
See camstudio.org for details.

Tortoise SVN
This is a very great tool. It makes using Subversion (our version control system on sf.net) a real pleasure. You can throught out the explorer integration,
easily manage Revisions, check on Diffs, resolve Confilcts, make branches, and so on.... The commit dialog itself is a piece of art. It gives you an
overview over your changed files and allows you to put them in the commit or not. That makes it easy to bundle the changes to logical units and give
them an clear commit message.
You find ToroiseSVN on tortoisesvn.tigris.org.
StarUML
A full featured Open Source UML programm. It has a lot of features of the big ones, including reverse engeniering C++ source code....
Download here: staruml.sourceforge.net

Tools on Linux
TODO
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Third_Party_Tools&oldid=16963"

Start up and Configuration


This page shows the different ways to start FreeCAD and the most important configuration features.

Starting FreeCAD from the Command line


FreeCAD can be started normally, by double-clicking on its desktop icon or selecting it from the start menu, but it can also be started directly from the
command line. This allows you to change soem of the default startup options.

Command line options


The command line options are subject of frequent changes, therefore it is a good idea to check the current options by typing:
FreeCAD --help
From the response you can read the possible parameters:
Usage:
FreeCAD [options] File1 File2 .....
Allowed options:
Generic options:
-v [ --version ]
-h [ --help ]
-c [ --console ]

print version string


print help message
start in console mode

Configuration:
-l [ --write-log ] arg
-t [ --run-test ] arg
-M [ --module-path ] arg
-P [ --python-path ] arg
--response-file arg

write a log file


test level
additional module paths
additional python paths
can be specified with '@name', too

Response and config files


FreeCAD can read some of these options from a config file. This file must be in the bin path and must be named FreeCAD.cfg. Be aware that options
specified in the command line override the config file!
Some operating system have very low limit of the command line length. The common way to work around those limitations is using response files. A
response file is just a configuration file which uses the same syntax as the command line. If the command line specifies a name of response file to use,
it's loaded and parsed in addition to the command line:
FreeCAD @ResponseFile.txt
or:
FreeCAD --response-file=ResponseFile.txt

Hidden options
There are a couple of options not visible to the user. These options are e.g. the X-Window parameters parsed by the Windows system:
-display display, sets the X display (default is $DISPLAY).
-geometry geometry, sets the client geometry of the first window that is shown.
-fn or -font font, defines the application font. The font should be specified using an X logical font description.
-bg or -background color, sets the default background color and an application palette (light and dark shades are calculated).
-fg or -foreground color, sets the default foreground color.
-btn or -button color, sets the default button color.
-name name, sets the application name.
-title title, sets the application title.
-visual TrueColor, forces the application to use a TrueColor visual on an 8-bit display.
-ncols count, limits the number of colors allocated in the color cube on an 8-bit display, if the application is using the QApplication::ManyColor
color specification. If count is 216 then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green, and 6 of blue); for other values, a cube
approximately proportional to a 2x3x1 cube is used.
-cmap, causes the application to install a private color map on an 8-bit display.

Running FreeCAD without User Interface


FreeCAD normally starts in GUI mode, but you can also force it to start in console mode by typing:
FreeCAD -c
from the command line. In console mode, no user interface will be displayed, and you will be presented with a python interpreter prompt. From that
python prompt, you have the same functionality as the python interpreter that runs inside the FreeCAD GUI, and normal access to all modules and
plugins of FreeCAD, excepted the FreeCADGui module. Be aware that modules that depend on FreeCADGui might also be unavailable.

Running FreeCAD as a python module


FreeCAD can also be used to run as a python module inside other applications that use python or from an external python shell. For that, the host
python application must know where your FreeCAD libs reside. The best way to obtain that is to temporarily append FreeCAD's lib path to the sys.path

variable. The following code typed from any python shell will import FreeCAD and let you run it the same way as in console mode:
import sys sys.path.append("path/to/FreeCAD/lib") # change this by your own FreeCAD lib path import FreeCAD
Once FreeCAD is loaded, it is up to you to make it interact with your host application in any way you can imagine!

The Config set


On every Startup FreeCAD examines its surrounding and the command line parameters. It builds up a configuration set which holds the essence of the
runtime information. This information is later used to determine the place where to save user data or log files. It is also very important for post
postmortem analyzes. Therefore it is saved in the log file.

User related information

Config var name

User config entries


Example M$

Synopsis

Example Posix (Linux)

UserAppData

Path where FreeCAD


stores User Related
application data.

C:\Documents and
Settings\username\Application
Data\FreeCAD

/home/username/.FreeCAD

UserParameter

File where FreeCAD


stores User Related
application data.

C:\Documents and
Settings\username\Application
Data\FreeCAD\user.cfg

/home/username/.FreeCAD/user.cfg

File where FreeCAD


SystemParameter stores Application
Related data.

C:\Documents and
Settings\username\Application
Data\FreeCAD\system.cfg

/home/username/.FreeCAD/system.cfg

UserHomePath

Home path of the current C:\Documents and


user
Settings\username\My Documents

/home/username

Command line arguments

User config entries


Synopsis

Config var name

Example

LoggingFile

1 if the logging is switched on

LoggingFileName

File name where the log is placed

C:\Documents and
Settings\username\Application
Data\FreeCAD\FreeCAD.log

RunMode

This indicates how the main loop will work. "Script" means that the
given script is called and then exit. "Cmd" runs the command line
interpreter. "Internal" runs an internal script. "Gui" enters the Gui
event loop. "Module" loads a given python module.

"Cmd"

FileName

Meaning depends on the RunMode

ScriptFileName

Meaning depends on the RunMode

Verbose

Verbosity level of FreeCAD

"" or "strict"

OpenFileCount

Holds the number of files opened through command line arguments

"12"

AdditionalModulePaths Holds the additional Module paths given in the cmd line

"extraModules/"

System related

User config entries


Synopsis

Config var name


AppHomePath

Path where FreeCAD is installed

PythonSearchPath

Holds a list of paths which python search modules. This is


at startup can change during execution

Example M$

Example Posix (Linux)

c:/Progam
/user/local/FreeCAD_0.7
Files/FreeCAD_0.7

Some libraries need to call system environment variables. Sometimes when there is a problem with a FreeCAD installation, it is because some
environment variable is absent or set wrongly. Therefore, some important variables get duplicated in the Config and saved in the log file.
Python related environment variables:
PYTHONPATH
PYTHONHOME
TCL_LIBRARY
TCLLIBPATH
OpenCascade related environment variables:
CSF_MDTVFontDirectory
CSF_MDTVTexturesDirectory
CSF_UnitsDefinition
CSF_UnitsLexicon
CSF_StandardDefaults
CSF_PluginDefaults
CSF_LANGUAGE
CSF_SHMessage

CSF_XCAFDefaults
CSF_GraphicShr
CSF_IGESDefaults
CSF_STEPDefaults
System related environment variables:
PATH

Build related information


The table below shows the availible informations about the Build version. Most of it comes from the Subversion repository. This stuff is needed to exactly
rebuild a version!

User config entries


Synopsis

Config var name

Example

BuildVersionMajor

Major Version number of the Build. Defined in


src/Build/Version.h.in

BuildVersionMinor

Minor Version number of the Build. Defined in


src/Build/Version.h.in

BuildRevision

SVN Repository Revision number of the src in the


Build. Generated by SVN

356

BuildRevisionRange Range of differnt changes

123-356

BuildRepositoryURL Repository URL

https://freecad.svn.sourceforge.net/svnroot/freecad/trunk/src

BuildRevisionDate

Date of the above Revision

2007/02/03 22:21:18

BuildScrClean

Indicates if the source was changed ager checkout

Src modified

BuildScrMixed

Src not mixed

Branding related
These Config entries are related to the branding mechanism of FreeCAD. See Branding for more details.

User config entries


Synopsis

Config var name

Example

ExeName

Name of the build Executable file. Can diver from FreeCAD if a different main.cpp
FreeCAD.exe
is used.

ExeVersion

Over all Version shows up at start time

V0.7

AppIcon

Icon which is used for the Executable, shows in Application MainWindow.

"FCIcon"

ConsoleBanner

Banner which is prompted in console mode

SplashPicture

Name of the Icon used for the Splash Screen

"FreeCADSplasher"

SplashAlignment

Alignment of the Text in the Splash dialog

Left"

SplashTextColor

Color of the splasher Text

"#000000"

StartWorkbench

Name of the Workbech which get started automaticly after Startup

"Part design"

HiddenDockWindow List of dockwindows (separated by a semicolon) which will be disabled


Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Start_up_and_Configuration&oldid=16752"

"Property editor"

FreeCAD Build Tool


The FreeCAD build tool or fcbt is a python script located at
trunc/src/Tools/fcbt.py
It can be used to simplify some frequent tasks in building, distributing and extending FreeCAD.

Usage
With Python correctly installed, fcbt can be invoked by the command
python fbct.py
It displays a menu, where you can select the task you want to use it for:
FreeCAD Build Tool
Usage:
fcbt <command name> [command parameter]
possible commands are:
- DistSrc
(DS)
Build a source Distr. of the current source tree
- DistBin
(DB)
Build a binary Distr. of the current source tree
- DistSetup
(DI)
Build a Setup Distr. of the current source tree
- DistSetup
(DUI) Build a User Setup Distr. of the current source tree
- DistAll
(DA)
Run all three above modules
- NextBuildNumber (NBN) Increase the Build Number of this Version
- CreateModule
(CM)
Insert a new FreeCAD Module in the module directory
For help on the modules type:
fcbt <command name> ?
At the input promt enter the abbreviated command you want to call. For example type "CM" for creating a module.

DistSrc
The command "DS" creates a source distribution of the current source tree.

DistBin
The command "DB" creates a binary distribution of the current source tree.

DistSetup
The command "DI" creates a setup distribution of the current source tree.

DistSetup
The command "DUI" creates a user setup distribution of the current source tree.

DistAll
The command "DA" executes "DS", "DB" and "DI" in sequence.

NextBuildNumber
The "NBN" command increments the build number to create a new release version of FreeCAD.

CreateModule
The "CM" command creates a new application module.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=FreeCAD_Build_Tool&oldid=16926"

Module Creation
Adding new modules and workbenches in FreeCAD is very easy. We call module any extension of FreeCAD, while a workbench is a special GUI
configuration that groups some toolbars and menus. Usually you create a new module which contains its own workbench.
Modules can be programmed in C++ or in python, or in a mixture of both, but the module init files must be in python. Setting up a new module with
those init files is easy, and can be done either manually or with the FreeCAD build tool.

Using the FreeCAD Build tool


Creating a new application module in FreeCAD is rather simple. In the FreeCAD development tree exists the FreeCAD Build Tool (fcbt) that does
the most important things for you. It is a Python script located under
trunk/src/Tools/fcbt.py
When your python interpreter is correctly installed you can execute the script from a command line with
python fcbt.py
It will display the following menu:
FreeCAD Build Tool
Usage:
fcbt <command name> [command parameter]
possible commands are:
- DistSrc
(DS)
Build a source Distr. of the current source tree
- DistBin
(DB)
Build a binary Distr. of the current source tree
- DistSetup
(DI)
Build a Setup Distr. of the current source tree
- DistSetup
(DUI) Build a User Setup Distr. of the current source tree
- DistAll
(DA)
Run all three above modules
- BuildDoc
(BD)
Create the documentation (source docs)
- NextBuildNumber (NBN) Increase the Build Number of this Version
- CreateModule
(CM)
Insert a new FreeCAD Module in the module directory
For help on the modules type:
fcbt <command name> ?
At the command prompt enter CM to start the creation of a module:
Insert command: CM
You are now asked to specify a name for your new module. Lets call it TestMod for example:
Please enter a name for your application: TestMod
After pressing enter fcbt starts copying all necessary files for your module in a new folder at
trunk/src/Mod/TestMod/
Then all files are modified with your new module name. The only thing you need to do now is to add the two new projects "appTestMod" and
"appTestModGui" to your workspace (on Windows) or to your makefile targets (unix). Thats it!

Setting up a new module manually


You need two things to create a new module:
A new folder in the FreeCAD Mod folder (either in InstalledPath/FreeCAD/Mod or in UserPath/.FreeCAD/Mod). You can name it as you like.
Inside that folder, an InitGui.py file. That file will be executed automatically on FreeCAD start (for ex, put a print("hello world") inside)
Additionally, you can also put an Init.py file. The difference is, the InitGui.py file is loaded only when FreeCAD runs in GUI mode, the Init.py file is loaded
always. But if we are going to make a workbench, we'll put it in InitGui.py, because workbenches are used only in GUI mode, of course.

Creating a new workbench


Inside the InitGui.py file, one of the first thing you will want to do is to define a workbench. Here is a minimal code that you can use:
class MyWorkbench ( Workbench ):
"My workbench object"
Icon = """
/* XPM */
static const char *test_icon[]={
"16 16 2 1",
"a c #000000",
". c None",
"................",
"................",
"..############..",
"..############..",
"..############..",
"......####......",
"......####......",
"......####......",
"......####......",
"......####......",

"......####......",
"......####......",
"......####......",
"......####......",
"................",
"................"};
"""
MenuText = "My Workbench"
ToolTip = "This is my extraordinary workbench"
def GetClassName(self):
return "Gui::PythonWorkbench"
def Initialize(self):
import myModule1, myModule2
self.appendToolbar("My Tools", ["MyCommand1","MyCommand2"])
self.appendMenu("My Tools", ["MyCommand1","MyCommand2"])
Log ("Loading MyModule... done\n")
def Activated(self):
# do something here if needed...
Msg ("MyWorkbench.Activated()\n")
def Deactivated(self):
# do something here if needed...
Msg ("MyWorkbench.Deactivated()\n")
FreeCADGui.addWorkbench(MyWorkbench)
The workbench must have all these attributes defined:
The Icon attribute is an XPM image (Most software such as GIMP can convert an image into xpm format, which is a text file. You can then paste
the contents here)
MenuText is the workbench name as it appears in the workbenches list
Tooltip appears when you hover on it with the mouse
Initialize() is executed on FreeCAD load, and must create all menus and toolbars that the workbench will use. If you are going to make your
module in C++, you can also define your menus and toolbars inside the C++ module, not in this InitGui.py file. The important is that they are
created now, and not when the module is activated.
Activated() is executed when the user switches to your workbench
Deactivated() is executed when the user switches from yours to another workbench or leaves FreeCAD

Creating FreeCAD commands in Python


Usually you define all your tools (called Commands in FreeCAD) in another module, then import that module before creating the toolbars and menus.
This is a minimal code that you can use to define a command:
import FreeCAD,FreeCADGui
class MyTool:
"My tool object"
def GetResources(self):
return {"MenuText": "My Command",
"Accel": "Ctrl+M",
"ToolTip": "My extraordinary command",
"Pixmap" : """
/* XPM */
static const char *test_icon[]={
"16 16 2 1",
"a c #000000",
". c None",
"................",
"................",
"..############..",
"..############..",
"..############..",
"......####......",
"......####......",
"......####......",
"......####......",
"......####......",
"......####......",
"......####......",
"......####......",
"......####......",
"................",
"................"};
"""}
def IsActive(self):
if FreeCAD.ActiveDocument == None:
return False
else:
return True
def Activated(self):
# do something here...
FreeCADGui.addCommand('MyCommand1',MyTool())
The GetResources() method must return a dictionnary with visual attributes of your tool. Accel defines a shortcut key but is not mandatory.

The IsActive() method defines if the command is active or greyed out in menus and toolbars.
The Activated() method is executed when the Command is called through a toolbar button or menu or even by script.

Creating FreeCAD Commands in C++


To Be Documented

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Module_Creation&oldid=16754"

Debugging
Test first
Before you go through the pain off debugging use the test framework to check if the standard tests work properly. If not there is maybe a broken
installation.

command line
The debugging of FreeCAD is supported by a few internal mechanisms. The command line version of FreeCAD provides to options for debugging support:
-v
With the "v" option FreeCAD gives a more verbose output.
-l
With the "l" option FreeCAD writes additional information to a logfile.

Generating a Backtrace
If you are running a version of FreeCAD from the bleeding edge of the development curve, it may "crash". You can help solve such problems by providing
the developers with a "backtrace". To do this, you need to be running a "debug build" of the software. "Debug build" is a parameter that is set at compile
time, so you'll either need to compile FreeCAD yourself, or obtain a pre-compiled "debug" version.

For Linux
Prerequisites:
software package gdb installed
a debug build of FreeCAD
a FreeCAD model that causes a crash
Steps: Enter the following in your terminal window:
cd FreeCAD/bin
gdb FreeCAD
handle SIG33 noprint nostop
run
FreeCAD will now start up. Perform the steps that cause FreeCAD to crash, then enter 'bt' in your terminal window. This will generate a lengthy listing of
exactly what the program was doing when it crash. Include this with your problem report.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Debugging&oldid=81971"

Testing
Introduction
FreeCAD comes with an extensive testing framework. The testing bases on a set of Python scripts which are located in the test module.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Testing&oldid=16927"

Branding
This article describes the Branding of FreeCAD. Branding means to start your own application on base of FreeCAD. That can be only your own
executable or splash screen till a complete reworked program. On base of the flexible architecture of FreeCAD it's easy to use it as base for your own
special purpose program.

General
Most of the branding is done in the MainCmd.cpp or MainGui.cpp. These Projects generate the executable files of FreeCAD. To make your own Brand
just copy the Main or MainGui projets and give the executable an own name, e.g. FooApp.exe. The most important settings for a new look can be made
in one place in the main() function. Here is the code section that controls the branding:
int main( int argc, char ** argv )
{
// Name and Version of the Application
App::Application::Config()["ExeName"] = "FooApp.exe";
App::Application::Config()["ExeVersion"] = "0.7";
// set the banner (for loging and console)
App::Application::Config()["ConsoleBanner"] = sBanner;
App::Application::Config()["AppIcon"] = "FCIcon";
App::Application::Config()["SplashPicture"] = "FooAppSplasher";
App::Application::Config()["StartWorkbench"] = "Part design";
App::Application::Config()["HiddenDockWindow"] = "Property editor";
App::Application::Config()["SplashAlignment" ] = "Bottom|Left";
App::Application::Config()["SplashTextColor" ] = "#000000"; // black
// Inits the Application
App::Application::Config()["RunMode"] = "Gui";
App::Application::init(argc,argv);
Gui::BitmapFactory().addXPM("FooAppSplasher", ( const char** ) splash_screen);
Gui::Application::initApplication();
Gui::Application::runApplication();
App::Application::destruct();
return 0;
}
The first Config entry defines the program name. This is not the executable name, which can be changed by renaming or by compiler settings, but the
name that is displayed in the task bar on windows or in the program list on Unix systems.
The next lines define the Config entries of your FooApp Application. A description of the Config and its entries you find in Start up and Configuration.

Images
All image resources are compiled into FreeCAD. This reduces delayed loading and keeps the installation compact. The images are included in XPMFormat which is basically a text format that uses C-syntax. You can basically draw this images with a text editor, but it is more comfortable to create
the images with your favorite graphics program and convert it later to XPM format.
The GNU image program Gimp can save XPM file.
For conversion you can use the ImageConv tool which is included with freecad. You can find it under
/trunk/src/Tools/ImageTools/ImageConv
It can not only convert images but also automatically update the BmpFactoryIcons.cpp file, where the images are registered. The typical usage is as
simple like the following example:
ImageConv -i InputImage.png -o OutputImage.xpm
This converts the file InputImage.png in XPM-format and writes the result to file OutputImage.xpm.
The line:
Gui::BitmapFactory().addXPM("FooAppSplasher", ( const char** ) splash_screen);
in the main() then include the image in the BitmapFactory of FreeCAD.
Icons
The main application icon FCIcon that appears in window titles and other places is defined in
/trunk/src/Gui/Icons/images.cpp
and starts with the line
static const char *FCIcon[]={
Replace it with your favourite icon, recompile freecad and the next step to create your own brand is done. There are many other icons in this file that you
might change to your gusto.
If you need to add new icons, you have to register it in
/trunk/src/Gui/Icons/BmpFactoryIcons.cpp

so that you can access from FreeCAD.


Background Image
The background image appears, when no document window is open. Like the splash screen it is defined in developers.h in the section starting with:
static const char* const background[]={
You should choose a low contrast image for the background. Otherwise it might irritate the user.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Branding&oldid=16920"

Localisation
Localisation is in general the process of providing a Software with a multiple language user interface. In FreeCAD you can set the language of the user
interface under EditPreferencesApplication. FreeCAD uses Qt to enable multiple language support. On Unix/Linux systems, FreeCAD uses the
current locale settings of your system by default.

Helping to translate FreeCAD


One of the very important things you can do for FreeCAD if you are not a programmer, is to help to translate the program in your language. To do so is
now easier than ever, with the use of the Crowdin collaborative on-line translation system.

How to Translate
Go to the FreeCAD translation project page on Crowdin;
Login by creating a new profile, or using a third-party account like your GMail address;
Click on the language you wish to work on;
Start translating by clicking on the Translate button next to one of the files. For example, FreeCAD.ts contains the text strings for the FreeCAD
main GUI.
You can vote for existing translations, or you can create your own.
Note: If you are actively taking part in translating FreeCAD and want to be
informed before next release is ready to be launched,
so there is time to review your translation, please subscribe
to this issue: http://www.freecadweb.org/tracker/view.php?id=137

Translating with Qt-Linguist (old way)


The following information doesn't need to be used anymore and will likely become obsolete. It is being kept here so that programmers may familiarize
themselves with how it works.
Open all of the language folders of FreeCAD shown below
Verify that a .ts file with your language code doesn't exist ("fr" for french, "de" for german, etc...)
If it exists, you can download that file, if you want to modify/review/better the translation (click the file, then download)
If it doesn't exist, download the .ts file without language code (or any other .ts available, it will work too)
Rename that file with your language code
Open it with the Qt-Linguist program
Start translating (Qt Linguist is very easy to use)
Once it's completely done, save your file
send the files to us so we can include them in the freecad source code so they benefit other users too.
Available translation files
FreeCAD main GUI
Complete Workbench
Drawing Workbench
Draft Workbench
Reverse Engineering Workbench
FEM Workbench
Robot Workbench
Image Workbench
Sketcher Workbench
Mesh Workbench
Test Workbench
Points Workbench
Raytracing Workbench
Part Workbench
PartDesign Workbench
Assembly Workbench
MeshPart Workbench

Preparing your own modules/applications for translation


Prerequisites
To localise your application module your need to helpers that come with Qt. You can download them from the Trolltech-Website, but they are also
contained in the LibPack:
qmake
Generates project files
lupdate
Extracts or updates the original texts in your project by scanning the source code
Qt-Linguist
The Qt-Linguist is very easy to use and helps you translating with nice features like a phrase book for common sentences.

Project Setup
To start the localisation of your project go to the GUI-Part of you module and type on the command line:
qmake -project
This scans your project directory for files containing text strings and creates a project file like the following example:
######################################################################
# Automatically generated by qmake (1.06c) Do 2. Nov 14:44:21 2006

######################################################################
TEMPLATE = app
DEPENDPATH += .\Icons
INCLUDEPATH += .
# Input
HEADERS += ViewProvider.h Workbench.h
SOURCES += AppMyModGui.cpp \
Command.cpp \
ViewProvider.cpp \
Workbench.cpp
TRANSLATIONS += MyMod_de.ts
You can manually add files here. The section TRANSLATIONS contains a list of files with the translation for each language. In the above example
MyMod_de.ts is the german translation.
Now you need to run lupdate to extract all string literals in your GUI. Running lupdate after changes in the source code is allways safe since it never
deletes strings from your translations files. It only adds new strings.
Now you need to add the .ts-files to your VisualStudio project. Specifiy the following custom build method for them:
python ..\..\..\Tools\qembed.py "$(InputDir)\$(InputName).ts"
"$(InputDir)\$(InputName).h" "$(InputName)"
Note: Enter this in one command line, the line break is only for layout purpose.
By compiling the .ts-file of the above example, a header file MyMod_de.h is created. The best place to include this is in App<Modul>Gui.cpp. In our
example this would be AppMyModGui.cpp. There you add the line
new Gui::LanguageProducer("Deutsch", <Modul>_de_h_data, <Modul>_de_h_len);
to publish your translation in the application.

Setting up python files for translation


To ease localization for the py files you can use the tool "pylupdate4" which accepts one or more py files. With the -ts option you can prepare/update
one or more .ts files. For instance to prepare a .ts file for French simply enter into the command line:
pylupdate4 *.py -ts YourModule_fr.ts
the pylupdate tool will scan your .py files for translate() or tr() functions and create a YourModule_fr.ts file. That file can the be translated with QLinguist
and a YourModule_fr.qm file produced from QLinguist or with the command
lrelease YourModule_fr.ts
Beware that the pylupdate4 tool is not very good at recognizing translate() functions, they need to be formatted very specifically ( see the Draft module
files for examples). Inside your file, you can then setup a translator like this (after loading your QApplication but BEFORE creating any qt widget):
translator = QtCore.QTranslator()
translator.load("YourModule_"+languages[ln])
QtGui.QApplication.installTranslator(translator)

Optionally, you can also create the file XML Draft.qrc with this content:
<RCC>
<qresource prefix="/translations" >
<file>Draft_fr.qm</file>
</qresource>
</RCC>
and running pyrcc4 Draft.qrc -o qrc_Draft.py creates a big Python containing all resources. BTW this approach also works to put icon files in one
resource file

Translating the wiki


This wiki is hosting a lot of contents, the majority of which build up the manual. You can browse the documentation starting from the Main Page, or
have a look at the User's manual Online Help Toc.

Translation plugin
When the Wiki moved away from SourceForge, Yorik installed a Translation plugin which allows to ease translations between pages. For example,
the page title can now be translated. Other advantages of the Translation plugin are that it keeps track of translations, notifies if the original page has
been updated, and maintains translations in sync with the original English page.
The tool is documented in Extension:Translate, and is part of a Language Extension Bundle.
To quickly get started on preparing a page for translation and activating the plugin, please read the Page translation example.
To see an example of how the Translation tool works once the translation plugin is activated on a page, you can visit the Main Page. You will see a new
language menu bar at the bottom. It is automatically generated. Click for instance on the German link, it will get you to Main Page/de. Right under the
title, you can read "This page is a translated version of a page Main Page and the translation is xx% complete." (xx being the actual percentage of
translation). Click on the "translated version" link to start translation, or to update or correct the existing translation.
You will notice that you cannot directly edit a page anymore once it's been marked as a translation. You have to go through the translation utility.
When adding new content, the English page should be created first, then translated into another language. If someone wants to change/add content in a

page, he should do the English one first.


REMARK: The first time you switch a page to the new translation system, it looses all its old 'manual' translations. To recover the
translation, you need to open an earlier version from the history, and copy/paste manually the paragraphs to the new translation system.
Remark: to be able to translate in the wiki, you must of course gain wiki edit permission.

Old translation instructions


These instructions are for historical background only, while the pages are being passed to the new translation plugin.
So the first step is to check if the manual translation has already been started for your language (look in the left sidebar, under "manual").
If not, head to the forum and say that you want to start a new translation, we'll create the basic setup for the language you want to work on.
You must then gain wiki edit permission.
If your language is already listed, see what pages are still missing a translation (they will be listed in red). The technique is simple: go into a red page,
and copy/paste the contents of the corresponding English page, and start translating.
Do not forget to include all the tags and templates from the original English page. Some of those templates will have an equivalent in your language (for
example, there is a French Docnav template called Docnav/fr). You should use a slash and your language code in almost all the links. Look at other
already translated pages to see how they did it.
Add a slash and your language code in the categories, like [[Category:Developer Documentation/fr]]
And if you are unsure, head to the forums and ask people to check what you did and tell you if it's right or not.
Four templates are commonly used in manual pages. These 4 templates have localized versions (Template:Docnav/fr, Template:fr, etc...)
Template:GuiCommand : is the Gui Command information block in upper-right of command documentation.
Template:Docnav : it is the navigation bar at the bottom of the pages, showing previous and next pages.
Page Naming Convention
Please take note that, due to limitations in the Sourceforge implementation of the MediaWiki engine, we require that your pages all keep their original
English counterpart's name, appending a slash and your language code. For example, the translated page for About FreeCAD should be About
Freecad/es for Spanish, About FreeCAD/pl for polish, etc. The reason is simple: so that if translators go away, the wiki's administrators, who do not
speak all languages, will know what these pages are for. This will facilitate maintenance and avoid lost pages.
If you want the Docnav template to show linked pages in your language, you can use redirect pages. They are basically shortcut links to the actual
page. Here is an example with the French page for About FreeCAD.
The page About FreeCAD/fr is the page with content
The page propos de FreeCAD contains this code:
#REDIRECT [[About FreeCAD/fr]]
In the About FreeCAD/fr page, the Docnav code will look like this:
{{docnav/fr|Bienvenue sur l'aide en ligne|Fonctionnalits}}
The page "Bienvenue sur l'aide en ligne" redirects to Online Help Startpage/fr, and the page "Fonctionnalits" redirects to Feature list/fr.
If you are unsure how to proceed, don't hesitate to ask for help in the forum.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Localisation&oldid=43056"

Extra python modules


This page lists several additional python modules or other pieces of software that can be downloaded freely from the internet, and add functionality to
your FreeCAD installation.

PyQt4
homepage: http://www.riverbankcomputing.co.uk/pyqt
license: GPL 2 & 3
optional, but needed by several modules: Draft, Arch, Ship, Plot, OpenSCAD, Spreadsheet
PyQt is required by several modules of FreeCAD to access FreeCAD's Qt interface. It is already bundled in the windows verison of FreeCAD, and is
usually installed automatically by FreeCAD on Linux, when installing from official repositories. If those modules (Draft, Arch, etc) are enabled after
FreeCAD is installed, it means PyQt is already there, and you don't need to do anything more.
Note:
PyQt4 will be progressively obsoleted in FreeCAD after version 0.13, in favour of PySide, which does exactly the same job but has a license (LGPL)
more compatible with FreeCAD.

Installation
Linux
The simplest way to install PyQt4 is through your distribution's package manager. On Debian/Ubuntu systems, the package name is generally pythonqt4, while on RPM-based systems it is named pyqt4. The necessary dependencies (Qt and SIP) will be taken care of automatically.
Windows
The program can be downloaded from http://www.riverbankcomputing.co.uk/pyqt/download.php . You'll need to install the Qt and SIP libraries
before installing pyqt4 (to be documented).
MacOSX
PyQt on Mac can be installed via homebrew or port. See CompileOnMac#Install_Dependencies for more information.

Usage
Once it is installed, you can check that everything is working by typing in FreeCAD python console:
import PyQt4
To access the FreeCAD interface, type:
from PyQt4 import QtCore,QtGui
app = QtGui.qApp
FreeCADWindow = app.activeWindow()
Now you can start to explore the interface with the dir() command. You can add new elements, like a custom widget, with commands like:
FreeCADWindow.addDockWidget(QtCore.Qt.RghtDockWidgetArea,my_custom_widget)

Additional documentation
More pyQt4 tutorials (including how to build interfaces with Qt Designer to use with python):
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/classes.html - the official PyQt4 API Reference
http://www.rkblog.rk.edu.pl/w/p/introduction-pyqt4/ - a simple introduction
http://www.zetcode.com/tutorials/pyqt4/ - very complete in-depth tutorial

Pivy
homepage: https://bitbucket.org/Coin3D/coin/wiki/Home
license: BSD
optional, but needed by several modules of FreeCAD: Draft, Arch
Pivy is a needed by several modules to access the 3D view of FreeCAD. On windows, Pivy is already bundled inside the FreeCAD installer, and on Linux
it is usually automatically installed when you install FreeCAD from an official repository. On MacOSX, unfortunately, you will need to compile pivy
yourself.

Installation
Prerequisites
I believe before compiling Pivy you will want to have Coin and SoQt installed.
I found for building on Mac it was sufficient to install the Coin3 binary package. Attempting to install coin from MacPorts was problematic: tried to add
a lot of X Windows packages and ultimately crashed with a script error.
For Fedora I found an RPM with Coin3.
SoQt compiled from source fine on Mac and Linux.
Debian & Ubuntu
Starting with Debian Squeeze and Ubuntu Lucid, pivy will be available directly from the official repositories, saving us a lot of hassle. In the meantime,
you can either download one of the packages we made (for debian and ubuntu karmic) availables on the Download pages, or compile it yourself.
The best way to compile pivy easily is to grab the debian source package for pivy and make a package with debuild. It is the same source code from the
official pivy site, but the debian people made several bug-fixing additions. It also compiles fine on ubuntu karmic:
http://packages.debian.org/squeeze/python-pivy (download the .orig.gz and the .diff.gz file, then unzip both, then apply the .diff to the source: go to
the unzipped pivy source folder, and apply the .diff patch:
patch -p1 < ../pivy_0.5.0~svn765-2.diff
then
debuild
to have pivy properly built into an official installable package. Then, just install the package with gdebi.
Other linux distributions
First get the latest sources from the project's repository:
hg clone http://hg.sim.no/Pivy/default Pivy
As of March 2012, the latest version is Pivy-0.5.
Then you need a tool called SWIG to generate the C++ code for the Python bindings. Pivy-0.5 reports that it has only been tested with SWIG 1.3.31,
1.3.33, 1.3.35, and 1.3.40. So you can download a source tarball for one of these old versions from http://www.swig.org. Then unpack it and from a
command line do (as root):
./configure
make
make install (or checkinstall if you use it)

It takes just a few seconds to build.


Alternatively, you can try building with a more recent SWIG. As of March 2012, a typical repository version is 2.0.4. Pivy has a minor compile problem
with SWIG 2.0.4 on Mac OS (see below) but seems to build fine on Fedora Core 15.
After that go to the pivy sources and call
python setup.py build
which creates the source files. Note that build can produce thousands of warnings, but hopefully there will be no errors.
This is probably obsolete, but you may run into a compiler error where a 'const char*' cannot be converted in a 'char*'. To fix that you just need to write a
'const' before in the appropriate lines. There are six lines to fix.
After that, install by issuing (as root):
python setup.py install (or checkinstall python setup.py install)
That's it, pivy is installed.
Mac OS
These instructions may not be complete. Something close to this worked for OS 10.7 as of March 2012. I use MacPorts for repositories, but other
options should also work.
As for linux, get the latest source:
hg clone http://hg.sim.no/Pivy/default Pivy
If you don't have hg, you can get it from MacPorts:
port install mercurial
Then, as above you need SWIG. It should be a matter of:
port install swig
I found I needed also:
port install swig-python
As of March 2012, MacPorts SWIG is version 2.0.4. As noted above for linux, you might be better off downloading an older version. SWIG 2.0.4 seems
to have a bug that stops Pivy building. See first message in this digest: https://sourceforge.net/mailarchive/message.php?msg_id=28114815
This can be corrected by editing the 2 source locations to add dereferences: *arg4, *arg5 in place of arg4, arg5. Now Pivy should build:
python setup.py build
sudo python setup.py install
Windows
Assuming you are using Visual Studio 2005 or later you should open a command prompt with 'Visual Studio 2005 Command prompt' from the Tools
menu. If the Python interpreter is not yet in the system path do
set PATH=path_to_python_2.5;%PATH%
To get pivy working you should get the latest sources from the project's repository:
svn co https://svn.coin3d.org/repos/Pivy/trunk Pivy
Then you need a tool called SWIG to generate the C++ code for the Python bindings. It is recommended to use version 1.3.25 of SWIG, not the latest
version, because at the moment pivy will only function correctly with 1.3.25. Download the binaries for 1.3.25 from http://www.swig.org. Then unpack it
and from the command line add it to the system path
set PATH=path_to_swig_1.3.25;%PATH%
and set COINDIR to the appropriate path
set COINDIR=path_to_coin
On Windows the pivy config file expects SoWin instead of SoQt as default. I didn't find an obvious way to build with SoQt, so I modified the file setup.py
directly. In line 200 just remove the part 'sowin' : ('gui._sowin', 'sowin-config', 'pivy.gui.') (do not remove the closing parenthesis).
After that go to the pivy sources and call
python setup.py build
which creates the source files. You may run into a compiler error several header files couldn't be found. In this case adjust the INCLUDE variable
set INCLUDE=%INCLUDE%;path_to_coin_include_dir
and if the SoQt headers are not in the same place as the Coin headers also
set INCLUDE=%INCLUDE%;path_to_soqt_include_dir
and finally the Qt headers
set INCLUDE=%INCLUDE%;path_to_qt4\include\Qt
If you are using the Express Edition of Visual Studio you may get a python keyerror exception. In this case you have to modify a few things in
msvccompiler.py located in your python installation.
Go to line 122 and replace the line
vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version
with
vsbase = r"Software\Microsoft\VCExpress\%0.1f" % version
Then retry again. If you get a second error like
error: Python was built with Visual Studio 2003;...
you must also replace line 128
self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
with
self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv2.0")
Retry once again. If you get again an error like

error: Python was built with Visual Studio version 8.0, and extensions need to be built with the same version of the compiler, but it isn't installed.
then you should check the environment variables DISTUTILS_USE_SDK and MSSDK with
echo %DISTUTILS_USE_SDK%
echo %MSSDK%
If not yet set then just set it e.g. to 1
set DISTUTILS_USE_SDK=1
set MSSDK=1
Now, you may run into a compiler error where a 'const char*' cannot be converted in a 'char*'. To fix that you just need to write a 'const' before in the
appropriate lines. There are six lines to fix. After that copy the generated pivy directory to a place where the python interpreter in FreeCAD can find it.

Usage
To check if Pivy is correctly installed:
import pivy
To have Pivy access the FreeCAD scenegraph do the following:
from pivy import coin
App.newDocument() # Open a document and a view
view = Gui.ActiveDocument.ActiveView
FCSceneGraph = view.getSceneGraph() # returns a pivy Python object that holds a SoSeparator, the main "container" of the Coin scenegraph
FCSceneGraph.addChild(coin.SoCube()) # add a box to scene
You can now explore the FCSceneGraph with the dir() command.

Additonal Documentation
Unfortunately documentation about pivy is still almost inexistant on the net. But you might find Coin documentation useful, since pivy simply translate
Coin functions, nodes and methods in python, everything keeps the same name and properties, keeping in mind the difference of syntax between C and
python:
http://doc.coin3d.org/Coin/classes.html - Coin3D API Reference
http://www-evasion.imag.fr/~Francois.Faure/doc/inventorMentor/sgi_html/index.html - The Inventor Mentor - The "bible" of Inventor scene
description language.
You can also look at the Draft.py file in the FreeCAD Mod/Draft folder, since it makes big use of pivy.

pyCollada
homepage: http://pycollada.github.com
license: BSD
optional, needed to enable import and export of Collada (.DAE) files
pyCollada is a python library that allow programs to read and write Collada (*.DAE) files. When pyCollada is installed on your system, FreeCAD will be
able to handle importing and exporting in the Collada file format.

Installation
Pycollada is usually not yet available in linux distributions repositories, but since it is made only of python files, it doesn't require compilation, and is
easy to install. You have 2 ways, or directly from the official pycollada git repository, or with the easy_install tool.
Linux
In either case, you'll need the following packages already installed on your system:
python-lxml
python-numpy
python-dateutil
From the git repository

git clone git://github.com/pycollada/pycollada.git pycollada


cd pycollada
sudo python setup.py install
With easy_install

Assuming you have a complete python installation already, the easy_install utility should be present already:
easy_install pycollada
You can check if pycollada was correctly installed by issuing in a python console:
import collada
If it returns nothing (no error message), then all is OK
Windows
To Be Documented
Mac OS
To Be Documented

IfcOpenShell
homepage: http://www.ifcopenshell.org
license: LGPL
optional, needed to extend import abilities of IFC files
IFCOpenShell is a library currently in development, that allows to import (and soon export) Industry foundation Classes (*.IFC) files. IFC is an
extension to the STEP format, and is becoming the standard in BIM workflows. When ifcopenshell is correctly installed on your system, the FreeCAD
Arch Module will detect it and use it to import IFC files, instead of its built-in rudimentary importer. Since ifcopenshell is based on OpenCasCade, like
FreeCAD, the quality of the import is very high, producing high-quality solid geometry.

Installation
Since ifcopenshell is pretty new, you'll likely need to compile it yourself.
Linux
You will need a couple of development packages installed on your system in order to compile ifcopenshell:
liboce-*-dev
python-dev
swig
but since FreeCAD requires all of them too, if you can compile FreeCAD, you won't need any extra dependency to compile IfcOpenShell.

Grab the latest source code from here:


svn co https://ifcopenshell.svn.sourceforge.net/svnroot/ifcopenshell ifcopenshell
The build process is very easy:
mkdir ifcopenshell-build
cd ifcopenshell-build
cmake ../ifcopenshell/cmake
or, if you are using oce instead of opencascade:
cmake -DOCC_INCLUDE_DIR=/usr/include/oce ../ifcopenshell/cmake
Since ifcopenshell is made primarily for Blender, it uses python3 by default. To use it inside FreeCAD, you need to compile it against the same version
of python that is used by FreeCAD. So you might need to force the python version with additional cmake parameters (adjust the python version to
yours):
cmake -DOCC_INCLUDE_DIR=/usr/include/oce -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/python2.7.so ../ifcopenshell/cmake
Then:
make
sudo make install
You can check that ifcopenshell was correctly installed by issuing in a python console:
import IfcImport
If it returns nothing (no error message), then all is OK
Windows
Copied from the IfcOpenShell README file
Users are advised to use the Visual Studio .sln file in the win/ folder. For Windows users a prebuilt Open CASCADE version is available from the
http://opencascade.org website. Download and install this version and provide the paths to the Open CASCADE header and library files to MS Visual
Studio C++.
For building the IfcPython wrapper, SWIG needs to be installed. Please download the latest swigwin version from http://www.swig.org/download.html
. After extracting the .zip file, please add the extracted folder to the PATH environment variable. Python needs to be installed, please provide the include
and library paths to Visual Studio.

Teigha Converter
homepage: http://www.opendesign.com/guestfiles/TeighaFileConverter
license: freeware
optional, used to enable import and export of DWG files
The Teigha Converter is a small freely available utility that allows to convert between several versions of DWG and DXF files. FreeCAD can use it to offer
DWG import and export, by converting DWG files to the DXF format under the hood,then using its standard DXF importer to import the file contents. The
restrictions of the DXF importer apply.

Installation
On all platforms, only by installing the appropriate package from http://www.opendesign.com/guestfiles/TeighaFileConverter . After installation, if
the utility is not found automatically by FreeCAD, you might need to set the path to the converter executable manually, in the menu Edit -> Preferences
-> Draft -> Import/Export options.
Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Extra_python_modules&oldid=84578"

Contributors
FreeCAD would not be what it is without the generous contributions of many people. Here's an overview of the people and companies who contributed to
FreeCAD over time. For credits for the third party libraries see the Third Party Libraries page.

Developement
Project managers
Lead developers of the FreeCAD project:
Jrgen Riegel
Werner Mayer
Yorik van Havre
Main developers
People who work regularly on the FreeCAD code:
Logari81
Luke A. Parry
Jose Luis Cercos Pita
Jan Rheinlaender
shoogen
tanderson69
Other coders
People who contributed code to the FreeCAD project:
ickby
jmaustpc
j-dowsett
keithsloan52
wandererfan
Joachim Zettler
Graeme van der Vlugt
Berthold Grupp
Georg Wiora
Martin Burbaum
Jacques-Antoine Gaudin
Ken Cline
Dmitry Chigrin
Remigiusz Fiedler (DXF-parser)

Companies
Companies which donated code or developer time:
Imetric 3D

Community
People from the community who put a lot of efforts in helping the FreeCAD project either by being active on the forum, keeping a blog about FreeCAD,
making video tutorials, packaging FreeCAD for Windows/Linux/MacOS X, writing a FreeCAD book... (listed by alphabetical order)
bejant
Brad Collette
cblt2l
jdurston (5needinput)
Daniel Falck
hobbes1069
jmaustpc
lhagan
Eduardo Magdalena
marcxs
John Morris (butchwax)
Kwahooo
Normandc
peterl94
pperisin
quick61
Renatorivo
Mario52

Online version: "http://w w w .freecadw eb.org/w iki/index.php?title=Contributors&oldid=83150"

Potrebbero piacerti anche