Std TextDocument/en: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 3: Line 3:
{{GuiCommand
{{GuiCommand
|Name=Std TextDocument
|Name=Std TextDocument
|MenuLocation={{StdMenu|Tools}} → Add text document
|MenuLocation={{StdMenu|[[Std Tools Menu|Tools]]}} → Add text document
|Workbenches=All
|Workbenches=All
|Version=0.19
|Version=0.19
Line 15: Line 15:
== Usage ==
== Usage ==


# Go to the {{MenuCommand|{{StdMenu|Tools}} → Add text document}} menu
# Go to the {{MenuCommand|{{StdMenu|[[Std Tools Menu|Tools]]}} → Add text document}} menu
# Double click on the new object created in the [[tree view|tree view]] to open a tab in which to write text.
# Double click on the new object created in the [[tree view|tree view]] to open a tab in which to write text.
# Add text.
# Add text.

Revision as of 00:26, 7 February 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.

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