Svg Namespace/fr: Difference between revisions

From FreeCAD Documentation
(Created page with "==Utilisation==")
(Updating to match new version of source page)
(43 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
Dans les documents [http://fr.wikipedia.org/wiki/Scalable_Vector_Graphics SVG] exportés par le [[Drawing Module/fr|Module de dessin]] de FreeCAD et utilisés comme [[Drawing templates/fr|template (modèle)]] de page, plusieurs [http://www.w3schools.com/xml/xml_attributes.asp attributs] personnalisés peuvent être utilisés, à l'origine pour un usage interne de FreeCAD, mais pourraient aussi être utilisés par d'autres applications FreeCAD à l'avenir. Tous ces attributs utilisent le préfixe '''freecad:[http://www.w3schools.com/xml/xml_namespaces.asp namespaces]'''. L'URL '''Namespaces''', défini dans le document [http://fr.wikipedia.org/wiki/Scalable_Vector_Graphics SVG] fait référence à cette page.
Dans les documents [http://fr.wikipedia.org/wiki/Scalable_Vector_Graphics SVG] exportés par le [[Drawing Module/fr|Module de dessin]] de FreeCAD et utilisés comme [[Drawing templates/fr|template (feuille de dessin)]], plusieurs [http://www.w3schools.com/xml/xml_attributes.asp attributs] personnalisés peuvent être utilisés, à l'origine pour un usage interne destiné à FreeCAD, mais pourraient aussi être utilisés par d'autres applications FreeCAD à l'avenir. Tous ces attributs utilisent le préfixe '''freecad:[http://www.w3schools.com/xml/xml_namespaces.asp namespaces]'''.

L'URL '''Namespaces''', défini dans le document [http://fr.wikipedia.org/wiki/Scalable_Vector_Graphics SVG] fait référence à cette page.


==Utilisation==
==Utilisation==


One pixel = one millimeter.
un pixel = un millimètre

Vous devez insérer, quelque part dans votre code svg, où vous souhaitez que le contenu du dessin apparaisse (par exemple à la fin du fichier, juste avant la derniere balise '''</svg> '''), la ligne suivante :


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:


<syntaxhighlight>
<syntaxhighlight>
<!-- DrawingContent -->
<!-- DrawingContent -->
</syntaxhighlight>
</syntaxhighlight>





Line 17: Line 22:
xmlns:freecad="http://www.freecadweb.org/wiki/index.php?title=Svg_Namespace"
xmlns:freecad="http://www.freecadweb.org/wiki/index.php?title=Svg_Namespace"
</syntaxhighlight>
</syntaxhighlight>
Pour obtenir une impression à l'échelle, la taille réelle doit être inscrite dans les attributs width et height du SVG-Tag. L'unité du document utilisateur doit être le pixel(px), et doit être renseigné dans l'attribut viewBox.


Ce qui suit doit être formaté comme dans l'exemple ci-dessous :
Additional information for Working space and Title block may be added, and is defined on the [[Drawing templates]] page.
* xxx = pixel width (largeur)
* yyy = pixel height (hauteur)


<syntaxhighlight>
==Attributes==
width="xxxmm"
height="yyymm"
viewBox="0 0 xxx yyy"
</syntaxhighlight>


Informations complémentaires pour l'espace de travail et titre bloc peut être ajouté, et est définie sur la page [[Drawing templates/fr|Drawing templates]].
===[[#Example_of_code freecad:EditableText|freecad:EditableText]]===


==Attributs==
To use any of the '''freecad:''' attributes in your SVG documents, you must first define the freecad namespace as an attribute of the opening <svg> tag:


===[[#Exemple_de_code freecad:EditableText|freecad:EditableText]]===
Defines a text in a template that can be edited by FreeCAD.


Vous devez utiliser de l'attribut '''freecad:''' dans vos documents SVG, vous devez d'abord définir l'espace de noms freecad comme un attribut à l'ouverture de la balise <svg> :
Example:

Définir un texte dans un '''template''', qui peut être édité par FreeCAD.

Exemple:


<syntaxhighlight>
<syntaxhighlight>
Line 38: Line 54:
===freecad:basepoint1===
===freecad:basepoint1===


Defines the first point of a [[Draft Dimension]] object (represented as a group in a SVG document). This attribute is used when importing the SVG fragment in FreeCAD, in order to recreate the dimension object. The group contains paths and other graphical items to correctly render the dimension object in other SVG applications.
Définit le premier point d'un objet '''[[Draft Dimension/fr|dimension]]''', (représenté par un groupe dans un document '''SVG'''). Cet attribut est utilisé, lorsque vous importez le fragment '''SVG''' dans FreeCAD, afin de recréer l'objet '''[[Draft Dimension/fr|dimension]]'''. Le groupe, contient les chemins d'accès, et, d'autres éléments graphiques, pour restituer correctement l'objet '''[[Draft Dimension/fr|dimension]]''' dans d'autres applications SVG.


Exemple:
Example:
<syntaxhighlight>
<syntaxhighlight>
<g freecad:basepoint1="0.5 4.34" freecad:basepoint2="2.4 5.8" dimpoint="3.2 7.76">
<g freecad:basepoint1="0.5 4.34" freecad:basepoint2="2.4 5.8" dimpoint="3.2 7.76">
Line 48: Line 64:
===freecad:basepoint2===
===freecad:basepoint2===


Defines the second point of a [[Draft Dimension|Draft Dimension]] object (represented as a group in a SVG document). This attribute is used when importing the SVG fragment in FreeCAD, in order to recreate the dimension object. The group contains paths and other graphical items to correctly render the dimension object in other SVG applications.
Définit le deuxième point d'un objet [[Draft Dimension/fr|dimension]] (représenté par un groupe dans un document '''SVG'''). Cet attribut est utilisé lorsque vous importez le fragment '''SVG''' dans FreeCAD, afin de recréer l'objet [[Draft Dimension/fr|dimension]]. Le groupe contient, les chemins d'accès, et, d'autres éléments graphiques pour restituer correctement l'objet [[Draft Dimension/fr|dimension]], dans d'autres applications '''SVG'''.


Example: see [[#freecad:basepoint1|freecad:basepoint1]]
Exemple: voir [[#freecad:basepoint1|freecad:basepoint1]]


===freecad:dimpoint===
===freecad:dimpoint===


Defines the point of a [[Draft Dimension]] object through which the dimension line passes. This attribute is used when importing the SVG fragment in FreeCAD, in order to recreate the dimension object. The group contains paths and other graphical items to correctly render the dimension object in other SVG applications.
Définit le point d'un objet [[Draft Dimension/fr|dimension]], qui traverse la ligne de dimension. Cet attribut est utilisé lorsque vous importez le fragment '''SVG''' dans FreeCAD, afin de recréer l'objet '''dimension'''. Le groupe contient les chemins d'accès, et, d'autres éléments graphiques pour restituer correctement l'objet [[Draft Dimension/fr|dimension]] dans d'autres applications SVG.


Example: see [[#freecad:basepoint1|freecad:basepoint1]]
Exemple: voir [[#freecad:basepoint1|freecad:basepoint1]]


===Example of code freecad:EditableText===
===Exemple de code freecad:EditableText===


This example is taken from a cartridge to a sheet [[Misc_templates#A3_Landscape_US_Text_Complet_With_Convention_US|A3_Landscape]]
Cet exemple provient du cartouche de la feuille [[Misc_templates#A3_Landscape_US_Text_Complet_With_Convention_US|A3_Landscape]]


====1 : Title without textedit====
====1 : Titre sans textedit====


[[Image:Svg Namespace 01.png|300px]]
[[Image:Svg Namespace 01.png|300px]]
Line 82: Line 98:


</syntaxhighlight>
</syntaxhighlight>
====2 : Title with textedit====
====2 : Titre avec textedit====


[[Image:Svg Namespace 02.png|300px]]
[[Image:Svg Namespace 02.png|300px]]
Line 110: Line 126:
</g>
</g>
</syntaxhighlight>
</syntaxhighlight>
====Explanations====
====Explications====
<syntaxhighlight>
<syntaxhighlight>
<g
<g
</syntaxhighlight>
</syntaxhighlight>
Début du cadre
Beginning of the framework
<syntaxhighlight>
<syntaxhighlight>
style="fill:none;stroke:#000000;stroke-width:0.13;stroke-linecap:butt;stroke-linejoin:miter"
style="fill:none;stroke:#000000;stroke-width:0.13;stroke-linecap:butt;stroke-linejoin:miter"
Line 120: Line 136:
transform="translate(0,4)">
transform="translate(0,4)">
</syntaxhighlight>
</syntaxhighlight>
Données dans le cadre
Data on the framework
<syntaxhighlight>
<syntaxhighlight>
<text
<text
</syntaxhighlight>
</syntaxhighlight>
Début du bloc de textes
Beginning of the text block
<syntaxhighlight>
<syntaxhighlight>
xml:space="preserve"
xml:space="preserve"
style="font-size:4px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans;-inkscape-font-specification:sans"
style="font-size:4px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans;-inkscape-font-specification:sans"
</syntaxhighlight>
</syntaxhighlight>
Toutes les informations sur le texte qui va être affiché
All the information about the text that will be displayed
<syntaxhighlight>
<syntaxhighlight>
x="220.9935"
x="220.9935"
Line 136: Line 152:
sodipodi:linespacing="125%"
sodipodi:linespacing="125%"
</syntaxhighlight>
</syntaxhighlight>
Coordonnées et renseignements du texte qui va être affiché.
Coordinates and identity where the text will appear
<syntaxhighlight>
<syntaxhighlight>
freecad:editable="AuthorName"><tspan
freecad:editable="AuthorName"><tspan
</syntaxhighlight>
</syntaxhighlight>
Here '''AuthorName''' is the var managed by '''freecad:editable''' who saves the string to change that will be displayed
Ici '''AuthorName''' est la variable qui va mémoriser la chaîne '''freecad:editable''' qui sera modifiée et affichée dans la feuille.
<syntaxhighlight>
<syntaxhighlight>
sodipodi:role="line"
sodipodi:role="line"
Line 147: Line 163:
y="228.95425">AUTHOR NAME</tspan></text>
y="228.95425">AUTHOR NAME</tspan></text>
</syntaxhighlight>
</syntaxhighlight>
Coordinates and identity of the text that is displayed by default and '''</text>''' means the end of the block text
Coordonnées et renseignements sur le texte qui est affiché par défaut, la balise '''</text>''' délimite la fin du bloc texte.
<syntaxhighlight>
<syntaxhighlight>
<text
<text
Line 156: Line 172:
</g>
</g>
</syntaxhighlight>
</syntaxhighlight>
Other blocks texts and end '''</g>''' the framework grouping text blocks
Autres blocs textes et la balise '''</g>''' détermine la fin du groupe de textes.


It is possible after having worked the Inkscape SVG file as the file no longer works, it is possible that information has gone missing.
Il est possible qu'après avoir travaillé dans le fichier SVG avec Inkscape le fichier ne fonctionne plus, il est possible que des informations aient disparu.


Ensuite, vérifiez que '''freecad:editable:''' n'est pas modifié.
Then check that the edit text is not modified


Exemple:
Example :
* '''editable''' = "AuthorName"
* '''editable''' = "AuthorName"
* replace by '''freecad:editable''' = "AuthorName"
* replacer par '''freecad:editable''' = "AuthorName"


==Autres attributs disponibles==
==Other attributes availlables==


See [[Drawing_templates]]
Voir [[Drawing_templates/fr|Drawing templates]]


[[Category:Poweruser_Documentation{{#translation:}}]]
<languages/>
[[Category:Developer{{#translation:}}]]
[[Category:Python_Code{{#translation:}}]]
[[Category:Macros{{#translation:}}]]

Revision as of 21:48, 24 March 2020

Dans les documents SVG exportés par le Module de dessin de FreeCAD et utilisés comme template (feuille de dessin), plusieurs attributs personnalisés peuvent être utilisés, à l'origine pour un usage interne destiné à FreeCAD, mais pourraient aussi être utilisés par d'autres applications FreeCAD à l'avenir. Tous ces attributs utilisent le préfixe freecad:namespaces.

L'URL Namespaces, défini dans le document SVG fait référence à cette page.

Utilisation

un pixel = un millimètre

Vous devez insérer, quelque part dans votre code svg, où vous souhaitez que le contenu du dessin apparaisse (par exemple à la fin du fichier, juste avant la derniere balise </svg> ), la ligne suivante :


<!-- DrawingContent -->


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:freecad="http://www.freecadweb.org/wiki/index.php?title=Svg_Namespace"

Pour obtenir une impression à l'échelle, la taille réelle doit être inscrite dans les attributs width et height du SVG-Tag. L'unité du document utilisateur doit être le pixel(px), et doit être renseigné dans l'attribut viewBox.

Ce qui suit doit être formaté comme dans l'exemple ci-dessous :

  • xxx = pixel width (largeur)
  • yyy = pixel height (hauteur)
width="xxxmm"
height="yyymm"
viewBox="0 0 xxx yyy"

Informations complémentaires pour l'espace de travail et titre bloc peut être ajouté, et est définie sur la page Drawing templates.

Attributs

freecad:EditableText

Vous devez utiliser de l'attribut freecad: dans vos documents SVG, vous devez d'abord définir l'espace de noms freecad comme un attribut à l'ouverture de la balise <svg> :

Définir un texte dans un template, qui peut être édité par FreeCAD.

Exemple:

 <text freecad:EditableText="MyTitleText">
     <tspan>This is a title</tspan>
 </text>

freecad:basepoint1

Définit le premier point d'un objet dimension, (représenté par un groupe dans un document SVG). Cet attribut est utilisé, lorsque vous importez le fragment SVG dans FreeCAD, afin de recréer l'objet dimension. Le groupe, contient les chemins d'accès, et, d'autres éléments graphiques, pour restituer correctement l'objet dimension dans d'autres applications SVG.

Exemple:

 <g freecad:basepoint1="0.5 4.34" freecad:basepoint2="2.4 5.8" dimpoint="3.2 7.76">
     <path d="...">
 </g>

freecad:basepoint2

Définit le deuxième point d'un objet dimension (représenté par un groupe dans un document SVG). Cet attribut est utilisé lorsque vous importez le fragment SVG dans FreeCAD, afin de recréer l'objet dimension. Le groupe contient, les chemins d'accès, et, d'autres éléments graphiques pour restituer correctement l'objet dimension, dans d'autres applications SVG.

Exemple: voir freecad:basepoint1

freecad:dimpoint

Définit le point d'un objet dimension, qui traverse la ligne de dimension. Cet attribut est utilisé lorsque vous importez le fragment SVG dans FreeCAD, afin de recréer l'objet dimension. Le groupe contient les chemins d'accès, et, d'autres éléments graphiques pour restituer correctement l'objet dimension dans d'autres applications SVG.

Exemple: voir freecad:basepoint1

Exemple de code freecad:EditableText

Cet exemple provient du cartouche de la feuille A3_Landscape

1 : Titre sans textedit

  <g
     id="g3587">
    <text
       sodipodi:linespacing="119.00001%"
       id="text3482"
       y="229.10912"
       x="220.8476"
       style="font-size:1.97555566px;font-style:normal;font-weight:normal;line-height:119.00000572%;letter-spacing:0.01975556px;word-spacing:0.00846667px;writing-mode:lr-tb;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
       xml:space="preserve"><tspan
         y="229.10912"
         x="220.8476"
         id="tspan3484"
         sodipodi:role="line">AUTHOR NAME :</tspan></text>

2 : Titre avec textedit

  <g
     style="fill:none;stroke:#000000;stroke-width:0.13;stroke-linecap:butt;stroke-linejoin:miter"
     id="g578-7"
     transform="translate(0,4)">
    <text
       xml:space="preserve"
       style="font-size:4px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans;-inkscape-font-specification:sans"
       x="220.9935"
       y="228.95425"
       id="text3331"
       sodipodi:linespacing="125%"
       freecad:editable="AuthorName"><tspan
         sodipodi:role="line"
         id="tspan3333"
         x="220.9935"
         y="228.95425">AUTHOR NAME</tspan></text>
    <text
    ...
    ...
    ...
    ... </text>
  
  </g>

Explications

  <g

Début du cadre

     style="fill:none;stroke:#000000;stroke-width:0.13;stroke-linecap:butt;stroke-linejoin:miter"
     id="g578-7"
     transform="translate(0,4)">

Données dans le cadre

    <text

Début du bloc de textes

       xml:space="preserve"
       style="font-size:4px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans;-inkscape-font-specification:sans"

Toutes les informations sur le texte qui va être affiché

       x="220.9935"
       y="228.95425"
       id="text3331"
       sodipodi:linespacing="125%"

Coordonnées et renseignements du texte qui va être affiché.

       freecad:editable="AuthorName"><tspan

Ici AuthorName est la variable qui va mémoriser la chaîne freecad:editable qui sera modifiée et affichée dans la feuille.

         sodipodi:role="line"
         id="tspan3333"
         x="220.9935"
         y="228.95425">AUTHOR NAME</tspan></text>

Coordonnées et renseignements sur le texte qui est affiché par défaut, la balise </text> délimite la fin du bloc texte.

    <text
    ...
    ...
    ...
    ... </text>
  </g>

Autres blocs textes et la balise </g> détermine la fin du groupe de textes.

Il est possible qu'après avoir travaillé dans le fichier SVG avec Inkscape le fichier ne fonctionne plus, il est possible que des informations aient disparu.

Ensuite, vérifiez que freecad:editable: n'est pas modifié.

Exemple:

  • editable = "AuthorName"
  • replacer par freecad:editable = "AuthorName"

Autres attributs disponibles

Voir Drawing templates