Difference between revisions of "Draft ShapeString"

From FreeCAD Documentation
Jump to navigation Jump to search
(More information for the properties)
(Marked this version for translation)
 
(70 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
<languages/>
 
<languages/>
 
<translate>
 
<translate>
 +
 +
<!--T:24-->
 +
{{Docnav
 +
|[[Draft_Facebinder|Facebinder]]
 +
|[[Draft_Text|Text]]
 +
|[[Draft_Module|Draft]]
 +
|IconL=Draft_Facebinder.svg
 +
|IconR=Draft_Text.svg
 +
|IconC=Workbench_Draft.svg
 +
}}
 +
 
<!--T:13-->
 
<!--T:13-->
{{GuiCommand|Name=Draft ShapeString|Workbenches=[[Draft Module|Draft]], [[Arch Module|Arch]]|MenuLocation=Draft → Shape from text ...|Shortcut=S S|SeeAlso=[[Draft Text|Draft Text]], [[Part Extrude|Part Extrude]]}}
+
{{GuiCommand
 +
|Name=Draft ShapeString
 +
|MenuLocation=Drafting → Shape from text
 +
|Workbenches=[[Draft_Module|Draft]], [[Arch_Module|Arch]]
 +
|Shortcut={{KEY|S}} {{KEY|S}}
 +
|Version=0.14
 +
|SeeAlso=[[Draft_Text|Draft Text]], [[Draft_Label|Draft Label]], [[Part_Extrude|Part Extrude]]
 +
}}
  
 
==Description== <!--T:1-->
 
==Description== <!--T:1-->
  
 
<!--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 [[Image:Draft_ShapeString.svg|24px]] [[Draft_ShapeString|Draft ShapeString]] command creates a compound shape that represents a text string. This shape can be used to create 3D letters with the [[Part_Extrude|Part Extrude]] command.
The resulting shape can be used with the [[Part Extrude]] tool to create 3D letters.
 
  
 
<!--T:19-->
 
<!--T:19-->
The [[Draft Text]] tool is a simpler alternative that does not produce a closed shape.
+
The Draft ShapeString command is not intended for standard text annotations. The [[Draft_Text|Draft Text]] command or the [[Draft_Label|Draft Label]] command should be used for that purpose.
  
 +
</translate>
 +
[[Image:Draft_ShapeString_Example400.png]]
 +
<translate>
 
<!--T:14-->
 
<!--T:14-->
[[Image:Draft_ShapeString_Example400.png]]
+
{{Caption|Single point required to position the ShapeString}}
 +
 
 +
==Usage== <!--T:3-->
 +
 
 +
<!--T:27-->
 +
# There are several ways to invoke the command:
 +
#* Press the {{Button|[[Image:Draft_ShapeString.svg|16px]] [[Draft_ShapeString|Draft ShapeString]]}} button.
 +
#* Select the {{MenuCommand|Drafting → [[Image:Draft_ShapeString.svg|16px]] Shape from text}} option from the menu.
 +
#* Use the keyboard shortcut: {{KEY|S}} then {{KEY|S}}.
 +
# The {{MenuCommand|ShapeString}} task panel opens.
 +
# Click a point in the [[3D_view|3D view]], or type [[Draft_Coordinates|coordinates]].
 +
# Optionally press the {{Button|Reset Point}} button to reset the point to the origin.
 +
# Enter a {{MenuCommand|String}}.
 +
# Specify the {{MenuCommand|Height}}.
 +
# To select a font do one of the following:
 +
#* Enter a file path in the {{MenuCommand|Font file}} input box.
 +
#* Press the {{Button|...}} button and select a file.
 +
# Press the {{Button|OK}} button to finish the command.
 +
 
 +
==Options== <!--T:5-->
 +
 
 +
<!--T:6-->
 +
* Press {{KEY|Esc}} or the {{Button|Close}} button to abort the command.
  
==How to use== <!--T:3-->
+
==Preferences== <!--T:31-->
  
<!--T:4-->
+
<!--T:32-->
# Press the {{Button|[[Image:Draft_ShapeString16.png]] [[Draft_ShapeString|Draft ShapeString]]}} button, or press {{KEY|S}} then {{KEY|S}} keys.
+
* The default font file can be changed in the preferences: {{MenuCommand|Edit → Preferences... Draft → Texts and dimensions → Default ShapeString font file}}. See [[Draft_Preferences|Draft Preferences]].
# Click a point on the 3D view, or type a [[Draft_Coordinates|coordinate]] and press the {{Button|[[Image:Draft_AddPoint.svg|16px]] [[Draft_AddPoint|add point]]}} button.
 
# Enter the desired text, and press {{KEY|Enter}}.
 
# Enter the desired size, and press {{KEY|Enter}}.
 
# Enter the desired tracking, and press {{KEY|Enter}}.
 
# Press {{KEY|Enter}} to accept the displayed font file, or press {{Button|...}} to select a font file.
 
  
The text, size, tracking, and font can be changed after creation, by modifying the shape properties.
+
==Notes== <!--T:33-->
  
Set the default font file in [[Draft Preferences]], in the {{Button|Texts and dimensions}} tab.
+
<!--T:12-->
 +
* Supported fonts include TrueType ({{FileName|.ttf}}), OpenType ({{FileName|.otf}}) and Type 1 ({{FileName|.pfb}}).
 +
* The command is restricted to left-to-right text.
 +
* Very small text heights may result in deformed character shapes due to loss of detail in scaling.
 +
* Many fonts will generate problematic geometry. 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 wires used to define faces.
 +
* Draft ShapeStrings can also be created with the [[Macro_Fonts_Win10_PYMP|Macro Fonts Win10 PYMP]].
 +
* To create Draft ShapeStrings arranged in a circular fashion use the [[Macro_FCCircularText|Macro FCCircularText]].
  
==Options== <!--T:5-->
+
==Tutorials== <!--T:18-->
  
<!--T:6-->
+
<!--T:28-->
* To enter coordinates manually, simply enter the numbers, then press {{KEY|Enter}} between each X, Y and Z component.
+
* [[Draft_ShapeString_tutorial|Draft ShapeString tutorial]]: extrude a ShapeString, position it in 3D space, and create an engraving in another body.
* Press {{KEY|Esc}} or the {{button|Close}} button to abort the current command.
+
* [https://forum.freecadweb.org/viewtopic.php?f=3&t=36623 How to use ShapeStrings in PartDesign]
  
 
==Properties== <!--T:7-->
 
==Properties== <!--T:7-->
 +
 +
<!--T:34-->
 +
See also: [[property_editor|Property editor]].
 +
 +
<!--T:35-->
 +
A Draft ShapeString object is derived from a [[Part_Part2DObject|Part Part2DObject]] and inherits all its properties. It also has the following additional properties:
 +
 +
===Data=== <!--T:36-->
 +
 +
<!--T:37-->
 +
{{TitleProperty|Draft}}
  
 
<!--T:8-->
 
<!--T:8-->
* {{PropertyData|Position}}: specifies the position of the base point of the compound shape.
+
* {{PropertyData|Font File|File}}: specifies the path of the font file used to draw the text.
* {{PropertyData|Angle}}: specifies the rotation of the baseline of the shape.
+
* {{PropertyData|Size|Length}}: specifies the general height of the text.
* {{PropertyData|Axis}}: specifies the axis to use for the rotation.
+
* {{PropertyData|String|String}}: specifies the text string to display. Unlike a [[Draft_Text|Draft Text]], a Draft ShapeString can only display a single text line.
* {{PropertyData|String}}: specifies the text string to display; unlike the [[Draft Text]] tool, the [[Draft ShapeString]] can only display a single line.
+
* {{PropertyData|Tracking|Length}}: specifies the additional inter-character spacing of the text.
* {{PropertyData|Size}}: specifies the general height of the letters.
+
 
* {{PropertyData|Tracking}}: specifies the additional inter-character spacing in the string.
+
===View=== <!--T:38-->
* {{PropertyData|Font File}}: specifies the full path of the font file used to draw the string.
+
 
 +
<!--T:39-->
 +
{{TitleProperty|Draft}}
 +
 
 +
<!--T:40-->
 +
* {{PropertyView|Pattern|Enumeration}}: specifies the [[Draft_Pattern|Draft Pattern]] with which to fill the faces of the text. This property only works if {{PropertyView|Display Mode}} is {{value|Flat Lines}}.
 +
* {{PropertyView|Pattern Size|Float}}: specifies the size of the [[Draft_Pattern|Draft Pattern]].
 +
 
 +
==Scripting== <!--T:41-->
  
==Scripting== <!--T:9-->
+
<!--T:9-->
 +
See also: [https://www.freecadweb.org/api Autogenerated API documentation] 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:
+
To create a Draft ShapeString use the {{incode|make_shapestring}} method ({{Version|0.19}}) of the Draft module. This method replaces the deprecated {{incode|makeShapeString}} method.
 +
 
 
</translate>
 
</translate>
 
 
{{Code|code=
 
{{Code|code=
ShapeString = makeShapeString(String, FontFile, Size=100, Tracking=0)
+
shapestring = make_shapestring(String, FontFile, Size=100, Tracking=0)
 
}}
 
}}
 
<translate>
 
<translate>
 +
 
<!--T:15-->
 
<!--T:15-->
* Creates a <code>ShapeString</code> compound shape using the specified <code>String</code>
+
* Creates a {{incode|shapestring}} compound shape using the specified {{incode|String}} and the full path of a supported {{incode|FontFile}}.
* <code>FontFile</code> is mandatory and must be the full path of a supported font file
+
* {{incode|Size}} is the height of the resulting text in millimeters.
* <code>Size</code> is the height of the resulting text in millimeters
+
* {{incode|Tracking}} is the additional inter-character spacing in millimeters.
* <code>Tracking</code> is the additional inter-character spacing in millimeters
+
 
 +
<!--T:22-->
 +
The placement of the ShapeString can be changed by overwriting its {{incode|Placement}} attribute, or by individually overwriting its {{incode|Placement.Base}} and {{incode|Placement.Rotation}} attributes.
  
 
<!--T:11-->
 
<!--T:11-->
Example: </translate>
+
Example:
 +
 
 +
</translate>
 
{{Code|code=
 
{{Code|code=
import FreeCAD, Draft
+
import FreeCAD as App
Draft.makeShapeString("This is a sample text",
+
import Draft
                      "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf",
+
 
                      200.0, 10)
+
doc = App.newDocument()
 +
 
 +
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.make_shapestring("This is a sample text", font1, 200)
 +
 
 +
S2 = Draft.make_shapestring("Inclined text", font2, 200, 10)
 +
 
 +
zaxis = App.Vector(0, 0, 1)
 +
p2 = App.Vector(-1000, 500, 0)
 +
place2 = App.Placement(p2, App.Rotation(zaxis, 45))
 +
S2.Placement = place2
 +
 
 +
S3 = Draft.make_shapestring("Upside-down text", font3, 200, 10)
 +
S3.Placement.Base = App.Vector(0, -1000, 0)
 +
S3.Placement.Rotation = App.Rotation(zaxis, 180)
 +
 
 +
doc.recompute()
 
}}
 
}}
 
<translate>
 
<translate>
  
==Selecting A Font== <!--T:16-->
 
[[Image:SSFontSelect.png]]
 
  
<!--T:17-->
+
<!--T:23-->
ShapeString uses the internal geometry of a font to make FreeCAD shapes.  To do this it must read the actual font file (*.tff, etc).  If the Font Selection box is empty, you must type the full path to the font file or use {{KEY|...}} to select a font file.
+
{{Docnav
 
+
|[[Draft_Facebinder|Facebinder]]
==Limitations== <!--T:12-->
+
|[[Draft_Text|Text]]
* This tool is not available in FreeCAD versions anterior to 0.14
+
|[[Draft_Module|Draft]]
* TrueType(*.ttf), OpenType(*.otf) and Type1(*.pfb) font files are supported.
+
|IconL=Draft_Facebinder.svg
* Very small text heights may result in deformed character glyphs due to loss of detail in scaling. 
+
|IconR=Draft_Text.svg
* The current version is limited to left-to-right layouts on a horizontal baseline.
+
|IconC=Workbench_Draft.svg
* For creating curved text you can use the macro [[File:FCCircularTextButtom.png|24px]][[Macro_Circular Text|Circular Text]]
+
}}
 
 
==Tutorials== <!--T:18-->
 
* [[Draft_ShapeString_tutorial|Draft ShapeString tutorial]]
 
  
{{Draft Tools navi}}
 
{{Userdocnavi}}
 
 
</translate>
 
</translate>
 +
{{Draft Tools navi{{#translation:}}}}
 +
{{Userdocnavi{{#translation:}}}}

Latest revision as of 11:22, 4 May 2021

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

Draft ShapeString.svg Draft ShapeString

Menu location
Drafting → Shape from text
Workbenches
Draft, Arch
Default shortcut
S S
Introduced in version
0.14
See also
Draft Text, Draft Label, Part Extrude

Description

The Draft ShapeString.svg Draft ShapeString command creates a compound shape that represents a text string. This shape can be used to create 3D letters with the Part Extrude command.

The Draft ShapeString command is not intended for standard text annotations. The Draft Text command or the Draft Label command should be used for that purpose.

Draft ShapeString Example400.png

Single point required to position the ShapeString

Usage

  1. There are several ways to invoke the command:
    • Press the Draft ShapeString.svg Draft ShapeString button.
    • Select the Drafting → Draft ShapeString.svg Shape from text option from the menu.
    • Use the keyboard shortcut: S then S.
  2. The ShapeString task panel opens.
  3. Click a point in the 3D view, or type coordinates.
  4. Optionally press the Reset Point button to reset the point to the origin.
  5. Enter a String.
  6. Specify the Height.
  7. To select a font do one of the following:
    • Enter a file path in the Font file input box.
    • Press the ... button and select a file.
  8. Press the OK button to finish the command.

Options

  • Press Esc or the Close button to abort the command.

Preferences

  • The default font file can be changed in the preferences: Edit → Preferences... → Draft → Texts and dimensions → Default ShapeString font file. See Draft Preferences.

Notes

  • Supported fonts include TrueType (.ttf), OpenType (.otf) and Type 1 (.pfb).
  • The command is restricted to left-to-right text.
  • Very small text heights may result in deformed character shapes due to loss of detail in scaling.
  • Many fonts will generate problematic geometry. 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 wires used to define faces.
  • Draft ShapeStrings can also be created with the Macro Fonts Win10 PYMP.
  • To create Draft ShapeStrings arranged in a circular fashion use the Macro FCCircularText.

Tutorials

Properties

See also: Property editor.

A Draft ShapeString object is derived from a Part Part2DObject and inherits all its properties. It also has the following additional properties:

Data

Draft

  • DataFont File (File): specifies the path of the font file used to draw the text.
  • DataSize (Length): specifies the general height of the text.
  • DataString (String): specifies the text string to display. Unlike a Draft Text, a Draft ShapeString can only display a single text line.
  • DataTracking (Length): specifies the additional inter-character spacing of the text.

View

Draft

  • ViewPattern (Enumeration): specifies the Draft Pattern with which to fill the faces of the text. This property only works if ViewDisplay Mode is Flat Lines.
  • ViewPattern Size (Float): specifies the size of the Draft Pattern.

Scripting

See also: Autogenerated API documentation and FreeCAD Scripting Basics.

To create a Draft ShapeString use the make_shapestring method (introduced in version 0.19) of the Draft module. This method replaces the deprecated makeShapeString method.

shapestring = make_shapestring(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 as App
import Draft

doc = App.newDocument()

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.make_shapestring("This is a sample text", font1, 200)

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

zaxis = App.Vector(0, 0, 1)
p2 = App.Vector(-1000, 500, 0)
place2 = App.Placement(p2, App.Rotation(zaxis, 45))
S2.Placement = place2

S3 = Draft.make_shapestring("Upside-down text", font3, 200, 10)
S3.Placement.Base = App.Vector(0, -1000, 0)
S3.Placement.Rotation = App.Rotation(zaxis, 180)

doc.recompute()


Arrow-left.svg Previous: Draft Facebinder.svg Facebinder
Next: Text Draft Text.svg Arrow-right.svg