Draft Text: Difference between revisions
No edit summary |
|||
(28 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Page_in_progress}} |
|||
<languages/> |
<languages/> |
||
<translate> |
<translate> |
||
<!--T:18--> |
<!--T:18--> |
||
{{Docnav |
{{Docnav |
||
|[[Draft_ShapeString|ShapeString]] |
|||
|[[Draft_Rectangle|Rectangle]] |
|||
|[[Draft_Dimension|Dimension]] |
|[[Draft_Dimension|Dimension]] |
||
|[[Draft_Module|Draft]] |
|[[Draft_Module|Draft]] |
||
|IconL= |
|IconL=Draft_ShapeString.svg |
||
|IconR=Draft_Dimension.svg |
|IconR=Draft_Dimension.svg |
||
|IconC=Workbench_Draft.svg |
|IconC=Workbench_Draft.svg |
||
Line 14: | Line 16: | ||
{{GuiCommand |
{{GuiCommand |
||
|Name=Draft Text |
|Name=Draft Text |
||
|MenuLocation= |
|MenuLocation=Annotation → Text |
||
|Workbenches=[[Draft_Module|Draft]], [[Arch_Module|Arch]] |
|Workbenches=[[Draft_Module|Draft]], [[Arch_Module|Arch]] |
||
|Shortcut={{KEY|T}} {{KEY|E}} |
|Shortcut={{KEY|T}} {{KEY|E}} |
||
Line 24: | Line 26: | ||
<!--T:2--> |
<!--T:2--> |
||
The |
The [[Image:Draft_Text.svg|24px]] [[Draft_Text|Draft Text]] command inserts a multi-line textbox at a given point. It uses the [[Draft_Linestyle|Draft Linestyle]] set on the [[Draft_Tray|Draft Tray]]. |
||
<!--T:11--> |
<!--T:11--> |
||
To insert a text element with an arrow use the [[Draft_Label|Draft Label]] command. |
|||
<!--T:3--> |
<!--T:3--> |
||
[[Image:Draft_Text_example.png|400px]] |
[[Image:Draft_Text_example.png|400px]] |
||
{{Caption|Single point required to position the textbox}} |
{{Caption|Single point required to position the textbox}} |
||
<!--T:21--> |
|||
'''Warning:''' The texts created with [[Release notes 0.18 |version 0.18]] are not backward compatible, so backup your work if you try to open files created with 0.18 with older versions. |
|||
==Usage== <!--T:23--> |
==Usage== <!--T:23--> |
||
<!--T:4--> |
<!--T:4--> |
||
# There are several ways to invoke the command: |
|||
# Press the {{Button|[[Image:Draft_Text.svg|16px]] [[Draft Text|Draft Text]]}} button, or press {{KEY|T}} then {{KEY|E}} keys. |
|||
# |
#* Press the {{Button|[[Image:Draft_Text.svg|16px]] [[Draft_Text|Draft Text]]}} button. |
||
#* Select the {{MenuCommand|Annotation → [[Image:Draft_Text.svg|16px]] Text}} option from the menu. |
|||
#* Use the keyboard shortcut: {{KEY|T}} then {{KEY|E}}. |
|||
# Click a point on the [[3D_view|3D view]], or type [[Draft_Coordinates|coordinates]] and press the {{Button|[[Image:Draft_AddPoint.svg|16px]] Enter point}} button. |
|||
# Enter the desired text, pressing {{KEY|Enter}} between each line. |
# Enter the desired text, pressing {{KEY|Enter}} between each line. |
||
# Press {{KEY|Enter}} twice to finish the |
# Press {{KEY|Enter}} twice to finish the command. |
||
==Options== <!--T:5--> |
==Options== <!--T:5--> |
||
<!--T:6--> |
<!--T:6--> |
||
* To enter coordinates manually, simply enter the numbers, then press {{KEY|Enter}} between each X, Y and Z component. You can press the {{Button|[[Image:Draft_AddPoint.svg|16px]] |
* To enter coordinates manually, simply enter the numbers, then press {{KEY|Enter}} between each X, Y and Z component. You can press the {{Button|[[Image:Draft_AddPoint.svg|16px]] Enter point}} button when you have the desired values to insert the point. |
||
* Hold {{KEY|Ctrl}} while placing the text to force [[Draft_Snap|snapping]] your point to the nearest snap location, independently of the distance. |
* Hold {{KEY|Ctrl}} while placing the text to force [[Draft_Snap|snapping]] your point to the nearest snap location, independently of the distance. |
||
* Press {{KEY|Enter}} or {{KEY|↓ Down arrow}} to enter a new line of text. |
* Press {{KEY|Enter}} or {{KEY|↓ Down arrow}} to enter a new line of text. |
||
* Press {{KEY|↑ Up arrow}} to edit the previous line of text. |
* Press {{KEY|↑ Up arrow}} to edit the previous line of text. |
||
* Press {{KEY|Enter}} or {{KEY|↓ Down arrow}} twice to finish editing the text. |
* Press {{KEY|Enter}} or {{KEY|↓ Down arrow}} twice to finish editing the text. |
||
* Press {{KEY|Esc}} or the {{Button|Close}} button to abort the |
* Press {{KEY|Esc}} or the {{Button|Close}} button to abort the command. |
||
==Notes== |
|||
<!--T:21--> |
|||
* Draft Texts created with [[Release_notes_0.18|FreeCAD version 0.18]] are not backward compatible. |
|||
==Properties== <!--T:7--> |
==Properties== <!--T:7--> |
||
See also: [[property_editor|Property editor]]. |
|||
=== Data === <!--T:12--> |
|||
* {{PropertyData|Text}}: specifies the contents of the text block as a list of strings; each element on the list, separated by a comma, indicates a new line. |
|||
* {{PropertyData|Position}}: specifies the base point of the first line of the text block. |
|||
* {{PropertyData|Angle}}: specifies the rotation of the baseline of the first line of the text block. |
|||
* {{PropertyData|Axis}}: specifies the axis to use for the rotation. |
|||
A Draft Text object is derived from an [[App_FeaturePython|App FeaturePython]] object and inherits all its properties. The following properties are additional unless otherwise stated. |
|||
=== View === <!--T:13--> |
|||
* {{PropertyView|Display Mode}}: if it is "3D text" the text will be aligned to the scene axes, initially lying on the XY plane; if it is "2D text" the text will always face the camera. |
|||
* {{PropertyView|Font Name}}: specifies the font to use to draw the text. It can be a font name, such as "Arial", a default style such as "sans", "serif" or "mono", a family such as "Arial,Helvetica,sans" or a name with a style such as "Arial:Bold". If the given font is not found on the system, a generic one is used instead. |
|||
* {{PropertyView|Font Size}}: specifies the size of the letters. If the text object is created in the tree view but no text is visible, increase the size of the text until it is visible. |
|||
* {{PropertyView|Justification}}: specifies if the text aligns to the left, right or at the center of the base point. |
|||
* {{PropertyView|Line Spacing}}: specifies the space between lines of text. |
|||
=== Data === |
|||
==Scripting== <!--T:8--> |
|||
{{Emphasis|See also:}} [[Draft API|Draft API]] and [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]]. |
|||
{{TitleProperty|Base}} |
|||
<!--T:12--> |
|||
* {{PropertyData|Placement|Placement}}: specifies the position of the text in the [[3D view|3D view]]. See [[Placement|Placement]]. |
|||
* {{PropertyData|Text|StringList}}: specifies the contents of the text. Each item in the list represents a new text line. |
|||
=== View === |
|||
{{TitleProperty|Annotation}} |
|||
* {{PropertyView|Annotation Style|Enumeration}}: specifies the annotation style applied to the text. See [[Draft_AnnotationStyleEditor|Draft AnnotationStyleEditor]]. |
|||
* {{PropertyView|Scale Multiplier|Float}}: specifies the general scaling factor applied to the text. |
|||
{{TitleProperty|Display Options}} |
|||
* {{PropertyView|Display Mode|Enumeration}}: specifies how the text is displayed. If it is {{value|3D text}} the text will be displayed in a plane defined by its {{PropertyData|Placement}}. If it is {{value|2D text}} the text will always face the camera. This is an inherited property. |
|||
{{TitleProperty|Graphics}} |
|||
* {{PropertyView|Line Color|Color}}: not used. |
|||
* {{PropertyView|Line Width|Float}}: not used. |
|||
{{TitleProperty|Text}} |
|||
<!--T:13--> |
|||
* {{PropertyView|Font Name|Font}}: specifies the font used to draw the text. It can be a font name, such as {{value|Arial}}, a default style such as {{value|sans}}, {{value|serif}} or {{value|mono}}, a family such as {{value|Arial,Helvetica,sans}}, or a name with a style such as {{value|Arial:Bold}}. If the given font is not found on the system, a default font is used instead. |
|||
* {{PropertyView|Font Size|Length}}: specifies the size of the letters. The text can be invisible in the [[3D_view|3D view]] if this value is very small. |
|||
* {{PropertyView|Justification|Enumeration}}: specifies if the alignment of the text: {{value|Left}}, {{value|Center}} or {{value|Right}}. |
|||
* {{PropertyView|Line Spacing|Float}}: specifies the factor applied to the default line height of the text. |
|||
* {{PropertyView|Text Color|Color}}: specifies the color of the text. |
|||
==Scripting== |
|||
<!--T:8--> |
|||
See also: [https://www.freecadweb.org/api Autogenerated API documentation] and [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]]. |
|||
<!--T:14--> |
<!--T:14--> |
||
To create a Draft Text use the {{incode|make_text}} method ({{Version|0.19}}) of the Draft module. This method replaces the deprecated {{incode|makeText}} method. |
|||
The Text tool can be used in [[macros|macros]] and from the [[Python|Python]] console by using the following function: |
|||
</translate> |
</translate> |
||
{{Code|code= |
{{Code|code= |
||
text = make_text(string, placement=None, screen=False) |
|||
}} |
}} |
||
<translate> |
<translate> |
||
<!--T:9--> |
|||
* Creates a {{incode|Text}} object, at a {{incode|point}} defined by a {{incode|FreeCAD.Vector}}. |
|||
* {{incode|stringlist}} is a string, or a list of strings; if it's a list, each element is displayed in its own line. |
|||
* If {{incode|screen}} is {{incode|True}}, the text always faces the camera view direction, otherwise it aligns with the scene axes, and lies on the XY plane. |
|||
<!--T: |
<!--T:9--> |
||
* Creates a {{incode|text}} object, at {{incode|placement}}, which can be a {{incode|FreeCAD.Placement}}, but also a {{incode|FreeCAD.Rotation}} or a {{incode|FreeCAD.Vector}}. |
|||
* {{incode|string}} is a string or a list of strings. If it is a list, each element is displayed on its own line. |
|||
* If {{incode|screen}} is {{incode|True}}, the text always faces the camera, otherwise it aligns with the scene axes and lies on the XY plane. |
|||
<!--T:16--> |
<!--T:16--> |
||
The view properties of {{incode| |
The view properties of {{incode|text}} can be changed by overwriting its attributes; for example, overwrite {{incode|ViewObject.FontSize}} with the new size in millimeters. |
||
<!--T:10--> |
<!--T:10--> |
||
Example: |
Example: |
||
</translate> |
</translate> |
||
{{Code|code= |
{{Code|code= |
||
import FreeCAD |
import FreeCAD as App |
||
import Draft |
|||
doc = App.newDocument() |
|||
p1 = FreeCAD.Vector(0, 0, 0) |
|||
t1 = "This is a sample text" |
t1 = "This is a sample text" |
||
p1 = App.Vector(0, 0, 0) |
|||
p2 = FreeCAD.Vector(1000, 1000, 0) |
|||
t2 = ["First line", "second line"] |
t2 = ["First line", "second line"] |
||
p2 = App.Vector(1000, 1000, 0) |
|||
text1 = Draft.make_text(t1, p1) |
|||
text2 = Draft.make_text(t2, p2) |
|||
text1.ViewObject.FontSize = 200 |
|||
text2.ViewObject.FontSize = 200 |
|||
zaxis = App.Vector(0, 0, 1) |
|||
p3 = FreeCAD.Vector(-1000, -500, 0) |
|||
t3 = ["Upside", "down"] |
t3 = ["Upside", "down"] |
||
p3 = App.Vector(-1000, -500, 0) |
|||
place3 = App.Placement(p3, App.Rotation(zaxis, 180)) |
|||
text3 = Draft.make_text(t3, place3) |
|||
text3.ViewObject.FontSize = 200 |
|||
doc.recompute() |
|||
Text3 = Draft.makeText(t3, point=p3) |
|||
Text3.ViewObject.FontSize = 200 |
|||
ZAxis = FreeCAD.Vector(0, 0, 1) |
|||
place3 = FreeCAD.Placement(p3, FreeCAD.Rotation(ZAxis, 175)) |
|||
Text3.Placement = place3 |
|||
Text4 = Draft.makeText(t3, point=p3) |
|||
Text4.ViewObject.FontSize = 200 |
|||
Text4.Placement.Rotation = FreeCAD.Rotation(ZAxis, -30) |
|||
}} |
}} |
||
<translate> |
<translate> |
||
<!--T:17--> |
<!--T:17--> |
||
{{Docnav |
{{Docnav |
||
|[[Draft_ShapeString|ShapeString]] |
|||
|[[Draft_Rectangle|Rectangle]] |
|||
|[[Draft_Dimension|Dimension]] |
|[[Draft_Dimension|Dimension]] |
||
|[[Draft_Module|Draft]] |
|[[Draft_Module|Draft]] |
||
|IconL= |
|IconL=Draft_ShapeString.svg |
||
|IconR=Draft_Dimension.svg |
|IconR=Draft_Dimension.svg |
||
|IconC=Workbench_Draft.svg |
|IconC=Workbench_Draft.svg |
||
Line 136: | Line 169: | ||
{{Draft Tools navi{{#translation:}}}} |
{{Draft Tools navi{{#translation:}}}} |
||
{{Userdocnavi{{#translation:}}}} |
{{Userdocnavi{{#translation:}}}} |
||
{{clear}} |
Revision as of 09:32, 30 March 2021
Draft Text |
Menu location |
---|
Annotation → Text |
Workbenches |
Draft, Arch |
Default shortcut |
T E |
Introduced in version |
0.7 |
See also |
Draft Label, Draft ShapeString |
Description
The Draft Text command inserts a multi-line textbox at a given point. It uses the Draft Linestyle set on the Draft Tray.
To insert a text element with an arrow use the Draft Label command.
Single point required to position the textbox
Usage
- There are several ways to invoke the command:
- Press the Draft Text button.
- Select the Annotation → Text option from the menu.
- Use the keyboard shortcut: T then E.
- Click a point on the 3D view, or type coordinates and press the Enter point button.
- Enter the desired text, pressing Enter between each line.
- Press Enter twice to finish the command.
Options
- To enter coordinates manually, simply enter the numbers, then press Enter between each X, Y and Z component. You can press the Enter point button when you have the desired values to insert the point.
- Hold Ctrl while placing the text to force snapping your point to the nearest snap location, independently of the distance.
- Press Enter or ↓ Down arrow to enter a new line of text.
- Press ↑ Up arrow to edit the previous line of text.
- Press Enter or ↓ Down arrow twice to finish editing the text.
- Press Esc or the Close button to abort the command.
Notes
- Draft Texts created with FreeCAD version 0.18 are not backward compatible.
Properties
See also: Property editor.
A Draft Text object is derived from an App FeaturePython object and inherits all its properties. The following properties are additional unless otherwise stated.
Data
Base
- DataPlacement (
Placement
): specifies the position of the text in the 3D view. See Placement. - DataText (
StringList
): specifies the contents of the text. Each item in the list represents a new text line.
View
Annotation
- ViewAnnotation Style (
Enumeration
): specifies the annotation style applied to the text. See Draft AnnotationStyleEditor. - ViewScale Multiplier (
Float
): specifies the general scaling factor applied to the text.
Display Options
- ViewDisplay Mode (
Enumeration
): specifies how the text is displayed. If it is3D text
the text will be displayed in a plane defined by its DataPlacement. If it is2D text
the text will always face the camera. This is an inherited property.
Graphics
- ViewLine Color (
Color
): not used. - ViewLine Width (
Float
): not used.
Text
- ViewFont Name (
Font
): specifies the font used to draw the text. It can be a font name, such asArial
, a default style such assans
,serif
ormono
, a family such asArial,Helvetica,sans
, or a name with a style such asArial:Bold
. If the given font is not found on the system, a default font is used instead. - ViewFont Size (
Length
): specifies the size of the letters. The text can be invisible in the 3D view if this value is very small. - ViewJustification (
Enumeration
): specifies if the alignment of the text:Left
,Center
orRight
. - ViewLine Spacing (
Float
): specifies the factor applied to the default line height of the text. - ViewText Color (
Color
): specifies the color of the text.
Scripting
See also: Autogenerated API documentation and FreeCAD Scripting Basics.
To create a Draft Text use the make_text
method (introduced in version 0.19) of the Draft module. This method replaces the deprecated makeText
method.
text = make_text(string, placement=None, screen=False)
- Creates a
text
object, atplacement
, which can be aFreeCAD.Placement
, but also aFreeCAD.Rotation
or aFreeCAD.Vector
. string
is a string or a list of strings. If it is a list, each element is displayed on its own line.- If
screen
isTrue
, the text always faces the camera, otherwise it aligns with the scene axes and lies on the XY plane.
The view properties of text
can be changed by overwriting its attributes; for example, overwrite ViewObject.FontSize
with the new size in millimeters.
Example:
import FreeCAD as App
import Draft
doc = App.newDocument()
t1 = "This is a sample text"
p1 = App.Vector(0, 0, 0)
t2 = ["First line", "second line"]
p2 = App.Vector(1000, 1000, 0)
text1 = Draft.make_text(t1, p1)
text2 = Draft.make_text(t2, p2)
text1.ViewObject.FontSize = 200
text2.ViewObject.FontSize = 200
zaxis = App.Vector(0, 0, 1)
t3 = ["Upside", "down"]
p3 = App.Vector(-1000, -500, 0)
place3 = App.Placement(p3, App.Rotation(zaxis, 180))
text3 = Draft.make_text(t3, place3)
text3.ViewObject.FontSize = 200
doc.recompute()
- Drafting: Line, Polyline, Fillet, Arc, Arc by 3 points, Circle, Ellipse, Rectangle, Polygon, B-spline, Cubic Bézier curve, Bézier curve, Point, Facebinder, ShapeString, Hatch
- Annotation: Text, Dimension, Label, Annotation styles, Annotation scale
- Modification: Move, Rotate, Scale, Mirror, Offset, Trimex, Stretch, Clone, Array, Polar array, Circular array, Path array, Path link array, Point array, Point link array, Edit, Subelement highlight, Join, Split, Upgrade, Downgrade, Wire to B-spline, Draft to sketch, Set slope, Flip dimension, Shape 2D view
- Draft Tray: Select plane, Set style, Toggle construction mode, AutoGroup
- Snapping: Snap lock, Snap endpoint, Snap midpoint, Snap center, Snap angle, Snap intersection, Snap perpendicular, Snap extension, Snap parallel, Snap special, Snap near, Snap ortho, Snap grid, Snap working plane, Snap dimensions, Toggle grid
- Miscellaneous: Apply current style, Layer, Manage layers, Add a new named group, Move to group, Select group, Add to construction group, Toggle normal/wireframe display, Create working plane proxy, Heal, Show snap toolbar
- Additional: Constraining, Pattern, Preferences, Import Export Preferences, DXF/DWG, SVG, OCA, DAT
- Context menu:
- Layer container: Merge layer duplicates, Add new layer
- Layer: Activate this layer, Select layer contents
- Text: Open hyperlinks
- Wire: Flatten
- Working plane proxy: Write camera position, Write objects state
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Start, Surface, TechDraw, Test Framework, Web
- Hubs: User hub, Power users hub, Developer hub