Draft Label

From FreeCAD Documentation
Revision as of 23:03, 9 November 2018 by Vocx (talk | contribs) (Capital letters, redaction)

Draft Label

Menu location
Draft → Label
Workbenches
Draft, Arch
Default shortcut
D L
Introduced in version
0.17
See also
Draft Text, Draft ShapeString

Description

The Label tool inserts a piece of text with a 2-segment leader line and an arrow. If an object or a sub-element (face, edge or vertex) is selected when starting the command, the Label can be made to display a certain attribute of the selected element, including, position, length, area, volume, and material.

To insert a simpler text element without an arrow use Draft Text. To create solid text shapes use Draft ShapeString with Part Extrude.

How to use

  1. Press the Draft Label button, or press D then L keys.
  2. Click a first point on the 3D view, or type a coordinate and press the add point button. This point indicates the target (arrow head). This can be anywhere, it doesn't need to be an element.
  3. Click a second point on the 3D view, or type a coordinate and press the add point button. This point indicates the start of a horizontal or vertical leader.
  4. Click a third point on the 3D view, or type a coordinate and press the add point button. This point indicates the base point of the text.

Note: the direction of the horizontal straight segment, to the right or to the left, will automatically align the text to the opposite direction. If the leader goes vertically up, the text is aligned to the left; if it goes vertically down, it is aligned to the right.

Note 2: by pre-selecting an object, or a sub-element (vertex, edge or face), before pressing the tool button, the label will become parametric, that is, it will remember which object it is bound to, and it will be able to display a particular attribute of that object. If the attributes of the object change later on, the label will adjust the displayed information.

Options

  • Click on Label type to select the type of information to display, including "Custom", "Name", "Label", "Position", "Length", "Area", "Volume", "Tag", and "Material".
  • To enter coordinates manually, simply enter the numbers, then press Enter between each X, Y and Z component.
  • Press Ctrl to force snapping your point to the nearest snap location, independently of the distance.
  • Press Esc or the Close button to abort the current command.

Properties

Data

  • DataLabel Type: specifies the type of information shown by this label (see below).
  • DataCustom Text: specifies the text block to display when DataLabel Type is set to "Custom", or the label is not parametric. The text is given as a list of strings; each element on the list, separated by a comma, indicates a new line of text.
  • DataText: (read-only) indicates the actual text displayed by the label, depending on the DataLabel Type.
  • DataTarget Point: specifies the position of the tip of the lead.
  • DataStraight Direction: specifies the direction of the straight segment of the lead, either horizontal or vertical.
  • DataStraight Distance: specifies the length of the straight segment of the lead, starting from the base point of the text. If the distance is positive, the lead starts from the right side of the text, and the text aligns to the right; otherwise, the lead starts from the left side of the text, and the text aligns to the left.
  • DataPosition: specifies the base point of the first line of the text block; it also influences how the lead is drawn.
  • DataAngle: specifies the rotation of the baseline of the first line of the text block; it also influences how the lead is drawn, as it will no longer be horizontal or vertical.
  • DataAxis: specifies the axis to use for the rotation.

Label types

  • Custom: displays the contents of DataCustom Text.
  • Name: displays the internal name of the target object; the internal name is assigned to the object at its creation time, and remains fixed throughout the existence of the object.
  • Label: displays the label of the target object; the label of the object can be changed by the user at any time.
  • Position: displays the coordinates of the base point of the target object, of the target vertex, or of the center of mass of the target sub-element, if applicable.
  • Length: displays the length of the target sub-element, if applicable.
  • Area: displays the area of the target sub-element, if applicable.
  • Volume: displays the volume of the target object, if applicable.
  • Tag: displays the tag attribute of the target object, if the object has such property, for example, objects created with the Arch Workbench.
  • Material: displays the label of the material of the target object, if the target object has such property

View

  • ViewText Font: specifies the font to use to draw the text. It can be a font name, such as "Arial", a default style such as "sans", "serif" or "mono", a family such as "Arial,Helvetica,sans" or a name with a style such as "Arial:Bold". If the given font is not found on the system, a generic one is used instead.
  • ViewText Size: specifies the size of the text. If the label object is created in the tree view but no text is visible, increase the size of the text until it is visible.
  • ViewText Alignment: specifies the vertical alignment of the baseline of the text with respect to the lead. It can be top, middle or bottom.
  • ViewText Color: specifies the color of the text in an RGB tuple (R, G, B).
  • ViewLine Width: specifies the width of the lead line.
  • ViewLine Color: specifies the color of the lead line.
  • ViewArrow Size: specifies the size of the symbol displayed at the tip of the lead.
  • ViewArrow Type: specifies the type of symbol displayed at the tip of the lead, which can be dot, circle, arrow, or tick.
  • ViewFrame: if it is "Rectangle" it will draw a frame around the text.
  • ViewLine: if it is true the lead line will be displayed; otherwise only the text and the symbol at the tip will be displayed.
  • ViewDisplay Mode: if it is "3D text" the text will be aligned to the scene axes, initially lying on the XY plane; if it is "2D text" the text will always face the camera.

Scripting

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

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

Label = makeLabel(targetpoint=None, target=None, direction=None, distance=None, labeltype=None, placement=None)
  • Creates a Label object, with the leader pointing to targetpoint, using the target which must be a DocumentObject (or a SelectionObject? unclear).
  • direction is either "Horizontal", "Vertical", or "Custom".
  • distance is the distance from the text's base point to the leader.
  • labeltype is one of "Custom", "Name", "Label", "Position", "Length", "Area", "Volume", "Tag", or "Material".
  • If a placement is given, it is used for the text's base point; otherwise the text is created at the origin.

Change the custom text by overwriting the CustomText attribute. A list of strings can be passed; each element will be displayed in its own row.

The view properties of Label can be changed by overwriting its attributes; for example, overwrite ViewObject.TextSize with the size of the text in millimeters.

Example:

import FreeCAD, Draft

Rectangle = Draft.makeRectangle(4000, 1000)

p1 = FreeCAD.Vector(-200, 1000, 0)
place1 = FreeCAD.Placement(FreeCAD.Vector(-1000, 1300, 0), FreeCAD.Rotation())

Label1 = Draft.makeLabel(p1, Rectangle, "Horizontal", 500, "Label", place1)
Label1.ViewObject.TextSize = 200

p2 = FreeCAD.Vector(-200, 0, 0)
place2 = FreeCAD.Placement(FreeCAD.Vector(-1000, -300, 0), FreeCAD.Rotation())

Label2 = Draft.makeLabel(p2, Rectangle, "Horizontal", 500, "Custom", place2)
Label2.CustomText = ["Build of a", "good material"]
Label2.ViewObject.TextSize = 200
FreeCAD.ActiveDocument.recompute()

p3 = FreeCAD.Vector(1000, 1200, 0)
place3 = FreeCAD.Placement(FreeCAD.Vector(2000, 1800, 0), FreeCAD.Rotation())
Label3 = Draft.makeLabel(p3, Rectangle, "Horizontal", -500, "Area", place3)
Label3.ViewObject.TextSize = 200
FreeCAD.ActiveDocument.recompute()