Draft Module

The draft Module is a work-in-progress and quite experimental module made to add basic 2d drawing functionality to FreeCAD. It is written entirely in python, and is also intended to showcase how far you can extend FreeCAD entirely in python, without even touching the source code. This module is currently developed outside of the main FreeCAD development structure.

Currently it is not really usable for production work, but already contains a couple of working basic functions. Feel free to test, and give us a feedback on the discussion page.

I also maintain a workplan of the whole thing here.

Installation
The draft Module is currently not part of the FreeCAD package, so you'll need to download it from here: http://yorik.orgfree.com/scripts/Draft.zip The zipfile here above contains just a "draft" directory. To install the module, simply place that draft directory into the "Mod" directory of FreeCAD.

Please note that the draft module requires two specific python modules to be installed and working on your system, PyQt4 and Pyvy. Instructions for installing or compiling these modules can be found on the extra python modules page. But if you are using an official FreeCAD package from the FreeCAD website, those two modules are already included in the package and you don't need to worry about it!

General use
Once installed, the draft workbench will be availible in your workbenches list. When you activate it, two toolbars will appear; a classical toolbar containing the standard draft commands listed below and a special command toolbar that has no tool icon on it, but that is used by the different functions to display their controls. On that toolbar, you can also change general things like current line color and width.

One thing is important to know, the draft workbench doesn't put you automatically in orthographic projection (why would it?). So before drawing, make sure you are in orthographic projection and in the appropriate view...

Import functions
These are functions for opening/importing other file formats. Opening will open a new document with the contents of the file, while importing will append the file content to the current document.

Autodesk DXF
File Menu > Open File Menu > Import

This function opens a DXF file (any version from 12 to 2007) in a new drawing. The color and linetype of objects is currently not used. DXF object types currently read by this script + implementation in FreeCAD:


 * line: read and converted to FreeCAD Polygon
 * lwpolyline: read and converted to FreeCAD Polygon w/ arcs straigthened
 * circle: read and converted to FreeCAD Circle
 * arc: read and converted to FreeCAD Circle
 * layer: read and layers containing objects are conveted to FreeCAD Group

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

SVG
File Menu > Open File Menu > Import

A function to import SVG files as workable 2D objects, in opposition to the built-in drawing module which imports svg files as sheet drawings. SVG objects that get imported at the moment:


 * PATH objects with M, C, L or A commands: converted to FreeCAD polygon
 * RECT objects: converted to FreeCAD polygon

Drawing functions
These are tools for creating objects

[[Image:Drafticonline.png]] 2-point Line
draft Toolbar > Line Context menu > draft > Line draft Menu > Line

This function asks the user for 2 points and draws a line betwen them. The newly created line will have the current color and width. The points can be picked with the mouse in the 3d view or by entering corrdinates with the keyboard. Following functionality is availible:
 * Picking a point on an empty area of the 3d view will return a point situated at your mouse location on the current workplane.
 * Picking a point on an object will return a point situated on the object, at your mouse location. An open "o" symbol appears to notify you.
 * Pressing CTRL will snap your point to availible snap locations. A filled "o" or square symbol appears.
 * Pressing SHIFT will constrain your new point in relation to the last one, horizontally or vertically, depending on the location of your mouse at the moment you press SHIFT. To change between horizontal and vertical, simply release SHIFT and press it again with your mouse in another location.
 * Enter numbers to insert manually a coordinate.
 * Pressing ENTER will switch you from X to Y, from Y to Z and pressing ENTER while you are editing Z will create a new point.
 * Pressing SPACE will switch between relative and absolute coordinates. In relative coordinates, the location you enter is relative to the last point.
 * Pressing CTRL+Z or pressing the "Undo" button will undo the last point.
 * Pressing ESCAPE will cancel the operation.

[[Image:Drafticonpolyline.png]] Multiple-point Line
draft Toolbar > Polyline Context menu > draft > Polyline draft Menu > Polyline

This function behaves exactly the same way as the previous one, except that it doesn't stop after 2 points. Besids that, a number of extra features are availible:
 * Double-clicking the last point, instead of simply clicking, will finish the line, leaving it open.
 * Pressing F or context menu > draft > Finish or pressing the "Finish" button will also finish the line, leaving it open.
 * CTRL-Clicking (snapping) on the first point will finish and close the line
 * Pressing C or context menu > draft > Close or pressing the "Close" button will also finish and close the line.

[[Image:Drafticoncircle.png]] Circle
draft Toolbar > Circle Context menu > draft > Circle draft Menu > Circle

This function draws a circle by asking for two points, the center and the radius. Both values can also be entered manually. The created circle will take the current line width and color. Availible features:
 * Pressing CTRL will snap you to availible snap locations. A filled symbol appears to notify you.
 * Pressing ESCAPE cancels the function.

[[Image:Drafticonarc.png]] Arc
draft Toolbar > Arc Context menu > draft > Arc draft Menu > Arc

This function draws an arc by picking four points: the center, the radius, the start angle and the end angle. All these values can also be entered manually. The created arc will take the current line width and color. Availible features:
 * Pressing CTRL will snap you to availible snap locations. A filled symbol appears to notify you.
 * Pressing SHIFT will constrain you vertically or horizontally in relation to the center.
 * Pressing ALT when choosing the end angle will switch you to counter-clockwise direction.
 * Pressing ESCAPE cancels the function.

Modification functions
These are tools for modifying objects

[[Image:Drafticonmove.png]] Move
draft Toolbar > Move Context menu > draft > Move draft Menu > Move

This function moves the selected objects from one point to another.
 * Pressing CTRL will snap you to availible snap locations. A filled symbol appears to notify you.
 * Pressing SHIFT will constrain you vertically or horizontally in relation to the center.
 * Pressing ESCAPE will cancel the move.
 * SPACE will switch you between relative and absolute coordinates.
 * C switches the copy mode on/off. With Copy on, objects will be copied instead of moved.
 * Pressing ALT will make a copy, even if the Copy check button is off.

[[Image:Drafticonrotate.png]] Rotate
draft Toolbar > Rotate Context menu > draft > Rotate draft Menu > Rotate

This function rotates the selected objects. The user is asked for the rotation center, the start angle and the rotation angle.
 * Pressing CTRL will snap you to availible snap locations. A filled symbol appears to notify you.
 * Pressing SHIFT will constrain you vertically or horizontally in relation to the center.
 * Pressing ESCAPE will cancel the operation.
 * SPACE will switch you between relative and absolute coordinates.
 * C switches the copy mode on/off. With Copy on, new objects will be created instead of rotating existing objects.
 * Pressing ALT will make a copy, even if the Copy check button is off.

[[Image:Drafticonoffset.png]] Offset
draft Toolbar > Offset Context menu > draft > Offset draft Menu > Offset

This function offsets the selected object. Only works if only one object is selected. You are simply asked for one point, giving the distance to offsrt from the selected object.
 * Pressing CTRL will snap you to availible snap locations. A filled symbol appears to notify you.
 * Pressing SHIFT will constrain you to the current segment, instead of picking the closest one.
 * Pressing ESCAPE will cancel the operation.
 * C switches the copy mode on/off. With Copy on, new objects will be created instead of rotating existing objects.
 * Pressing ALT will make a copy, even if the Copy check button is off.

Other functions
These is a category for tools I don't know where else to put :)

[[Image:Drafticonapply.png]] Apply Style
Context menu > draft > Apply Style

This function applies current line width and color to selected objects. If groups are selected, all objects inside them will take the style too. This function is only availible when something is selected. It is also availible from the tree context menu.

[[Image:Drafticonreset.png]] Reset Draft view
draft Menu > Reset

This provisory function resets the view to Top view, puts the camera in orthographic mode, and sets the focal plane to (0,0,0), to ensure that you are drawing on ground plane. Later on, when all this gets more 3D behaviour, this function should be replaced by something more general.

Export functions
These are functions for exporting the current document to other file formats.

Autodesk DXF
There is currently no interface control for exporting dxf files, but you can already access it by typing the following commands in the python interpreter:

The exported DXF is compatible with Autocad version 10 and up, so it should open in about any application that supports dxf format. Currently the following FreeCAD features get exported:


 * Lines get converted to dxf lines
 * Polylines get converted to single lines (provisory)
 * Circles get converted to circles
 * Arcs (open circles) get converted to arcs
 * colors are mapped from objects RGB colors to autocad color index (ACI). Black will always be "by layer"
 * layers are mapped from group names When groups are nested, the deepest group gives the layer name.

Snapping
CTRL while drawing

In all tools that support snapping, following snap locations are currently availible:
 * Endpoint of lines/polylines
 * Midpoint of lines/polylines
 * Center of circles and arcs
 * Quadrant points of circles and arcs
 * Endpoints of arcs
 * Vertically or horizontally aligned points on lines/polylines, if constraining (SHIFT)

In tools that support both snapping and constraining, the combination of both behaviours (SHIFT+CTRL) can extend much the snapping possibilities.

Constraining
SHIFT while drawing

In all tools that support constraining, you can force the next point to be constrained horizontally or vertically in relation to the last point entered. The vertical or horizontal constraining depends on where your mouse lies when you press SHIFT. If you are more north or south from the last point, it will be vertical. If you are more east or west, it will be horizontal. To change, just release SHIFT and press again at another location.

Copying
ALT while drawing

All modification tools can either modify the selected objects or create a modified copy of them. Pressing ALT while using the tool will make a copy.