Difference between revisions of "Draft ShapeString"

From FreeCAD Documentation
Jump to: navigation, search
(Marked this version for translation)
 
(4 intermediate revisions by 3 users not shown)
Line 18: Line 18:
 
<!--T:2-->
 
<!--T:2-->
 
The ShapeString tool inserts a compound shape that represents a text string.  Text height, tracking and font can be specified.
 
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 resulting shape can be used with the [[Part Extrude|Part Extrude]] tool to create 3D letters.
  
 
<!--T:19-->
 
<!--T:19-->
To insert a simpler text element without a closed shape use [[Draft Text]]. To create a text label with a lead and an arrow use [[Draft Label]].
+
To insert a simpler text element without a closed shape use [[Draft Text|Draft Text]]. To create a text label with a lead and an arrow use [[Draft Label|Draft Label]].
  
 
</translate>
 
</translate>
Line 43: Line 43:
 
<translate>
 
<translate>
  
 +
<!--T:27-->
 
If your Draft interface mode is set to TaskView:
 
If your Draft interface mode is set to TaskView:
 
# Press the {{Button|[[Image:Draft_ShapeString16.png]] [[Draft_ShapeString|Draft ShapeString]]}} button, or press {{KEY|S}} then {{KEY|S}} keys.
 
# Press the {{Button|[[Image:Draft_ShapeString16.png]] [[Draft_ShapeString|Draft ShapeString]]}} button, or press {{KEY|S}} then {{KEY|S}} keys.
 
# A dialog will appear where you can specify your parameters.  
 
# A dialog will appear where you can specify your parameters.  
# Press OK to create the ShapeString.  
+
# Press {{KEY|OK}} to create the ShapeString.  
  
  
 
<!--T:20-->
 
<!--T:20-->
 
*The text, size, tracking, and font can be changed after creation, by modifying the values in the Property Editor.
 
*The text, size, tracking, and font can be changed after creation, by modifying the values in the Property Editor.
*You will want to set the default font file in [[Draft Preferences]], in the {{Button|Texts and dimensions}} tab. This will prefill the font file box in the dialog.
+
*You will want to set the default font file in [[Draft Preferences|Draft Preferences]], in the {{Button|Texts and dimensions}} tab. This will prefill the font file box in the dialog.
 
*Supported fonts include TrueType (.ttf), OpenType (.otf), and Type 1 (.pfb).
 
*Supported fonts include TrueType (.ttf), OpenType (.otf), and Type 1 (.pfb).
  
Line 71: Line 72:
 
* {{PropertyData|Angle}}: specifies the rotation of the baseline of the shape.
 
* {{PropertyData|Angle}}: specifies the rotation of the baseline of the shape.
 
* {{PropertyData|Axis}}: specifies the axis to use for the rotation.
 
* {{PropertyData|Axis}}: specifies the axis to use for the rotation.
* {{PropertyData|String}}: specifies the text string to display; unlike the [[Draft Text]] tool, the [[Draft ShapeString]] can only display a single line.
+
* {{PropertyData|String}}: specifies the text string to display; unlike the [[Draft Text|Draft Text]] tool, the [[Draft ShapeString|Draft ShapeString]] can only display a single line.
 
* {{PropertyData|Size}}: specifies the general height of the letters.
 
* {{PropertyData|Size}}: specifies the general height of the letters.
 
* {{PropertyData|Tracking}}: specifies the additional inter-character spacing in the string.
 
* {{PropertyData|Tracking}}: specifies the additional inter-character spacing in the string.
Line 77: Line 78:
  
 
==Scripting== <!--T:9-->
 
==Scripting== <!--T:9-->
{{Emphasis|See also:}} [[Draft API]] and [[FreeCAD Scripting Basics]].
+
{{Emphasis|See also:}} [[Draft API|Draft API]] and [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]].
  
 
<!--T:10-->
 
<!--T:10-->
The ShapeString tool can be used in [[macros]] and from the [[Python]] console by using the following function:
+
The ShapeString tool can be used in [[macros|macros]] and from the [[Python|Python]] console by using the following function:
 
</translate>
 
</translate>
 
{{Code|code=
 
{{Code|code=
Line 121: Line 122:
  
 
==Tutorials== <!--T:18-->
 
==Tutorials== <!--T:18-->
 +
 +
<!--T:28-->
 
* [[Draft_ShapeString_tutorial|Draft ShapeString tutorial]]: extrude a ShapeString, position it in 3D space, and create an engraving in another body.
 
* [[Draft_ShapeString_tutorial|Draft ShapeString tutorial]]: extrude a ShapeString, position it in 3D space, and create an engraving in another body.
 
* [https://forum.freecadweb.org/viewtopic.php?f=3&t=36623| Nice write up on using ShapeString with PartDesign]
 
* [https://forum.freecadweb.org/viewtopic.php?f=3&t=36623| Nice write up on using ShapeString with PartDesign]
 +
 +
==Notes== <!--T:29-->
 +
 +
<!--T:30-->
 +
* Many fonts will generate problematic geometric. This is because font contours are allowed to overlap, have small gaps and have varying directions within a glyph.  These conditions are considered errors in the Wires used to define Faces.  Options are to correct the font definition with a tool like FontForge or to use another font.
  
 
<!--T:23-->
 
<!--T:23-->

Latest revision as of 21:24, 6 October 2019

Other languages:
čeština • ‎Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎polski • ‎română • ‎русский • ‎svenska • ‎Türkçe
Arrow-left.svg Previous: Draft Point.svg Point
Next: Facebinder Draft Facebinder.svg Arrow-right.svg

Draft ShapeString.svg Draft ShapeString

Menu location
Draft → Shape from text ...
Workbenches
Draft, Arch
Default shortcut
S S
Introduced in version
0.14
See also
Draft Text, Part Extrude,
Macro Fonts Win10 PYMP Macro Fonts Win10 PYMP.png


Description

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.

To insert a simpler text element without a closed shape use Draft Text. To create a text label with a lead and an arrow use Draft Label.

Draft ShapeString Example400.png

Single point required to position the Shapestring


How to use

If your Draft interface mode is set to ToolBar:

  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.

SSFontSelect.png

If your Draft interface mode is set to TaskView:

  1. Press the Draft ShapeString16.png Draft ShapeString button, or press S then S keys.
  2. A dialog will appear where you can specify your parameters.
  3. Press OK to create the ShapeString.


  • The text, size, tracking, and font can be changed after creation, by modifying the values in the Property Editor.
  • You will want to set the default font file in Draft Preferences, in the Texts and dimensions tab. This will prefill the font file box in the dialog.
  • Supported fonts include TrueType (.ttf), OpenType (.otf), and Type 1 (.pfb).

Limitations

  • 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.

Options

  • To enter coordinates manually, simply enter the numbers, then press Enter between each X, Y and Z component. You can press the Draft AddPoint.svg add point button when you have the desired values to insert the point.
  • Press Esc or the Close button to abort the current command.

Properties

  • 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.

Scripting

See also: Draft API and FreeCAD Scripting Basics.

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.

Example:

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)

Tutorials

Notes

  • Many fonts will generate problematic geometric. This is because font contours are allowed to overlap, have small gaps and have varying directions within a glyph. These conditions are considered errors in the Wires used to define Faces. Options are to correct the font definition with a tool like FontForge or to use another font.
Arrow-left.svg Previous: Draft Point.svg Point
Next: Facebinder Draft Facebinder.svg Arrow-right.svg