|
Расположение в меню |
---|
Annotation → Annotation styles |
Верстаки |
Draft |
Быстрые клавиши |
- |
Представлено в версии |
0.19 |
См. также |
Draft Text, Draft Dimension, Draft Label |
The 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.
The Annotation Styles Editor dialog box
Add new...
to define a new style.To apply an annotation style change the ВидAnnotation Style property of annotation objects. This property can be found on the View tab of the Property editor.
Selecting an annotation style
See also: Autogenerated API documentation and FreeCAD Scripting Basics.
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_Text red"])
{"ArrowSize": 2.0, "ArrowType": 0, "Decimals": 2, "DimOvershoot": 4.0, "ExtLines": 0.0, "ExtOvershoot": 4.0, "FontName": "DejaVu Sans", "FontSize": 10.0, "LineColor": 255, "LineSpacing": 1.0, "LineWidth": 2, "ScaleMultiplier": 1.0, "ShowLine": true, "ShowUnit": false, "TextColor": 4278190335, "TextSpacing": 3.0, "UnitOverride": ""}
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 = {"ArrowSize": 7.0, "LineWidth": 6}
meta["Draft_Style_Thick_lines"] = json.dumps(props)
App.ActiveDocument.Meta = meta
The properties not entered will be filled automatically when this style is selected in the style editor and the OK button is pressed.
In a similar way, any serialized dictionary can be unpacked for edition.
import json
meta = App.ActiveDocument.Meta
new_dict = json.loads(meta["Draft_Style_Thick_lines"])
The properties must have the following types:
Strings:
props = {
"FontName": "DejaVu Sans",
"UnitOverride": ""
}
Floats (must be supplied with a decimal point):
props = {
"ArrowSize": 2.0,
"DimOvershoot": 4.0,
"ExtLines": 0.0,
"ExtOvershoot": 4.0
"FontSize": 10.0,
"LineSpacing": 1.0,
"ScaleMultiplier": 1.0,
"TextSpacing": 3.0
}
Integers:
props = {
"ArrowType": 0,
"Decimals": 2,
"LineColor": 255,
"LineWidth": 2,
"TextColor": 4278190335
}
The TextColor
and LineColor
correspond to a 32-bit integer, from which the individual RGBA values can be extracted. The ArrowType
is an enumerator.
Booleans:
props = {
"ShowLine": true
"ShowUnit": false,
}