Draft Text: Difference between revisions

From FreeCAD Documentation
m (Changed section to 'Usage')
(Updated default shortcuts.)
 
(65 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:18-->
<!--T:18-->
{{Docnav
{{Docnav|[[Draft_Rectangle|Rectangle]]|[[Draft_Dimension|Dimension]]|[[Draft_Module|Draft]]|IconL=Draft_Rectangle.svg |IconC=Workbench_Draft.svg|IconR=Draft_Dimension.svg }}
|[[Draft_Hatch|Hatch]]
|[[Draft_Dimension|Dimension]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_Hatch.svg
|IconR=Draft_Dimension.svg
|IconC=Workbench_Draft.svg
}}


<!--T:1-->
<!--T:1-->
{{GuiCommand
{{GuiCommand
|Name=Draft Text
|Name=Draft Text
|MenuLocation=Draft → Text
|MenuLocation=Annotation → Text
|Workbenches=[[Draft Module|Draft]], [[Arch Module|Arch]]
|Workbenches=[[Draft_Workbench|Draft]], [[Arch_Workbench|Arch]]
|Shortcut=T E
|Shortcut={{KEY|T}} {{KEY|E}}
|Version=0.7
|SeeAlso=[[Draft Label|Draft Label]], [[Draft ShapeString|Draft ShapeString]]
|SeeAlso=[[Draft_Label|Draft Label]], [[Draft_ShapeString|Draft ShapeString]]
|Version=0.7}}
}}


==Description== <!--T:2-->
==Description== <!--T:22-->

The Text tool inserts a multi-line textbox at a given point. It uses the [[Draft Linestyle|Draft Linestyle]] set on the [[Draft Tray|Draft Tray]].
<!--T:2-->
The [[Image:Draft_Text.svg|24px]] '''Draft Text''' command creates a multi-line text at a given point.


<!--T:11-->
<!--T:11-->
To create a text label with a leader and an arrow use [[Draft Label|Draft Label]]. To create solid text or 3D letters use [[Draft ShapeString|Draft ShapeString]] with [[Part Extrude|Part Extrude]].
To create a text element with an arrow use the [[Draft_Label|Draft Label]] command instead.


<!--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 text}}


<!--T:21-->
==Usage== <!--T:23-->
'''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:4-->
<!--T:24-->
See also: [[Draft_Tray|Draft Tray]] and [[Draft_Snap|Draft Snap]].
# Press the {{Button|[[Image:Draft Text.png|16px]] [[Draft Text|Draft Text]]}} button, or press {{KEY|T}} then {{KEY|E}} keys.

# Click a point on the 3D view, or type a [[Draft_Coordinates|coordinate]] and press the {{Button|[[Image:Draft_AddPoint.svg|16px]] [[Draft_AddPoint|add point]]}} button.
<!--T:4-->
# Enter the desired text, pressing {{KEY|Enter}} between each line.
# Press {{KEY|Enter}} twice to finish the operation.
# There are several ways to invoke the command:
#* Press the {{Button|[[Image:Draft_Text.svg|16px]] [[Draft_Text|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}}.
# The {{MenuCommand|Text}} task panel opens. See [[#Options|Options]] for more information.
# Pick a point in the [[3D_view|3D view]], or type coordinates and press the {{Button|[[Image:Draft_AddPoint.svg|16px]] Enter point}} button.
# Enter the desired text, press {{KEY|Enter}} to start a new line.
# Press {{KEY|Enter}} twice or press the {{Button|[[Image:Button_valid.svg|16px]] Create text}} button to finish the command.


==Options== <!--T:5-->
==Options== <!--T:5-->

<!--T:25-->
The single character keyboard shortcuts available in the task panel can be changed. See [[Draft_Preferences|Draft Preferences]]. The shortcuts mentioned here are the default shortcuts (for version 0.22).


<!--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]] [[Draft_AddPoint|add point]]}} button when you have the desired values to insert the point.
* To manually enter coordinates enter the X, Y and Z component, and press {{KEY|Enter}} after each. Or you can press the {{Button|[[Image:Draft_AddPoint.svg|16px]] Enter point}} button when you have the desired values. It is advisable to move the pointer out of the [[3D_view|3D view]] before entering coordinates.
* Press {{KEY|G}} or click the {{MenuCommand|Global}} checkbox to toggle global mode. If global mode is on, coordinates are relative to the global coordinate system, else they are relative to the [[Draft_SelectPlane|working plane]] coordinate system. {{Version|0.20}}
* 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|N}} or click the {{MenuCommand|Continue}} checkbox to toggle continue mode. If continue mode is on, the command will restart after finishing, allowing you to continue creating texts. The shortcut does not work in the second task panel. This option is not available in the first task panel in FreeCAD version 0.19 and earlier.
* 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|S}} to switch [[Draft_Snap|Draft snapping]] on or off.
* Press {{KEY|Enter}} or {{KEY|↓ Down arrow}} twice to finish editing the text.
* Press {{KEY|Esc}} or the {{Button|Close}} button to abort the command.

* Press {{KEY|Esc}} or the {{Button|Close}} button to abort the current command.
==Notes== <!--T:26-->

<!--T:21-->
* A Draft Text can be edited by double-clicking it in the [[Tree_view|Tree view]]. {{Version|0.20}}
* Draft Texts created or saved with [[Release_notes_0.21|FreeCAD version 0.21]] are not backward compatible.


==Properties== <!--T:7-->
==Properties== <!--T:7-->


=== Data === <!--T:12-->
<!--T:27-->
See also: [[Property_editor|Property editor]].
* {{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.


=== View === <!--T:13-->
<!--T:28-->
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.
* {{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.


==Scripting== <!--T:8-->
=== Data === <!--T:29-->

{{Emphasis|See also:}} [[Draft API|Draft API]] and [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]].
<!--T:30-->
{{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 === <!--T:31-->

<!--T:32-->
{{TitleProperty|Annotation}}

<!--T:33-->
* {{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.

<!--T:34-->
{{TitleProperty|Display Options}}

<!--T:35-->
* {{PropertyView|Display Mode|Enumeration}}: specifies how the text is displayed. If it is {{value|World}} the text will be displayed on a plane defined by its {{PropertyData|Placement}}. If it is {{value|Screen}} the text will always face the screen. This is an inherited property. The mentioned options are the renamed options ({{Version|0.21}}).

<!--T:36-->
{{TitleProperty|Graphics}}

<!--T:37-->
* {{PropertyView|Line Color|Color}}: not used.
* {{PropertyView|Line Width|Float}}: not used.

<!--T:38-->
{{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:39-->

<!--T:8-->
See also: [https://freecad.github.io/SourceDoc/ 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 = makeText(stringlist, point=Vector(0,0,0), screen=False)
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:15-->
<!--T:9-->
The placement of the {{incode|Text}} can be changed by overwriting its {{incode|Placement}} attribute, or by individually overwriting its {{incode|Placement.Base}} and {{incode|Placement.Rotation}} attributes.
* 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 is displayed in a plane defined by its {{PropertyData|Placement}}.


<!--T:16-->
<!--T:16-->
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.
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, Draft
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.makeText(t1, point=p1)
text1 = Draft.make_text(t1, p1)
Text2 = Draft.makeText(t2, point=p2)
text2 = Draft.make_text(t2, p2)
Text1.ViewObject.FontSize = 200
text1.ViewObject.FontSize = 200
Text2.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-->
{{Docnav|[[Draft_Rectangle|Rectangle]]|[[Draft_Dimension|Dimension]]|[[Draft_Module|Draft]]|IconL=Draft_Rectangle.svg |IconC=Workbench_Draft.svg|IconR=Draft_Dimension.svg }}


<!--T:19-->
<!--T:17-->
{{Docnav
{{Draft Tools navi}}
|[[Draft_Hatch|Hatch]]

|[[Draft_Dimension|Dimension]]
<!--T:20-->
|[[Draft_Workbench|Draft]]
{{Userdocnavi}}
|IconL=Draft_Hatch.svg
|IconR=Draft_Dimension.svg
|IconC=Workbench_Draft.svg
}}


</translate>
</translate>
{{Draft Tools navi{{#translation:}}}}
{{clear}}
{{Userdocnavi{{#translation:}}}}

Latest revision as of 18:30, 6 January 2024

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 creates a multi-line text at a given point.

To create a text element with an arrow use the Draft Label command instead.

Single point required to position the text

Usage

See also: Draft Tray and Draft Snap.

  1. There are several ways to invoke the command:
    • Press the Text button.
    • Select the Annotation → Text option from the menu.
    • Use the keyboard shortcut: T then E.
  2. The Text task panel opens. See Options for more information.
  3. Pick a point in the 3D view, or type coordinates and press the Enter point button.
  4. Enter the desired text, press Enter to start a new line.
  5. Press Enter twice or press the Create text button to finish the command.

Options

The single character keyboard shortcuts available in the task panel can be changed. See Draft Preferences. The shortcuts mentioned here are the default shortcuts (for version 0.22).

  • To manually enter coordinates enter the X, Y and Z component, and press Enter after each. Or you can press the Enter point button when you have the desired values. It is advisable to move the pointer out of the 3D view before entering coordinates.
  • Press G or click the Global checkbox to toggle global mode. If global mode is on, coordinates are relative to the global coordinate system, else they are relative to the working plane coordinate system. introduced in version 0.20
  • Press N or click the Continue checkbox to toggle continue mode. If continue mode is on, the command will restart after finishing, allowing you to continue creating texts. The shortcut does not work in the second task panel. This option is not available in the first task panel in FreeCAD version 0.19 and earlier.
  • Press S to switch Draft snapping on or off.
  • Press Esc or the Close button to abort the command.

Notes

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 is World the text will be displayed on a plane defined by its DataPlacement. If it is Screen the text will always face the screen. This is an inherited property. The mentioned options are the renamed options (introduced in version 0.21).

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 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 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 or Right.
  • 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, at placement, which can be a FreeCAD.Placement, but also a FreeCAD.Rotation or a FreeCAD.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 is True, the text always faces the camera, otherwise it is displayed in a plane defined by its DataPlacement.

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()