Draft CubicBezCurve
This documentation is not finished. Please help and contribute documentation.
GuiCommand model explains how commands should be documented. Browse Category:UnfinishedDocu to see more 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.
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 curves in computer graphics applications. 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 general 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 position and curvature of the spline; on the other hand the Draft BSpline tool specifies the exact points through which the curve will go.
Cubic Bezier curve defined by three control points
How to use
- Press the Draft CubicBezCurve button.
- Click a first point on the 3D view, and hold the mouse pointer.
- Drag the pointer to another point on the 3D view, and release the pointer.
- Move the pointer to another point on the 3D view to adjust the curvature of the spline, and click and hold on the point.
- 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.
- Repeat the process of clicking, holding, dragging, and releasing to add points, and create further 3rd-degree Bezier segments.
- 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. 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 extreme points indicate where the spline passes through, and the two intermediate points are control points.
- If only 3 points are given, it creates a quadratic Bezier instead, with only one control point.
- 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 4th and the 5th points are used to create a straight line.
- If 6 points are given, the first 4 create a cubic Bezier segment; the 4th 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 4th and the other three are used to create a second cubic Bezier segment.
- In general, the last point in a group of four is shared with the following three points to create another curve.
- To have smooth curves, with no straight segments, the number of points should be
3n + 1
or3n
, wheren
is the number of segments, forn >= 1
.
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)
p8 = App.Vector(6000, 1500, 0)
rot = App.Rotation()
c1 = Draft.makeCircle(100, placement=App.Placement(p1, rot), face=False)
c1.Label = "B1_E1"
c2 = Draft.makeCircle(50, placement=App.Placement(p2, rot), face=True)
c2.Label = "B1_c1"
c3 = Draft.makeCircle(50, placement=App.Placement(p3, rot), face=True)
c3.Label = "B1_c2"
c4 = Draft.makeCircle(100, placement=App.Placement(p4, rot), face=False)
c4.Label = "B1_E2"
c5 = Draft.makeCircle(50, placement=App.Placement(p5, rot), face=True)
c5.Label = "B2_c3"
c6 = Draft.makeCircle(50, placement=App.Placement(p6, rot), face=True)
c6.Label = "B2_c4"
c7 = Draft.makeCircle(100, placement=App.Placement(p7, rot), face=False)
c7.Label = "B2_E3"
c8 = Draft.makeCircle(50, placement=App.Placement(p8, rot), face=True)
c8.Label = "B3_c5"
App.ActiveDocument.recompute()
B1 = Draft.makeBezCurve([p1, p2], degree=3)
B1.Label = "B_lin"
B1.ViewObject.DrawStyle = "Dashed"
B2 = Draft.makeBezCurve([p1, p2, p3], degree=3)
B2.Label = "B_quad"
B2.ViewObject.DrawStyle = "Dotted"
B3 = Draft.makeBezCurve([p1, p2, p3, p4], degree=3)
B3.Label = "B_cub"
B3.ViewObject.LineWidth = 4
B4 = Draft.makeBezCurve([p1, p2, p3, p4, p5], degree=3)
B4.Label = "B_cub+lin"
B4.ViewObject.DrawStyle = "Dashed"
B5 = Draft.makeBezCurve([p1, p2, p3, p4, p5, p6], degree=3)
B5.Label = "B_cub+quad"
B5.ViewObject.DrawStyle = "Dotted"
B6 = Draft.makeBezCurve([p1, p2, p3, p4, p5, p6, p7], degree=3)
B6.Label = "B_cub+cub"
B6.ViewObject.LineWidth = 2
B7 = Draft.makeBezCurve([p1, p2, p3, p4, p5, p6, p7, p8], degree=3)
B7.Label = "B_cub+cub+lin"
B7.ViewObject.DrawStyle = "Dashed"
App.ActiveDocument.recompute()
- Drafting: Line, Polyline, Fillet, Arc, Arc by 3 points, Circle, Ellipse, Rectangle, Polygon, B-spline, Cubic Bézier curve, Bézier curve, Point, Facebinder, ShapeString, Hatch
- Annotation: Text, Dimension, Label, Annotation styles, Annotation scale
- Modification: Move, Rotate, Scale, Mirror, Offset, Trimex, Stretch, Clone, Array, Polar array, Circular array, Path array, Path link array, Point array, Point link array, Edit, Subelement highlight, Join, Split, Upgrade, Downgrade, Wire to B-spline, Draft to sketch, Set slope, Flip dimension, Shape 2D view
- Draft Tray: Select plane, Set style, Toggle construction mode, AutoGroup
- Snapping: Snap lock, Snap endpoint, Snap midpoint, Snap center, Snap angle, Snap intersection, Snap perpendicular, Snap extension, Snap parallel, Snap special, Snap near, Snap ortho, Snap grid, Snap working plane, Snap dimensions, Toggle grid
- Miscellaneous: Apply current style, Layer, Manage layers, Add a new named group, Move to group, Select group, Add to construction group, Toggle normal/wireframe display, Create working plane proxy, Heal, Show snap toolbar
- Additional: Constraining, Pattern, Preferences, Import Export Preferences, DXF/DWG, SVG, OCA, DAT
- Context menu:
- Layer container: Merge layer duplicates, Add new layer
- Layer: Activate this layer, Select layer contents
- Text: Open hyperlinks
- Wire: Flatten
- Working plane proxy: Write camera position, Write objects state
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Assembly, BIM, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub