Draft AnnotationStyleEditor

From FreeCAD Documentation
Jump to navigation Jump to search
This page contains changes which are not marked for translation.
Under construction icon-blue.svg
This documentation is work in progress. Please don't mark it as translatable since it will change the next hours and days.
Other languages:
Deutsch • ‎English • ‎français • ‎italiano • ‎русский
Arrow-left.svg Previous: Draft Label.svg Label
Next: Move Draft Move.svg Arrow-right.svg

Draft AnnotationStyleEditor.svg Draft AnnotationStyleEditor

Menu location
Annotation → Annotation styles...
Default shortcut
Introduced in version
See also
Draft Text, Draft Label, Draft Dimension


The Draft AnnotationStyleEditor.svg Draft_AnnotationStyleEditor command allows you to define styles that affect the visual properties of annotation-like objects, such as those create by the Draft Text, Draft Dimension and Draft Label commands.

Draft AnnotationStyleEditor example.png

The Annotation Styles Editor dialog box


  1. There are several ways to invoke the command:
  2. The Annotation Styles Editor dialog box opens.
  3. Select a style from the Style name dropdown list, or choose Add new... to define a new style.
  4. Optionally adjust the properties of the style.
  5. Optionally press the Accessories-text-editor.svg Rename button to rename the style.
  6. Optionally press the Edit Cancel.svg Delete button to delete the style.
  7. Optionally press the Std Import.svg button to import all styles from a .json file. This will overwrite existing styles with the same name.
  8. Optionally press the Std Export.svg button to export all styles to a .json file.
  9. Press the OK button to close the dialog box and finish the command.


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.


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


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.


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

Arrow-left.svg Previous: Draft Label.svg Label
Next: Move Draft Move.svg Arrow-right.svg