Sandbox:TechDraw TemplateExplained

Introduction
TechDraw templates are SVG files used as the basis to create Technical drawings in FreeCAD. They can be used with the Draft workbench as well.

This document lists the necessary elements while building an A3 template.

Just a simple text editor is needed to create a simple svg file. The necessary lines could be typed or copied into the document.

Such a tidied up file could be a basis for a Python macro...

Structure of a simple blank page
The SVG format is a subset of the XML format. That is why an SVG file, like any XML file, consists of two parts:
 * Head, a format declaration
 * Body, containing the information what to show and where to place it

Head
The head is just one line to declare which version of the XML language an interpreter should use to handle the instructions in the body.

Body
The Body starts with an opening tag which contains information about name spaces and about the size of the template and where to place it. And it finishes with a closing tag.


 * xmlns="http://www.w3.org/2000/svg": External link to the xml name space to look up standard xml commands
 * version="1.1": used xml version is 1.1
 * xmlns:freecad="http://www.freecad.org/wiki/index.php?title=Svg_Namespace": External link to FreeCAD's name space extension
 * to look up special commands that are only used inside a FreeCAD environment e.g. for editable texts
 * width="420mm": Width of the drawing area
 * height="297mm": Height of the drawing area
 * viewBox="0 0 420 297": Position of the upper left corner (0;0) and the lower right corner (420;297) in the svg construction space (in svg units).
 * Width, height, and viewBox in this combination set 1 svg-unit to 1 mm for the whole document. A dimensional unit can be omitted from now on.

Result: a blank page of DIN A3 format
For a blank page size DIN A3 in landscape orientation that's all.


 * Just copy or type these few lines and save it as e.g. MyFirstA3Template-blank.svg

Frame elements
With FreeCAD it is not (yet) possible to draw frames and title blocks onto blank pages, and so it is done in advance by placing those elements inside the svg template file.

To create frame, title block, annotations, graphical elements, and editable texts the related code segments need to be added between the svg-tags.

Similar objects are grouped with the g-tag where the opening tag could contain an ID, some style parameters, and sub-groups.

For a complete drawing frame we need the frame(s) itself, separators, and indexes, folding lines, and a center mark for puncher holes.

Frame
The frame consists of two rectangles, one for the sheet frame and one for the drawing area.
 * The sheet frame has an offset of 5 mm from the page edges except on the left where additional 10 mm are added.
 * The drawing area has another 5 mm offset from the sheet frame


 * The group's ID is "drawing-frame"
 * It contains two rectangles which represent the sheet (outer) frame and the outline of the drawing area.
 * fill:none means closed shapes will not be filled. If this is missing only a black rectangle representing the sheet frame area would be visible.
 * stroke:#000000 means the outline of all grouped objects will be black.
 * Rectangles are defined by their Width, hight, and the position of the upper left corner.

Separators
In order to virtually split the drawing area into indexed fields index separators are placed between sheet frame and drawing area.


 * Since no transformation is involved yet each path starts at the svg file's origin.
 * At first a relative movement of a virtual pen to a certain position without drawing
 * followed by a horizontal or vertical movement drawing a line.
 * Capital letters denote movements to absolute positions otherwise the movements are relative to the last position.

Indexes
Now the indexes are inserted.


 * Since no transformation is involved yet each distance relates to the svg file's origin and so capital letters could be used for x and y as well.

Folding Marks
Folding marks show where to fold a drawing to reduce its size to DIN A4. (DIN based drawings at least)

Center mark
The center mark shows where to put the centre of puncher to get perfectly positioned puncher holes. But a DIN A3 formatted drawing is a bad example for a center mark, because it is substituted with a longer index separator this case.

See

above

Title block elements
The title block contains elements like a frame, a segmentation, non-editable texts, and editable texts.


 * This group is used to set the title block's origin and to move all elements between its tags.
 * If it is copied into another file defining a different page format then only the coordinates need to be updated and the whole title block is moved into the wanted location.
 * transform="translate(230,287)" defines a translation of 230 units in x direction and 287 units in y direction.
 * Remember: One unit was set to 1 mm within the svg-tag. And so all is moved 230 mm to the right and 287 mm down.

Title block frame
This group defines the outline and the coarse segmentation of the title block. The coordinates relate to the svg-file's origin, because relocation is done with the "titleblock" group.

Title block segmentation
This group defines the fine segmentation of the title block. Two groups of segmentation lines are needed, because they use different stroke-width values.

Title block text non-editable
To label the entry fields of the title block non-editable texts are used.

Projection mode symbol
That symbol shows if first angle projection is used to arrange the views or third angle projection. It is drawn around the origin and the moved to its position inside the title block.


 * Parameters can be placed inside not only in the group tag but inside the circle and path tags as well.
 * the values defined inside the circle and path tags override the values defined in the group tag.

FreeCAD logo
The FreeCAD logo consists of an F symbol and a cog symbol. The shared parameters are within the group tag and the individual parameters inside the Path tag.


 * The group tag contains all parameters to draw outline only symbols
 * The colour parameters inside the Path tags override the "none" value of the Group tag.
 * The logo paths are copied from an existing file and not split in single strokes like in the other sections, and so the coordinates are less clearly represented.

Title block text editable
The editable texts are sorted according to font size. The group tag defines the font family and the colour of the editable texts. Sub group tags add the font size and the position of the text anchor.

Attention! Coordinates of editable texts have to be absolute (relate to the document's origin)! They are not compatible with transformations!
 * (Only the texts could be moved but the green handles would stay in place)


 * The text tags are extended with freecad:editable=" variable name " to supply the FreeCAD file with addressable variables when the template is inserted.
 * The default texts need to be surrounded by tspan tags otherwise the displayed text within the title block will not synchronise with modified variable content.

Complete template


Dies ist eine Sandbox