Draft BezCurve: Difference between revisions

From FreeCAD Documentation
(Data and View sections)
(Code more complete)
Line 64: Line 64:
==Scripting== <!--T:8-->
==Scripting== <!--T:8-->


{{emphasis|See also:}} [[FreeCAD Scripting Basics]], [[Draft API]], and the [https://www.freecadweb.org/api autogenerated API documentation].


<!--T:9-->
<!--T:9-->
The BezCurve tool can by used in [[macros]] and from the python console by using the following function:
The BezCurve tool can be used in [[macros]] and from the [[Python]] console by using the following function:
</translate>
</translate>
{{Code|code=
{{Code|code=
makeBezCurve(pointslist,[closed],[placement],[support],[degree])
BezCurve = makeBezCurve(pointslist, closed=False, placement=None, face=None, support=None, Degree=None)
BezCurve = makeBezCurve(Part.Wire, closed=False, placement=None, face=None, support=None, Degree=None)
}}
}}
<translate>
<translate>
<!--T:10-->
<!--T:10-->
* Create a Bezier Curve object from the given list of vectors. Instead of a pointslist, you can also pass a Part Wire.
* Creates a {{incode|BezCurve}} object with the given list of points, {{incode|pointslist}}.
** Each point in the list is defined by its {{incode|FreeCAD.Vector}}, with units in millimeters.
** Alternatively, the input can be a {{incode|Part.Wire}}, from which points are extracted.
* If {{incode|closed}} is {{incode|True}}, or if the first and last points are identical, the curve is closed.
* If a {{incode|placement}} is given, it is used; otherwise the shape is created at the origin.
* If {{incode|face}} is {{incode|True}}, and the wire is closed, the wire will make a face, that is, it will appear filled.


Example:
</translate>
</translate>
Example:
{{Code|code=
{{Code|code=
import FreeCAD,Draft
import FreeCAD, Draft

myFeature = Draft.makeBezCurve(Draft.makeBezCurve(points,False)
p1 = FreeCAD.Vector(0, 0, 0)
p2 = FreeCAD.Vector(1000, 1000, 0)
p3 = FreeCAD.Vector(2000, 0, 0)
p4 = FreeCAD.Vector(1500, -2000, 0)

BezCurve1 = Draft.makeBezCurve([p1, p2, p3, p4], closed=True)
BezCurve2 = Draft.makeBezCurve([p4, 1.3*p2, p1, 4.1*p3], closed=True)
BezCurve3 = Draft.makeBezCurve([1.7*p3, 1.5*p4, 2.1*p2, p1], closed=True)
}}
}}
<translate>
<translate>

==Contraining Nodes== <!--T:13-->
==Contraining Nodes== <!--T:13-->
The segment endpoints in a piecewise Bezier Curve can be constrained such that adjacent control points are tangent or symmetric to the segments at the endpoint. This is done after object creation using {{KEY|[[Image:Draft Edit.png|16px]] [[Draft Edit]]}}.
The segment endpoints in a piecewise Bezier Curve can be constrained such that adjacent control points are tangent or symmetric to the segments at the endpoint. This is done after object creation using {{KEY|[[Image:Draft Edit.png|16px]] [[Draft Edit]]}}.

Revision as of 16:53, 9 November 2018

Draft BezCurve

Menu location
Draft → BezCurve
Workbenches
Draft, Arch
Default shortcut
B Z
Introduced in version
0.14
See also
None

Description

The BezCurve tool creates a Bezier Curve, or a piecewise Bezier curve, from several points in the current work plane. It uses the Draft Linestyle set on the Draft Tray.

How to use

  1. Press the Draft BezCurve button, or press B then Z keys.
  2. Click a first point on the 3D view, or type a coordinate and press the add point button.
  3. Click additional points on the 3D view, or type a coordinate and press the add point button.
  4. Press Esc or the Close button, or double-click the last point to complete the edition.

The object is created as a single Bezier curve of degree number_of_points - 1.

The curve can be transformed to a piecewise wire made of curves of a specified degree by changing its properties.

The control points of the Bezier curve can be edited by double clicking on the element in the tree view, or by pressing the Draft Edit button.

Options

  • Press A or the Finish button to finish the curve, leaving it open.
  • Press O or the Close button to close the curve, that is, a segment will be added from the last point to the first one to form a face. At least four points, a curve of degree three, are required to form a face.
  • Press W or the Wipe button to remove the curve segments already placed, but keep editing the curve from the last point.
  • Press U or the Set WP button to adjust the current working plane in the orientation of the last point.
  • Press X, Y or Z after a point to constrain the next 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 toggle relative mode. If relative mode is on, the coordinates of the next point are relative to the last one; if not, they are absolute, taken from the origin (0,0,0).
  • Press T or click the checkbox to toggle continue mode. If continue mode is on, the BezCurve tool will restart after you finish the curve, allowing you to draw another one without pressing the tool button again.
  • Press L or click the checkbox to toggle filled mode. If filled mode is on, a closed wire will create a filled face (DataMake Face true); if not, the closed wire will not make a face (DataMake Face false).
  • 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 next point horizontally or vertically in relation to the last one.
  • Press Ctrl+Z or press the Undo button to undo the last point.
  • Press Esc or the Close button to abort the current command; curve segments already placed will remain.

Properties

Data

  • DataDegree: specifies the degree of the Bezier curve or the individual segments.
  • DataClosed: specifies if the curve is closed or not. If the curve is initially open, this value is false; setting it to true will draw a segment to close the curve. If the curve is initially closed, this value is true; setting it to false will remove the last segment, and make the curve open.
  • DataMake Face: specifies if the curve makes a face or not. If it is true a face is created, otherwise only the perimeter is considered part of the object. This property only works if DataClosed is true.
  • DataContinuity: (read-only) when the curve is closed, indicates the continuity of the curve [0], or [0,0]. Otherwise it's [].

View

  • ViewArrow Size: specifies the size of the symbol displayed at the end of the curve.
  • ViewArrow Type: specifies the type of symbol displayed at the end of the curve, which can be dot, circle, arrow, and tick.
  • ViewEnd Arrow: specifies whether to show a symbol at the last point of the curve, so it can be used as an annotation line.
  • ViewPattern: specifies a Draft Pattern with which to fill the face of the closed curve. This property only works if DataMake Face is true, and if ViewDisplay Mode is "Flat Lines".
  • ViewPattern Size: specifies the size of the Draft Pattern.

Scripting

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

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

BezCurve = makeBezCurve(pointslist, closed=False, placement=None, face=None, support=None, Degree=None)
BezCurve = makeBezCurve(Part.Wire, closed=False, placement=None, face=None, support=None, Degree=None)
  • Creates a BezCurve object with the given list of points, pointslist.
    • Each point in the list is defined by its FreeCAD.Vector, with units in millimeters.
    • Alternatively, the input can be a Part.Wire, from which points are extracted.
  • If closed is True, or if the first and last points are identical, the curve is closed.
  • If a placement is given, it is used; otherwise the shape is created at the origin.
  • If face is True, and the wire is closed, the wire will make a face, that is, it will appear filled.

Example:

import FreeCAD, Draft

p1 = FreeCAD.Vector(0, 0, 0)
p2 = FreeCAD.Vector(1000, 1000, 0)
p3 = FreeCAD.Vector(2000, 0, 0)
p4 = FreeCAD.Vector(1500, -2000, 0)

BezCurve1 = Draft.makeBezCurve([p1, p2, p3, p4], closed=True)
BezCurve2 = Draft.makeBezCurve([p4, 1.3*p2, p1, 4.1*p3], closed=True)
BezCurve3 = Draft.makeBezCurve([1.7*p3, 1.5*p4, 2.1*p2, p1], closed=True)

Contraining Nodes

The segment endpoints in a piecewise Bezier Curve can be constrained such that adjacent control points are tangent or symmetric to the segments at the endpoint. This is done after object creation using Draft Edit.

  • Sharp - remove constraints
  • Tangent - force adjacent control points to be tangent
  • Symmetric - force adjacent control points to be tangent and equi-distant

Limitations

  • This tool is not available before FreeCAD version 0.14
  • The Points Property does not yet appear in the properties list.
  • OpenCascade does not support Bezier Curve with degree > 25. This should not be a problem in practice.