Creating templates for the Drawing module is very easy. See also the tutorial Drawing_Template_HowTo. Templates are svg files, created with any application capable of exporting svg files, such as Inkscape. However, you will often need to open the svg file in a text editor afterwards, to comply with the following rules. Only two rules must be followed:
width="1067" height = "762"
Although svg supports inches ("42 in"), these are currently not supported by FreeCAD, so it's always better to have your svg page size specified in millimeters. The "viewBox" attribute must have the same value, for example:
viewBox="0 0 1067 762"
<!-- DrawingContent -->
This text above (which is actually an XML comment) must be on a separate line, and not embedded in the middle of other pieces of text. Beware that if you reopen and resave your template in inkscape, after adding the above line, inkscape will keep the line, but will add other xml elements on the same line, causing the template to not work anymore. You will need to edit it with a text editor and isolate the comment above on its own line again.
In addition to these rules, since FreeCAD 0.14, information about the Border and Title block can be added to the template for use by the orthographic projection tool. This information defines where FreeCAD can, and can not place the projections.
To define the Border, the following line must appear before the <metadata> tag in the svg file.
<!-- Working space X1 Y1 X2 Y2 -->
Where X1, Y1, X2, Y2 are defined as:
To define the Title block the following line must be inserted before the <metadata> tag and after the Working space tag.
<!-- Title block X1a Y1a X2a Y2a -->
Where X1a, Y1a, X2a, Y2a are defined as:
The following is an example of the code that defines the Working space and Title block areas that are to be inserted before the <metadata> tag. You needn't specify a title block, but if you do it must be defined on the next line immediately following the Working space:
<!-- Working space X1 Y1 X2 Y2 --> <!-- Title block X1a Y1a X2a Y2a -->
In order to enable up to scale printing, the real word size has to be given in the width and height attributes of the SVG-Tag. The size of the document in user units, (px), has to be given in the viewBox attribute.
The following is to be formatted like the example below where:
width="xxxmm" height="yyymm" viewBox="0 0 xxx yyy"
Since version 0.15, FreeCAD can reliably export a Drawing page to the DXF format. This system also uses templates. If a dxf file with the same name is found in the same folder as the SVG template used for a page, it will be used for export. If not, a default empty template is created on the fly.
Consequently, if you create your own SVG templates, and wish to be able to export the Drawing pages that you create with it to DXF, you just need to create a corresponding DXF template, and save it with the same name in the same folder.
DXF templates can be created with any application that produces DXF files, such as LibreCAD. You then need to edit them with a text editor, and add two additional lines, one at the beginning or end of the BLOCKS section, and another at the beginning or end of the ENTITIES section, which are where FreeCAD will add its own blocks and entities.
A very simple template looks like this:
999 FreeCAD DXF exporter v0.15 0 SECTION 2 HEADER 9 $ACADVER 1 AC1009 0 ENDSEC 0 SECTION 2 BLOCKS $blocks 0 ENDSEC 0 SECTION 2 ENTITIES $entities 0 ENDSEC 0 EOF
The above template doesn't contain any entity. If you create your DXF file with a CAD application, there will likely be much more content inside the HEADER, BLOCKS and ENTITIES sections.
The two lines that FreeCAD will be looking for are "$blocks" and "$entities". They must exist in the template, and they must be placed on their own line. You can choose to place them right after the BLOCKS or ENTITIES line, which is easier (just use the "search" function of your text editor to find them), or at the end, just before the "0 ENDSEC" lines (beware that there is one for each SECTION, make sure to use the ones relative to BLOCKS and ENTITIES). The latter method will place the FreeCAD objects after the objects defined in the template, which might be more logical.