Difference between revisions of "Draft ShapeString"

From FreeCAD Documentation
Jump to navigation Jump to search
(Code with Placement.)
(Version 0.14)
Line 8: Line 8:
|Shortcut=S S
|Shortcut=S S
|SeeAlso=[[Draft Text|Draft Text]], [[Part Extrude|Part Extrude]]
|SeeAlso=[[Draft Text|Draft Text]], [[Part Extrude|Part Extrude]]
==Description== <!--T:1-->
==Description== <!--T:1-->

Revision as of 05:09, 9 November 2018

Other languages:
Deutsch • ‎English • ‎Türkçe • ‎español • ‎français • ‎italiano • ‎polski • ‎română • ‎svenska • ‎čeština • ‎русский

Draft ShapeString.svg Draft ShapeString

Menu location
Draft → Shape from text ...
Draft, Arch
Default shortcut
Introduced in version
See also
Draft Text, Part Extrude


The ShapeString tool inserts a compound shape that represents a text string. Text height, tracking and font can be specified. The resulting shape can be used with the Part Extrude tool to create 3D letters.

The Draft Text tool is a simpler alternative that does not produce a closed shape.

Draft ShapeString Example400.png

How to use

  1. Press the Draft ShapeString16.png Draft ShapeString button, or press S then S keys.
  2. Click a point on the 3D view, or type a coordinate and press the Draft AddPoint.svg add point button.
  3. Enter the desired text, and press Enter.
  4. Enter the desired size, and press Enter.
  5. Enter the desired tracking, and press Enter.
  6. Press Enter to accept the displayed font file, or press ... to select a font file.


The text, size, tracking, and font can be changed after creation, by modifying the shape properties.

Set the default font file in Draft Preferences, in the Texts and dimensions tab. Supported fonts include TrueType (.ttf), OpenType (.otf), and Type 1 (.pfb).


  • Very small text heights may result in deformed character shapes due to loss of detail in scaling.
  • The current version is limited to left-to-right writing.
  • To create text arranged in a circular fashion use the FCCircularTextButtom.png Circular Text macro.


  • To enter coordinates manually, simply enter the numbers, then press Enter between each X, Y and Z component.
  • Press Esc or the Close button to abort the current command.


  • DataPosition: specifies the position of the base point of the compound shape.
  • DataAngle: specifies the rotation of the baseline of the shape.
  • DataAxis: specifies the axis to use for the rotation.
  • DataString: specifies the text string to display; unlike the Draft Text tool, the Draft ShapeString can only display a single line.
  • DataSize: specifies the general height of the letters.
  • DataTracking: specifies the additional inter-character spacing in the string.
  • DataFont File: specifies the full path of the font file used to draw the string.


See also: FreeCAD Scripting Basics, Draft API, and the autogenerated API documentation.

The ShapeString tool can be used in macros and from the Python console by using the following function:

ShapeString = makeShapeString(String, FontFile, Size=100, Tracking=0)
  • Creates a ShapeString compound shape using the specified String and the full path of a supported FontFile.
  • Size is the height of the resulting text in millimeters.
  • Tracking is the additional inter-character spacing in millimeters.

The placement of the ShapeString can be changed by overwriting its Placement attribute, or by individually overwriting its Placement.Base and Placement.Rotation attributes.


import FreeCAD, Draft

font1 = "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf"
font2 = "/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf"
font3 = "/usr/share/fonts/truetype/freefont/FreeSerifItalic.ttf"

S1 = Draft.makeShapeString("This is a sample text", font1, 200)

S2 = Draft.makeShapeString("Inclined text", font2, 200, 10)

ZAxis = FreeCAD.Vector(0, 0, 1)
p2 = FreeCAD.Vector(-1000, 500, 0)
place2 = FreeCAD.Placement(p2, FreeCAD.Rotation(ZAxis, 45))

S2.Placement = place2

S3 = Draft.makeShapeString("Upside-down text", font3, 200, 10)

S3.Placement.Base = FreeCAD.Vector(0, -1000, 0)
S3.Placement.Rotation = FreeCAD.Rotation(ZAxis, 180)