Drawing templates/it: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 3: Line 3:


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]. 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:
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]. 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 ===
=== 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:
* 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:

Revision as of 20:25, 13 October 2016

Creare modelli SVG

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 Drawing_Draft 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 -->

Per scalare la stampa, la dimensione effettiva deve essere data negli attributi width e height del tag SVG. Le dimensioni del documento, nelle unità utilizzate (px), deve essere fornita nell'attributo Viewbox.

In questo caso deve essere formattato come nell'esempio sottostante dove:

  • xxx = pixel width larghezza
  • yyy = pixel height altezza
width="xxxmm"
height="yyymm"
viewBox="0 0 xxx yyy"
  • Nelle squadrature si possono posizionare diversi attributi personalizzati. L'elenco degli attributi attualmente supportati sono disponibili nella pagina Svg Namespace.
  • Di default, i modelli di squadrature, nei sistemi Windows si trovano in C:/Program Files/FreeCAD0.13/data/Mod/Drawing/Templates/A3_Landscape.svg, e nei sistemi Linux in /usr/share/freecad/Mod/Drawing/Templates/A3_Landscape.svg.

Modelli DXF

Dalla versione 0.15, FreeCAD può esportare in modo affidabile una pagina Drawing nel formato DXF. Questo sistema utilizza anche i modelli. Se nella stessa cartella del modello SVG utilizzata per una pagina si trova anche un file dxf con lo stesso nome, esso viene utilizzato per l'esportazione. In caso contrario, viene creato al volo un modello vuoto predefinito.

Di conseguenza, se si crea i propri modelli SVG, e si vuole essere in grado di esportare in DXF le pagine create con Drawing, è sufficiente creare un modello DXF corrispondente, e salvarlo con lo stesso nome nella stessa cartella.

I modelli DXF possono essere creati con qualsiasi applicazione che produce dei file DXF, come LibreCAD. È quindi necessario modificarli con un editor di testo, e aggiungere due ulteriori righe, una all'inizio o alla fine della sezione BLOCKS, e un'altra all'inizio o alla fine della sezione ENTITIES, che sono il posto dove FreeCAD aggiungerà i propri blocchi e entità.

Un modello molto semplice si presenta così:

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

Il modello precedente non contiene alcuna entità. Se si crea il file DXF con un'applicazione CAD, ci sarà probabilmente molto più contenuto all'interno delle sezioni HEADER, BLOCKS e ENTITIES.

Le due righe cercate da FreeCAD sono "$blocks" e "$entities". Esse devono essere esistenti nel modello, e devono essere posizionate sulla loro riga. Si può scegliere di metterle subito dopo le righe BLOCKS o ENTITIES, che è più facile (basta utilizzare la funzione "cerca" del vostro editor di testo per trovarle), o alla fine, prima delle righe "0 ENDSEC" (fate attenzione che ce n'è una per ogni sezione, assicurarsi di usare quella relativa a BLOCKS e ENTITIES). Quest'ultimo metodo mette gli oggetti di FreeCAD dopo gli oggetti definiti nel modello, che potrebbe essere più logico.

Modelli A3

A3 Classic:

A3 Clean:

A3 Modern:

A3 Showcase:

A3 Landscape english:

Modelli A4

A4 Landscape english:

A4 Portrait 1 english:

Modelli US Letter

US Letter landscape:


US Letter portrait:

US Letter ds Landscape:

US Legal ds Landscape:

US Ledger ds Landscape:

Altri standard disponibili