Терминатров Джон Коннорович
Frecad manual

Самиздат: [Регистрация] [Найти] [Рейтинги] [Обсуждения] [Новинки] [Обзоры] [Помощь|Техвопросы]
Links
Создай обложку книги бесплатно
Кожевенное мастерство: сумки, ремни своими руками
 Ваша оценка:

Обложка

Table of Contents

Introduction

Discovering FreeCAD

What is FreeCAD?

Installing

The FreeCAD interface

Navigating in the 3D view

The FreeCAD document

Parametric objects

Import and export to other filetypes

Working with FreeCAD

All workbenches at a glance

Traditional modeling, the CSG way

Traditional 2D drafting

Modeling for product design

Preparing models for 3D printing

Generating 2D drawings

BIM modeling

Using spreadsheets

Creating FEM analyses

Creating renderings

Python scripting

A gentle introduction

Creating and manipulating geometry

Creating parametric objects

Creating interface tools

The community

Table of Contents

Introduction 1.1

Discovering FreeCAD 1.2

What is FreeCAD? 1.2.1

Installing 1.2.2

Installing on Windows 1.2.2.1

Installing on Linux 1.2.2.2

Installing on Mac OS 1.2.2.3

Uninstalling 1.2.2.4

Setting basic preferences 1.2.2.5

Installing additional content 1.2.2.6

The FreeCAD interface 1.2.3

Workbenches 1.2.3.1

The interface 1.2.3.2

Customizing the interface 1.2.3.3

Navigating in the 3D view 1.2.4

A word about the 3D space 1.2.4.1

The FreeCAD 3D view 1.2.4.2

Selecting objects 1.2.4.3

The FreeCAD document 1.2.5

Parametric objects 1.2.6

Import and export to other filetypes 1.2.7

Working with FreeCAD 1.3

All workbenches at a glance 1.3.1

Traditional modeling, the CSG way 1.3.2

Traditional 2D drafting 1.3.3

Modeling for product design 1.3.4

Preparing models for 3D printing 1.3.5

Exporting to slicers 1.3.5.1

Converting objects to meshes 1.3.5.2

Using Slic3r 1.3.5.3

Using the Cura addon 1.3.5.4

Generating G-code 1.3.5.5

Generating 2D drawings 1.3.6

BIM modeling 1.3.7

Using spreadsheets 1.3.8

Reading properties 1.3.8.1

Writing properties 1.3.8.2

Creating FEM analyses 1.3.9

Creating renderings 1.3.10

Python scripting 1.4

A gentle introduction 1.4.1

Writing Python code 1.4.1.1

Manipulating FreeCAD objects 1.4.1.2

Vectors and Placements 1.4.1.3

Creating and manipulating geometry 1.4.2

Creating parametric objects 1.4.3

Creating interface tools 1.4.4

The community 1.5

A FreeCAD manual

Note: The manual has been moved to the official FreeCAD wiki which is now its new home. If you wish to propose edits, please do them there, as this repository will be kept only for generating the ebook versions and will not be directly edited anymore.

Introduction

FreeCAD is a free, open-source parametric 3D modeling application. It is made primarily to model real-world objects, ranging from the small electronic components up to buildings and civil engineering projects, with a strong focus on 3D-printable objects. FreeCAD is free to download, use, distribute and modify, and its source code is open and published under the very permissive LGPL license. The data you produce with FreeCAD is fully yours, and can be recovered without FreeCAD.

FreeCAD is also fundamentally a social project, as it is developed and maintained by a community of developers and users united by their passion for FreeCAD.

This manual is an experiment at taking the opposite way from the official FreeCAD documentation wiki. The wiki is written collaboratively by dozens of community members and, like most wikis, it contains huge amounts of information, but is very hard to access and navigate by newcomers. This makes it a precious resource for reference, but not a very practical tool to learn FreeCAD. This manual will walk you through the same information available on the wiki. However, we hope that the more step-by-step pace, based on examples, and the more unified tone given by a smaller number of authors, will make it more suitable for a first contact with FreeCAD, and that it will become a perfect companion for the wiki.

This manual has been written for the current stable version of FreeCAD which is version 0.16.

All the contents of this manual are published under the Creative Commons 4.0 license, and can be freely used, downloaded, copied, and modified. The source files of this manual are hosted on github.

This book has been written mostly by Yorik, but using a lot of information built by FreeCAD users, mostly from the FreeCAD wiki. The real author of this book is actually the whole FreeCAD community!

Discovering FreeCAD

What is FreeCAD?

a3c790fc.jpg

FreeCAD is an open-source parametric 3D modeling application, made primarily to design real-life objects. Parametric modeling describes a certain type of modeling, where the shape of the 3D objects you design are controlled by parameters. For example, the shape of a brick might be controlled by three parameters: height, width and length. In FreeCAD, as in other parametric modelers, these parameters are part of the object, and stay modifiable at any time, after the object has been created. Some objects can have other objects as parameters, for example you could have an object that takes our brick as input, and creates a column from it. You could think of a parametric object as a small program that creates geometry from parameters.

FreeCAD is not designed for a particular kind of work, or to make a certain kind of objects. Instead, it allows a wide range of uses, and permits users to produce models of all sizes and purposes, from small electronic components to 3D-printable pieces and all the way up to buildings. Each of these tasks have different dedicated sets of tools and workflows available.

FreeCAD is also multiplatform (it runs exactly the same way on Windows, Mac OS and Linux platforms), and it is open-source. Being open-source, FreeCAD benefits from the contributions and efforts of a large community of programmers, enthusiasts and users worldwide. FreeCAD is essentially an application built by the people who use it, instead of being made by a company trying to sell you a product. And of course, it also means that FreeCAD is free, not only to use, but also to distribute, copy, modify, or even sell.

FreeCAD also benefits from the huge, accumulated experience of the open-source world. In its bowels, it includes several other open source components, as FreeCAD itself can be used as a component in other applications. It also possesses all kinds of features that have become a standard in the open-source world, such as supporting a wide range of file formats, being hugely scriptable, customizable and modifiable. All made possible through a dynamic and enthusiast community of users.

The official website of FreeCAD is at http://www.freecadweb.org

Read more:

Installing

FreeCAD uses the LGPL license, which means you are free to download, install, redistribute and use FreeCAD the way you want, regardless of the type of work you'll do with it (commercial or non-commercial). You are not bound to any clause or restriction, and the files you produce with it are fully yours. The only thing that the license prohibits, really, is to claim that you programmed FreeCAD yourself!

FreeCAD runs without any difference on Windows, Mac OS and Linux. However, the ways to install it differ slightly depending on your platform. On Windows and Mac, the FreeCAD community provides precompiled packages (installers) ready to download, while on Linux, the source code is made available to Linux distributions maintainers, who are then responsible for packaging FreeCAD for their specific distribution. As a result, on Linux, you can usually install FreeCAD right from the software manager application.

The official FreeCAD download page for Windows and Mac OS is https://github.com/FreeCAD/FreeCAD/releases

FreeCAD versions

The official releases of FreeCAD, on the page above or in your distribution's software manager, are stable versions. However, the development of FreeCAD is fast! New features and bug fixes are added almost every single day. Since it can sometimes take a long time between stable releases, you might be interested in trying a more bleeding-edge version of FreeCAD. These development versions, or pre-releases, are uploaded from time to time to the download page mentioned above, or, if you are using Ubuntu, the FreeCAD community also maintains PPA (Personal Package Archives) or 'daily builds' which are regularly updated with the most recent changes.

If you are installing FreeCAD in a virtual machine, please be aware that the performance might be low, or in some cases unusable due to the limits of OpenGL support on most virtual machines.

Installing on Windows

  1. Download an installer (.exe) package corresponding to your version of Windows (32bit or 64bit) from the download page. The FreeCAD installers should work on any windows version starting from Windows 7.
  2. Double-click the downloaded installer.
  3. Accept the terms of the LGPL license (this will be one of the few cases where you can really, safely click the "accept" button without reading the text. No hidden clauses): f46014b1.jpg
  4. You can leave the default path here, or change if you wish: 791be63c.jpg
  5. No need to set the PYTHONPATH variable, unless you plan to do some advanced python programming, in which case you probably already know what this is for: a7650732.jpg
  6. During the installation, a couple of additional components, which are bundled inside the installer, will be installed too: dff31bab.jpg
  7. That's it, FreeCAD is installed. You will find it in your start menu. d14975a9.jpg

Installing a development version

Packaging FreeCAD and creating an installer takes some time and dedication, so usually, development (also called pre-release) versions are provided as .zip (or .7z) archives. These don't need to be installed, just unpack them and lauch FreeCAD by double-clicking the FreeCAD.exe file that you will find inside. This also allows you to keep both the stable and "unstable" versions together on the same computer.

Installing on Linux

On most modern Linux distributions (Ubuntu, Fedora, OpenSUSE, Debian, Mint, Elementary, etc), FreeCAD can be installed with the click of a button, directly from the software management application provided by your distribution (the aspect of it can differ from the images below, each distribution uses its own tool).

  1. Open the software manager and search for "freecad": f0ba34f9.jpg
  2. Click the "install" button and that's it, FreeCAD gets installed. Don't forget to rate it afterwards! 83919b75.jpg

Alternative ways

One of the big joys of using Linux is the multitude of possibilities to tailor your software, so don't restrain yourself. On Ubuntu and derivatives, FreeCAD can also be installed from a PPA maintained by the FreeCAD community (it contains both stable and development versions) and since this is open-source software, you can also easily compile FreeCAD yourself.

Installing on Mac OS

Installing FreeCAD on Mac OSX is nowadays as easy as on other platforms. However, since there are less people in the community who own a Mac, the available packages often lag a couple of versions behind the other platforms.

  1. Download a zipped package corresponding to your version from the download page.
  2. Open the Downloads folder, and expand the downloaded zip file: 62016e9d.jpg
  3. Drag the FreeCAD application from inside the zip to the Applications folder: e08c98d6.jpg
  4. That's it, FreeCAD is installed! 951e11f5.jpg
  5. If the system prevents FreeCAD to launch, due to restricted permissions for applications not coming from the App store, you will need to enable it in the system settings: 6f620e3f.jpg

Uninstalling

Hopefully you won't want to do that, but it is good to know anyway. On Windows and Linux, uninstalling FreeCAD is very straightforward. Use the standard "remove software" option found in the control panel on Windows, or remove it with the same software manager you used to install FreeCAD on Linux. On Mac, all you need to do is remove it from the Applications folder.

Setting basic preferences

Once FreeCAD is installed, you might want to open it and set a couple of preferences. Preferences settings in FreeCAD are located under menu Edit -> Preferences. You can browse through the different pages to see if there is anything else you would want to change, but here are a couple of basic ones:

  1. Language: FreeCAD will automatically pick the language of your operating system, but you might want to change that. FreeCAD is almost fully translated to 5 or 6 languages, plus many others that are at the moment only partially translated. You can easily help to translate FreeCAD. 6b7675d3.jpg
  2. Auto-load module: Normally, FreeCAD will start showing you the start center page. You can skip this and begin a FreeCAD session directly in the workbench of your choice. Workbenches will be explained in detail in the next chapter.
  3. Create document at startup: Combined with the option above, this starts FreeCAD ready for work. 90bfb65c.jpg
  4. Storage options: As any complex application, FreeCAD might crash from time to time. Here you can configure a few options that will help you to recover your work in case of a crash.
  5. Authoring and license: You can set the default settings that will be used for your new files. Consider making your files shareable right from the start, by using a friendlier, copyleft license like Creative Commons.
  6. Redirect python messages to output view: These two options are always good to mark, as they will permit you to see what's wrong in the Report View when there's a problem with running a particular python script. b2cc47ba.jpg
  7. Units: Here you can set the default units you wish to use. It will be easier working the examples later, to stay in MKS. b94be8da.jpg

Installing additional content

As the FreeCAD project and its community grows quickly, and also because it is easy to extend, external contributions and side-projects made by community members and other enthusiasts begin to appear everywhere on the internet. There is an effort going on to gather all these interesting additions in one place, on the FreeCAD github page. There, among other things, you will find:

  1. A Parts library, which contains all kinds of useful models, or pieces of models, created by FreeCAD users that can be freely used in your projects. The library can be used and accessed right from inside your FreeCAD installation.
  2. A collection of addons, most of them additional workbenches, that extend the functionality of FreeCAD for certain tasks. Instructions for installing are given on each separate addon page.
  3. A collection of macros, which are also available on the FreeCAD wiki along with documentation about how to use them. The wiki contains many more macros.

If you are using Ubuntu or any of its derivatives, the FreeCAD-extras PPA contains most of these addons. On other platforms, any of the addons, including the Parts library, can easily be installed using an addon-installer macro provided in the addons repository. The following procedure shows how to install the addon-installer (other macros can be installed the same way)

  1. Download the addons-installer.FCMacro file from https://github.com/FreeCAD/FreeCAD-addons by clicking it, then right-clicking the "RAW" button, and choosing "Save as".
  2. Place the macro in your FreeCAD Macros destination path. You FreeCAD Macros destination path is indicated at the bottom of the Execute macro dialog in FreeCAD: 51217682.jpg
  3. Close and reopen the Execute macro dialog, and start the addons_installer.FCMacro. The installer will launch, from where you can install, update and uninstall any of the addons:

45bb8cfa.jpg

Read more

The FreeCAD interface

FreeCAD uses the Qt framework) to draw and manage its interface. This framework is used in a wide range of applications, so the FreeCAD interface is very classical and presents no particular difficulty to understand. Most buttons are standard and will be found where you expect them (File -> Open, Edit -> Paste, etc). Here is the look of FreeCAD when you open it for the first time, just after installing, showing you the start center:

c179cdd7.jpg

The start center is a convenient "welcome screen", that shows useful information for newcomers, like the latest files you have been working on, what's new in the FreeCAD world, or quick info about the most common Workbenches. It will also notify you if a new stable version of FreeCAD is available.

Close the Start Page tab (click on the tab x near the bottom) and create a new document (Ctrl-N):

4cfc9cce.jpg

Workbenches

Note that some of the icons have changed between the two screencaptures above. This is where the most important concept used in the FreeCAD interface comes into play: Workbenches.

Workbenches are group of tools (toolbar buttons, menus, and other interface controls) that are grouped together by specialty. Think of a workshop where you have different people working together: A person who works with metal, another with wood. Each of them has, in their workshop, a separate table with specific tools for his/her job. However, they can all work on the same objects. The same happens in FreeCAD.

The most important control of the FreeCAD interface is the Workbench selector, which you use to switch from one Workbench to another:

74e35b9b.jpg

Workbenches often confuse new users, since it's not always easy to know in which Workbench to look for a specific tool. But they are quick to learn, and after a short while, they will feel natural. New users quickly realize Workbenches are a convenient way to organize the multitude of tools FreeCAD has to offer. In addition, Workbenches are also fully customizable (see below).

Later in this manual, you will find a table showing typical Workbench contents.

The interface

Let's have a better look at the different parts of the interface:

92ef5292.jpg

ad5b52b6.jpg

Any of the panels above can be turned on/off from menu View -> Panels.

Customizing the interface

The interface of FreeCAD is deeply customizable. All panels and toolbars can be moved to different places or stacked one with another. They can also be closed and reopened when needed from the View menu or by right-clicking on an empty area of the interface. There are, however, many more options available, such as creating custom toolbars with tools from any of the Workbenches, or assigning and changing keyboard shortcuts.

These advanced customization options are availabe from the Tools -> Customize menu:

e1ded5d7.jpg

Read more

Navigating in the 3D view

A word about the 3D space

If this is your first contact with a 3D application, you will need to grab some concepts first. If not, you can safely skip this section.

The FreeCAD 3D space is an euclidian space. It has an origin point and three axes: X, Y and Z. If you look at your scene from above, conventionally, the X axis points to the right, the Y axis to the back, and the Z axis upwards. In the lower right corner of the FreeCAD view, you can always see from where you are viewing the scene:

a7758eae.png

Every point of every object that exists in that space can be located by its (x,y,z) coordinates. For example, a point with coordinates (2,3,1) will lie at 2 units on the X axis, 3 units on the Y axis, and 1 unit on the Z axis:

cc168b8e.jpg

You can look at that scene from any angle, like if you were holding a camera. That camera can be moved left, right, up and down (pan), rotated around what it is looking at (rotate) and brought closer or further from the scene (zoom).

The FreeCAD 3D view

Navigating in the FreeCAD 3D view can be done with a mouse, a Space Navigator device, the keyboard, a touchpad, or a combination of those. FreeCAD can use several navigation modes, which determine how the three basic view manipulation operations (pan, rotate and zoom) are done, as well as how to select objects on the screen. Navigation modes are accessed from the Preferences screen, or directly by right-clicking anywhere on the 3D view:

8f46170.jpg

Each of these modes attributes different mouse buttons, or mouse + keyboard combinations, or mouse gestures, to these four operations. The following table shows the principal available modes:

Mode

Pan

Rotate

Zoom

Select

Inventor

ab21a02f.png

16ef88freecad-72.png

48f18d0c.png

CTRL + ab21a02f.png

CAD (default)

aa8e92freecad-53.png

16ef8872.png

48f18d0c.png

ab21a02f.png

Blender

SHIFT + aa8e9253.png

aa8e9253.png

48f18d0c.png

bf1817c4.png

Touchpad

SHIFT + a418f5ee.png

ALT + a418f5ee.png

PGUP / PGDOWN

c95e9ea0.png

Gesture

bf1817c4.png + DRAG

ab21a02f.png + DRAG

48f18d0c.png

ab21a02f.png

Alternatively, some keyboard controls are always available, no matter the navigation mode:

These controls are also available from the View menu and some from the View toolbar.

Selecting objects

Objects in the 3D view can be selected by clicking them with the corresponding mouse button, depending on the navigation mode. (For the rest of the manual we'll assume the default CAD navigation.) A single click will select the object, and one of its subcomponents (edge, face, vertex). Double-clicking will select the object, and all its subcomponents. You can select more than one subcomponent, or even different subcomponents from different objects, by pressing the CTRL key. With multiple items selected, keeping the CTRL key pressed, and pressing a selected item removes it from the selection. Clicking with the selection button on an empty portion of the 3D view will deselect everything.

A panel called "Selection view", available from the View menu, can also be turned on, which shows you what is currently selected:

ffd9decb.jpg

You can also use the Selection View to select objects by searching for a particular object.

Read more

The FreeCAD document

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 and/or objects within that 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.

946e268.jpg

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. There, you can create groups, move objects to groups, delete objects or groups. By right-clicking in the tree view or on an object, you can rename objects, change their color, hide or show them, or possibly other operations, depending on the current workbench.

a967e1a7.jpg

The objects inside a FreeCAD document can be of different types. Each workbench can add its own types of objects, for example the Mesh Workbench adds mesh objects, the Part Workbench adds Part objects, etc.

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. If you switch tabs to another document, that one becomes the active document. Most operations always work on the active document.

FreeCAD documents are saved with the .FcStd extension, which is a zip-based compound format, similar to LibreOffice. If something goes very wrong, it is often possible to unzip it and fix the problem or rescue the data.

Read more

Parametric objects

FreeCAD is designed for parametric modeling. This means that the geometry that you create, instead of being freely sculptable, is produced by rules and parameters. For example, a cylinder might be produced from a radius and a height. With these two parameters, the program has enough information to build the cylinder.

Parametric objects, in FreeCAD, are in reality small pieces of a program that run whenever one of the parameters has changed. Objects can have a lot of different kinds of parameters: numbers (integers like 1, 2, 3 or floating-point values like 3.1416), real-world sizes (1mm, 2.4m, 4.5ft), (x,y,z) coordinates, text strings ("hello!") or even another object.

This last type allows quickly building complex chains of operations, each new object being based on a previous one, adding new features to it.

In the example below, a solid, cubic object (Pad) is based on a rectangular 2D shape (Sketch) and has an extrusion distance. With these two properties, it produces a solid shape by extruding the base shape by the given distance. You can then use this object as a base for further operations, such as drawing a new 2D shape on one of its faces (Sketch001) and then making a subtraction (Pocket), until arriving at your final object.

All the intermediary operations (2D shapes, pad, pocket, etc) are still there, and you can still change any of their parameters anytime. The whole chain will be rebuilt (recomputed) whenever needed.

7912f8cf.jpg

Two important things are necessary to know:

  1. Recomputation is not always automatic. Heavy operations, that might modify a big portion of your document, and therefore take some time, are not performed automatically. Instead, the object (and all the objects that depend on it) will be marked for recomputation (a small blue icon appears on them in the tree view). You must then press the recompute button (F5 key or the two blue arrows pointing head to tail) to have all the marked objects recomputed.
  2. The dependency tree must always flow in the same direction. Loops are forbidden. You can have object A which depends on object B which depend on object C. But you cannot have object A which depends on object B which depends on object A. That would be a circular dependency. However, you can have many objects that depend on the same object, for example objects B and C both depend on A. Menu Tools -> Dependency graph shows you a dependency diagram like the image above. It can be useful to detect problems.

Not all objects are parametric in FreeCAD. Often, the geometry that you import from other files won't contain any parameter, and will be simple, non-parametric objects. However, these can often be used as a base, or starting point for newly created parametric objects, depending, of course, on what the parametric object requires and the quality of the imported geometry.

All objects, however, parametric or not, will have a couple of basic parameters, such as a Name, which is unique in the document and cannot be edited, a Label, which is a user-defined name that can be edited, and a placement, which holds its position in the 3D space.

Finally, it is worth noting that custom parametric objects are easy to program in python.

Read more

Import and export to other filetypes

FreeCAD can import and export to many filetypes. Here is a list of the most important ones with a short description of the available features:

Format

Import

Export

Notes

STEP

Yes

Yes

This is the most faithful import/export format available, since it supports solid geometry and NURBS. Use it whenever possible.

IGES

Yes

Yes

An older solid format, also very well supported. Some older applications don't support STEP but have IGES.

BREP

Yes

Yes

The native format of OpenCasCade, FreeCAD's geometry kernel.

DXF

Yes

Yes

An open format maintained by Autodesk. Since the 3D data inside a DXF file is encoded in a proprietary format, FreeCAD can only import/export 2D data to/from this format.

DWG

Yes

Yes

A proprietary file format. Requires the installation of the Teigha File Converter utility. This format suffers from the same proprietary limitations as DXF.

OBJ

Yes

Yes

A mesh-based format. Can only contain triangulated meshes. All solid and NURBS-based objects of FreeCAD will be converted to mesh on export. An alternative exporter is provided by the Arch workbench, more suited to the export of architectural models.

DAE

Yes

Yes

The main import/export format of Sketchup. Can only contain triangulated meshes. All solid and NURBS-based objects of FreeCAD will be converted to mesh on export.

STL

Yes

Yes

A mesh-based format, commonly used for 3D printing. Can only contain triangulated meshes. All solid and NURBS-based objects of FreeCAD will be converted to mesh on export.

PLY

Yes

Yes

An older mesh-based format. Can only contain triangulated meshes. All solid and NURBS-based objects of FreeCAD will be converted to mesh on export.

IFC

Yes

Yes

Industry Foundation Classes. Requires the installation of IfcOpenShell-python. The IFC format and its compatibility with other applications is a complex affair, use with care.

SVG

Yes

Yes

An excellent, widespread 2D graphics format

VRML

Yes

Yes

A rather old mesh-based web format.

GCODE

Yes

Yes

FreeCAD can import and export to/from several flavors of GCode, (aka RS-274) but only a small number of machines are supported at the moment.

CSG

Yes

No

OpenSCAD's CSG (Constructive Solid Geometry) format.

Some of these file formats have options. These can be configured from menu Edit -> Preferences -> Import/export: 85f58bca.jpg

Read more

Working with FreeCAD

All workbenches at a glance

One of the biggest difficulty for new users of FreeCAD, is to know in which workbench to find a specific tool. The table below will give you an overview of the most important workbenches and their tools. Refer to each workbench page in the FreeCAD documentation for a more complete list.

Four workbenches are also designed to work in pairs, and one of them is fully included into the other: Arch contains all the Draft tools, and PartDesign all the Sketcher tools. However, for clarity, they are separated below.

Part

The Part Workbench provides basic tools for working with solid parts: primitives, such as cube and sphere, and simple geometric operations and boolean operations. Being the main anchor point with OpenCasCade, the Part workbench provides the foundation of FreeCAD's geometry system, and almost all other workbenches produce Part-based geometry.

Tool

Description

Tool

Description

929949bd.png Box

Draws a box

92930554.png Cone

Draws a cone

f4af840f.png Cylinder

Draws a cylinder

99e9fa2f.png Sphere

Draws a sphere

4d8022a0.png Torus

Draws a torus (ring)

2ad77c8e.png Create Primitives

Creates various other parametric geometric primitives

d86ebafreecad-96.png Shape Builder

Create more complex shapes from primitives

dbca9518.png Fuse

Fuses (unions) two objects

48d038freecad-92.png Common

Extracts the common (intersection) part of two objects

928d792e.png Cut

Cuts (subtracts) one object from another

560e2f04.png Join Connect

Connects interiors of walled objects

6d9c0afreecad-81.png Join Embed

Embeds a walled object into another walled object

766308freecad-79.png Join Cutout

Creates a cutout in a wall of an object for another walled object

539430freecad-71.png Extrude

Extrudes planar faces of an object

7202e360.png Fillet

Fillets (rounds) edges of an object

25b6fffreecad-98.png Revolve

Creates a solid by revolving another object (not solid) around an axis

8548d49a.png Section

Creates a section by intersecting an object with a section plane

ecbb4bff.png Section Cross

Creates multiple cross sections along an object

a17590b6.png Chamfer

Chamfers edges of an object

63219f16.png Mirror

Mirrors the selected object on a given mirror plane

d4f0fddb.png Ruled Surface

Create a ruled surface between selected curves

925f05cb.png Sweep

Sweeps one or more profiles along a path

418026f4.png Loft

Lofts from one profile to another

acd29835.png Offset

Creates a scaled copy of the original object

91c40d44.png Thickness

Assign a thickness to the faces of a shape

Draft

The Draft Workbench provides tools to do basic 2D CAD drafting tasks: lines, circles, etc... and a series of generic handy tools such as move, rotate or scale. It also provides several drawing aids, such as grid and snapping. It is principally meant to draw the guidelines for Arch objects, but also serves as FreeCAD's "swiss knife".

Tool

Description

Tool

Description

e7650e78.png Line

Draws a line segment between 2 points

85aa1e1a.png Wire

Draws a line made of multiple line segments (polyline)

4e13ab0c.png Circle

Draws a circle from center and radius

a5b5039b.png Arc

Draws an arc segment from center, radius, start angle and end angle

20418374.pngEllipse

Draws an ellipse from two corner points

9a8fb5a0.png Polygon

Draws a regular polygon from a center and a radius

f494654.png Rectangle

Draws a rectangle from 2 opposite points

14a35659.png Text

Draws a multi-line text annotation

54568c16.png Dimension

Draws a dimension annotation

cfc0f6f7.png BSpline

Draws a B-Spline from a series of points

a0eb16a8.png Point

Inserts a single point

a4aedb4c.png Shape String

The ShapeString tool inserts a compound shape representing a text string at a given point in the current document

a2c3ba5e.png Facebinder

Creates a new object from selected faces on existing objects

b2d382b3.png Bezier Curve

Draws a Bezier curve from a series of points

e586f45.png Move

Moves or copies objects from one location to another

cbfd33c8.png Rotate

Rotates objects by a certain angle around a point

e5120e2b.png Offset

Offsets an object to a certain distance

909532e8.png Trimex

Trims, extends or extrudes an object

ea0498ef.png Upgrade

Turns or joins objects into a higher-level object

113581c7.png Downgrade

Turns or separtes objects into lower-level objects

e724c589.png Scale

Scales objects in relation to a point

5aaee15.png Shape2D View

Creates a 2D object which is a flattened view of another object

86f3ba5f.png Draft2Sketch

Converts a Draft object to a Sketch and vice-versa

3d80bfb1.png Array

Creates a polar or rectangular array from an object

de891dc7.png PathArray

Creates an array from an object by placing copies along a path

a736af8a.png Clone

Creates linked copies of objects

2c719ce0.png Mirror

Mirrors objects across a line

Sketcher

The Sketcher Workbench contains tools to build and edit complex 2D objects, called sketches. The geometry inside these sketches can be precisely positioned and relationed by the use of constraints. They are meant primarily to be the building blocks of PartDesign geometry, but are useful everywhere in FreeCAD.

Tool

Description

Tool

Description

6c8e67e1.png Point

Draws a point

50adfcae.png Line by 2 points

Draws a line segment from 2 points

328d7ddb.png Arc

Draws an arc segment from center, radius, start angle and end angle

2a94fb41.png Arc by 3 points

Draws an arc segment from two endpoints and another point on the circumference

4cab05c3.png Circle

Draws a circle from center and radius

e214b6f2.png Circle by 3 points

Draws a circle from three points on the circumference

750a1c15.png Ellipse by center

Draws an ellipse by center point, major radius point and minor radius point

db4829.png Ellipse by 3 points

Draws an ellipse by major diameter (2 points) and minor radius point

60b45802.png Arc of ellipse

Draws an arc of ellipse by center point, major radius point, starting point and ending point

383609df.png Polyline

Draws a line made of multiple line segments. Several drawing modes available

cb8d0739.png Rectangle

Draws a rectangle from 2 opposite points

ec07fe32.png Triangle

Draws a regular triangle inscribed in a construction geometry circle

2ef58a85.png Square

Draws a regular square inscribed in a construction geometry circle

f2726921.png Pentagon

Draws a regular pentagon inscribed in a construction geometry circle

2e688cf7.png Hexagon

Draws a regular hexagon inscribed in a construction geometry circle

32f71e10.png Heptagon

Draws a regular heptagon inscribed in a construction geometry circle

c2364freecad-126.png Octagon

Draws a regular octagon inscribed in a construction geometry circle

69ca86a2.png Slot

Draws an oval by selecting the center of one semicircle and an endpoint of the other semicircle

62916023.png Fillet

Makes a fillet between two lines joined at one point

5db839f6.png Trim

Trims a line, circle or arc with respect to a clicked point

a46b620c.png External Geometry

Creates an edge linked to external geometry

e9c4e4bb.png Construction Mode

Toggles an element to/from construction mode. A construction object will not be used in a 3D geometry operation and is only visible while editing the Sketch that contains it

82df2a76.png Coincident constraint

Affixes a point onto (coincident with) one or more other points.

bee24f2a.png Point On Object constraint

Affixes a point onto another object such as a line, arc, or axis.

f4907433.png Vertical constraint

Constrains the selected lines or polyline elements to a true vertical orientation. More than one object can be selected before applying this constraint.

de73649e.png Horizontal constraint

Constrains the selected lines or polyline elements to a true horizontal orientation. More than one object can be selected before applying this constraint.

7e7d618d.png Parallel constraint

Constrains two or more lines parallel to one another.

d9596053.png Perpendicular constraint

Constrains two lines perpendicular to one another, or constrains a line perpendicular to an arc endpoint.

4137f88.png Tangent constraint

Creates a tangent constraint between two selected entities, or a co-linear constraint between two line segments.

55d214a.png Equal Length constraint

Constrains two selected entities equal to one another. If used on circles or arcs their radii will be set equal.

c18cb040.png Symmetric constraint

Constrains two points symmetrically about a line, or constrains the first two selected points symmetrically about a third selected point.

f6adb915.png Lock constraint

Constrains the selected item by setting vertical and horizontal distances relative to the origin, thereby locking the location of that item

808999eb.png Horizontal Distance constraint

Fixes the horizontal distance between two points or line endpoints. If only one item is selected, the distance is set to the origin.

db40447.png Vertical Distance constraint

Fixes the vertical distance between 2 points or line endpoints. If only one item is selected, the distance is set to the origin.

737d0a92.png Length constraint

Defines the distance of a selected line by constraining its length, or defines the distance between two points by constraining the distance between them.

2ee99ad5.png Radius constraint

Defines the radius of a selected arc or circle by constraining the radius.

263298f3.png Internal Angle constraint

Defines the internal angle between two selected lines.

7e280767.png Snell's Law constraint

Constrains two lines to obey a refraction law to simulate the light going through an interface

eb0e56ff.png Internal Alignment constraint

Aligns selected elements to selected shape (e.g. a line to become major axis of an ellipse)

dc4bd3d3.png Map sketch to face

Maps a sketch to the previously selected face of a solid

efd0f5f5.png Merge

Merge two or more sketches

a286d64.png Mirror

Mirrors selected elements of a sketch

Part Design

The Part Design Workbench contains advanced tools to build solid parts. It also contains all the tools from the sketcher. Since it can only produces solid shapes (the rule number one of Part Design), it is the main workbench to use when designing pieces (parts) to be manufactured or 3D-printed, as you will always obtain a printable object.

Tool

Description

Tool

Description

c230d541.png Pad

Extrudes a solid object from a selected sketch

592deef6.png Pocket

Creates a pocket from a selected sketch. The sketch must be mapped to an existing solid object's face

b75f9066.png Revolution

Creates a solid by revolving a sketch around an axis

4daf5d1.png Groove

Creates a groove by revolving a sketch around an axis

9195c785.png Fillet

Fillets (rounds) edges of an object

a06d846d.png Chamfer

Chamfers edges of an object

4396f2c0.png Draft

Applies angular draft to faces of an object

3974d1c9.png Mirrored

Mirrors features on a plane or face

c3e56e75.png Linear Pattern

Creates a linear pattern of features

fc0c1096.png Polar Pattern

Creates a polar pattern of features

4ac619d7.png Scaled

Scales features to a different size

c1a48463.png MultiTransform

Allows creating a pattern with any combination of the other transformations

7c373106.png Shaft wizard

Generates a shaft from a table of values and allows to analyze forces and moments

a94d68e5.png Involute Gear wizard

Allows you to create several types of gears

Arch

The Arch Workbench contains tools to work with BIM projects (civil engineering and architecture). It also contains all the tools from the Draft workbench. The main use of the Arch Workbench is to create BIM objects or give BIM attributes to objects built with other workbenches, in order to export them to IFC.

Tool

Description

Tool

Description

cf044083.png Wall

Creates a wall from scratch or using a selected object as a base

a6dc737d.png Structure

Creates a structural element from scratch or using a selected object as a base

7e7a6038.png Reinforcement Bar

Creates a reinforcement bar in a selected structural element

b7cb5a66.png Floor

Creates a floor including selected objects

3ea19023.png Building

Creates a building including selected objects

cca1778f.png Site

Creates a site including selected objects

2de7e83f.png Window

Creates a window using a selected object as a base

c6cde061.png Section Plane

Adds a section plane object to the document

6f34c644.png Axes

Adds an axes system to the document

bf912edc.png Roof

Creates a sloped roof from a selected face

1ecb5f.png Space

Creates a space object in the document

2a3027a2.png Stairs

Creates a stairs object in the document

1cf5bf04.png Panel

Creates a panel object from a selected 2D object

720f5e58.png Frame

Creates a frame object from a selected layout

b3131ef2.png Equipment

Creates an equipment or furniture object

c9042f47.png Set Material

Attributes a material to selected objects

1b8f65ec.png Schedule

Creates different types of schedules

163ddc4c.png Cut Plane

Cut an object according to a plan.

78ab1f50.png Add Component

Adds objects to a component

cf0fe099.png Remove Component

Subtracts or removes objects from a component

2c8b1c2d.png Survey Mode

Enters or leaves surveying mode

Drawing

The Drawing Workbench handles the creation and manipulation of 2D drawing sheets, used for displaying views of your 3D work in 2D. These sheets can then be exported to 2D applications in SVG or DXF formats, to a PDF file or printed.

Tool

Description

Tool

Description

b6f98c6e.png New sheet

Creates a new drawing sheet

5733346b.png Insert view

Inserts a view of the selected object in the active drawing sheet

cffe399.png Annotation

Adds an annotation to the current drawing sheet

5b20a5fc.png Clip

Adds a clip group to the current drawing sheet

2790770d.png Browser preview

Opens a preview of the current sheet in the browser

f25222ad.png Ortho Views

Automatically creates orthographic views of an object on the current drawing sheet

48dafd2e.png Symbol

Adds the contents of a SVG file as a symbol on the current drawing sheet

853b1051.png Draft View

Inserts a special Draft view of the selected object in the current drawing sheet

9b0eb2be.png Export

Saves the current sheet as a SVG file

Other built-in workbenches

Although the above summarizes the most important tools of FreeCAD, many more workbenches are available, among them:

External workbenches

A number of other very useful workbenches produced by FreeCAD community members also exist. Although they are not included in a standard FreeCAD installation,they are easy to install as plug-ins. They are all referenced in the FreeCAD-addons repository. Among the most developed are:

Read more

Traditional modeling - the CSG way

CGS stands for Constructive Solid Geometry and describes the most basic way to work with solid 3D geometry, which is creating complex objects by adding and removing pieces to/from solids by using Boolean operations such as union, subtraction or intersection.

As we saw earlier in this manual, FreeCAD can handle many types of geometry, but the preferred and most useful type for the kind of 3D objects that we want to design with FreeCAD, that is, real-world objects, is, without a doubt, solid, BREP geometry, that is mainly handled by the Part Workbench. Unlike polygon meshes, which are made only of points and triangles, BREP objects have their faces defined by mathematical curves, which permits abolute precision, no matter the scale.

1c0a58b9.jpg

The difference between the two can be compared to the difference between bitmap and vectorial images. As with bitmap images, polygon meshes have their curved surfaces fractionned in a series of points. If you look at it from very close, or print it very large, you will see not a curved but a faceted surface. In both vectorial images and BREP data, the position of any point on a curve is not stored in the geometry but calculated on the fly, with exact precision.

In FreeCAD, all BREP-based geometry is handled by another piece of open-source software, OpenCasCade. The main interface between FreeCAD and the OpenCasCade kernel is the Part Workbench. Most other workbenches build their functionality on top of the Part Workbench.

Although other workbenches often offer more advanced tools to build and manipulate geometry, since they all actually manipulate Part objects, it is very useful to know how these objects work internally, and be able to use the Part tools since, being more simple, they can very often help you to work around problems that the more intelligent tools fail to solve properly.

To illustrate the working of the Part Workbench, we will model this table, using only CSG operations (except the screws, for which we will use one of the addons, and the dimensions, which will see in the next chapter):

7e2822c8.jpg

Let's create a new document (Ctrl+N or menu File -> New Document), switch to the Part Workbench, and begin with the first foot:

You should obtain two high boxes, one 8mm apart from the other:

9760057b.jpg

a4316f6a.jpg

Observe that the newly created object, called "Cut", still contains the two cubes we used as operands. In fact, the two cubes are still there in the document, they have merely been hidden and grouped under the Cut object in the tree view. You can still select them by expanding the arrow next to the Cut object, and, if you wish, turn them visible again by right-clickig them or change any of their properties.

ac267766.jpg

You might have been thinking that, instead of duplicating the base cube six times, we could have duplicated the complete foot three times. This is totally true, as always in FreeCAD, there are many ways to achieve a same result. This is a precious thing to remember, because, as we will advance into more complex objects, some operations might not give the correct result and we often need to try other ways.

8138de1a.jpg

You will notice that the cylinders are a bit longer than needed. This is because, as in all solid-based 3D applications, boolean operations in FreeCAD are sometimes oversensitive to face-on-face situations and might fail. By doing this, we put ourselves on the safe side.

4502e0e5.jpg

As you can see, each foot has become a quite long series of operations. All this stays parametric, and you can go change any parameter of any of the older operations anytime. In FreeCAD, we often refer to this pile as "modeling history", since it in fact carries all the history of the operations you did.

Another particularity of FreeCAD is that the concept of 3D object and the concept of 3D operation tend to blend into one same thing. The Cut is at the same time an operation, and the 3D object resulting from this operation. In FreeCAD this is called a "feature", rather than object or operation.

4fb2c71.jpg

Notice that, although the legs are 8mm thick, we placed it 10mm away, leaving 2mm between them. This is not necessary, of course, it won't happen with the real table, but it is a common thing to do in that kind of "assembled" models, it helps people who look at the model to understand that these are independent parts, that will need to be attached together manually later.

Now that our five pieces are complete, it is a good time to give them more proper names than "Cut015". By right-clicking the objects in the tree view (or pressing F2), you can rename them to something more meaningful to yourself or to another person who would open your file later. It is often said that simlpy giving proper names to your objects is much more important than the way you model them.

16079b5a.jpg

cb771d69.jpg

The internal structure of Part objects

As we saw above, it is possible in FreeCAD to select not only whole objects, but parts for them, such as the circular border of our screw hole. This is a good time to have a quick look at how Part objects are constructed internally. Every workbench that produces Part geometry will be based on these:

In the 3D view, you can select individual vertices, edges or faces. Selecting one of these also selects the whole object.

A note about shared design

You might look at the table above, and think its design is not good. The tightening of the feet with the tabletop is probably too weak. You might want to add reforcing pieces, or simply you have other ideas to make it better. This is where sharing becomes interesting. You can download the file made during this exercise from the link below, and modify it to make it better. Then, if you share that improved file, others might be able to make it even better, or use your well-designed table in their projects. Your design might then give other ideas to other people, and maybe you will have helped a tiny bit to make a better world...

Downloads

Read more

Traditional 2D drafting

You might be interested by FreeCAD because you already have some technical drawing experience, for example with software like AutoCAD. Or you already know something about design, or you prefer to draw things before building them. In either cases, FreeCAD features a more traditional workbench, with tools found in most 2D CAD applications: The Draft Workbench.

The Draft Workbench, although it adopts ways of working inherited from the traditional 2D CAD world, is not limited at all to the 2D realm. All its tools work in the whole 3D space and many of the Draft tools, for example c5afca14.png Move or f42c0c67.png Rotate, are commonly used all over FreeCAD because they are often more intuitive than changing placement parameters manually.

Among the tools offered by the Draft Workbench, you will find traditional drawing tools like 5dc4ab59.png Line, 8d1edeee.png Circle, or bbc90c1f.png Wire (polyline), modification tools like c5afca14.png Move, f42c0c67.png Rotate or 1b2020a7.png Offset, a working plane/grid system that allows you to define precisely in which plane you are working, and a complete snapping system that makes it very easy to draw and position elements precisely in relation to each other.

To showcase the working and possibilities of the Draft Workbench, we will walk through a simple exercise, the result of which will be this little drawing, showing the floor plan of a small house that contains only a kitchen top (A pretty absurd floor plan, but we can do what we want here, can't we?):

bd8a4747.jpg

c3d88814.jpg

6a6744bf.jpg

73900432.jpg

79cf9451.jpg

bffbba35.jpg

2e9b8360.jpg

d5f6f1a9.jpg

8abf2582.jpg

eb1249d9.jpg

ed6e79b6.jpg

b6fd9436.jpg

ae6bd724.jpg

14dc2503.jpg

e5cd8bd3.jpg

Fundamentally, what the Draft Workbench does is provide graphical ways to create basic Part operations. While in Part you will usually position objects by setting their placement property by hand, in Draft you can do it on-screen. There are times when one is better, other times when the other is preferable. Don't forget, you can create custom toolars in one of these workbenches, add the tools from the other, and get the best of both worlds.

Downloads

Read more

Modeling for product design

Product design is originally a comercial term, but in the 3D world, it often means modeling something with the idea to have it 3D-printed or, more generally, manufactured by a machine, being a 3D printer or a CNC machine.

When you print objects in 3D, it is of ultimate importance that your objects are solid. As they will become real, solid objects, this is obvious. Nothing prevent them from being hollow inside, of course. But you always need to have a clear notion of which point is inside the material, and which point is outside, because the 3D printer or the CNC machine needs to know exactly what is filled with material and what is not. For this reason, in FreeCAD, the Part Design Workbench is the perfect tool to build such pieces, because it will always take care for you that your objects stay solid and buildable.

To illustrate how the PartDesign Workbench works, let's model this well-known piece of Lego:

4f77373e.jpg

The cool thing with Lego pieces is that the dimensions are easy to obtain on the internet, at least for the standard pieces. These are pretty easy to model and print on a 3D printer, and with a bit of patience (3D printing often requires much adjustment and fine-tuning) you can make pieces that are totally compatible and click perfectly into original Lego blocks.In the example below, we will make a piece that is 1.5 times bigger than the original.

We will now use exclusively the Sketcher and Part Design tools. Since all the tools from the Sketcher Workbench are also included in the Part Design Workbench, we can stay in Part Design and we will not need to switch back and forth between the two.

Part Design objects are fully based on Sketches. A Sketch is a 2D object, made of linear segments (lines, arcs of circle or ellipses) and constraints. These constraints can be applied either on linear segments or on their endpoints or center points, and will force the geometry to adopt certain rules. For example, you can place a vertical constraint on a line segment to force it to stay vertical, or a position (lock) constraint on an endpoint to prohibit it to move. When a sketch has an exact amount of constraints that prohibits any point of the sketch to be moved anymore, we talk about a fully constrained sketch. when there are redundant constraints, that could be removed without allowing the geometry to be moved, it is called over-constrained. This should be avoided, and FreeCAD will notify you if such case occurs.

Sketches have an edit mode, where their geometry and constraints can be changed. When you are done with editing, and leave edit mode, sketches behaves like any other FreeCAD object, and can be used as building blocks for all the Part Design tools, but also in other workbenches, such as Part or Arch. The Draft Workbench also has a tool that converts Draft objects to Sketches, and vice-versa.

4a3f42dc.jpg

4b2c7.jpg

Note that the last point-on-point constraint was not absolutely necessary. You are never forced to work with fully constrained sketches. However, if we are going to print this block in 3D, it will be necessary to maintain our piece close to the origin point (which will be the center of the space where the printer head can move). By adding that constraint we are making sure that our piece will always stay "anchored" to that origin point.

6a76fa1a.jpg

The Pad behaves very much like the Part Extrude tool that we used in the previous chapter. There are a couple of differences, though, the main one being that a pad cannot be moved. It is attached forever to its sketch. If you want to change the position of the pad, you must move the base sketch. In the current context, where we want to be sure nothing will move out of position, this is an additional security.

da842c95.jpg

136d7dc.jpg

You will notice that only edges from the the base face can be added by this tool. When you create a sketch with a face selected, a relation is created between that face and the sketch, which is important for further operations. You can always remap a sketch to another face later with the 2bc7738f.png Map Sketch tool.

633db981.jpg

6ef0dbb.jpg

b73516c8.jpg

8f32cf5f.jpg

4e33da1d.jpg

c40b49d1.jpg

75d152a2.jpg

50a8a368.jpg

d6237793.jpg

You will notice that our modeling history (what appears in the tree view) has become quite long. This is of precious because every single step of what we did can be changed later on. Adapting this model for another kind of brick, for example one with 2x2 dots, instead of 2x4, would be a piece of cake, we would just need to change a couple of dimensions and the number of occurences in linear patterns. We could as easily create bigger pieces that don't exist in the original Lego game.

But we could also need to get rid of the history, for example if we are going to model a castle with this brick, and we don't want to have this whole history repeated 500 times in our file.

There are two simple ways to get rid of the history, one is using the Create simple copy tool from the Part Workbench, which will create a copy of our piece that doesn't depend anymore on the history (you can delete the whole history afterwards), the other way is exporting the piece as a STEP file and reimporting it.

Assembling

But the best of both worlds also exists, which is the Assembly2 Workbench, an addon that can be installed from the FreeCAD-addons repository. This Workbench is named "2" because there is also an official built-in Assembly Workbench in development, which is not ready yet. The Assembly2 Workbench, however, already works very well to construct assemblies, and also features a couple of object-to-object constraints which you can use to constrain the position of one object in relation to another. In the example below, however, it will be quicker and easier to position the pieces using c5afca14.png Draft Move and f42c0c67.png Draft Rotate than using the Assembly2 constraints.

bd31ddd2.jpg

Downloads

Read more

Preparing models for 3D printing

One of the main uses of FreeCAD is to produce real-world objects. These can be designed in FreeCAD, and then made real by different ways, such as communicated to other people who will then build them, or, more and more fequently, sent directly to a 3D printer or a CNC mill. This chapter will show you how to get your models ready to send to these machines.

If you have been cautious while modeling, most of the difficulty you might encounter when printing your model in 3D has already been avoided. This involves basically:

Below, we will assume that the first two criterias are met, and that by now you are able to produce solid objects with correct dimensions. We will now see how to address the third point.

Exporting to slicers

This is the technique most commonly used for 3D printing. The 3D object is exported to another program (the slicer) which will generate the G-code from the object, by slicing it into thin layers (hence the name), which will reproduce the movements that the 3D printer will do. Since many of those printers are home-built, there are often small differences from one to the other. These programs usually offer advanced configuration possibilities that allow to tailor the output exactly for the particularities of your 3D printer.

Actual 3D printing, however, is a too vast subject for this manual. But we will see how to export and use these slicers to check that the output is correct.

Converting objects to meshes

None of the slicers will, at this date, take directly solid geometry as we produce in FreeCAD. So we will need to convert any object we want to 3D print into a mesh first, that the slicer can open. Fortunately, converting a solid to a mesh, is very straightforward. All we need to be careful about, is that it is now that the degradation we mentioned above will occur. We need to check that the degradation stays inside acceptable limits.

All the mesh handling, in FreeCAD, is done by another specific workbench, the Mesh Workbench. This workbench contains, the tools that convert between Part and Mesh objects, several utilities meant to analyze and repair meshes. Although working with meshes is not the focus of FreeCAD, when working with 3D modeling, you often need to deal with mesh objects, since their use is very widespread among other applications. This workbench allows you to handle them fully in FreeCAD.

9a108499.jpg

cab86d89.jpg

In most cases, though, the default values will give a satisfying result.

If you don't own a 3D printer, it is usually very easy to find commercial services that will print and send you the printed objects by mail. Among the famous ones are Shapeways and Sculpteo, but you will also usually find many others in your own city. In all major cities, you will also nowadays find Fab labs, which are workshops equipped with a range of 3D manufacturing machines, almost always including at least one 3D printer. Fab labs are usually community spaces, that will let you use their machines, for a fee or for free depending on the Fab lab, but also teach you how to use them, and promote other activities around 3D manufacturing.

Using Slic3r

Slic3r is an application that converts STL objects into G-code that can be sent directly to 3D printers. Like FreeCAD, it is free, open-source and runs on Windows, Mac OS and Linux. Correctly configurating things for 3D printing is a complicated process, where you must have a good knowledge of your 3D printer, so it is not very useful to generate G-code before actually going to print (your G-code file might not work well on another printer), but it is useful for us anyway, to check that our STL file will be printable without problems.

This is our exported STL file opened in Slic3r. By using the preview tab, and moving the right slider, we can visualize the path that the 3D printer head will follow to construct our object.

1ceede0.jpg

Using the Cura addon

Cura is another free and open-source slicer application for Windows, Mac and Linux, maintained by the 3D printer maker Ultimaker. Some FreeCAD users have created a Cura Workbench that uses cura internally. The Cura Workbench is available from the FreeCAD addons repository. To use the Cura Workbench, you also need to install Cura itself, which is not included in the workbench.

Once you have installed both Cura and the Cura Workbench, you will be able to use it to produce the G-code file directly from Part objects, without the need to convert them to meshes, and without the need to open an external application. Producing another G-code file from our Lego brick, using the Cura Workbench this time, is done as follows:

d8ae9a2d.jpg

Generating G-code

FreeCAD also offers more advanced ways to generate G-code directly. This is often much more complicated than using automatic tools as we saw above, but has the advantage to let you fully control the output. This is usually not needed when using 3D printers, but becomes very important when dealing with CNC milling, as the machines are much more complex.

G-code path generation in FreeCAD is done with the Path Workbench. It features tools that generate full machine paths and others that generate only parts of a G-code project, that can be assembled to form a whole milling operation.

Generating CNC milling paths is another subject that is much too vast to fit in this manual, so we are going to show how to build a simple Path project, without caring much about most of the details of real CNC machining.

bacb73e6.jpg

24115007.jpg

d7234446.jpg

c3a36062.jpg

There are many applications available to simulate the real cutting, one of them that is also multi-platform and open-source, like FreeCAD, is Camotics.

Downloads

Read more

Generating 2D drawings

When your model cannot be printed or milled directly by a machine, for example it is too big (a building) or it requires manual assembly after the pieces are ready, you will usually need to explain to another person how to do that. In technical fields (engineering, architecture, etc), this is usually done with drawings, that are handed over to the person responsible for assembling the final product, that will explain how to do it.

Typical examples are Ikea instructions, architectural drawings or blueprints. These drawings usually contain not only the drawing itself, but also many annotations, such as texts, dimensions, numbers, symbols that will help other people to understand what needs to be done and how.

In FreeCAD, the workbench responsible for making such drawings is the Drawing Workbench.

The Drawing Workbench allows you to create sheets, which can be blank or use a pre-made template to already have a series of items on the sheet, such as borders and title. On these sheets, you can then place views of the 3D objects you modeled previously, and configure how these views must appear on the sheet. Finally, thanks to an addon called Drawing Dimensioning Workbench, you can also place all kinds of annotations on the sheet, such as dimensions, texts, and other usual symbols commonly used in technical drawings.

Drawing sheets, once complete, can be printed or exported as SVG, PDF or DXF files.

In the following exercise, we will see how to create a simple drawing of a chair model found in the FreeCAD library (Furniture -> Chairs -> IkeaChair). The FreeCAD library can easily be added to your FreeCAD installation (refer to the installing chapter of this manual), or you can simply download the model from the library webpage, or via the direct link provided at the bottom of this chapter.

85bb549c.jpg

832e62bf.jpg

1efefa9e.jpg

8672ee9a.jpg

We will now place dimensions and indications on our drawing. There are two ways to add dimensions to a model, one is placing the dimensions inside the 3D model, using the b5f58288.png Dimension tool of the Draft Workbench, and then place a view of these dimensions on our sheet with the 6bcc11c5.png Draft View tool (which can be used with a single dimension or a group containing dimensions), or we can do things directly on the Drawing sheet, using the Drawing Dimensioning Workbench, which is installable from the FreeCAD addons. We will use here this latter method.

5a7c148b.jpg

9ca177c0.jpg

62d10340.jpg

Our page can now be exported to SVG to be worked further in graphical applications like inkscape, or to DXF by selecting menu File -> Export. The Drawing Dimensioning workbench also features its own DXF export tool, which also supports the annotations added with that workbench. The DXF format is importable in almost all existing 2D CAD applications. Drawing pages can also be directly printed or exported to PDF.

Downloads

Read more

BIM modeling

BIM stands for Building Information Modeling. The exact definition of what it is varies, but we can say simply that is how buildings and other large structures like bridges, tunnels, etc... are modeled today. BIM models are usually based on 3D models, and also include a series of additional layers of information, such as materials information, relationships to other objects or models, or special instructions for building or maintenance. This extra information permits all kinds of advanced analyses of the model, such as structural resistance, cost and construction time estimations, or calculaitons of energy consumption.

The Arch Workbench of FreeCAD implements a series of tools and facilities for BIM modeling. Although it has a different purpose, it is made to work in tight integration with the rest of FreeCAD: Anything made with any other workbench of FreeCAD can become an Arch object, or be used as a base for an Arch object.

As in the PartDesign Workbench, the objects produced by the Arch Workbench are meant to be built in the real world. Therefore, they need to be solid. The Arch tools usually take care of that automatically, and also provide utility tools to help you check the validity of objects.

The Arch Workbench also includes all the tools from the Draft Workbench, and uses its grid and snapping system. Before beginning, it is always a good idea to browse through the preferences pages of both Draft and Arch and set the default settings to your likings.

In this chapter, we will see how to model this small building:

10d8ef7b.jpg

and produce a plan and a section view from it:

cb6a1432.jpg

f60a3d82.jpg

Notice that we drew always in the same direction (clockwise). This is not necessary, but will ensure that the walls that we will build next all have the same left and right directions. You might also think we could simply have drawn a rectangle here, which is true. But the four lines will allow us to illustrate better how to add one object into another.

13c0ded1.jpg

Now we need to join these walls together, so they intersect properly. This is not necessary when your walls are drawn in a way that they already connect cleanly, but here we need to, since they are intersecting. In Arch, this is done by electing one of the walls to be the "host", and adding the others to it, as "additions". All arch objects can have any number of additions (objects whose geometry will be added to the host's geometry), and subtractions (objects whose geometry will be subtracted). The additions and subtractions of an object can be managed anytime by double-clicking the object in the tree.

f93b8138.jpg

The individual walls are however still accessible, by expanding the wall in the tree view.

9fca9d5c.jpg

3f90f889.jpg

603878be.jpg

c32a467c.jpg

Windows are always built on sketches. It is easy to create custom windows by first creating a sketch on a face, then turning it into a window by selecting it, then pressing the window button. Then, the window creation parameters, that is, which wires of the sketch must be extruded and how much, can be defined by double-clickingthe window in the tree view. Let's now create a slab:

87772859.jpg

1fb56090.jpg

710d49fa.jpg

ac6f943b.jpg

379f5631.jpg

c6cdd49b.jpg

That's it, our model is now complete. We should now organize it so it exports correctly to IFC. The IFC format requires that all objects of a building are inside a building object, and optionally, inside a storey. It also requires that all buildings are placed on a site, but the IFC exporter of FreeCAD will add a default site automatically if needed, so we don't need to add one here.

Our model is now ready to export:

dbe6a8d7.jpg

The IFC format is one of the most precious assets in a free BIM world, because it allows the exchange of data between any application and actor of the construction world, in an open manner (the format is open, free and maintained by an independent consortium). Exporting your BIM models as IFC ensures that anyone can see and analyze them, no matter the application used.

In FreeCAD, IFC import and export is done by interfacing with another piece of software, called IfcOpenShell. To be able to export to IFC from FreeCAD, the IfcOpenShell-python package must be installed on your system. Be sure to select one which uses the same python version as FreeCAD. The python version that FreeCAD uses is informed when opening the View -> Panels -> Python console panel in FreeCAD. When that is done, we can now export our model:

2f546b0c.jpg

We will now place some dimensions. Unlike the previous chapter, where we drew all the dimensions directly on the Drawing sheet, we will use another method here, and place Draft dimensions directly in the 3D model. These dimensions will then be placed on the Drawing sheet. We will first make two groups for our dimensions, one for the dimensions that will appear in the plan view, and another for those that appear on the elevation.

7f3509af.jpg

684feae8.jpg

We will now prepare a set of views from our model, to be paced on a Drawing page. We can do that with the tools from the Drawing Workbench, as we have seen in the previous chapter, but the Arch Workbench also offers an all-in-one advanced tool to produce plan, section and elevation views, called Section Plane. We will now add two of these section planes, to create a plan view and an elevation view.

14e16a86.jpg

ce0360dd.jpg

bc10cc94.jpg

We will now create two more Draft Views, one for each group of dimensions.

Our page is now ready, and we can export it to SVG or DXF formats, or print it. The SVG format allows to open the file illustration applications such as inkscape, with which you can quickly enhance technical drawings and turn them into much nicer presentation drawings. It offers many more possibilities than the DXF format.

Downloads

Read more

Using spreadsheets

FreeCAD features another interesting workbench to explore: the Spreadsheet Workbench. This workbench allows to create spreadsheets such as those made with Excel or LibreOffice directly in FreeCAD. These spreadsheets can then be populated with data extracted from your model, and can also perform a series of calculations between values. Spreadsheets can be exported as CSV files, which can be imported in any other spreadsheet application.

In FreeCAD, however, spreadsheets have an additional utility: Their cells can receive a name, and can then be referenced by any field supported by the expressions engine. This turns spreadsheets into powerful control structures, where the values inserted in specific cells can drive dimensions of the model. There is only one thing to keep in mind, as FreeCAD prohibits circular dependencies between objects, a same spreadsheet cannot be used to set a property of an object and at the same time retrieve a property value from the same object. That would make the spreadsheet and the object depending on each other.

In the following example, we will create a couple of objects, retrieve some of their properties in a spreadsheet, then use the spreadsheet to directly drive properties of other objects. se

Reading properties

79a7fb46.jpg

a964be48.jpg

The spreadsheet editor of FreeCAD, although it is not as complete and powerful as the more complete spreadsheet applications we listed above, has nevertheless most of the basic tools and functions that are commonly used, such as the possibility to change the aspect of the cells (size, color, alignment), join and split cells, use formulas such as =2+2, or reference other cells with =B1.

In FreeCAD, to these common behaviours, has been added one very interesting: The possibility to reference not only other cells, but other objects from the document, and retrieve values from their properties. For example, let's retrieve a couple of properties from the 3 objects we created above. Properties are what we can see in the properties editor window, under the Data tab, when an object is selected.

a4616623.jpg

b2fbb47c.jpg

The Spreadsheet Workbench page will describe more in detail all the possible operations and functions that you can use in spreadsheets.

Writing properties

Another very interesting use of the Spreadsheet Workbench in FreeCAD is to do the contrary of what we have been doing until now: Instead of reading the values of properties of 3D objects, we can also assign values to these objects. Remember, however, one of the fundamental rules of FreeCAD: Circular dependencies are forbidden. We can therefore not use the same spreadsheet to read and write values to a 3D object. That would make the object depend on the spreadsheet, which would also depend on the object. Instead, we will create another spreadsheet.

cc5373a1.jpg

6d338c70.jpg

You might wonder why we had to use "Spreadsheet001" instead of "Input" in the expression above. This is beacause each object, in a FreeCAD document, has an internal name, which is unique in the document, and a label, which is what appears in the tree view. If you uncheck the appropriate option in the preferences settings, FreeCAD will allow you to give the same label to more than one object. This is why all operations that must identify an object with absolutely no doubt, will use the internal name instead of the label, which could designate more than one object. The easiest way to know the internal name of an object is by keeping the selection panel (menu Edit->Panels) open, it will always indicate the internal name of a selected object:

42963c1f.jpg

By using cell aliases in spreadsheets, we are able to use a spreadsheet to store "master values" in a FreeCAD document. This can be used, for example, to have a model of a piece of certain dimensions, and to store these dimensions in a spreadsheet. It becomes then very easy to produce another model with different dimensions, it is just a matter of opening the file and changing a couple of dimensions in the spreadsheet.

Finally, note that the constraints inside a sketch can also receive the value of a spreadsheet cell:

ff1a44d1.jpg

You can also give aliases to dimensional constraints (horizontal, vertical or distance) in a sketch (you can then use that value from outside the sketch as well):

98b2ab1b.jpg

Download

Read more

Creating FEM analyses

FEM stands for Finite Element Method. It is a vast mathematical subject, but in FreeCAD we can resume it as a way to calculate propagations inside a 3D object, by cutting it into small pieces, and analyzing the impact of each small piece over its neighbours. This has several uses in the engineering and electomagnetism fields, but we will look here more in depth at one use that is already well developed in FreeCAD, which is simulating deformations in objects which are submitted to forces and weights.

Obtaining such simulation is done in FreeCAD with the FEM Workbench. It involves different steps: Preparing the geometry, setting its material, performing the meshing (division into smaller parts, like we did in the Preparing objects for 3D printing chapter, and finally calculating the simulation.

6d3df26.jpg

Preparing FreeCAD

The simulation itself is done by another piece of software, that is used by FreeCAD to obtain the results. As there are several interesting open-source FEM simulation applications available, the FEM Workbench has been made to be able to use more than one. However, currently only CalculiX is fully implemented. Another piece of software, called NetGen, which is responsible for generating the subdivision mesh, is also required. Detailed instructions to install these two components are provided in the FreeCAD documentation.

Preparing the geometry

We will start with the house we modelled in the BIM modeling chapter. However, some changes have to be made to make the model suitable for FEM calculations. This involves, basically, discarding the objects that we don't want to include in the calculaiton, such as the door and window, and joining all the remaining objects into one.

dfff2621.jpg

256dc4.jpg

Creating the analysis

990859ba.jpg

5f50940f.jpg

22fe02d1.jpg

f4f3cb4d.jpg

92675de1.jpg

586c71de.jpg

f938a74a.jpg

The results displayed by the FEM workbench are of course currently not enough to perform real-life decisions about structures dimensionning and materials. However, they can already give precious information about how the forces flow through a structure, and which are the weak areas that will bear the more stress.

Downloads

Read more

Creating renderings

In computer talk, a rendering is a word used to describe a nice image produced from a 3D model. Of course, we could say that what se see in the FreeCAD 3D view is already nice. But anybody who saw a recent Hollywood movie knows that it is possible to produce images with a computer that are almost undistinguishable from a photograph.

Of course, producing such photo-realistic images requires a lot of work, and a 3D application that offers specific tools for that, such as precise controls for materials and lighting. FreeCAD being an application more geared towards technical modeling, it doesn't feature any advanced rendering tool.

Fortunately, the opens-source world offers many applications to produce realistic images. Probably the most famous one is Blender, which is very popular and widely used in the movies and gaming industries. 3D models can very easily and faithfully be exported from FreeCAD and imported into Blender, where you can add realistic materials and illumination, and produce the final images or even animations.

Some other open-source rendering tools are made to be used inside another application, and will take care of doing the complex calculations to produce realistic images. Through its Raytracing Workbench, FreeCAD can use two of these rendering tools: POV-Ray and Luxrender. POV-Ray is a very old project, and is considered a classical raytracing engine, while Luxrender is much newer, and is categorized as an unbiased renderer. Both have their strengths and weaknesses, depending on the type of image one wants to render. The best way to know is to look at examples on both engines websites.

Installation

Before being able to use the Raytracing Workbench in FreeCAD, one of these two rendering applications needs to be installed on your system. This is usually very straightforward, both provide installers for many platforms or are usually included in the software repositories of most Linux distributions.

Once POV-Ray or Luxrender is installed, we need to set the path to their main executable in the FreeCAD preferences. This is usually only required on Windows and Mac. On Linux FreeCAD will pick it from the standard locations. The location of the povray or luxrender executables can be found by simply searching your system for files named povray (or povray.exe on Windows) and luxrender (or luxrender.exe on Windows).

cdbf1b28.jpg

In this preferences screen we can also set the desired image size we want to produce.

Rendering with PovRay

We will use the table we have been modeling in the tradtional modeling chapter to produce renderings with PovRay and Luxrender.

5708f666.jpg

72c38289.jpg

f9275d9.jpg

Rendering with LuxRender

93acb19b.jpg

You can extend greatly the render possibilities of FreeCAD by creating new templates for povray or luxrender. This is explained in the Raytracing Workbench documentation.

Downloads

Read more

Python scripting

A gentle introduction

Python is a widely popular, open-source programming language, very often used as a scripting language, embedded in applications, as this is the case with FreeCAD. It also has a series of features that makes it specially interesting for us FreeCAD users: It is very easy to learn, specially for people who had never programmed before, and it is embedded in many other applications, which makes it a very valuable tool to learn, as you will be able to use it in many other applications, such as Blender, Inkscape or GRASS.

FreeCAD makes an extensive use of Python. With it, you can access and control almost any feature of FreeCAD. You can for example create new objects, modify their geometry, analyze their contents, or even create new interface controls, tools and panels. Some workbenches of FreeCAD and most of the addon workbenches are fully programmed in python. FreeCAD has an advanced python console, available from menu View->Panels->Python console. It is often useful to perform operations for which there is no toolbar button yet, or to check shapes for problems, or to perform repetitive tasks:

578724d5.jpg

But the python console also has another very important use: Everytime you press a toolbar button, or perform other operations in FreeCAD, some python code is printed in the console and executed. By leaving the Python console open, you can litterally see the python code unfold as you work, and in no time, almost without knowing it, you will be learning some python language.

FreeCAD also has a macros system, which allows you to record actions to be replayed later. This system also uses the Python console, by simply recording everything that is done in it.

In this chapter, we will discover very generally the Python language. If you are interested in learning more, the FreeCAD documentation wiki has an extensive section related to python programming.

Writing python code

There are two easy ways to write python code in FreeCAD: From the python console (menu View -> Panels -> Python Console), or from the Macro editor (menu Tools -> Macros -> New). 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 launched from the same Macros window.

In this chapter, you will be able to use both methods, but it is highly recommended to use the Python Console, since it will immediately inform you of any error you could do while typing.

If this is the first time you are doing Python coding, consider reading this short introduction to Python programming before going further, it will make the basic concepts of Python clearer.

Manipulating FreeCAD objects

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." (the word FreeCAD followed by a dot), 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.

f71474b3.jpg

As soon as you press Enter our new document will be created. This is similar to pressing the "new document" button on the toolbar. In Python, the dot is used to indicate something that is contained inside something else (newDocument is a function that is inside the FreeCAD module). The window that pops up therefore shows you everything that is contained inside "FreeCAD". If you would add a dot after newDocument, instead of the parentheses, it would show you everything that is contained inside the newDocument function. The parentheses are mandatory when you are calling a Python function, such as this one. We will illustrate that better below.

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")

Our box is added in the tree view, but nothing happens in the 3D view yet, because when working from Python, the document is never recomputed automatically. We must do that manually, whenever we need:

doc.recompute()

Now our box appeared in the 3D view. Many of the toolbar buttons that add objects in FreeCAD actually do two 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 appropriate button in the Part Workbench, and you will see the two lines of python code being executed one after the other.

You can get a list of all possible object types like Part::Box:

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 will see that in the properties panel, under the Data tab, our Height property appears with the new value. All properties of a FreeCAD object that appear in the Data and View tabs are directly accessible by python too, by their names, like we did with the Height property. Data properties are accessed directly from the object itself, for example:

box.Length

View properties are stored inside a ViewObject. Each FreeCAd object possesses a ViewObject, which stores the vieual properties of the object. When running FreeCAD without its Graphical Interface (for example when launching it from a terminal with the -c command line option, or using it from another Python script), the ViewObject is not available, since there is no visual at all.

For example, to access the line color of our box:

box.ViewObject.LineColor

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) print(myvec) prnimarkdownt(myvec.x) print(myvec.y) othervec = FreeCAD.Vector(0,3,0) sumvec = myvec.add(othervec)

Another common feature of FreeCAD objects is their Placement. As we saw in earlier chapters, each object has a Placement property, which contains the position (Base) and orientation (Rotation) of the object. It is easy to manipulate from Python, for example to move our object:

print(box.Placement) print(box.Placement.Base) box.Placement.Base = sumvec otherpla = FreeCAD.Placement() otherpla.Base = FreeCAD.Vector(5,5,0) box.Placement = otherpla

Read more

Creating and manipulating geometry

In the previous chapters, we learned about the different workbenches of FreeCAD, and that each of them implements its own tools and geometry types. The same concepts applies when working from Python code.

We also saw that the big majority of the FreeCAD workbenches depend on a very fundamental one: the Part Workbench. In fact, may other workbenches, such as Draft or Arch, do exactly what we will do in this chapter: They use Python code to create and manipulate Part geometry.

So the first thing we need to do to work with Part geometry, is to do the Python equivalent to switching to the Part Workbench: import the Part module:

import Part

Take a minute to explore the contents of the Part module, by typing Part. and browsing through the different methods offered there. The Part module offers several convenience fuctions such as makeBox, makeCircle, etc... which will instantly build an object for you. Try this, for example:

Part.makeBox(3,5,7)

When you press Enter after typing the line above, nothing will appear in the 3D view, but something like this will be printed on the Python Console:

<Solid object at 0x5f43600>

This is where an important concept takes place. What we created here is a Part Shape. It is not a FreeCAD document object (yet). In FreeCAD, objects and their geometry are independent. Think of a FreeCAD document object as a container, that will host a shape. Parametric objects will also have properties such as Length and Width, and will recalculate their Shape on-the-fly, whenever one of the properties changes.What we did here is calculate a shape manually.

We can now easily create a "generic" document object in the current document (make sure you have at least one new document open), and give it a box shape like we just made:

boxShape = Part.makeBox(3,5,7) myObj = FreeCAD.ActiveDocument.addObject("Part::Feature","MyNewBox") myObj.Shape = boxShape FreeCAD.ActiveDocument.recompute()

Note how we handled myObj.Shape, see that it is done exactly like we did in the previous chapter, when we changed other properties of an object, such as box.Height = 5. In fact, Shape is also a property, just like Height. Only it takes a Part Shape, not a number. In next chapter we will have a deeper look at how those parametric objects are constructed.

For now, let's explore our Part Shapes more in detail. At the end of the chapter about traditional modeling with the Part Workbench we showed a table that explains how Part Shapes are constructed, and their different components (Vertices, edges, faces, etc). The exact same components exist here and can be retrieved from Python. All Part Shape always have the following attributes:Vertexes, Edges, Wires, Faces, Shells and Solids. All of them are lists, that can contain any number of elements or be empty:

print(boxShape.Vertexes) print(boxShape.Edges) print(boxShape.Wires) print(boxShape.Faces) print(boxShape.Shells) print(boxShape.Solids)

For example, let's find the area of each face of our box shape above:

for f in boxShape.Faces: print(f.Area)

Or, for each edge, its start point and end point:

for e in boxShape.Edges: print("New edge") print("Start point:") print(e.Vertexes[0].Point) print("End point:") print(e.Vertexes[1].Point)

As you see, if our boxShape has a "Vertexes" attribute, each Edge of the boxShape also has a "Vertexes" attribute. As we can expect, the boxShape will have 8 vertices, while the edge will only have 2, which are both part of the list of 8.

We can always check what is the type of a shape:

print(boxShape.ShapeType) print(boxShape.Faces[0].ShapeType) print (boxShape.Vertexes[2].ShapeType)

So to resume the whole diagram of Part Shapes: Everything starts with Vertices. With one or two vertices, you form an Edge (full circles have only one vertex). With one or more Edges, you form a Wire. With one or more closed Wires, you form a Face (the additional Wires become "holes" in the Face). With one or more Faces, you form a Shell. When a Shell is fully closed (watertight), you can form a Solid from it. And finally, you can join any number of Shapes of any types together, which is then called a Compound.

We can now try creating complex shapes from scratch, by constructing all their components one by one. For example, let's try to create a volume like this:

49cf7e2f.jpg

We will start by creating a planar shape like this:

e0c757a1.png

First, let's create the four base points:

V1 = FreeCAD.Vector(0,10,0) V2 = FreeCAD.Vector(30,10,0) V3 = FreeCAD.Vector(30,-10,0) V4 = FreeCAD.Vector(0,-10,0)

Then we can create the two linear segments:

d20ff9ba.png

L1 = Part.Line(V1,V2) L2 = Part.Line(V4,V3)

Note that we didn't need to create Vertices? We could immediately create Part.Lines from FreeCAD Vectors. This is because here we haven't created Edges yet. A Part.Line (as well as Part.Circle, Part.Arc, Part.Ellipse or PArt.BSpline) does not create an Edge, but rather a base geometry on which an Edge will be created. Edges are always made from such a base geometry, which is stored its Curve attribute. So if you have an Edge, doing:

print(Edge.Curve)

will show you what kind of Edge this is, that is, if it is based on a line, an arc, etc... But let's come back to our exercise, and build the arc segments. For this, we will need a third point, so we can use the convenient Part.Arc, which takes 3 points:

54b1c6b3.png

VC1 = FreeCAD.Vector(-10,0,0) C1 = Part.Arc(V1,VC1,V4) VC2 = FreeCAD.Vector(40,0,0) C2 = Part.Arc(V2,VC2,V3)

Now we have 2 lines (L1 and L2) and 2 arcs (C1 and C2). We need to turn them into edges:

E1 = Part.Edge(L1) E2 = Part.Edge(L2) E3 = Part.Edge(C1) E4 = Part.Edge(C2)

Alternatively, base geometries also have a toShape() function that do exactly the same thing:

E1 = L1.toShape() E2 = L2.toShape() ...

Once we have a series of Edges, we can now form a Wire, by giving it a list of Edges. We don't need to take care of the order. OpenCasCade, the geometry "engine" of FreeCAD, is extraordinarily tolerant to unordered geometry. It will sort out what to do:

W = Part.Wire([E1,E2,E3,E4])

And we can check if our Wire was correctly understood, and that it is correclty closed:

print( W.isClosed() )

Which will print "True" or "False". In order to make a Face, we need closed Wires, so it is always a good idea to check that before creating the Face. Now we can create a Face, by giving it a single Wire (or a list of Wires if we had holes):

F = Part.Face(W)

Then we extrude it:

P = F.extrude(FreeCAD.Vector(0,0,10))

Note that P is already a Solid:

print(P.ShapeType)

Because when extruding a single Face, we always get a Solid. This wouldn't be the case, for example, if we had extruded the Wire instead:

S = W.extrude(FreeCAD.Vector(0,0,10)) print(s.ShapeType)

Which will of course give us a hollow shell, with the top and bottom faces missing.

Now that we have our final Shape, we are anxious to see it on screen! So let's create a generic object, and attribute it our new Solid:

myObj2 = FreeCAD.ActiveDocument.addObject("Part::Feature","My_Strange_Solid") myObj2.Shape = P FreeCAD.ActiveDocument.recompute()

Altenatively, the Part module also provides a shortcut that does the above operation quicker (but you cannot choose the name of the object):

Part.show(P)

All of the above, and much more, is explained in detail on the Part Scripting page, together with examples.

Read more:

Creating parametric objects

In the previous chapter, we saw how to create Part geometry, and how to display it on screen, by attaching it to a "dumb" (non-parametric) document object. This is tedious when we want to change the shape of that object. We would need to create a new shape, then attribute it again to our object.

However, we also saw in all the preceding chapters of this manual how parametric objects are powerful. We only need to change one property, and the shape is recalculated on-the-fly.

Internally, parametric objects don't do anything different than we just did: They recalculate the contents of their Shape property, over and over, each time another property has changed.

FreeCAD provides a very convenient system to build such parametric objects fully in Python. They consist of a simple Python class, which defines all the properties that the object needs, and what will happen when one of these properties changes. The structure of such parametric object is as simple as this:

class myParametricObject: def __init__(self,obj): obj.Proxy = self obj.addProperty("App::PropertyFloat","MyLength") ... def execute(self,obj): print ("Recalculating the shape...") print ("The value of MyLength is:") print (obj.MyLength) ...

All Python classes usually have an init method. What is inside that method is executed when that class is instantiated (which means, in programming slang, that a Python Object is created from that class. Think of a class as a "template" to create live copies of it). In our init function here, we do two important things: 1) store our class itself into the "Proxy" attribute of our FreeCAD documetn object, that is, the FreeCAD document object will carry this code, inside itself, and 2) create all the properties our object needs. There are many types of properties available, you can get the full list by typing this code:

FreeCAD.ActiveDocument.addObject("Part::FeaturePython","dummy").supportedProperties()

Then, the second important part is the execute method. Any code in this method will be executed when the object is marked to be recomputed, which will happen when a property has been changed. That is all there is to it. Inside execute, you need to do all that needs tobe done, that is, calculating a new shape, and attributing to the object itself with something like obj.Shape = myNewShape. That is why the execute method takes an "obj" argument, which will be the FreeCAD document object itself, so we can manipulate it inside our python code.

One last thing is important to remember: When you create such parametric objects in a FreeCAD document, when you save the file, the python code above is not stored inside the file. This is for security reasons, if a FreeCAD file contained code, it would be possible for someone to distribute FreeCAD files containing malicious code that could harm other people's computers. So, if you distribute a file that contains objects made with the above code, such code must also be present on the computer that will open the file. The easiest way to achieve that is usually to save the code above in a macro, and distribute the macro together with your FreeCAD file, or share your macro on the FreeCAD macros repository where anybody can download it.

Below, we will do a small exercise, building a parametric object that is a simple parametric rectangular face. More complex examples are available on the parametric object example and in the FreeCAD source code itself.

We will give our object two properties: Length and Width, which we will use to construct a rectangle. Then, since our object will already have a pre-built Placement property (all geometric object have one by default, no need to add it ourselves), we will displace our rectangle to the location/rotation set in the Placement, so the user will be able to move the rectangle anywhere by editing the Placement property.

class ParametricRectangle: def __init__(self,obj): obj.Proxy = self obj.addProperty("App::PropertyFloat","Length") obj.addProperty("App::PropertyFloat","Width") def execute(self,obj): # we need to import the FreeCAD module here too, because we might be running out of the Console # (in a macro, for example) where the FreeCAD module has not been imported automatically import Part,FreeCAD # first we need to make sure the values of Length and Width are not 0 # otherwise the Part.Line will complain that both points are equal if (obj.Length == 0) or (obj.Width == 0): # if yes, exit this method without doing anything return # we create 4 points for the 4 corners v1 = FreeCAD.Vector(0,0,0) v2 = FreeCAD.Vector(obj.Length,0,0) v3 = FreeCAD.Vector(obj.Length,obj.Width,0) v4 = FreeCAD.Vector(0,obj.Width,0) # we create 4 edges e1 = Part.Line(v1,v2).toShape() e2 = Part.Line(v2,v3).toShape() e3 = Part.Line(v3,v4).toShape() e4 = Part.Line(v4,v1).toShape() # we create a wire w = Part.Wire([e1,e2,e3,e4]) # we create a face f = Part.Face(w) # All shapes have a Placement too. We give our shape the value of the placement # set by the user. This will move/rotate the face automatically. f.Placement = obj.Placement # all done, we can attribute our shape to the object! obj.Shape = f

Instead of pasting the above code in the Python console, we'd better save it somewhere, so we can reuse and modify it later. For example in a new macro (menu Tools -> Macros -> Create). Name it, for example, "ParamRectangle". However, FreeCAD macros are saved with a .FCMacro extension, which Python doesn't recognize when using import. So, before using the above code, we will need to rename the ParamRectangle.FCMacro file to ParamRectangle.py. This can be done simply from your file explorer, by navigating to the Macros folder indicated in menu Tools -> Macros.

Once that is done, we can now do this in the Python Console:

import ParamRectangle

By exploring the contents of ParamRectangle, we can verify that it contains our ParametricRectangle class.

To create a new parametric object using our ParametricRectangle class, we will use the following code. Observe that we use Part::FeaturePython instead of Part::Feature that we have been using in the previous chapters (The Python version allows to define our own parametric behaviour):

myObj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Rectangle") ParamRectangle.ParametricRectangle(myObj) myObj.ViewObject.Proxy = 0 # this is mandatory unless we code the ViewProvider too FreeCAD.ActiveDocument.recompute()

Nothing will appear on screen just yet, because the Length and Width properties are 0, which will trigger our "do-nothing" condition inside execute. We just need to change the values of Length and Width, and our object will magically appear and be recalculated on-the-fly.

Of course it would be tedious to have to type these 4 lines of Python code each time we want to create a new parametric rectangle. A very simple way to solve this is placing the 4 lines above inside our ParamRectangle.py file, at the end, after the end of the ParametricRectange class (We can do this from the Macro editor).

Now, when we type import ParamRectangle, a new parametric rectangle will automatically be created. Even better, we can add a toolbar button that will do just that:

8f9ac6bc.jpg

b5a611bb.jpg

Remeber, if you want to distribute files created with this new tool to other people, they must have the ParamRectangle.py macro installed on their computer too.

Read more

Creating interface tools

In the last two chapters, we saw how to create Part geometry and create parametric objects. One last piece is missing to gain full control over FreeCAD: Create tools that will interact with the user.

In many situations, it is not very user-friendly to construct an object with zero-values, like we did with the rectangle in the previous chapter, and then ask the user to fill in the Height and Width values in the Properties panel. This works for a very small number of objects, but will become very tedious if you have a lot of rectangles to make. A better way would be to be able to already give the Height and Width when creating the rectangle.

Python offers a basic tool to have the user enter text on screen:

text = raw_input("Height of the rectangle?") print("The entered height is ",text)

However, this requires a running Python console, and when running our code from a macro, we are not always sure that the Python console will be turned on on the user's machine.

The Graphical User Interface, or GUI, that is, all the part of FreeCAD that is displayed on your screen (the menu, toolbars, 3D view, etc), is all there for that purpose: interact with the user. FreeCAD's interface is built with Qt), a very common open-source GUI toolkit that offers a big range of tools such as dialog boxes, buttons, labels, text input boxes or pull-down menus (all these are generically called "widgets").

The Qt tools are very easy to use from Python, thanks to a Python module called Pyside (there are several other Python modules to communicate with Qt from Python too). This module allows you to create and interact with widgets, read what the user did with them (what was filled in text boxes) or do things when, for example, a button was pressed.

Qt also provides another interesting tool called Qt Designer, which is today embedded inside a bigger application called Qt Creator. It allows to design dialog boxes and interface panels graphically, instead of having to code them manually. In this chapter, we will use Qt Creator to desig a panel widget that we will use in the Task panel of FreeCAD. So you will need to download and install Qt Creator from its official page if you are on Windows or Mac (on Linux it will usually be available from your software manager application).

In the following exercise, we will first create a panel with Qt Creator that asks for length, width and height values, then we will create a Python class around it, that will read the values entered by the user from the panel, and create a box with the given dimensions. This Python class will then be used by FreeCAD to display and control the task panel:

2855686d.jpg

Let's start by creating the widget. Start Qt Creator, then menu File -> New File or Project -> Files and Classes -> Qt -> Qt Designer Form -> Dialog without buttons. Click Next, give it a filename to save, click Next, leave all project fields to their default value (""), and Create. FreeCAD's Task system will automatically add OK/Cancel buttons, that's why we chose here a dialog without buttons.

3112a30f.jpg

5a9746a4.jpg

1b9148bc.jpg

9d721220.jpg

import FreeCAD,FreeCADGui,Part # CHANGE THE LINE BELOW path_to_ui = "C:\Users\yorik\Documents\dialog.ui" class BoxTaskPanel: def __init__(self): # this will create a Qt widget from our ui file self.form = FreeCADGui.PySideUic.loadUi(path_to_ui) def accept(self): length = self.form.BoxLength.value() width = self.form.BoxWidth.value() height = self.form.BoxHeight.value() if (length == 0) or (width == 0) or (height == 0): print("Error! None of the values can be 0!") # we bail out without doing anything return box = Part.makeBox(length,width,height) Part.show(box) FreeCADGui.Control.closeDialog() panel = BoxTaskPanel() FreeCADGui.Control.showDialog(panel)

In the code above, we used a convenience function (PySideUic.loadUi) from the FreeCADGui module. That function loads a .ui file, creates a Qt Widget from it, and maps names, so we can easily access the subwidget by their names (ex: self.form.BoxLength).

The "accept" function is also a convenience offered by Qt. When there is a "OK" button in a dialog (which is the case by default when using the FreeCAD Tasks panel), any funcion named "accept" will automatically be executed when the "OK" button is pressed. Similarily, you can also add a "reject" function which gets executed when the "Cancel" button is pressed. In our case, we ommitted that function, so pressing "Cancel" will do the default behaviour (do nothing and close the dialog).

If we implement any of the accept or reject functions, their default behaviour (do nothing and close) will not occur anymore. So we need to close the Task panel ourselves. This is done with:

FreeCADGui.Control.closeDialog()

Once we have our BoxTaskPanel that has 1) a widget called "self.form" and 2) if needed, accept and reject functions, we can open the task panel with it, which is done with these two last lines:

panel = BoxTaskPanel() FreeCADGui.Control.showDialog(panel)

Note that the widget created by PySideUic.loadUi is not specific to FreeCAD, it is a standard Qt widget which can be used with other Qt tools. For example, we could have shown a separate dialog box with it. Try this in the Python Console of FreeCAD (using the correct path to your .ui file of course):

from PySide import QtGui w = FreeCADGui.PySideUic.loadUi("C:\Users\yorik\Documents\dialog.ui") w.show()

Of course we didn't add any "OK" or "Cancel" button to our dialog, since it was made to be used from the FreeCAD Task panel, which already provides such buttons. So there is no way to close the dialog (other than pressing its Window Close button). But the function show() creates a non-modal dialog, which means it doesn't block the rest of the interface. So, while our dialog is still open, we can read the values of the fields:

w.BoxHeight.value()

This is very useful for testing.

Finally, don't forget there is much more documentation about using Qt widgets on the FreeCAD Wiki, in the Python Scripting section, which contains a dialog creation tutorial, a special 3-part PySide tutorial that covers the subject extensively.

Read more

The Community

No manual dealing with free and open-source software would be complete without a chapter about the community. As the vast majority of free and open-source software projects, FreeCAD is made by a community, and maintained by that community. Instead of the opaque, unknown, impersonal and inaccessable firm that is more than often found behind commercial software, free and open-source software communities are open spaces, where you as a user are welcome, and where you can get answers very fast, and even have your say in the development of the software itself. You are also more than welcome to help, there are tasks for everybody.

The community is a growing, eclectic group of all kinds of people united by their passion for FreeCAD. All work on FreeCAD voluntarily, during their free time (although sometimes firms or individuals gather to pay a couple of programming hours to a developer to implement a specific function). Some are professional programmers, some are long-time FreeCAD users (some of them are true FreeCAD gurus, who know almost everything, and many of them end up knowing a lot about FreeCAD programming too), and many are new users of FreeCAD. There is nothing specific to do to be part of the community. Just use FreeCAD!

The main place where the community meets and discusses is the FreeCAD forum. All you need to do to participate to the discussions is to register an account on the forum (Your first post will need to be approved by a moderator before you can post more, to prevent spamming). The forum is a great place to ask questions when you are new to FreeCAD. Provided you made a good question (be sure to read the forum rules as they contain useful information to turn your question into a good question), you will usually get several replies within the same hour. If you think someone might have asked your question already, be sure to search, your answer might already be there.

The forum is also a great place to show what you achieved with FreeCAD, to help newcomers when you are more experienced, and to follow and give your opinions in more technical discussions about development. All the FreeCAD development is discussed on the forum, and anybody is free to read or participate.

There are also FreeCAD communities forming outside of the FreeCAD forum, for example on Facebook or Google+.

If you are becoming as enthusiastic about FreeCAD as we are, you might want to help the project. This can be done in many different ways, and there are tasks for everybody, programmers and non-programmers, for example:

The source code of FreeCAD is located on the Github account of the FreeCAD project. Anybody can download, use and modify the code. You can publish your modifications (on Github or any other Git hosting service). If you made interesting modifications, that you wish to see included in the FreeCAD source code, you must ask the community to have them included. This can be done using Github's pull requests mechanism, but the very best way is to discuss what you intend to do first on the forum, and then post an official request in the Pull requests section of the forum when your code is ready. This avoids that you work on something that someone else is already working on too, and ensures that others agree with the way you are doing it, so there is no risk of having your work refused for some reason you didn't foresee.

Hopefully, we managed to give you a good taste of FreeCAD in this manual, and you are already our newest community member. Welcome!

Read more


 Ваша оценка:

Связаться с программистом сайта.

Новые книги авторов СИ, вышедшие из печати:
О.Болдырева "Крадуш. Чужие души" М.Николаев "Вторжение на Землю"

Как попасть в этoт список

Кожевенное мастерство | Сайт "Художники" | Доска об'явлений "Книги"