[Feature idea] Smart constraint tool

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
paddle
Veteran
Posts: 1391
Joined: Mon Feb 03, 2020 4:47 pm

[Feature idea] Smart constraint tool

Post by paddle »

So I was thinking about the constraint tools in FreeCad.
I remember when I learned to use FreeCad that each constraint have its button was very painful. And only after learning some shortcuts did it get easier. Though it still isn't as fast as I'd like.

I was thinking that a 'smart constraint' tool could be very nice and speed up work.

The idea is that this tool will make different constraint based on what you are clicking.
So for instance :
- You select the 'smart constraint' tool.
- You click on a line
- A preview of distance constraint appears
- You click on a second non parallel line
- The preview switch to angle constraint.
- You click on empty space
- It brings the dialog box of the last previewed constraint tool.

Other example :
- You select a circle
- Preview of radius constraint
- You select a line
- Preview of tangency constraint.
...

While this does not cover all the constraint and won't replace the other tools, it would cover most of the workflow and would speed the process, especially for beginners who don't know shortcuts (let's be honest, even after two years I don't know half of the shortcuts and still struggle some times).

For reference, this tool is found on Catia for instance. And before anyone gets on the 'freecad won't be a clone of other cad software' let me clear things up: it doesn't mean that I want FreeCad to be turned in a clone of Catia. It's just a nice feature that make things faster. Catia has its own annoying flaws that FreeCad handle much better (vertical and horizontal distances for instance). I just think it would be best to take the best of both.

Your thoughts ? If enough people are interested to get it integrated then I'd like to develop it.
Thanks
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: [Feature idea] Smart constraint tool

Post by chrisb »

When I'm constraining I prefer to add geometric constraints, so I would call this a "smart dimensioning" tool.
When I select a line, they are very often horizontal or vertical. If I dimension such lines it is mostly
- horizontal distance for horizontal lines
- vertical distance for vertical lines.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
obelisk79
Veteran
Posts: 1061
Joined: Thu Sep 24, 2020 9:01 pm

Re: [Feature idea] Smart constraint tool

Post by obelisk79 »

Additionally, I dislike using the term 'smart' in this case, even though I realize other cad software uses the term. A more accurate term would be 'contextual constraints'. For constraints or dimensioning, this would have to be something that is an optional feature, because many prefer to apply constraints/dimensions 100% manually. Personally I find value in both approaches.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: [Feature idea] Smart constraint tool

Post by adrianinsaval »

This would be a welcomed addition by most people I think, also consider making the m key switch between the different constraints available for the selection.
User avatar
paddle
Veteran
Posts: 1391
Joined: Mon Feb 03, 2020 4:47 pm

Re: [Feature idea] Smart constraint tool

Post by paddle »

Smartconstraint was just a name idea, it's not important, it can be something else. Contextual is fine for me
User avatar
Pauvres_honteux
Posts: 728
Joined: Sun Feb 16, 2014 12:05 am
Location: Far side of the moon

Re: [Feature idea] Smart constraint tool

Post by Pauvres_honteux »

issue #1416 Constraints creation "on the fly"
User avatar
paddle
Veteran
Posts: 1391
Joined: Mon Feb 03, 2020 4:47 pm

Re: [Feature idea] Smart constraint tool

Post by paddle »

Pauvres_honteux wrote: Mon Dec 20, 2021 9:25 pm issue #1416 Constraints creation "on the fly"
Oh I see, yes that's exactly what I had in mind.
abdullah wrote: Thanks for the pictures. I have understood what you mean.

Some of the concepts are similar to an old idea called "Constrinator", which was never implemented. I intended to start developing parts of that tool this year.

I will consider your input when giving shape to that new tool.
Hi Abdullah! :)
Is it actually being worked on or not yet? If yes I can help on the 'if tree' of the tool. If not I have started to think on it and have a few questions on how constraints code work.

Code: Select all

CmdSketcherConstrainHorizontal::activated(int iMsg) 
This constraint function is the one that is called when you click the icon right? So the code is useful if the user already selected geometries before clicking it, correct?

Code: Select all

CmdSketcherConstrainHorizontal::applyConstraint(std::vector<SelIdPair> &selSeq, int seqIndex)
This function is the one that is used in continuous mode, so when the tool is already activated. Right?
But then what is seqIndex ? And where is it defined? Why the function code use a Switch on this and not directly a 'if tree' on selSeq vector?
What is strange for me is that the seqIndex seems to represent different case between the different constraint functions. So it's hard to make sens of it.
tjking293
Posts: 6
Joined: Mon Mar 15, 2021 6:46 pm

Re: [Feature idea] Smart constraint tool

Post by tjking293 »

Does anyone know why the horizontal and vertical constraints are two different constraints and not one?
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: [Feature idea] Smart constraint tool

Post by chrisb »

tjking293 wrote: Wed Jan 19, 2022 6:22 am Does anyone know why the horizontal and vertical constraints are two different constraints and not one?
Because one makes a line vertical and the other makes it horizontal?
Attachments
SnipScreenshot-364db8.png
SnipScreenshot-364db8.png (1.33 KiB) Viewed 14819 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
paddle
Veteran
Posts: 1391
Joined: Mon Feb 03, 2020 4:47 pm

Re: [Feature idea] Smart constraint tool

Post by paddle »

One problem I face is that the commands clear the selection (not the point but the edges yes).
So for instance :

Code: Select all

        Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Add equality constraint"));
        Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Equal',%d,%d)) ",
            GeoId1, GeoId2);
        Gui::Command::commitCommand();
clears the selection.

Is there a way to prevent that?
Or alternatively I could reselect all the perviously selected geometries as their GeoId are stored. But how to add to selection with GeoIds ? Now I'm using

Code: Select all

                Gui::Selection().addSelection(Obj->getDocument()->getName(),
                    Obj->getNameInDocument(),
                    ss.str().c_str(), onSketchPos.x, onSketchPos.y, 0.f);
Which use onSketchPos so I can't use that to reselect all the geometries.
Post Reply