Draft CubicBezCurve/en: Difference between revisions
(Updating to match new version of source page) |
(Updating to match new version of source page) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
{{Docnav |
{{Docnav |
||
|[[ |
|[[Draft_BSpline|BSpline]] |
||
|[[ |
|[[Draft_BezCurve|BezCurve]] |
||
|[[ |
|[[Draft_Workbench|Draft]] |
||
|IconL= |
|IconL=Draft_BSpline.svg |
||
⚫ | |||
|IconC=Workbench_Draft.svg |
|IconC=Workbench_Draft.svg |
||
⚫ | |||
}} |
}} |
||
{{GuiCommand |
{{GuiCommand |
||
|Name=Draft CubicBezCurve |
|Name=Draft CubicBezCurve |
||
|MenuLocation= |
|MenuLocation=Drafting → Bézier tools → Cubic Bézier curve |
||
|Workbenches=[[ |
|Workbenches=[[Draft_Workbench|Draft]], [[Arch_Workbench|Arch]] |
||
|Version=0.19 |
|Version=0.19 |
||
|SeeAlso=[[ |
|SeeAlso=[[Draft_BezCurve|Draft BezCurve]], [[Draft_BSpline|Draft BSpline]] |
||
}} |
}} |
||
==Description== |
==Description== |
||
The |
The [[Image:Draft_CubicBezCurve.svg|24px]] '''Draft CubicBezCurve''' command creates a [http://en.wikipedia.org/wiki/Bezier_curve Bézier curve] of the third degree (four points required). |
||
The Bézier Curve is one of the most commonly used curves in computer graphics. This command allows you to create a continuous spline made up of several 3rd-degree Bézier segments, in a way that is similar to the Bézier tool in [https://inkscape.org/ Inkscape]. A general Bézier curve of any degree can be created with the [[Draft_BezCurve|Draft BezCurve]] command. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
{{Caption|Spline defined by three cubic Bezier segments. Each cubic Bezier is defined by four points, but when the tool is used graphically, only three such points are placed: 1-2-3 for the first segment, 3-4-5 for the second segment, and 5-6-7 for the third segment; the fourth point in each segment is defined implicitly; the last point 8 is necessary to finish the operation, and would be part of a fourth Bezier segment if the operation is continued.}} |
|||
⚫ | |||
{{Caption|Spline consisting of three cubic Bézier segments. The first segment is defined by four points. Subsequent segments reuse two points from the previous segment and therefore require only two additional points.}} |
|||
==Usage== |
==Usage== |
||
See also: [[Draft_Tray|Draft Tray]], [[Draft_Snap|Draft Snap]] and [[Draft_Constrain|Draft Constrain]]. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
# At this moment you already have one Bezier curve of 3rd degree. The command can be completed by pressing {{KEY|Esc}} or the {{Button|Close}} button, or you may repeat the process of clicking and holding (5), and dragging and releasing (6) to add more 3rd-degree Bezier segments. |
|||
# There are several ways to invoke the command: |
|||
Note that with this workflow you need two click-hold-release sequences to create a single Bezier curve of third degree. |
|||
⚫ | |||
* The first click-hold defines the first end point. |
|||
#* Select the {{MenuCommand|Drafting → Bézier tools → [[Image:Draft_CubicBezCurve.svg|16px]] Cubic Bézier curve}} option from the menu. |
|||
* The first release defines the first control point. |
|||
# The {{MenuCommand|Cubic Bézier curve}} task panel opens. See [[#Options|Options]] for more information. |
|||
* The second click-hold defines the second end point, and the general direction of the spline. |
|||
# It is not possible the enter points via the task panel. |
|||
# For the following [[Mouse_navigation|Mouse Navigation Models]] a keyboard key must to be held down: |
|||
* The second control point is not explicitly given, but is determined from the location of the pointer during the second release. |
|||
#* If you are using [[Mouse_navigation#OpenInventor_Navigation|OpenInventor Navigation]] the {{KEY|Ctrl}} key must be held down throughout the command. |
|||
#* If you are using [[Mouse_navigation#Gesture_Navigation|Gesture Navigation]] the {{KEY|Alt}} key must be held down for each click-hold-release sequence, but is also possible to keep this key held down throughout the command. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
# You now have one Bézier curve of the 3rd degree. |
|||
# Optionally repeat the process of clicking and holding (5), and dragging and releasing (6) to add more segments. |
|||
# Each subsequent segment will use the second endpoint and second control point of the previous segment as its first endpoint and first control point respectively. |
|||
# Press {{KEY|Esc}} or the {{Button|Close}} button to finish the command. |
|||
== |
==Options== |
||
See [[Draft_BezCurve#Options|Draft BezCurve]]. |
|||
=== Creating several Bezier segments === |
|||
* The second release also correspond to the first control point of the subsequent Bezier curve. |
|||
* This means that the second click-hold was also the first end point of the second Bezier curve. |
|||
* A third click-hold would be the second end point. |
|||
* A third release would define the final curvature of the second curve, and it would also be the first control point of a third curve. |
|||
== Notes == |
|||
This means that for every two click-hold (c-h) and release (r) sequences, the second sequence is already part of a subsequent curve segment, as indicated in the following graphic: |
|||
<pre> |
|||
|c-h -- r -- c-h -- r| 1 |
|||
|c-h -- r -- c-h -- r| 2 |
|||
|c-h -- r -- c-h -- r| 3 |
|||
|c-h -- r -- c-h -- r| 4 |
|||
</pre> |
|||
* A Draft CubicBezCurve can be edited with the [[Draft_Edit|Draft Edit]] command. |
|||
=== How to exactly place the control points === |
|||
The graphical operation of this tool only allows the user to specify the first control point of the curve when it is being drawn. The second control point can be adjusted after the object is created: double click on the curve object in tree view, or select it and press {{Button|[[File:Draft_Edit.svg|16px]] [[Draft Edit|Edit]]}}. Then drag the second control point to the desired position. |
|||
In order to choose exactly both end points and both control points, the Python command {{incode|Draft.makeBezCurve()}} must be used. See the [[#Scripting|Scripting]] section. |
|||
==Options== |
|||
See the options in [[Draft BezCurve|Draft BezCurve]]. |
|||
==Properties== |
==Properties== |
||
See |
See [[Draft_BezCurve#Properties|Draft BezCurve]]. |
||
==Scripting== |
==Scripting== |
||
See also: [https://freecad.github.io/SourceDoc/ Autogenerated API documentation] and [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]]. |
|||
See [[ |
See [[Draft_BezCurve|Draft BezCurve]] for general information. A cubic Bézier is created by passing the option <code>degree=3</code> to {{incode|makeBezCurve()}}. |
||
For each cubic |
For each cubic Bézier 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 |
* If only 3 points are given, it creates a quadratic Bézier instead, with only one control point. |
||
* If only 2 points are given, it creates a linear |
* If only 2 points are given, it creates a linear Bézier, that is, a straight line. |
||
* If 5 points are given, the first 4 create a cubic |
* If 5 points are given, the first 4 create a cubic Bézier 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 |
* If 6 points are given, the first 4 create a cubic Bézier segment; the 4th and the other two points are used to create a quadratic Bézier segment. |
||
* If 7 points are given, the first 4 create a cubic |
* If 7 points are given, the first 4 create a cubic Bézier segment; the 4th and the other three points are used to create a second cubic Bézier segment. |
||
* In general, the last point in a group of four is shared with the following three points maximum to create another |
* In general, the last point in a group of four is shared with the following three points maximum to create another Bézier segment. |
||
* To have smooth curves, with no straight segments, the number of points should be {{incode|3n + 1}} or {{incode|3n}}, where {{incode|n}} is the number of segments, for <code>n >= 1</code>. |
* To have smooth curves, with no straight segments, the number of points should be {{incode|3n + 1}} or {{incode|3n}}, where {{incode|n}} is the number of segments, for <code>n >= 1</code>. |
||
[[File:Draft_CubicBezCurve_API_example.png|600px]] |
[[File:Draft_CubicBezCurve_API_example.png|600px]] |
||
{{Caption|Examples of |
{{Caption|Examples of Bézier curves produced by using 2, 3, 4, 5, 6, 7, and 8 points. The solid lines indicate cubic Bézier segments; the other lines are quadratic or linear.}} |
||
Example: |
Example: |
||
Line 98: | Line 86: | ||
import FreeCAD as App |
import FreeCAD as App |
||
import Draft |
import Draft |
||
doc = App.newDocument() |
|||
p1 = App.Vector(-3500, 0, 0) |
p1 = App.Vector(-3500, 0, 0) |
||
Line 110: | Line 100: | ||
rot = App.Rotation() |
rot = App.Rotation() |
||
c1 = Draft. |
c1 = Draft.make_circle(100, placement=App.Placement(p1, rot), face=False) |
||
c1.Label = "B1_E1" |
c1.Label = "B1_E1" |
||
c2 = Draft. |
c2 = Draft.make_circle(50, placement=App.Placement(p2, rot), face=True) |
||
c2.Label = "B1_c1" |
c2.Label = "B1_c1" |
||
c3 = Draft. |
c3 = Draft.make_circle(50, placement=App.Placement(p3, rot), face=True) |
||
c3.Label = "B1_c2" |
c3.Label = "B1_c2" |
||
c4 = Draft. |
c4 = Draft.make_circle(100, placement=App.Placement(p4, rot), face=False) |
||
c4.Label = "B1_E2" |
c4.Label = "B1_E2" |
||
c5 = Draft. |
c5 = Draft.make_circle(50, placement=App.Placement(p5, rot), face=True) |
||
c5.Label = "B2_c3" |
c5.Label = "B2_c3" |
||
c6 = Draft. |
c6 = Draft.make_circle(50, placement=App.Placement(p6, rot), face=True) |
||
c6.Label = "B2_c4" |
c6.Label = "B2_c4" |
||
c7 = Draft. |
c7 = Draft.make_circle(100, placement=App.Placement(p7, rot), face=False) |
||
c7.Label = "B2_E3" |
c7.Label = "B2_E3" |
||
c8 = Draft. |
c8 = Draft.make_circle(50, placement=App.Placement(p8, rot), face=True) |
||
c8.Label = "B3_c5" |
c8.Label = "B3_c5" |
||
App.ActiveDocument.recompute() |
|||
doc.recompute() |
|||
⚫ | |||
⚫ | |||
B1.Label = "B_lin" |
B1.Label = "B_lin" |
||
B1.ViewObject.DrawStyle = "Dashed" |
B1.ViewObject.DrawStyle = "Dashed" |
||
B2 = Draft. |
B2 = Draft.make_bezcurve([p1, p2, p3], degree=3) |
||
B2.Label = "B_quad" |
B2.Label = "B_quad" |
||
B2.ViewObject.DrawStyle = "Dotted" |
B2.ViewObject.DrawStyle = "Dotted" |
||
B3 = Draft. |
B3 = Draft.make_bezcurve([p1, p2, p3, p4], degree=3) |
||
B3.Label = "B_cub" |
B3.Label = "B_cub" |
||
B3.ViewObject.LineWidth = 4 |
B3.ViewObject.LineWidth = 4 |
||
B4 = Draft. |
B4 = Draft.make_bezcurve([p1, p2, p3, p4, p5], degree=3) |
||
B4.Label = "B_cub+lin" |
B4.Label = "B_cub+lin" |
||
B4.ViewObject.DrawStyle = "Dashed" |
B4.ViewObject.DrawStyle = "Dashed" |
||
B5 = Draft. |
B5 = Draft.make_bezcurve([p1, p2, p3, p4, p5, p6], degree=3) |
||
B5.Label = "B_cub+quad" |
B5.Label = "B_cub+quad" |
||
B5.ViewObject.DrawStyle = "Dotted" |
B5.ViewObject.DrawStyle = "Dotted" |
||
B6 = Draft. |
B6 = Draft.make_bezcurve([p1, p2, p3, p4, p5, p6, p7], degree=3) |
||
B6.Label = "B_cub+cub" |
B6.Label = "B_cub+cub" |
||
B6.ViewObject.LineWidth = 2 |
B6.ViewObject.LineWidth = 2 |
||
B7 = Draft. |
B7 = Draft.make_bezcurve([p1, p2, p3, p4, p5, p6, p7, p8], degree=3) |
||
B7.Label = "B_cub+cub+lin" |
B7.Label = "B_cub+cub+lin" |
||
B7.ViewObject.DrawStyle = "Dashed" |
B7.ViewObject.DrawStyle = "Dashed" |
||
App.ActiveDocument.recompute() |
|||
doc.recompute() |
|||
}} |
}} |
||
{{Docnav |
{{Docnav |
||
|[[ |
|[[Draft_BSpline|BSpline]] |
||
|[[ |
|[[Draft_BezCurve|BezCurve]] |
||
|[[ |
|[[Draft_Workbench|Draft]] |
||
|IconL= |
|IconL=Draft_BSpline.svg |
||
⚫ | |||
|IconC=Workbench_Draft.svg |
|IconC=Workbench_Draft.svg |
||
⚫ | |||
}} |
}} |
||
{{Draft Tools navi{{#translation:}}}} |
{{Draft Tools navi{{#translation:}}}} |
||
{{Userdocnavi{{#translation:}}}} |
{{Userdocnavi{{#translation:}}}} |
||
{{clear}} |
Latest revision as of 19:30, 7 December 2023
Draft CubicBezCurve |
Menu location |
---|
Drafting → Bézier tools → Cubic Bézier curve |
Workbenches |
Draft, Arch |
Default shortcut |
None |
Introduced in version |
0.19 |
See also |
Draft BezCurve, Draft BSpline |
Description
The Draft CubicBezCurve command creates a Bézier curve of the third degree (four points required).
The Bézier Curve is one of the most commonly used curves in computer graphics. This command allows you to create a continuous spline made up of several 3rd-degree Bézier segments, in a way that is similar to the Bézier tool in Inkscape. A general Bézier curve of any degree can be created with the Draft BezCurve command.
The Draft BezCurve and the Draft CubicBezCurve commands use control points to define the position and curvature of the spline. The Draft BSpline command, on the other hand, specifies the exact points through which the curve will pass.
Spline consisting of three cubic Bézier segments. The first segment is defined by four points. Subsequent segments reuse two points from the previous segment and therefore require only two additional points.
Usage
See also: Draft Tray, Draft Snap and Draft Constrain.
- There are several ways to invoke the command:
- Press the Cubic Bézier curve button.
- Select the Drafting → Bézier tools → Cubic Bézier curve option from the menu.
- The Cubic Bézier curve task panel opens. See Options for more information.
- It is not possible the enter points via the task panel.
- For the following Mouse Navigation Models a keyboard key must to be held down:
- If you are using OpenInventor Navigation the Ctrl key must be held down throughout the command.
- If you are using Gesture Navigation the Alt key must be held down for each click-hold-release sequence, but is also possible to keep this key held down throughout the command.
- Pick the first point in the 3D view and hold the mouse button (1), this is the first endpoint.
- Drag the pointer to another point in the 3D view and release the mouse button (2), this is the first control point.
- Move the pointer to another point in the 3D view, pick this point and hold the mouse button (3), this is the second endpoint.
- Move the pointer to another point in the 3D view to adjust the final curvature of the segment and release the mouse button (4), this is the second control point.
- You now have one Bézier curve of the 3rd degree.
- Optionally repeat the process of clicking and holding (5), and dragging and releasing (6) to add more segments.
- Each subsequent segment will use the second endpoint and second control point of the previous segment as its first endpoint and first control point respectively.
- Press Esc or the Close button to finish the command.
Options
See Draft BezCurve.
Notes
- A Draft CubicBezCurve can be edited with the Draft Edit command.
Properties
See Draft BezCurve.
Scripting
See also: Autogenerated API documentation and FreeCAD Scripting Basics.
See Draft BezCurve for general information. A cubic Bézier is created by passing the option degree=3
to makeBezCurve()
.
For each cubic Bézier 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 Bézier instead, with only one control point.
- If only 2 points are given, it creates a linear Bézier, that is, a straight line.
- If 5 points are given, the first 4 create a cubic Bézier 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 Bézier segment; the 4th and the other two points are used to create a quadratic Bézier segment.
- If 7 points are given, the first 4 create a cubic Bézier segment; the 4th and the other three points are used to create a second cubic Bézier segment.
- In general, the last point in a group of four is shared with the following three points maximum to create another Bézier segment.
- 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
.
Examples of Bézier curves produced by using 2, 3, 4, 5, 6, 7, and 8 points. The solid lines indicate cubic Bézier segments; the other lines are quadratic or linear.
Example:
import FreeCAD as App
import Draft
doc = App.newDocument()
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.make_circle(100, placement=App.Placement(p1, rot), face=False)
c1.Label = "B1_E1"
c2 = Draft.make_circle(50, placement=App.Placement(p2, rot), face=True)
c2.Label = "B1_c1"
c3 = Draft.make_circle(50, placement=App.Placement(p3, rot), face=True)
c3.Label = "B1_c2"
c4 = Draft.make_circle(100, placement=App.Placement(p4, rot), face=False)
c4.Label = "B1_E2"
c5 = Draft.make_circle(50, placement=App.Placement(p5, rot), face=True)
c5.Label = "B2_c3"
c6 = Draft.make_circle(50, placement=App.Placement(p6, rot), face=True)
c6.Label = "B2_c4"
c7 = Draft.make_circle(100, placement=App.Placement(p7, rot), face=False)
c7.Label = "B2_E3"
c8 = Draft.make_circle(50, placement=App.Placement(p8, rot), face=True)
c8.Label = "B3_c5"
doc.recompute()
B1 = Draft.make_bezcurve([p1, p2], degree=3)
B1.Label = "B_lin"
B1.ViewObject.DrawStyle = "Dashed"
B2 = Draft.make_bezcurve([p1, p2, p3], degree=3)
B2.Label = "B_quad"
B2.ViewObject.DrawStyle = "Dotted"
B3 = Draft.make_bezcurve([p1, p2, p3, p4], degree=3)
B3.Label = "B_cub"
B3.ViewObject.LineWidth = 4
B4 = Draft.make_bezcurve([p1, p2, p3, p4, p5], degree=3)
B4.Label = "B_cub+lin"
B4.ViewObject.DrawStyle = "Dashed"
B5 = Draft.make_bezcurve([p1, p2, p3, p4, p5, p6], degree=3)
B5.Label = "B_cub+quad"
B5.ViewObject.DrawStyle = "Dotted"
B6 = Draft.make_bezcurve([p1, p2, p3, p4, p5, p6, p7], degree=3)
B6.Label = "B_cub+cub"
B6.ViewObject.LineWidth = 2
B7 = Draft.make_bezcurve([p1, p2, p3, p4, p5, p6, p7, p8], degree=3)
B7.Label = "B_cub+cub+lin"
B7.ViewObject.DrawStyle = "Dashed"
doc.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, Arch, Assembly, 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