[New feature] Sketcher Constrain Contextually

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
cadcam
Posts: 273
Joined: Thu Apr 02, 2020 10:39 am

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by cadcam »

"just constrain until it goes green" strategy
While I can see this as one way forward, I am slightly of a different
design philosphy, where the user tries to constrain as the item would be
build/drawn it to a standard.**
I know some will say this may be slower in the solver but, if you follow the
much vaunted KISS principle to the sketch, modern (even a few years old) cpus can probably
cope.
Thus a repeated plea for an option where the system inserts dimensions/constraints as
the user draw, i,e, the sketch is always 'green'! [Advantages, sketches rarely fold, no concerns
about what to with redundant constraints, the user is prompted to see what the system requires to close the calcs]
If the system selected constraints/dimensions are not what the user wants the contextual functionality,
being offered by the OP, makes it easy to overide system selection! [If a user added
dimension/constraint results in alternatives to keep the sketch 'solved', the system selects
one or more new ones to keep everything solved. It/they may be what the user wants, in which case great, if not use this functionality described in this thread eases the task
toupdate to what the users wants.]

Hopefully simpler for the newbie, and really no extra hassle for the experienced user.
[It could always be offered as a selectable option]


** I am sure to generate some flames, but constraining [typ. offset from a datum,
symmetric or equal dims] and adding dimensions to the sketch which are similar to the final
technical drawing can be very thought provoking! The drawing standards are there to ensure
the shape of the geometry is captured and traditionally how the item is to be made/inspected, e.g.
simple things like diameters rather than radius of rod, distances from datums - fixed edges or
centerlines/lines of symmetry. SO for the penalty of a few more clock cycles if the user
approaches the sketch this way, there is a chance that the generation of the technical drawings,
GD&T, manufacturing methodology & inspection may be easier.

I understand this is FreeCAD and it may not be the way it works, and I should read the manuals.
However, can I gently suggest that anyone who has not used one of the commercial packages with
this sort of functionality they try one of the demo packages, or watch a Youtube presentation,
when/if they have a chance. You may be surprised at how the option can free the designer
to generate what they want rather than what they think the system will accept to make a robust set of constraints.
It may not be the way for everyone, but it could be useful and user
friendly to others.

I don't know enough about the working of Sketcher and the generation/transfer of
dimensions/constraints to/from Techdraw etc, but if auto-dimensioning ( I assume
the info must already be being captured in the background) + user overide is thought to
be a relatively low hanging fruit I would really like someone much cleverer than I has a look at
offering some of the users the option. [If it would mean a complete re-writeof , or even substantial
change to, Sketcher +++, then obviously the concept is trashed/drops to the
bottom of any request pile! However it would be interesting to understand something
about the technical difficulties involved]

Just my 0.2 cents
chrisb
Veteran
Posts: 53924
Joined: Tue Mar 17, 2015 9:14 am

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by chrisb »

We had this discussion some time ago, so can someone please dig the archives?

This is convenient for the user, and leads perhaps faster to fully constrained sketches. But I hold any bet that it will lead to more badly constrained sketches because it is provoking the usage of dimensions instead of well thought geometric constraints. I know that good constraining is by far not an easy task. But solving this by using less than optimal constraints is no option.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
cadcam
Posts: 273
Joined: Thu Apr 02, 2020 10:39 am

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by cadcam »

This is convenient for the user, and leads perhaps faster to fully constrained sketches. But I hold any bet that it will lead to more badly constrained sketches because it is provoking the usage of dimensions instead of well thought geometric constraints. I know that good constraining is by far not an easy task. But solving this by using less than optimal constraints is no option.
Possibly a few of quick comments

1) I think you may find it will lead in general to better constrained sketches. Once a user has struggled to get their
sketch constrained they are likely to leave it as is. However faced with a sketch that is always fully constrained they
are much more likely to add a symmetric, horizontal... constraint confident that the sketch will stay solved.
[ If you have the chance try one of the packages that offer the functionality, I think you will find it interesting
how it changes your use. Think how you would feel if you are new to CAD, not just FreeCAD]

2) While you may not get the optimum geometrically constrained sketch, having the sketch that captures the
user's design intent, rather than an optimum geometric representation, means that

- It is more likely be correct as the user will understand it better [Given the confidence from(1) they may subsequently modify it] It is good to allow the user to input their design intent rather than be concentrating on whether a complex simultaneous equation solver has the correct number of variable

- Probably easier for the user to correct/modify, if that is the way they have thought about/sketched (pencil/pen)
the concept*

- If it takes a few addition ms to solve a sketch, does it matter if it is easier for the user. [The really useful thing is that the inexperiened user save the minutes (hrs?) trying to get the consistent set of constraints/dimensions. It can also save the experienced user a few seconds when items like very short random line segments get 'highlighted' with dimensions.

3)
But solving this by using less than optimal constraints is no option
I am not sure I understand this. It may not be good, but it is AN option and gets the pad/cut/sweep.... into 3D visual form much quicker. Tis is what most new users to 3D cad want, otherwise they would have stayed with pencil/paper or 2D.

4) If the same dims/constraints in the sketcher are automatically available/drawn in Techdraw it may become obvious to
the user if they have missed a symmetry etc. They will be more willing to update if they are confident that the sketch will not break and any changes will be automatically carried forward to the '2D' drawing

Best Wishes
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by GeneFC »

I am a bit puzzled by the discussion on radius vs diameter. FreeCAD already has an automatic function to choose diameter for complete circles and radius for partial circles.

Circular Constraints.jpg
Circular Constraints.jpg (43.27 KiB) Viewed 10151 times

Why does this need to be changed?

One can select "Diameter", "Radius", or "Auto" and that choice remains in the widget icon for the next use.

What else is there?

Gene
user1234
Veteran
Posts: 3339
Joined: Mon Jul 11, 2016 5:08 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by user1234 »

GeneFC wrote: Sat Jan 22, 2022 10:07 pmFreeCAD already has an automatic function to choose diameter for complete circles and radius for partial circles.
I also do not get, what is the issue in radius and diameter. Works great here.

Greetings
user1234
User avatar
paddle
Veteran
Posts: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by paddle »

GeneFC wrote: Sat Jan 22, 2022 10:07 pm I am a bit puzzled by the discussion on radius vs diameter. FreeCAD already has an automatic function to choose diameter for complete circles and radius for partial circles.


Circular Constraints.jpg


Why does this need to be changed?

One can select "Diameter", "Radius", or "Auto" and that choice remains in the widget icon for the next use.

What else is there?
user1234 wrote: Sat Jan 22, 2022 10:34 pm I also do not get, what is the issue in radius and diameter. Works great here.
This topic is about the "constrain contextually" tool. Please check the video on the first post of the topic to understand what it is about.

They ask that the "constrain contextually" tool use the "auto" behaviour rather than just "Radius" when selecting a circle/arc.
Haavard
Posts: 217
Joined: Wed Feb 17, 2021 10:48 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by Haavard »

Yeah there seems to be some bugs in the request. I can compile master just fine, and pulled in and successfully compiled both 0penBrains requests (5402 and 5404), and also his "misc" branch.

It looks like the gitlab CI pipeline also fails, so its not just me :roll:
https://github.com/FreeCAD/FreeCAD/pull/5407

Errors so far:
1. Rename the icon mentioned earlier
/src/Mod/Sketcher/Gui/Resources/icons/constraints/Constraint_Contextual_driven.svg
to
/src/Mod/Sketcher/Gui/Resources/icons/constraints/Constraint_Contextual_Driven.svg

2. There seem to be a missing keyword before "SbVec2s prvMoveCursorPos;" line 411 in "/src/Mod/Sketcher/Gui/ViewProviderSketch.h"

Code: Select all

freecad-source/src/Mod/Sketcher/Gui/ViewProviderSketch.h:411:13: error: field ‘prvMoveCursorPos’ has incomplete type ‘SbVec2s’
  411 |     SbVec2s prvMoveCursorPos;
Should it be static?

Code: Select all

static SbVec2s prvMoveCursorPos;
3: "SoKeyboardEvent" is not declared in at least the following files: CommandConstraints.cpp and TaskSketcherTool.cpp.

Code: Select all

freecad-source/src/Mod/Sketcher/Gui/CommandConstraints.cpp:956:21: error: ‘SoKeyboardEvent’ has not been declared
  956 |         if ((key == SoKeyboardEvent::RIGHT_SHIFT || key == SoKeyboardEvent::LEFT_SHIFT) && pressed)
Adding

Code: Select all

#include <Inventor/events/SoKeyboardEvent.h>
seems to fix this, but i'm unsure if this header file should be declared elsewere.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by Kunda1 »

Haavard wrote: Sun Jan 23, 2022 4:04 pm Errors so far:
It may make sense to work in github. You could even submit the changes to paddlestroke's repo directly to be merged in to the current PR ;)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
paddle
Veteran
Posts: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by paddle »

Interesting, so it seems visual studio is somehow forgiving on some mistakes.
Can you compile with those corrections?
I'll integrate them unless you make a PR on my branch.
Haavard
Posts: 217
Joined: Wed Feb 17, 2021 10:48 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by Haavard »

I'm unfortunately not able to compile, even with my corrections. PS, i have not studied the code, only tried to fix with the compile errors, so please check if those are actual corrections. I could make a PR, but it wont change the "not compilable" issue ;)
Post Reply