TechDraw TemplateHowTo: Difference between revisions

From FreeCAD Documentation
(Marked this version for translation)
 
(28 intermediate revisions by 11 users not shown)
Line 2: Line 2:
<translate>
<translate>


<!--T:25-->
{{TutorialInfo
{{TutorialInfo
|Topic=Drafting
|Topic=Drafting
Line 10: Line 11:
}}
}}


== Introduction ==
== Introduction == <!--T:26-->


<!--T:27-->
This tutorial shows you how to create an [[SVG]] file that can be used as the background [[TechDraw Templates|template]] for the [[TechDraw Workbench]] pages.
This tutorial shows you how to create an [[SVG|SVG]] file that can be used as the background [[TechDraw_Templates|template]] for the [[TechDraw_Workbench|TechDraw Workbench]] pages.


<!--T:21-->
<!--T:21-->
This tutorial assumes you are moderately familiar with [https://en.wikipedia.org/wiki/Inkscape Inkscape] and [[SVG]], as well as FreeCAD and the [[TechDraw Workbench]].
This tutorial assumes you are moderately familiar with [https://en.wikipedia.org/wiki/Inkscape Inkscape] and [[SVG|SVG]], as well as FreeCAD and the [[TechDraw_Workbench|TechDraw Workbench]].


<!--T:22-->
<!--T:22-->
We're going to make a simple template for US Letter size paper in landscape orientation.
We're going to make a simple template for US Letter size paper in landscape orientation.


<!--T:28-->
A copy of the result of this tutorial is available in
A copy of the result of this tutorial is available in
{{Code|code=
{{Code|code=
Line 25: Line 28:
}}
}}


<!--T:29-->
Where {{incode|$INSTALL_DIR}} is the directory where FreeCAD was installed, for example
Where {{incode|$INSTALL_DIR}} is the directory where FreeCAD was installed, for example
{{Code|code=
{{Code|code=
Line 35: Line 39:
1. Open a new document in Inkscape.
1. Open a new document in Inkscape.


<!--T:30-->
2. In Document Properties
2. In Document Properties
* Select page size "US Letter" and orientation "landscape".
* Select page size "US Letter" or "A4" and orientation "landscape".
* Set default units to "mm", and the page size to width "279.4" and height "215.9".
* Set default units to "mm", and the page size to width "279.4" and height "215.9". For DIN-A4 you would use "210" and "297".
[[Image:InkDocProp.png|800px|center]]
[[Image:InkDocProp.png|800px|center]]
{{CaptionCenter|Inskcape: document with page size and orientation}}
{{Caption|align=center|Inkscape: document with page size and orientation}}
{{clear}}
{{clear}}


<!--T:31-->
3. Use the XML Editor to add a "freecad" namespace clause to the {{incode|<svg>}} item.
3. Use the XML Editor to add a "freecad" namespace clause to the {{incode|<svg>}} item.
* <code>xmlns:freecad="http://www.freecadweb.org/wiki/index.php?title=Svg_Namespace"</code>.
: <code>xmlns:freecad="http://www.freecadweb.org/wiki/index.php?title=Svg_Namespace"</code>
Note that your editable texts will ''not'' work if you use "https://...", even though the wiki is reached via https these days. Since SVG is a human readable format you could also enter the line above into the file with a text editor.
[[File:InkXMLNameSpace.png|800px|center]]
[[File:InkXMLNameSpace.png|800px|center]]
{{CaptionCenter|Inkscape: XML Editor adding the "freecad" namespace clause to the <svg> item}}
{{Caption|align=center|Inkscape: XML Editor adding the "freecad" namespace clause to the <svg> item}}
{{clear}}
{{clear}}


== Create template drawing ==
== Create template drawing == <!--T:32-->


<!--T:33-->
4. Draw outlines, zone numbers, center lines, and other geometry.
4. Draw outlines, zone numbers, center lines, and other geometry.


<!--T:34-->
5. Draw the boxes and lines for the title block.
5. Draw the boxes and lines for the title block.


<!--T:35-->
6. Add and position your static text.
6. Add and position your static text.


<!--T:36-->
7. Add and position the text that will be editable.
7. Add and position the text that will be editable.


<!--T:37-->
8. You now have your finished artwork, that should look something like this:
8. You now have your finished artwork, that should look something like this:
[[File:InkFinishedArt.png|800px|center]]
[[File:InkFinishedArt.png|800px|center]]
{{CaptionCenter|Inkscape: tentative template layout}}
{{Caption|align=center|Inkscape: tentative template layout}}
{{clear}}
{{clear}}


== Create editable fields ==
== Create editable fields == <!--T:38-->


<!--T:39-->
9. Use the XML Editor to add a {{incode|freecad:editable}} tag to each editable {{incode|<text>}} item.
9. Use the XML Editor to add a {{incode|freecad:editable}} tag to each editable {{incode|<text>}} item.
* Assign a meaningful field name to each editable text.
* Assign a meaningful field name to each editable text.
[[File:InkXMLeditableTag.png|800px|center]]
[[File:InkXMLeditableTag.png|800px|center]]
{{CaptionCenter|Inkscape: XML Editor adding the "freecad:editable" property to the desired <text> item}}
{{Caption|align=center|Inkscape: XML Editor adding the "freecad:editable" property to the desired <text> item}}
{{clear}}
{{clear}}


== Adjust size of the SVG ==
== Adjust size of the SVG == <!--T:40-->


<!--T:41-->
10. Use the XML editor to adjust the {{incode|viewBox}} attribute to match your page size in millimeters.
10. Use the XML editor to adjust the {{incode|viewBox}} attribute to match your page size in millimeters.
* It is four values, in the format {{incode|"0 0 width height"}}
* It is four values, in the format {{incode|"0 0 width height"}}
[[File:InkXMLviewBox.png|800px|center]]
[[File:InkXMLviewBox.png|800px|center]]
{{CaptionCenter|Inkscape's XML Editor adjusting the viewbox to match the page size in millimeters}}
{{Caption|align=center|Inkscape: XML Editor adjusting the viewbox to match the page size in millimeters}}
{{clear}}
{{clear}}


<!--T:42-->
11. Your template will now appear much bigger than desired.
11. Your template will now appear much bigger than desired.
[[File:InkMuchTooBig.png|800px|center]]
[[File:InkMuchTooBig.png|800px|center]]
{{CaptionCenter|Tentative template layout in Inkscape exceeding the page size}}
{{Caption|align=center|Inkscape: tentative template layout exceeding the page size}}
{{clear}}
{{clear}}


<!--T:43-->
12. We need to shrink it.
12. We need to shrink it.
* {{MenuCommand|Edit → Select All in All Layers}}, or box select and select all.
* {{MenuCommand|Edit → Select All in All Layers}}, or box select and select all.
Line 89: Line 105:
* Set it to the page size less any applicable margins, for example, {{Button|W: 250}}, and {{Button|H: 200}}.
* Set it to the page size less any applicable margins, for example, {{Button|W: 250}}, and {{Button|H: 200}}.


<!--T:44-->
13. Use "Align and Distribute" or the {{Button|X:}} and {{Button|Y:}} spinboxes to position the artwork within the limits of the page if required.
13. Use "Align and Distribute" or the {{Button|X:}} and {{Button|Y:}} spinboxes to position the artwork within the limits of the page if required.


<!--T:45-->
14. Your template should now look right, just like it did in the finished artwork picture above.
14. Your template should now look right, just like it did in the finished artwork picture above.


== Remove transformans on the SVG ==
== Remove transformans on the SVG == <!--T:46-->


<!--T:47-->
15. Ensure that all your editable texts are "ungrouped" with {{KEY|Shift}}+{{KEY|Ctrl}}+{{KEY|g}}.
15. Ensure that all your editable texts are "ungrouped" with {{KEY|Shift}}+{{KEY|Ctrl}}+{{KEY|g}}.


<!--T:48-->
16. Select everything on your page, {{MenuCommand|Edit → Select All}}, and then {{MenuCommand|Edit → Copy}}.
16. Select everything on your page, {{MenuCommand|Edit → Select All}}, and then {{MenuCommand|Edit → Copy}} ({{KEY|Ctrl}}+{{KEY|c}}).


<!--T:49-->
17. Then delete the current layer, {{MenuCommand|Layer → Delete Current Layer}}.
17. Then delete the current layer, {{MenuCommand|Layer → Delete Current Layer}}.
: Note: if you deleted the layer already (in your layer panel is no layer listed) this step is not required. In that case you should select all ({{KEY|Ctrl}}+{{KEY|a}}), cut the selection ({{KEY|Ctrl}}+{{KEY|x}}) and paste it with the command in the next step.


<!--T:50-->
18. Then paste, {{MenuCommand|Edit → Paste in Place}}.
18. Then paste, {{MenuCommand|Edit → Paste in Place}}.
: '''Note:''' This command prevents that the text positions are stored in transform tags. <u>It's important that you do not use the normal paste command!</u>


<!--T:51-->
19. Your template should now look right and shouldn't have any unwanted transforms.
19. Your template should now look right and shouldn't have any unwanted transforms.


<!--T:52-->
20. Save your template.
20. Save your template. When you use Inkscape, save it preferably as '''Plain SVG''' because FreeCAD can only handle the features of the SVG 1.1 specification. '''Plain SVG''' will remove any Inkscape-specific XML tags.


<!--T:53-->
21. Try it in FreeCAD and [[TechDraw Workbench]] with [[TechDraw New Pick]].
21. Try it in FreeCAD and [[TechDraw_Workbench|TechDraw Workbench]] with [[TechDraw_PageTemplate|Insert Page using Template]].
[[File:FCTemplateHow.png|center]]
[[File:FCTemplateHow.png|center]]
{{CaptionCenter|Finished template in FreeCAD with an editable text field being modified}}
{{Caption|align=center|FreeCAD: finished template with an editable text field being modified}}
{{clear}}
{{clear}}


== Notes == <!--T:24-->
<!--T:24-->
== Notes ==
Don't use Layers in Inkscape until you've mastered template creation without them. Layers and Groups can automatically insert unwanted transforms into your [[SVG]] file.
Don't use Layers in Inkscape until you've mastered template creation without them. Layers and Groups can automatically insert unwanted transforms into your [[SVG|SVG]] file.


<!--T:54-->
As a final step before using your new template, make sure to remove any transform clauses from the Svg code. Transform clauses '''will cause problems'''.

<!--T:57-->
See a Stackoverflow discussion on [https://stackoverflow.com/questions/13329125/removing-transforms-in-svg-files removing transform clauses in SVG files].
See a Stackoverflow discussion on [https://stackoverflow.com/questions/13329125/removing-transforms-in-svg-files removing transform clauses in SVG files].


<!--T:20-->
<!--T:58-->
If you do not see the green boxes for your editable texts, there might be something wrong with your document scale. Open your file in Inkscape again and confirm the values of the viewBox and the sizes are matching.
{{TechDraw Tools navi}}

{{Userdocnavi}}
<!--T:59-->
[[Category:Tutorials]]
If texts appear offset in FreeCAD, you may need to remove the {{Incode|xml:space<nowiki>=</nowiki>"preserve"}} attributes in the SVG file. See: https://www.forum.freecadweb.org/viewtopic.php?t=50897.

</translate>
</translate>
{{TechDraw Tools navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}

Latest revision as of 13:11, 14 April 2023

Tutorial
Topic
Drafting
Level
Intermediate
Time to complete
60 minutes
Authors
wandererfan
FreeCAD version
0.17
Example files
None
See also
None

Introduction

This tutorial shows you how to create an SVG file that can be used as the background template for the TechDraw Workbench pages.

This tutorial assumes you are moderately familiar with Inkscape and SVG, as well as FreeCAD and the TechDraw Workbench.

We're going to make a simple template for US Letter size paper in landscape orientation.

A copy of the result of this tutorial is available in

$INSTALL_DIR/Mod/TechDraw/Templates/HowToExample.svg

Where $INSTALL_DIR is the directory where FreeCAD was installed, for example

/usr/share/freecad/Mod/TechDraw/Templates/HowToExample.svg

Create base document

1. Open a new document in Inkscape.

2. In Document Properties

  • Select page size "US Letter" or "A4" and orientation "landscape".
  • Set default units to "mm", and the page size to width "279.4" and height "215.9". For DIN-A4 you would use "210" and "297".

Inkscape: document with page size and orientation

3. Use the XML Editor to add a "freecad" namespace clause to the <svg> item.

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

Note that your editable texts will not work if you use "https://...", even though the wiki is reached via https these days. Since SVG is a human readable format you could also enter the line above into the file with a text editor.

Inkscape: XML Editor adding the "freecad" namespace clause to the <svg> item

Create template drawing

4. Draw outlines, zone numbers, center lines, and other geometry.

5. Draw the boxes and lines for the title block.

6. Add and position your static text.

7. Add and position the text that will be editable.

8. You now have your finished artwork, that should look something like this:

Inkscape: tentative template layout

Create editable fields

9. Use the XML Editor to add a freecad:editable tag to each editable <text> item.

  • Assign a meaningful field name to each editable text.

Inkscape: XML Editor adding the "freecad:editable" property to the desired <text> item

Adjust size of the SVG

10. Use the XML editor to adjust the viewBox attribute to match your page size in millimeters.

  • It is four values, in the format "0 0 width height"

Inkscape: XML Editor adjusting the viewbox to match the page size in millimeters

11. Your template will now appear much bigger than desired.

Inkscape: tentative template layout exceeding the page size

12. We need to shrink it.

  • Edit → Select All in All Layers, or box select and select all.
  • Adjust the W: and H: spinboxes to match your artwork's size in millimeters.
  • Set it to the page size less any applicable margins, for example, W: 250, and H: 200.

13. Use "Align and Distribute" or the X: and Y: spinboxes to position the artwork within the limits of the page if required.

14. Your template should now look right, just like it did in the finished artwork picture above.

Remove transformans on the SVG

15. Ensure that all your editable texts are "ungrouped" with Shift+Ctrl+g.

16. Select everything on your page, Edit → Select All, and then Edit → Copy (Ctrl+c).

17. Then delete the current layer, Layer → Delete Current Layer.

Note: if you deleted the layer already (in your layer panel is no layer listed) this step is not required. In that case you should select all (Ctrl+a), cut the selection (Ctrl+x) and paste it with the command in the next step.

18. Then paste, Edit → Paste in Place.

Note: This command prevents that the text positions are stored in transform tags. It's important that you do not use the normal paste command!

19. Your template should now look right and shouldn't have any unwanted transforms.

20. Save your template. When you use Inkscape, save it preferably as Plain SVG because FreeCAD can only handle the features of the SVG 1.1 specification. Plain SVG will remove any Inkscape-specific XML tags.

21. Try it in FreeCAD and TechDraw Workbench with Insert Page using Template.

FreeCAD: finished template with an editable text field being modified

Notes

Don't use Layers in Inkscape until you've mastered template creation without them. Layers and Groups can automatically insert unwanted transforms into your SVG file.

As a final step before using your new template, make sure to remove any transform clauses from the Svg code. Transform clauses will cause problems.

See a Stackoverflow discussion on removing transform clauses in SVG files.

If you do not see the green boxes for your editable texts, there might be something wrong with your document scale. Open your file in Inkscape again and confirm the values of the viewBox and the sizes are matching.

If texts appear offset in FreeCAD, you may need to remove the xml:space="preserve" attributes in the SVG file. See: https://www.forum.freecadweb.org/viewtopic.php?t=50897.