Drawing templates: Difference between revisions

From FreeCAD Documentation
m (Fixed "<metadata tag".)
mNo edit summary
 
(21 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<languages/>
<translate>

<!--T:56-->
{{VeryImportantMessage|The [[Drawing_Workbench|Drawing Workbench]] became obsolete in v0.17. Consider using the [[TechDraw_Workbench|TechDraw Workbench]] instead.}}

</translate>
{{TOCright}}
<translate>
<translate>


== SVG templates creation == <!--T:36-->
== SVG templates creation == <!--T:36-->

<!--T:49-->
Creating templates for the Drawing module is very easy. See also the tutorial [[Drawing_Template_HowTo|Drawing Template HowTo]]. Templates are svg files, created with any application capable of exporting svg files, such as [http://www.inkscape.org 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:

=== Base rules === <!--T:53-->


<!--T:1-->
<!--T:1-->
* One pixel = one millimeter. You can have the page size specified inside the opening <svg> tag, either without units or with "mm". For example, these two forms are valid:
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 [http://www.inkscape.org Inkscape]. Only two rules must be followed:

* One pixel = one millimeter
</translate>
<syntaxhighlight lang="html">
width="1067mm"
height="762mm"
</syntaxhighlight>
<translate>

<!--T:45-->
or

</translate>
<syntaxhighlight lang="html">
width="1067"
height = "762"
</syntaxhighlight>
<translate>

<!--T:46-->
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:

</translate>
<syntaxhighlight lang="html">
viewBox="0 0 1067 762"
</syntaxhighlight>
<translate>

<!--T:47-->
* You must insert, somewhere inside your svg code, where you want the contents of the drawing to appear (for example at the end of the file, just before the last </svg> tag), the following line:
* You must insert, somewhere inside your svg code, where you want the contents of the drawing to appear (for example at the end of the file, just before the last </svg> tag), the following line:

</translate>
</translate>
<syntaxhighlight>
<syntaxhighlight lang="html">
<!-- DrawingContent -->
<!-- DrawingContent -->
</syntaxhighlight>
</syntaxhighlight>
<translate>
<translate>

<!--T:50-->
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.

=== Namespace === <!--T:54-->

<!--T:48-->
* Several objects (specifically those created with the [[Draft_Drawing|Draft Drawing]] command and if your template has editable texts) use a special [[Svg_Namespace|Svg Namespace]] specific to FreeCAD. This makes FreeCAD able to detect specific items inside svg files, that other applications will just ignore. If you plan to use any of these, you must add this line inside the opening <svg> tag, for example together with the other xmlns lines added by inkscape:

</translate>
xmlns:freecad="http://www.freecadweb.org/wiki/index.php?title=Svg_Namespace"
<translate>

=== Title block === <!--T:55-->

<!--T:22-->
<!--T:22-->
In addition to these two rules, as of FreeCAD 0.14, Revision 2995, 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.
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.


<!--T:23-->
<!--T:23-->
To define the Border, the following line must appear before the <metadata> tag in the svg file.
To define the Border, the following line must appear before the <metadata> tag in the svg file.

</translate>
</translate>
<syntaxhighlight>
<syntaxhighlight lang="html">
<!-- Working space X1 Y1 X2 Y2 -->
<!-- Working space X1 Y1 X2 Y2 -->
</syntaxhighlight>
</syntaxhighlight>
<translate>
<translate>

<!--T:24-->
<!--T:24-->
Where X1, Y1, X2, Y2 are defined as:
Where X1, Y1, X2, Y2 are defined as:
Line 28: Line 86:
* X2 is the X axis distance from the left edge of the page to the right side of the Border.
* X2 is the X axis distance from the left edge of the page to the right side of the Border.
* Y2 is the Y axis distance from the top edge of the page to the bottom of the Border.
* Y2 is the Y axis distance from the top edge of the page to the bottom of the Border.

</translate>
</translate>
[[File:XY_Working_v2.svg]]
[[File:XY_Working_v2.svg]]

<translate>
<translate>

<!--T:25-->
<!--T:25-->
To define the Title block the following line must be inserted before the <metadata> tag and after the Working space tag.
To define the Title block the following line must be inserted before the <metadata> tag and after the Working space tag.

</translate>
</translate>
<syntaxhighlight>
<syntaxhighlight lang="html">
<!-- Title block X1a Y1a X2a Y2a -->
<!-- Title block X1a Y1a X2a Y2a -->
</syntaxhighlight>
</syntaxhighlight>
<translate>
<translate>

<!--T:26-->
<!--T:26-->
Where X1a, Y1a, X2a, Y2a are defined as:
Where X1a, Y1a, X2a, Y2a are defined as:
Line 47: Line 108:
* X1a <= X1 or X2a >= X2
* X1a <= X1 or X2a >= X2
* Y1a <= Y1 or Y2a >= Y2
* Y1a <= Y1 or Y2a >= Y2

</translate>
</translate>
[[File:XY_Title_v2.svg]]
[[File:XY_Title_v2.svg]]

<translate>
<translate>

<!--T:27-->
<!--T:27-->
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:
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:

</translate>
</translate>
<syntaxhighlight>
<syntaxhighlight lang="html">
<!-- Working space X1 Y1 X2 Y2 -->
<!-- Working space X1 Y1 X2 Y2 -->
<!-- Title block X1a Y1a X2a Y2a -->
<!-- Title block X1a Y1a X2a Y2a -->
</syntaxhighlight>
</syntaxhighlight>

<translate>
<translate>

<!--T:34-->
<!--T:34-->
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.
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.
Line 67: Line 130:
* xxx = pixel width
* xxx = pixel width
* yyy = pixel height
* yyy = pixel height

</translate>
</translate>
<syntaxhighlight>
<syntaxhighlight lang="html">
width="xxxmm"
width="xxxmm"
height="yyymm"
height="yyymm"
Line 76: Line 140:


<!--T:2-->
<!--T:2-->
* Several custom attributes can be placed in templates. The list of currently supported attributes is available on the [[Svg Namespace]] page.
* Several custom attributes can be placed in templates. The list of currently supported attributes is available on the [[Svg_Namespace|Svg Namespace]] page.


== DXF templates == <!--T:37-->
== DXF templates == <!--T:37-->


<!--T:38-->
<!--T:38-->
Since version 0.15, FreeCAD can reliably export a [[Drawing Module|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.
Since version 0.15, FreeCAD can reliably export a [[Drawing_Workbench|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.


<!--T:39-->
<!--T:39-->
Line 92: Line 156:
A very simple template looks like this:
A very simple template looks like this:


</translate>
<!--T:42-->
<pre>
999
999
FreeCAD DXF exporter v0.15
FreeCAD DXF exporter v0.15
0
0
SECTION
SECTION
2
2
HEADER
HEADER
9
9
$ACADVER
$ACADVER
1
1
AC1009
AC1009
0
0
ENDSEC
ENDSEC
0
0
SECTION
SECTION
2
2
BLOCKS
BLOCKS
$blocks
$blocks
0
0
ENDSEC
ENDSEC
0
0
SECTION
SECTION
2
2
ENTITIES
ENTITIES
$entities
$entities
0
0
ENDSEC
ENDSEC
0
0
EOF
EOF
</pre>
<translate>


<!--T:43-->
<!--T:43-->
Line 131: Line 198:


=== A3 Classic: === <!--T:4-->
=== A3 Classic: === <!--T:4-->

</translate>
[[Image:A3_Classic.svg|800px]]
[[Image:A3_Classic.svg|800px]]
<translate>


=== A3 Clean: === <!--T:5-->
=== A3 Clean: === <!--T:5-->

</translate>
[[Image:A3_Clean.svg|800px]]
[[Image:A3_Clean.svg|800px]]
<translate>


=== A3 Modern: === <!--T:6-->
=== A3 Modern: === <!--T:6-->

</translate>
[[Image:A3_Modern.svg|800px]]
[[Image:A3_Modern.svg|800px]]
<translate>


=== A3 Showcase: === <!--T:7-->
=== A3 Showcase: === <!--T:7-->

</translate>
[[Image:A3_Showcase.svg|800px]]
[[Image:A3_Showcase.svg|800px]]
<translate>


=== A3 Landscape english: === <!--T:8-->
=== A3 Landscape english: === <!--T:8-->

</translate>
[[File:A3_Landscape_english.svg|800px]]
[[File:A3_Landscape_english.svg|800px]]
<translate>


==A4 Templates == <!--T:9-->
==A4 Templates == <!--T:9-->
Line 149: Line 231:
=== A4 Landscape english: === <!--T:10-->
=== A4 Landscape english: === <!--T:10-->


</translate>
<!--T:11-->
[[File:A4_Landscape_english.svg|800px]]
[[File:A4_Landscape_english.svg|800px]]
<translate>


=== A4 Portrait 1 english:=== <!--T:12-->
=== A4 Portrait 1 english:=== <!--T:12-->


</translate>
<!--T:13-->
[[File:A4_Portrait_1_english.svg|400px]]
[[File:A4_Portrait_1_english.svg|400px]]
<translate>


==US Letter Templates == <!--T:14-->
==US Letter Templates == <!--T:14-->
Line 161: Line 245:
=== US Letter landscape: === <!--T:15-->
=== US Letter landscape: === <!--T:15-->


</translate>
<!--T:16-->
[[File:US_Letter_landscape.svg|800px]]
[[File:US_Letter_landscape.svg|800px]]
<translate>



=== US Letter portrait: === <!--T:17-->
=== US Letter portrait: === <!--T:17-->


</translate>
<!--T:18-->
[[File:US_Letter_portrait.svg|400px]]
[[File:US_Letter_portrait.svg|400px]]
<translate>


=== US Letter ds Landscape: === <!--T:28-->
=== US Letter ds Landscape: === <!--T:28-->


</translate>
<!--T:29-->
[[File:US_Letter_ds_Landscape.svg|800px]]
[[File:US_Letter_ds_Landscape.svg|800px]]
<translate>


=== US Legal ds Landscape: === <!--T:30-->
=== US Legal ds Landscape: === <!--T:30-->


</translate>
<!--T:31-->
[[File:US_Legal_ds_Landscape.svg|800px]]
[[File:US_Legal_ds_Landscape.svg|800px]]
<translate>


=== US Ledger ds Landscape: === <!--T:32-->
=== US Ledger ds Landscape: === <!--T:32-->


</translate>
<!--T:33-->
[[File:US_Ledger_ds_Landscape.svg|800px]]
[[File:US_Ledger_ds_Landscape.svg|800px]]
<translate>


==Other standards available== <!--T:19-->
==Other standards available== <!--T:19-->
Line 192: Line 280:
* [[Misc_templates|Misc templates]]: mixed templates
* [[Misc_templates|Misc templates]]: mixed templates



<!--T:21-->
[[Category:Documentation]]


</translate>
</translate>
{{Drawing Tools navi{{#translation:}}}}
<languages/>
{{Userdocnavi{{#translation:}}}}
[[Category:Developer Documentation{{#translation:}}]]
[[Category:Documentation{{#translation:}}]]

Latest revision as of 17:22, 23 August 2021

The Drawing Workbench became obsolete in v0.17. Consider using the TechDraw Workbench instead.

SVG templates creation

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:

Base rules

  • One pixel = one millimeter. You can have the page size specified inside the opening <svg> tag, either without units or with "mm". For example, these two forms are valid:
width="1067mm"
height="762mm"

or

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"
  • You must insert, somewhere inside your svg code, where you want the contents of the drawing to appear (for example at the end of the file, just before the last </svg> tag), the following line:
<!-- 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.

Namespace

  • Several objects (specifically those created with the Draft Drawing command and if your template has editable texts) use a special Svg Namespace specific to FreeCAD. This makes FreeCAD able to detect specific items inside svg files, that other applications will just ignore. If you plan to use any of these, you must add this line inside the opening <svg> tag, for example together with the other xmlns lines added by inkscape:

xmlns:freecad="http://www.freecadweb.org/wiki/index.php?title=Svg_Namespace"

Title block

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:

  • X1 is the X axis distance from the left edge of the page to the left side of the Border.
  • Y1 is the Y axis distance from the top edge of the page to the top of the Border.
  • X2 is the X axis distance from the left edge of the page to the right side of the Border.
  • Y2 is the Y axis distance from the top edge of the page to the bottom of the Border.

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:

  • X1a is the X axis distance from the left edge of the page to the left side of the Title block
  • Y1a is the Y axis distance from the top edge of the page to the top of the Title block
  • X2a is the X Axis distance from the left edge of the page to the right side of the Title block
  • Y2a is the Y axis distance from the top edge of the page to the bottom of the Title block
  • X1a <= X1 or X2a >= X2
  • Y1a <= Y1 or Y2a >= Y2

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:

  • xxx = pixel width
  • yyy = pixel height
width="xxxmm"
height="yyymm"
viewBox="0 0 xxx yyy"
  • Several custom attributes can be placed in templates. The list of currently supported attributes is available on the Svg Namespace page.

DXF templates

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.

A3 templates

A3 Classic:

A3 Clean:

A3 Modern:

A3 Showcase:

A3 Landscape english:

A4 Templates

A4 Landscape english:

A4 Portrait 1 english:

US Letter Templates

US Letter landscape:

US Letter portrait:

US Letter ds Landscape:

US Legal ds Landscape:

US Ledger ds Landscape:

Other standards available