Developers,
I want to develop a feature of automated hover symmetrical contstraint,
inside sketcher
if there is a line or curve already drawn (line A), and the user wants to add an additional line or curve (Line B)
if the user's tool tip hovers close enough to the center of line A, I want to suggest a symmetrical constraint.
upon sketching Line B, it should snap to the center point of Line A and establish a symmetrical constraint.
there are already a number of automated hover constraints available including coincident, point on object, vertical, horizontal, concentric ...
this is available in solid works and was always my most used feature in order to help make symmetrical parts.
Some questions:
a. if I work on this feature, would the freecad community accept it?
b. how do you guys suggest that I implement, (given that this sort of thing is very common in FREECAD)
thanks!
-micha
automated hover symmetrical constraint
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: automated hover symmetrical constraint
I'm sure that it would be highly appreciated by many users. For me, it's one of the largest potential improvements of the sketcher waiting for the implementation.
This was already discussed briefly here: https://forum.freecadweb.org/viewtopic. ... 0&start=10
and here: https://forum.freecadweb.org/viewtopic.php?f=8&t=59890
but there are no works on that at the moment.
Let's start with the fact that the Draft workbench offers a similar feature. It's called snap and several other types are available (like snap to center). However, in the Sketcher the nomenclature is different. The feature that allows you e.g. to constrain points together and make lines vertical/horizontal with proper placement of the cursor is called an auto constraint. Unfortunately, it doesn't support several important constraints such as the symmetry one mentioned here. It doesn't detect centers of objects like rectangles too but that could be partially replaced with automatic symmetry constraint for now. Anyway, if you want to implement the auto symmetry constraint (which is really great), I think that you should start by examining the part of the source code responsible for existing auto constraints. Likely some pieces of this code are what you will need: https://github.com/FreeCAD/FreeCAD/blob ... andler.cpp
Re: automated hover symmetrical constraint
Abdullah is the grand master of Sketcher. Let's hear his advice.
Abdullah wrote:ping
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
- adrianinsaval
- Veteran
- Posts: 5553
- Joined: Thu Apr 05, 2018 5:15 pm
Re: automated hover symmetrical constraint
It probably will be useful for some situations but keep in mind that T joints are not allowed for many sketch based features.
Re: automated hover symmetrical constraint
Yes, but construction lines placed this way are often helpful.adrianinsaval wrote: ↑Sun May 08, 2022 3:56 pm It probably will be useful for some situations but keep in mind that T joints are not allowed for many sketch based features.
Re: automated hover symmetrical constraint
This has been discussed indeed and is a welcome addition.
So there are 2 aspects to this:
1 - The autoconstraint (what you called hover constraint). For this I'm not familiar with the current code so I don't know how to implement it. Looking at the auto constraint code should shed some light on it. It shouldn't be too hard to follow the current auto constraint code logic to replicate for this case.
2 - The snapping into position. And more largely snapping to objects in general. This is basically overridding the position of the mouse when close to an object.
This snapping feature (snap to object and snap 5 degree) has already been developped and is waiting merging. Adding the special case of snapping to the center of lines will be easy to do.
To give more details about merging : We're currently working with Abdullah on a development branch called "paddle_widget" to merge tool settings widget. On this branch many tools have been reimplemented in the new code framework. While working on this I made the snap feature but it has not yet been merged to paddle_widget because Abdullah wants to finish work on the tool settings first before adding snap.
So long story short, snap will be merged sooner or later and adding line middle is no problem for me.
So you can focus on the autoconstraint task.
So there are 2 aspects to this:
1 - The autoconstraint (what you called hover constraint). For this I'm not familiar with the current code so I don't know how to implement it. Looking at the auto constraint code should shed some light on it. It shouldn't be too hard to follow the current auto constraint code logic to replicate for this case.
2 - The snapping into position. And more largely snapping to objects in general. This is basically overridding the position of the mouse when close to an object.
This snapping feature (snap to object and snap 5 degree) has already been developped and is waiting merging. Adding the special case of snapping to the center of lines will be easy to do.
To give more details about merging : We're currently working with Abdullah on a development branch called "paddle_widget" to merge tool settings widget. On this branch many tools have been reimplemented in the new code framework. While working on this I made the snap feature but it has not yet been merged to paddle_widget because Abdullah wants to finish work on the tool settings first before adding snap.
So long story short, snap will be merged sooner or later and adding line middle is no problem for me.
So you can focus on the autoconstraint task.
Support me on Patreon: https://www.patreon.com/FreeCadDevDiary
FreeCad Dev Diary channel:[/b] https://www.youtube.com/channel/UCGMTmJ ... NiPSSEhBHA
FreeCad Dev Diary channel:[/b] https://www.youtube.com/channel/UCGMTmJ ... NiPSSEhBHA
Re: automated hover symmetrical constraint
Little coding should support a symmetric autoconstraint in the master framework. It is more about looking into ensuring that it does not interfere with other autoconstraints. This is specially the case if the autoconstraint only has two objects (one in the sketch and the new one to be created). For a more general symmetric autoconstraint three objects are necessary (two preexisting + new one). This would require to extend the autoconstraint framework as only two objects are currently supported.
If the code is clean, I would either merge it into master or to the paddle_widget branch on which we are working (and then from there to master). This depends on the amount of conflict that this work and the paddle_widget work would generate. If there is no conflict, it will go directly into master.
So, yes, please, go ahead.
Some heads-up. Look here:
https://github.com/FreeCAD/FreeCAD/blob ... dler.h#L93
and here:
https://github.com/FreeCAD/FreeCAD/blob ... r.cpp#L492
and here:
https://github.com/FreeCAD/FreeCAD/blob ... r.cpp#L761