Draft CubicBezCurve

From FreeCAD Documentation
Revision as of 21:09, 12 September 2019 by Vocx (talk | contribs) (More information.)
Jump to: navigation, search
Other languages:
English • ‎français • ‎italiano

This documentation is not finished. Please help and contribute documentation.

Gui Command explains how tools should be documented. See Draft ShapeString for an example of a well documented tool. Browse Category:UnfinishedDocu to see incomplete pages like this one. See Category:Command Reference for all commands.

See WikiPages to learn about editing the wiki pages, and go to Help FreeCAD to learn about other ways in which you can contribute.

Arrow-left.svg Previous: Draft BezCurve.svg BezCurve
Next: Label Draft Label.svg Arrow-right.svg


Draft CubicBezCurve.svg Draft CubicBezCurve

Menu location
Draft → Bezier tools → CubicBezCurve
Workbenches
Draft, Arch
Default shortcut
None
Introduced in version
0.19
See also
Draft Wire, Draft BSpline, Draft BezCurve


Description

The CubicBezCurve tool creates a Bezier Curve of third degree. This is one of the most commonly used Bezier curves. This tool allows you to create a big spline made of several 3rd-degree Bezier segments, in a way that is similar to the Bezier tool in Inkscape. A Bezier curve of any degree can be created with Draft BezCurve.

The Draft BezCurve and the Draft CubicBezCurve tools use control points to define the direction of the curve; on the other hand the Draft BSpline tool specifies the exact points through which the curve will go.

Cub bez curve.png

Cubic Bezier curve defined by three control points


How to use

  1. Press the Draft CubicBezCurve.svg Draft CubicBezCurve button.
  2. Click a first point on the 3D view, and hold the mouse pointer.
  3. Drag the pointer to another point on the 3D view, and release the pointer.
  4. Move the pointer to another point on the 3D view to adjust the curvature of the spline, and click and hold on the point.
  5. Move the pointer to another point on the 3D view to adjust the final curvature of the spline, and then release the pointer. This creates a Bezier curve of 3rd degree, and continues drawing from the last point.
  6. Repeat the process of clicking, holding, dragging, and releasing to add points, and create further 3rd-degree Bezier segments.
  7. Press Esc or the Close button, to complete the edition.

Options

Properties

Data

View

Scripting

See also: Draft API and FreeCAD Scripting Basics.

See Draft BezCurve for the general information information. A cubic Bezier is created by passing the option degree=3 to makeBezCurve().

For each cubic Bezier segment four points must be used, of which the two intermediate points are the control points.

  • If only 3 points are given, it creates a quadratic Bezier instead.
  • If only 2 points are given, it creates a linear Bezier, that is, a straight line.
  • If 5 points are given, the first 4 create a cubic Bezier segment; the fourth and the fifth points are used to create a straight line.
  • If 6 points are given, the first 4 create a cubic Bezier segment; the fourth and the other two points are used to create a quadratic Bezier segment.
  • If 7 points are given, the first 4 create a cubic Bezier segment; the fourth and the other three are used to create a second cubic Bezier segment.
  • That is, whenever possible, the last point in a cubic Bezier is shared withe following points.

Example:

import FreeCAD as App
import Draft

p1 = App.Vector(-3500, 0, 0)
p2 = App.Vector(-3000, 2000, 0)
p3 = App.Vector(-1100, 2000, 0)
p4 = App.Vector(0, 0, 0)

p5 = App.Vector(1500, -2000, 0)
p6 = App.Vector(3000, -1500, 0)
p7 = App.Vector(5000, 0, 0)
rot = App.Rotation()

Draft.makeCircle(100, placement=App.Placement(p1, rot), face=False)
Draft.makeCircle(50, placement=App.Placement(p2, rot), face=True)
Draft.makeCircle(50, placement=App.Placement(p3, rot), face=True)
Draft.makeCircle(100, placement=App.Placement(p4, rot), face=False)
Draft.makeCircle(50, placement=App.Placement(p5, rot), face=True)
Draft.makeCircle(50, placement=App.Placement(p6, rot), face=True)
Draft.makeCircle(100, placement=App.Placement(p7, rot), face=False)

B1 = Draft.makeBezCurve([p1, p2], degree=3)
B1.ViewObject.DrawStyle = "Dashed"

B2 = Draft.makeBezCurve([p1, p2, p3], degree=3)
B1.ViewObject.DrawStyle = "Dotted"

B = Draft.makeBezCurve([p1, p2, p3, p4], degree=3)
B3 = Draft.makeBezCurve([p1, p2, p3, p4, p5, p6, p7], degree=3)
App.ActiveDocument.recompute()
Arrow-left.svg Previous: Draft BezCurve.svg BezCurve
Next: Label Draft Label.svg Arrow-right.svg