Draft AnnotationStyleEditor/fr: Difference between revisions

From FreeCAD Documentation
(Created page with "# Appuyez sur le bouton {{Button|16px Draft Manage or create annotation styles}} # Ouvrez la zone de...")
(Created page with "Utilisez le {{Button|16px Rename}} ou {{Button|16px Delete}} pour renommer ou supprimer le style actif .")
Line 23: Line 23:
# Ajustez les propriétés du style, puis appuyez sur {{Button|OK}} lorsque vous êtes satisfait.
# Ajustez les propriétés du style, puis appuyez sur {{Button|OK}} lorsque vous êtes satisfait.


Use the {{Button|[[File:Accessories-text-editor.svg|16px]] Rename}} or {{Button|[[File:Edit_Cancel.svg|16px]] Delete}} to rename or delete the active style.
Utilisez le {{Button|[[File:Accessories-text-editor.svg|16px]] Rename}} ou {{Button|[[File:Edit_Cancel.svg|16px]] Delete}} pour renommer ou supprimer le style actif .


== Scripting ==
== Scripting ==

Revision as of 12:54, 24 May 2020

Draft Editeur styles d'annotations

Emplacement du menu
Annotation → Annotation styles
Ateliers
Draft
Raccourci par défaut
Aucun
Introduit dans la version
0.19
Voir aussi
Draft Texte, Draft Dimension, Draft Etiquette

Description

L'outil Draft Editeur styles d'annotations vous permet de définir des styles qui affectent les propriétés visuelles des objets de type annotation, comme ceux créés par Draft Texte, Draft Dimension et Draft Etiquette.

File:Draft AnnotationStyleEditor example.png

Éditeur de style pour configurer les annotations.

Utilisation

  1. Appuyez sur le bouton Draft Manage or create annotation styles
  2. Ouvrez la zone de liste déroulante, puis choisissez Add new ... pour définir un nouveau style ou sélectionnez l'un des styles existants.
  3. Ajustez les propriétés du style, puis appuyez sur OK lorsque vous êtes satisfait.

Utilisez le Rename ou Delete pour renommer ou supprimer le style actif .

Scripting

The annotation styles are saved as serialized dictionaries in the Meta attribute of the document. This attribute is inspected by the annotation style editor when it is opened.

>>> print(App.ActiveDocument.Meta["Draft_Style_Lane 1:100"])
{"FontName": "DejaVu Sans", "FontSize": "8.0000 ", "LineSpacing": "1 cm", "ScaleMultiplier": 1.0, "ShowUnit": false, "UnitOverride": "", "Decimals": 2, "ShowLines": true, "LineWidth": 2, "LineColor": 1095216660480, "ArrowType": 0, "ArrowSize": "5.0000 ", "DimensionOvershoot": "1.0000 ", "ExtensionLines": "5.0000 ", "ExtensionOvershoot": "1.0000 "}

Each style that appears in the editor is internally saved with the style name prefixed by Draft_Style_; this will prevent name clashes with other keys that may be saved in Meta, which can hold arbitrary information.

You may define any new style by adding the necessary information to a key that starts with Draft_Style_. The corresponding value of this key must be a dictionary serialized using json.

import json

meta = App.ActiveDocument.Meta
props = {"LineWidth": 6, "ArrowSize": "7"}
meta["Draft_Style_Thick_lines"] = json.dumps(props)
App.ActiveDocument.Meta = meta

The values not entered will be filled automatically when this style is selected in the style editor.

In a similar way, any serialized dictionary can be unpacked for edition.

meta = App.ActiveDocument.Meta
new_dict = json.loads(meta["Draft_Style_Thick_lines"])

Because the graphical interface widgets check the units of the input values, many of these values must be saved as strings, rather than floating point numbers.

Strings:

props = {
  "FontName": "DejaVu Sans",
  "FontSize": "12.0000 ",
  "LineSpacing": "1 cm",
  "UnitOverride": "m",
  "ArrowSize": "5.0000 ",
  "DimensionOvershoot": "1.0000 ",
  "ExtensionLines": "5.0000 ",
  "ExtensionOvershoot": "1.0000 "
}

Numbers:

props = {
  "ScaleMultiplier": 1.0,
  "Decimals": 2,
  "LineWidth": 1,
  "LineColor": 1095216660480,
  "ArrowType": 0
}

The line color corresponds to the 32-bit integer, from which the individual RGBA values can be extracted.

Boolean:

props = {
  "ShowUnit": False,
  "ShowLines": True
}