Draft Line: Difference between revisions

From FreeCAD Documentation
(Link.)
(See also API, category, and code)
Line 32: Line 32:


==Scripting== <!--T:7-->
==Scripting== <!--T:7-->
{{emphasis|See also:}} [[Draft API]], and the autogenerated API documentation https://www.freecadweb.org/api

The Line tool can be used in [[macros]] and from the [[Python]] console by using the following function:
The Line tool can be used in [[macros]] and from the [[Python]] console by using the following function:
</translate>
</translate>
Line 39: Line 41:
Line = makeLine(Shape)
Line = makeLine(Shape)
}}
}}

<translate>
<translate>

<!--T:8-->
<!--T:8-->
* Creates a <code>Line</code> object between points <code>p1</code> and <code>p2</code>, each defined as a <code>FreeCAD.Vector</code>
* Creates a <code>Line</code> object between points <code>p1</code> and <code>p2</code>, each defined as a <code>FreeCAD.Vector</code>
Line 52: Line 54:
{{Code|code=
{{Code|code=
import FreeCAD, Draft
import FreeCAD, Draft

Draft.makeLine(FreeCAD.Vector(0,0,0), FreeCAD.Vector(2,0,0))
Line1 = Draft.makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(1000, 500, 0))
Line2 = Draft.makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(500, 1000, 0))
Line3 = Draft.makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(100, 1500, 0))
Line4 = Draft.makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(-500, 2000, 0))
Line5 = Draft.makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(-1000, 2500, 0))
}}
}}


See also: [[Draft API]], and the autogenerated API documentation https://www.freecadweb.org/api
{{clear}}
{{clear}}
[[Category:Draft]]

Revision as of 06:00, 5 November 2018

Draft Line

Menu location
Draft → Line
Workbenches
Draft, Arch
Default shortcut
L I
Introduced in version
-
See also
Draft Wire

Description

The Line tool creates a straight line defined by two points. It uses the Draft Linestyle set on the Draft tray toolbar. The Line tool behaves exactly like the Draft Wire tool, except that it stops after two points.

How to use

  1. Press the Draft Line button, or press L then I keys
  2. Click a first point on the 3D view, or type a coordinate
  3. Click a second point on the 3D view, or type a coordinate

Options

  • Press X, Y or Z after the first point to constrain the second point on the given axis.
  • To enter coordinates manually, simply enter the numbers, then press ENTER between each X, Y and Z component.
  • Press R or click the checkbox to check/uncheck the Relative button. If relative mode is on, the coordinates of the second point are relative to the first one. If not, they are absolute, taken from the (0,0,0) origin point.
  • Press T or click the checkbox to check/uncheck the Continue button. If continue mode is on, the Line tool will restart after you give the second point, allowing you to draw another line segment without pressing the Line button again.
  • Press CTRL while drawing to force snapping your point to the nearest snap location, independently of the distance.
  • Press SHIFT while drawing to constrain your second point horizontally or vertically in relation to the first one.
  • Press CTRL+Z or press the Undo button to undo the last point.
  • Press ESC or the Cancel button to abort the current Line command.
  • If several connected Draft Lines are selected they can be transformed into a wire by pressing the Draft Upgrade button.

Properties

  • DataStart: The start point
  • DataEnd: The end point
  • DataSubdivisions: Divides the line with the given number of subdivisions introduced in version 0.16

Scripting

See also: Draft API, and the autogenerated API documentation https://www.freecadweb.org/api

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

Line = makeLine(p1, p2)
Line = makeLine(LineSegment)
Line = makeLine(Shape)
  • Creates a Line object between points p1 and p2, each defined as a FreeCAD.Vector
  • Creates a Line object from a Part.LineSegment
  • Creates a Line object from the first vertex to the last vertex of the given Shape
  • The current Draft Linestyle will be used

Example:

import FreeCAD, Draft

Line1 = Draft.makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(1000, 500, 0))
Line2 = Draft.makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(500, 1000, 0))
Line3 = Draft.makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(100, 1500, 0))
Line4 = Draft.makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(-500, 2000, 0))
Line5 = Draft.makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(-1000, 2500, 0))