Bezier curve tool bug
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Bezier curve tool bug
Hello, I noticed the strange behaviour of the bezier curve tool:
the user keep adding points and the tool just create a big bezier curve, instead of splitting it into several segments.
I'd like it to work like this: The behaviour in the gif is good but i think i broke the tool
soo... I investigated a bit ad i realized that the tool, when committing the creation of the curve dont give Draft.makeBezCurve the degree of the curve. If i'm able to fix also the preview i'll start with this small fix that should improve the usability a lot i think
PS I've not finished with the editing tool, but i was searching for something to have fun and not thinking about it
the user keep adding points and the tool just create a big bezier curve, instead of splitting it into several segments.
I'd like it to work like this: The behaviour in the gif is good but i think i broke the tool
soo... I investigated a bit ad i realized that the tool, when committing the creation of the curve dont give Draft.makeBezCurve the degree of the curve. If i'm able to fix also the preview i'll start with this small fix that should improve the usability a lot i think
PS I've not finished with the editing tool, but i was searching for something to have fun and not thinking about it
follow my experiments on BIM modelling for architecture design
Re: Bezier curve tool bug
I don't understand. Do you want to change the default behavior of the tool?
- Current: the Bezier curve creates a single curve with many control points.
- Your proposal: it should create multiple segments, each segment being its own Bezier curve.
What exactly is broken?The behaviour in the gif is good but i think i broke the tool
Last edited by vocx on Sun May 12, 2019 6:13 pm, edited 1 time in total.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: Bezier curve tool bug
Exactly:
the draft bezier creation tool works with these arguments:
Code: Select all
Draft.makeBezCurve(pointslist,closed=False,placement=None,face=None,support=None,Degree=None):
Code: Select all
Draft.makeBezCurve(points,closed='+str(closed)+',support='+sup+')
I also find this comment on the code:
# not quite right. draws 1 big bez. sb segmented
Do you agree?
follow my experiments on BIM modelling for architecture design
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Bezier curve tool bug
The Draft Bezier tools creates for n points a bezier curve of degree n-1. You can change the property degree to get lower degree bezier segments in a next step
If you have 7 points and set degree to 3 you get 2 bezier segments.
with 10 points you get 3 bezier segments.
Here an example with teh same controlpoints anbd different degrees.
red is linear Degree 1
yellow is degree 3 - this is inkscape like.
more examples see
http://freecadbuch.de/doku.php?id=blog: ... zierkurven
If you have 7 points and set degree to 3 you get 2 bezier segments.
with 10 points you get 3 bezier segments.
Here an example with teh same controlpoints anbd different degrees.
red is linear Degree 1
yellow is degree 3 - this is inkscape like.
more examples see
http://freecadbuch.de/doku.php?id=blog: ... zierkurven
Re: Bezier curve tool bug
OK, I think I understand now. Draft.makeBezCurve() in Draft.py is the low level code that creates a Bezier curve by calling the even more primitive Part.BezierCurve() function.carlopav wrote: ↑Wed Apr 03, 2019 5:58 am Exactly:
the draft bezier creation tool works with these arguments:but the Drafttools.bezCurve just give him this:Code: Select all
Draft.makeBezCurve(pointslist,closed=False,placement=None,face=None,support=None,Degree=None):
Code: Select all
Draft.makeBezCurve(points,closed='+str(closed)+',support='+sup+')
Then, the class BezCurve in DraftTools.py is the higher level code (user interface, button) that calls Draft.makeBezCurve().
I also found this behavior a bit strange at the beginning, but actually... I think it's not that bad. I don't have a lot of experience using Bezier curves, but I think in most cases a user will use a curve to smooth or round a corner made of two other straight lines. In this case, what the user wants is to produce a smooth curve by clicking many intermediate points. So the more he or she clicks, the smoother the curve gets because the degree becomes larger. This is similar to how Draft BSpline works.without the Degree, Draft just create a single bezier segment, aumenting the degree with every node added. And i think this is not good and counterintuitive.
The degree of the Bezier is one less than the number of points, so if the user clicks 5 times, he or she will get a curve of degree 4, which is two end points and three intermediate points. I think in most cases, the user would not need degrees larger than 4, which is why quadratic (2nd degree, 3 points) and cubic (3rd degree, 4 points) Beziers are so popular in most drawing programs.
In this picture, from top to bottom, the two lines are tied with Beziers of degrees 4 (quartic), 3 (cubic) and 2 (quadratic).
I do think that having an option in the Task panel (DraftGui.py) to lock the degree of the Bezier would be good, as it gives more possibilities to the user. But how would the user use the tool, just a start point and end point? It would need two points?Instead the user should set the curve degree before starting the creation and it should remain fixed for the whole curve.
I also find this comment on the code:
# not quite right. draws 1 big bez. sb segmented
Do you agree?
If the order is three, and I put two points, the code would have to automatically create the two intermediate control points at an arbitrary location without regards for my preferred curvature. Then I would have to go back into edit mode to modify the control points to suit my needs. If the tool stays as it is now, I can more or less direct the curvature of the Bezier by how I place the points along a path.
What I wouldn't like is to click many times on the 3D view, and that it creates multiple curves; that would be surprising. A single use of the tool should create a single object, not multiple objects. For example, if I use the Draft Wire, I want to get a single wire object, not many individual line objects; that'd just get messy in the tree view, you'd end with many, many objects in a short time.
Now, Draft already has a "continuation mode" to create multiple objects, one after the other. You activate this mode by pressing T in the keyboard (or checking the "continue" checkbox) after you enter the Task panel. That means that when you finish one object, it immediately starts creating a new object from the last point selected. So, basically, a Draft Wire is the same as a Draft Line with continuation mode on. It just creates line segments one after the other.
In your case, it would be like choosing (locking) the degree of the curve to 3, using continuation mode, then clicking two points; after the second point it would start creating a second curve, also of 3rd degree, and so on.
I think locking the degree of the curve is fine (with a checkbox and spinbox to choose the degree), but not breaking a high order curve into many objects, if the user doesn't want to.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: Bezier curve tool bug
+1I do think that having an option in the Task panel (DraftGui.py) to lock the degree of the Bezier would be good, as it gives more possibilities to the user.
i think we could provide two options:But how would the user use the tool, just a start point and end point? It would need two points?
- cubic (fixed 3rd degree),
- incremental degree (actual behaviour).
Agree, i think the goal should be to obtain a single curve object with several segments (depending on how many points the user clicked and the curve degree)I think locking the degree of the curve is fine (with a checkbox and spinbox to choose the degree), but not breaking a high order curve into many objects, if the user doesn't want to.
follow my experiments on BIM modelling for architecture design
Re: Bezier curve tool bug
Sorry, didnt see the response before. Of course you can. But that behaviour seemed odd to me, maybe i worked too much with inkscape in the last times... I'd like to draw it cubic since the beginning (eventually with drag and drop to define control points).microelly2 wrote: ↑Wed Apr 03, 2019 7:29 am The Draft Bezier tools creates for n points a bezier curve of degree n-1. You can change the property degree to get lower degree bezier segments in a next step
Letting of course the user decide if he wants keep using the current mode. What do you think?
PS I realized that i should change the name of the topic if everyone thinks that it's acceptable like it is
follow my experiments on BIM modelling for architecture design
Re: Bezier curve tool bug
It is not a bug, so the title might well be changed.
Here are quite some Inkscape users around, so an Inkscape-compatibility mode seems reasonable.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Bezier curve tool bug
It is not a bug, "it just works in a particular way that may be unexpected if you come from other drawing applications".
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: Bezier curve tool bug
I think this makes sense. The tool should create by default a cubic Bezier, as it's probably the most used degree. But the user should also have the possibility of having the current system.carlopav wrote: ↑Wed Apr 03, 2019 12:59 pm i think we could provide two options:
- cubic (fixed 3rd degree),
Keep in mind that the user can always change the degree of the curve after the creation, and this will affects the segment subdivision on document recompute.
- incremental degree (actual behaviour).
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.