Std TextDocument: Difference between revisions

From FreeCAD Documentation
(Marked this version for translation)
mNo edit summary
 
(15 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:16-->
{{Docnav
|[[Std_MeasureDistance|MeasureDistance]]
|[[Std_DemoMode|DemoMode]]
|[[Std_Tools_Menu|Std Tools Menu]]
|IconL=Std_MeasureDistance.svg
|IconR=Std_DemoMode.svg
|IconC=Freecad.svg
}}


<!--T:1-->
<!--T:1-->
Line 11: Line 21:
}}
}}


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


<!--T:3-->
<!--T:3-->
[[Std TextDocument|Std TextDocument]] creates an object capable of holding arbitrary text. This element can be used to write general information or documentation about the model.
The '''Std TextDocument''' command creates an object capable of holding arbitrary text. This element can be used to write general information or documentation about the model.


== How to use == <!--T:4-->
==Usage== <!--T:4-->


<!--T:5-->
<!--T:5-->
# Go to the menu {{MenuCommand|Tools → Add text document}}.
# Select the {{MenuCommand|Tools → Add text document}} option from the menu.
# Double click on the new object created in the [[tree view|tree view]] to open a tab where to write text.
# Double-click the newly created object in the [[tree view|tree view]] to open a tab in which to write text.
# Add text.
# Add text.
# Close the tab and save the file when asked.
# Close the tab and save the file when asked.


== Scripting == <!--T:6-->
==Properties== <!--T:12-->

===View=== <!--T:13-->

<!--T:14-->
{{TitleProperty|Editor}}

<!--T:15-->
* {{PropertyView|Font Name|Font}}: a font name, for example, {{Value|Ubuntu Mono}}.
* {{PropertyView|Font Size|Float}}: a font size in points, for example, {{Value|11}}.
* {{PropertyView|Read Only|Bool}}: it defaults to {{FALSE}}. If set to {{TRUE}} the text cannot be edited.
* {{PropertyView|Syntax Highlighter|Enumeration}}: it defaults to {{Value|None}}. If set to {{Value|Python}}, the text will be highlighted like the [[Python_console|Python console]].

==Scripting== <!--T:6-->


<!--T:7-->
<!--T:7-->
Line 33: Line 56:


<!--T:9-->
<!--T:9-->
An {{incode|App::TextDocument}} object is created with the {{incode|addObject()}} method of the document. Once a TextDocument exists, its textual information is stored in its {{incode|Text}} attribute. This attribute can be used in other objects, for example, as the string in a [[Draft_ShapeString|Draft ShapeString]].
An {{incode|App::TextDocument}} object is created with the {{incode|addObject()}} method of the document. Once a TextDocument exists, its textual information is stored in its {{incode|Text}} attribute. This attribute can be used in other objects, for example, as the string in a {{Button|[[Image:Draft_ShapeString.svg|16px]] [[Draft_ShapeString|Draft ShapeString]]}}.


</translate>
</translate>
Line 50: Line 73:
<translate>
<translate>



<!--T:10-->
<!--T:17-->
{{Std Base}}
{{Docnav
{{Userdocnavi}}
|[[Std_MeasureDistance|MeasureDistance]]
|[[Std_DemoMode|DemoMode]]
|[[Std_Tools_Menu|Std Tools Menu]]
|IconL=Std_MeasureDistance.svg
|IconR=Std_DemoMode.svg
|IconC=Freecad.svg
}}

</translate>
</translate>
{{Std Base navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{clear}}

Latest revision as of 15:48, 29 December 2020

Std TextDocument

Menu location
Tools → Add text document
Workbenches
All
Default shortcut
None
Introduced in version
0.19
See also
Draft ShapeString, Draft Text

Description

The Std TextDocument command creates an object capable of holding arbitrary text. This element can be used to write general information or documentation about the model.

Usage

  1. Select the Tools → Add text document option from the menu.
  2. Double-click the newly created object in the tree view to open a tab in which to write text.
  3. Add text.
  4. Close the tab and save the file when asked.

Properties

View

Editor

  • ViewFont Name (Font): a font name, for example, Ubuntu Mono.
  • ViewFont Size (Float): a font size in points, for example, 11.
  • ViewRead Only (Bool): it defaults to false. If set to true the text cannot be edited.
  • ViewSyntax Highlighter (Enumeration): it defaults to None. If set to Python, the text will be highlighted like the Python console.

Scripting

See also: FreeCAD Scripting Basics, and scripted objects.

See Part Feature for the general information on adding objects to a document.

An App::TextDocument object is created with the addObject() method of the document. Once a TextDocument exists, its textual information is stored in its Text attribute. This attribute can be used in other objects, for example, as the string in a Draft ShapeString.

import FreeCAD as App
import Draft

doc = App.newDocument()
obj = App.ActiveDocument.addObject("App::TextDocument", "Text_document")
obj.Text = "textual information"
App.ActiveDocument.recompute()

obj2 = Draft.makeShapeString(obj.Text, "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 10)
App.ActiveDocument.recompute()