Std TextDocument: Difference between revisions

From FreeCAD Documentation
mNo edit summary
(View properties for the text document.)
Line 23: Line 23:
# Add text.
# Add text.
# Close the tab and save the file when asked.
# Close the tab and save the file when asked.

== Properties ==

=== View ===

{{TitleProperty|Editor}}

* {{PropertyView|Font Name|Font}}: a font name provided by the system, 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 it is {{TRUE}} the text cannot be edited until this property is set to {{FALSE}}.
* {{PropertyView|Syntax Highlighter|Enumeration}}: it defaults to {{Value|None}}. If it is set to {{Value|Python}}, it will highlight the text like the [[Python_console|Python console]].


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

Revision as of 05:20, 19 March 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

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

Usage

  1. Go to the Tools → Add text document menu
  2. Double click on the new object created 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 provided by the system, for example, Ubuntu Mono.
  • ViewFont Size (Float): a font size in points, for example, 11.
  • ViewRead Only (Bool): it defaults to false. If it is true the text cannot be edited until this property is set to false.
  • ViewSyntax Highlighter (Enumeration): it defaults to None. If it is set to Python, it will highlight the text 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()