[merged] PR #4835 New sketch object rounded rectangle

Post here if you have re-based and finalised code to integrate into master, which was discussed, agreed to and tested in other forums. You can also submit your PR directly on github.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

[merged] PR #4835 New sketch object rounded rectangle

Post by uwestoehr »

https://github.com/FreeCAD/FreeCAD/pull/4835

While constructing I miss often that one cannot insert directly rounded rectangles. As it is, one needs first to insert a rectangle, then go to fillet mode, then click 4 times, then set equal constraint, then often also replace the vertical/horiztontal constraints since a rectangle must not necessarily be parallel to a sketch axis

As solution this PR adds rounded rectangles in one step. This saves a lot of time since this object is e.g. often used for milled rectangular pockets, for 3D-printed pads etc.

Since the slot is a special case of a rounded rectangle and the use cases are similar as well, I grouped the lot and rounded rectangle.

Here is a screencast how I implemented it:
5FRpUoPC9m.gif
5FRpUoPC9m.gif (126.38 KiB) Viewed 8240 times
I asses the 4 auxiliary lines because in practice one wants to place the rectangle within 2 marks. So the rounded rectangle should be as usable as the normal rectangle - the first and the final click defines the dimensions of the rectangle.

The only minor thing that I cannot resolve is that the radius of the corners during the preview/seeking is incorrect. I spent a lot of time in debugging and the coordinates are correct, but the display is not. Any hint is welcome. The code is in CommandCreateGeo.cpp in line 6694 ff.

abdullah wrote: .
Last edited by uwestoehr on Mon Jun 21, 2021 10:53 pm, edited 1 time in total.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: PR #4835 New sketch object rounded rectangle

Post by uwestoehr »

Inviting Adrian.
adrianinsaval wrote: .
User avatar
adrianinsaval
Veteran
Posts: 5534
Joined: Thu Apr 05, 2018 5:15 pm

Re: PR #4835 New sketch object rounded rectangle

Post by adrianinsaval »

I'm not an expert but I believe it would be better to constraint the corners using just one construction point and two point on object constraints instead of two construction lines and their corresponding constraints, if I'm not mistaken the later introduces 4x as many equations for the solver. Here's a gif of how to do this in the GUI:
Attachments
filleted-corner-constraining.gif
filleted-corner-constraining.gif (638.3 KiB) Viewed 8219 times
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: PR #4835 New sketch object rounded rectangle

Post by uwestoehr »

adrianinsaval wrote: Mon Jun 07, 2021 12:54 am I'm not an expert but I believe it would be better to constraint the corners using just one construction point...
Many thanks, apparently you are an expert ;) . Your solution is much smarter, saves 4 constraints and 2 elements.

I changed the PR accordingly. It works now this way:
d6Lnbwl4UD.gif
d6Lnbwl4UD.gif (81.38 KiB) Viewed 8208 times
chrisb
Veteran
Posts: 53785
Joined: Tue Mar 17, 2015 9:14 am

Re: PR #4835 New sketch object rounded rectangle

Post by chrisb »

We may hear edi's comments, athor of the original macro CenteredFiguresInSketcher.FCMacro
edi wrote: Thu Aug 13, 2020 2:41 pm Attached the latest revised version of the script.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Pauvres_honteux
Posts: 728
Joined: Sun Feb 16, 2014 12:05 am
Location: Far side of the moon

Re: PR #4835 New sketch object rounded rectangle

Post by Pauvres_honteux »

Is it a prerequisit to already have a couple of existing points?
In other words, can I use this magic "rounded rectangle"-maker without already existing points?
chrisb
Veteran
Posts: 53785
Joined: Tue Mar 17, 2015 9:14 am

Re: PR #4835 New sketch object rounded rectangle

Post by chrisb »

Wouldn't it better match the existing geometric constructors if you use the common vertical and horizontal constraints? You could add the tilted versions as additional variants - which could be helpful for the rectangle too. So for the user interface we may have a drop down menu with Rectangle - Rounded Rectangle - Tilted Rectangle - Tilted Rounded Rectangle.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: PR #4835 New sketch object rounded rectangle

Post by uwestoehr »

Pauvres_honteux wrote: Mon Jun 07, 2021 5:48 am Is it a prerequisit to already have a couple of existing points?
No, you can use the feature the same way like you do when creating a rectangle.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: PR #4835 New sketch object rounded rectangle

Post by uwestoehr »

chrisb wrote: Mon Jun 07, 2021 6:33 am Wouldn't it better match the existing geometric constructors if you use the common vertical and horizontal constraints?
I purposely did not do this. It annoys me that I have these constraints by default for rectangles. When I want to create a rectangle, well then I want to get a rectangle, nothing else. It is time-consuming to replace the horizontal/vertical constraints of the rectangles by parallel and perpendicular ones to get the rectangle I need. That's why I don't use the rectangle feature rarely (and the consecutive lines feature instead).

With my implementation you can add just one single constraint and get the rectangle parallel to a sketch axis if you need this.

So for the user interface we may have a drop down menu with Rectangle - Rounded Rectangle - Tilted Rectangle - Tilted Rounded Rectangle.
Please not. The UI should be clean. When the difference is just a single constraint, it is not worth to stuff the UI with all these different cases.
chrisb
Veteran
Posts: 53785
Joined: Tue Mar 17, 2015 9:14 am

Re: PR #4835 New sketch object rounded rectangle

Post by chrisb »

uwestoehr wrote: Mon Jun 07, 2021 2:02 pm Please not. The UI should be clean. When the difference is just a single constraint, it is not worth to stuff the UI with all these different cases.
I understand this approach. I prefer to have my sketches as clean as possible, which includes to avoid more constraints than needed. Vertical and horizontal constraints are self containing, while for parallel and orthogonal you need another geometric element to get their meaning. As a rather minor point the solver may find vertical and horizontal easier to solve.

Besides personal preferences a consistent UI is a value which should have serious weight.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply