Drawing Vorlagen

From FreeCAD Documentation
Revision as of 16:48, 15 December 2018 by Le Loup (talk | contribs) (Created page with "=== Namensraum === * Verschiedene Objekte (besonders die mit dem Draft_Drawing-Befehl erstellten und wenn Deine Vorlage editierbaren Text enthält) benutz...")

SVG-Vorlagenerstellung

Das Anlegen von Vorlagen für den Zeichnungs-Arbeitsbereich ist sehr einfach (siehe auch das Tutorial Drawing_Template_HowTo/de). Vorlagen sind svg-Dateien, die mit jeder Anwendung erstellt werden können, die svg-Dateien exportieren kann, wie z.B. Inkscape. Trotzdem musst Du oftmals später die Datei mit einem Texteditor öffnen, um die folgenden Regeln zu erfüllen. Es geht nur um zwei Regeln:

Basisregeln

  • Ein Pixel = ein Millimeter. Die Seitengröße kann innerhalb des öffnenden <svg>-Tags angegeben werden, entweder ohne Einheit oder mit "mm". Beispielsweise sind diese beiden Formen gültig:
width="1067mm"
height="762mm"

oder

width="1067"
height = "762"

Obwohl svg Inches ("42 in") unterstützt, ist das bei FreeCAD bisher nicht der Fall, so dass es immer besser ist, die svg-Seitengröße in Millimeter anzugeben. Das "viewBox"-Attribut muss den gleichen Wert haben, z.B.:

viewBox="0 0 1067 762"
  • Du musst irgendwo innerhalb Deines svg-Codes angeben, wo der Inhalt der Zeichnung auftauchen soll (z.B. am Ende der Datei, direkt vor dem letzten </svg>-Tag). Dazu dient die folgende Zeile:
 <!-- DrawingContent -->

Der Text oben (bei dem es sich eigentlich um einen XML-Kommentar handelt) muss auf einer eigenen Zeile stehen und darf nicht Teil eines anderen Textes sein. Achte darauf, dass Inkscape bei erneutem öffnen und speichern die Zeile zwar beibehält, aber andere XML-Elemente in der gleichen Zeile hinzufügt, so dass diese Vorlagen nicht mehr funktioniert. Du musst die Datei daher mit einem Texteditor öffnen und dafür sorgen, dass diese Zeile einzeln steht.

Namensraum

  • Verschiedene Objekte (besonders die mit dem Draft_Drawing-Befehl erstellten und wenn Deine Vorlage editierbaren Text enthält) benutzen einen speziellen Namensraum, der spezifisch für FreeCAD ist. Dies erlaubt FreeCAD, diese Elemente in svg-Dateien zu erkennen, die andere Anwendungen einfach ignorieren. Wenn Du beabsichtigst, diese Elemente zu nutzen, musst Du diese Zeile nach dem öffnenden <svg>-Tag einfügen, z.B. zusammen mit den anderen xmlns-Zeilen, die durch Inkscape hinzugefügt werden.
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