[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!
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: PR #4835 New sketch object rounded rectangle

Post by easyw-fc »

edi wrote: Mon Jun 14, 2021 5:38 am
PointSymetricRoundedRectangle01.FCMacro
Workflow:
- open a sketch in the x/y plane
- start the macro
- select the center of the rounded rectangle
- select a fictive corner of the rounded rectangle

Benefits:
- the figure can be streched keeping the contraints
- the figure can be moved and/or fixed using the center point
- fictive corners can be fixed using two times the "PointOnObject" constraint (as shown in the post above)
:geek: :geek: :geek:
easy and fantastic tool!
a must have macro for designing a basic electronic pcb :D
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 »

abdullah wrote: Sun Jun 13, 2021 6:08 am I looked at the code. Save for the handler/final result inconsistency, it is ok and it is very useful. I can tell you that the inconsistency is not due to the solver moving you result, so I guess it is in the drawing while moving. Maybe in the xi, yi. Not sure, did not have enough time to look into it.
Thanks for having a look.
What do you mean with "inconsistency ... drawing while moving"? Here the solver runs fine. I used my rounded rectangle tool as in the PR now for several real-life constructions and could not see solver issues. Teh solver succeds. Maybe it is because I always connect the rectangle directly to 2 pre-existing points in the sketch.

abdullah wrote: Sun Jun 13, 2021 6:08 am Is a slot a class of rounded rectangle? It is a rounded rectangle a class of rectangle? The current grouping of toolbar buttons is that the rounded rectangle goes together with the slot. Though I can see the geometric similarity, I am not sure it is where a user would expect it.
Good point. Geometrically a rounded rectangle is a special case of a rectangle, and thus should maybe appear under the rectangle icon, not the slot.
However, the slot is a special case of a rounded rectangle, there 2 parallel lines have the length zero. And a circle is a special case of a slot :lol:
So you are right, maybe we don't group the rounded rectangle under the slot but under the rectangle.

abdullah wrote: Sun Jun 13, 2021 6:08 am The other observation is about the discussion of "more buttons" vs "more complex constraints". Looking at the other PR about the slot, I think I am beginning to see a pattern. Composed shapes are generally best constrained using horizontal/vertical, but sometimes we want to make the rotatable.
I hope I understood you right?:
- we add a toggle icon named "rotateable" (we already have the construction geometry toggle icon)
- when this icon is in the pressed state, and the user adds a rectangle, it gets parallel + rectangle constraints so that the user can rotate the rectangle as he likes without prior need to remove constraints?

Yes, this would be optimal!
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 »

edi wrote: Mon Jun 14, 2021 5:38 am IMO desirable features are a centered rectangle and a centered rounded corner rectangle. Unfortunately the "Create regular polygon" feature is not able to do this.
As the rectangle feature in in FC since almost ever, I guess users are happy of using the edge points for definitions and unless we have very good reasons, I would not change this.
Otherwise almost every FC user has to change its existing construction habit to construct that he can define rectangles using their center point.

(I looked now also through my real-live constructions (not only for 3D-printing, also those for milling) and the vast majority of more than 90% of the cases defines the rectangles using the corner points. The point is that when construction I need to "make a rectangle from here to there", so I click from and to and I am ready. The only uses cases where I used a central point are squares, since I found first later out that for squares I can use the regular polygon feature.)
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: PR #4835 New sketch object rounded rectangle

Post by GeneFC »

uwestoehr wrote: Mon Jun 14, 2021 7:23 pm As the rectangle feature in in FC since almost ever, I guess users are happy of using the edge points for definitions and unless we have very good reasons, I would not change this.
I am not recommending a change, but one of most common constructions I use is to center a rectangle on a point. :shock:

Gene
chrisb
Veteran
Posts: 53939
Joined: Tue Mar 17, 2015 9:14 am

Re: PR #4835 New sketch object rounded rectangle

Post by chrisb »

uwestoehr wrote: Mon Jun 14, 2021 7:14 pm - we add a toggle icon named "rotateable" (we already have the construction geometry toggle icon)
- when this icon is in the pressed state, and the user adds a rectangle, it gets parallel + rectangle constraints so that the user can rotate the rectangle as he likes without prior need to remove constraints?
I had understood it differently and wasn't quite happy with a function working on existing geometry to make it rotateable, albeit more general.
So I would prefer the decide-on-creation variant above changing existing geometry later.
uwestoehr wrote: Mon Jun 14, 2021 7:23 pm (I looked now also through my real-live constructions (not only for 3D-printing, also those for milling) and the vast majority of more than 90% of the cases defines the rectangles using the corner points.
In the real life examples there are quite some rectangles with a defined center point, mostly it is the origin. I haven't counted them, but I would say that half of the rectangles which are used to start a basically rectangular model (e.g. all these boxes with holes here and there) are centered around the origin - or better should be. So we may have two of the aforementioned toggles: one for aligned parallel to axes vs rotateable, and one for centered vs. corner points.

Example: I just had a box for an electronic device with a lid and a seal, all together not very exotic. Started with the box (centered rectangle); made it hollow (centered rectangle); made a groove for the seal (two centered rectangles); and the same once more for the lid. For the centering it needs currently 3 clicks on points which don't lie close to each other. So a toggle would be a real click and mouse mileage saver.
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 »

chrisb wrote: Mon Jun 14, 2021 9:00 pm In the real life examples there are quite some rectangles with a defined center point, mostly it is the origin.
E.g. for a casing this is reasonable, but how often do you need this then in a sketch?
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 »

We are drifting off-topic. This thread is about my the rounded rectangle PR. I think the consensus is that rounded rectangles are a useful feature. abudullah pointed out that it should be better grouped under the rectangle than the slot. I can change the PR accordingly if abdullah agrees.

Next is the issue on how to constrain the feature. I like the proposal of having a general toggle icon to make structures rotatable. This would nevertheless be a new PR and can be introduced independently of my PR, thus I would keep the PR in this respect as it is (also since it doesn't touch the existing rectangle feature).

Let's discuss further other sketcher issues please in a new thread to keep the overview.
C_h_o_p_i_n
Posts: 225
Joined: Fri Apr 26, 2019 3:14 pm

Re: PR #4835 New sketch object rounded rectangle

Post by C_h_o_p_i_n »

chrisb wrote: Mon Jun 14, 2021 9:00 pm one for aligned to axes vs rotateable, and one for centered vs. corner points.
I propose in this case: "aligned" (means parallel) to a vertex or to axes ... (otherwise ... how to constraint the rotation ?!? )

And I'd realy like the Idea to click to points and a (rounded corner) rectangle will show up arround the imaginary line connecting the both points.

just my 2 cents.
Regards,
Stefan
chrisb
Veteran
Posts: 53939
Joined: Tue Mar 17, 2015 9:14 am

Re: PR #4835 New sketch object rounded rectangle

Post by chrisb »

C_h_o_p_i_n wrote: Tue Jun 15, 2021 8:52 am I propose in this case: "aligned" (means parallel)
I have corrected my post.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: PR #4835 New sketch object rounded rectangle

Post by abdullah »

uwestoehr wrote: Mon Jun 14, 2021 7:14 pm Thanks for having a look.
What do you mean with "inconsistency ... drawing while moving"? Here the solver runs fine. I used my rounded rectangle tool as in the PR now for several real-life constructions and could not see solver issues. Teh solver succeds. Maybe it is because I always connect the rectangle directly to 2 pre-existing points in the sketch.
Sorry for my longer than usual delay in replying.

The "issue" (very small one):Arcs represented when creating (drawsketchhandler) are not the same size as the arcs that appear after hitting the mouse button.

What I meant is that what you see after executing the addGeometry instruction is exactly what you are telling it to add (i.e. the solver is not making the arcs of a different radius on its own).
uwestoehr wrote: Mon Jun 14, 2021 7:14 pm Good point. Geometrically a rounded rectangle is a special case of a rectangle, and thus should maybe appear under the rectangle icon, not the slot.
However, the slot is a special case of a rounded rectangle, there 2 parallel lines have the length zero. And a circle is a special case of a slot :lol:
So you are right, maybe we don't group the rounded rectangle under the slot but under the rectangle.
I am not sure myself. Do not change anything at this point. I think I need to figure out the fate of the rotatable tool first, then with that input, think in the UI, then with that input find the right place for it.
uwestoehr wrote: Mon Jun 14, 2021 7:14 pm I hope I understood you right?:
- we add a toggle icon named "rotateable" (we already have the construction geometry toggle icon)
- when this icon is in the pressed state, and the user adds a rectangle, it gets parallel + rectangle constraints so that the user can rotate the rectangle as he likes without prior need to remove constraints?

Yes, this would be optimal!
I did not think about it in that way. That solution would not "solve" the code explosion of providing specific constraints for each supported complex geometry. Save for that, your description is not a bad idea either.

I was actually meaning what Chrisb actually understood (and feared). A generic tool (simplified description) to mangle horizontal/vertical constraints into parallel/perpendicular ones. The "charm" of this, if it works properly, is that we do not need to code specific shapes for "stable" constraints vs "less stable but more flexible" constraints.

For example, if we add, as it is requested, a rectangle taking a center point and a vertex (another droppable under rectangle), we could still provide stable constraints and get the same with rotatable constraints with a single click.

I expect to be able to take a further look tomorrow. :D
Post Reply