sketcher: fun with trimming

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
uwestoehr
Posts: 587
Joined: Sun Jan 27, 2019 3:21 am

sketcher: fun with trimming

Postby uwestoehr » Thu Jul 18, 2019 3:40 pm

I am aware that there are issues with trimming but all I found in the forum was reported years ago.
Nevertheless this might be a still known issue but it is a funny one:

- take this example:
trim-issue.FCStd
(11 KiB) Downloaded 8 times

-try to trim the line inside the arc to be consistent with the other arcs:
FreeCAD_X0mpHIe8Nd.png
FreeCAD_X0mpHIe8Nd.png (15.74 KiB) Viewed 230 times

result: the line is not trimmed but extended

Is this a known issue or not?

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17433 (Git)
Build type: Release
Branch: master
Hash: 125380ddd9a1fdeb45ffc736040dad1f6343daa4
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)
User avatar
papyblaise
Posts: 329
Joined: Thu Jun 13, 2019 4:28 pm
Location: France

Re: sketcher: fun with trimming

Postby papyblaise » Thu Jul 18, 2019 4:34 pm

Hello
it's several edge open in your sketch
for your specific question , you constraint first to the segment , you don't hable make an other constraint of length
kisolre
Posts: 1120
Joined: Wed Nov 21, 2018 1:13 pm

Re: sketcher: fun with trimming

Postby kisolre » Thu Jul 18, 2019 5:46 pm

The problem is again some automation. When the trim is executed it automatically creates PointOnLine or Coincidence constraint (which was probably why trim was executed) depending on resulting number of edges left at that point. This is visible on a screenshot but not explained in the docs Sketcher_Trimming.
Here existing PointOnLine constraints on both arc edges make the solver to produce confusing (but valid) result. Removing bottom PointOnLine constraint makes it work as expected.
Last edited by kisolre on Thu Jul 18, 2019 9:38 pm, edited 1 time in total.
User avatar
bejant
Posts: 5728
Joined: Thu Jul 11, 2013 3:06 pm

Re: sketcher: fun with trimming

Postby bejant » Thu Jul 18, 2019 9:09 pm

uwestoehr wrote:
Thu Jul 18, 2019 3:40 pm
Is this a known issue or not?
I'm not completely sure but in the context of that Sketch I'm more of the opinion that this is not so much a FreeCAD issue as it is an improper method of making the Sketch, and I'm leaning that way because:
  • Auto Constraints could have been ticked to On;
  • This shape could more easily be drawn using the Polyline tool (even if creating the Sketch using several small continuous lengths of different types of geometry) instead of Sketching each edge individually and separately;
  • If the edges of the Arc(Edge7) and Line(Edge2) were originally overlapping we would normally use the Trim tool first [instead of applying the Point On Edge Constraint, and then applying a Coincident Constraint between the Endpoint of Line(Edge2) and the center of Arc(Edge7)] and so a Coincident Constraint would be applied automatically to the end of the line segment and the end of the arc (and if the edges weren't overlapping, the Point On Edge is likely the wrong Constraint to use there);
  • Geometric Constraints should have been applied before Length Constraints. Without changing any Constraints, notice how the edges can be dragged apart from one another:
    20190718a.png
    20190718a.png (24.26 KiB) Viewed 193 times


To me it looks like that Sketch was purposely constructed in a manner that is opposite of how someone should make it. The ability to make good Sketches is a skill that has to be learned, and some tips are here:
https://www.freecadweb.org/wiki/Sketche ... _Practices
https://forum.freecadweb.org/viewtopic. ... 04#p248329 (at the end of the post).


FWIW the Trim tool does delete the Coincident Constraint (Constraint19) previously applied between the endpoint of the line segment and the center of the arc.

OS: Ubuntu 18.04.2 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.18.1.
Build type: Release
Python version: 3.6.7
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
User avatar
uwestoehr
Posts: 587
Joined: Sun Jan 27, 2019 3:21 am

Re: sketcher: fun with trimming

Postby uwestoehr » Thu Jul 18, 2019 10:00 pm

kisolre wrote:
Thu Jul 18, 2019 5:46 pm
The problem is again some automation. When the trim is executed it automatically creates PointOnLine or Coincidence constraint (which was probably why trim was executed) depending on resulting number of edges left at that point. This is visible on a screenshot but not explained in the docs Sketcher_Trimming.
Here existing PointOnLine constraints on both arc edges make the solver to produce confusing (but valid) result. Removing bottom PointOnLine constraint makes it work as expected.
Many thanks for the explanation. The question is if the solver can be improved in this respect or not. If yes, I will file a bug if not, then not.

bejant wrote:
Thu Jul 18, 2019 9:09 pm
an improper method of making the Sketch
My aim was not to get a working sketch but to find a reproducible case for a strange thing I see frequently with trimming.
(The original sketch is the result of a DXF import, thus no autoconstraints.)

In my understanding the sketcher should work as expected no matter in which order the user set what constraint or not. I mean I performed a trimming action therefore it should not matter how other sketch parts are constrained or not. I want a line to be trimmed and FC should just do this. But I get the opposite - an extension. This is at the first look very confusion and it took me few minutes to get it right.
I stumble over these workflow-breakers every day since I started to do more work with FC. More work means collaboration and and this means DXF files to import and manage. The DXF import results gives you sketches in sometimes strange state. Therefore it would be very helpful if FC would be more tolerant and just performs the actions as can be expected by the user.
User avatar
bejant
Posts: 5728
Joined: Thu Jul 11, 2013 3:06 pm

Re: sketcher: fun with trimming

Postby bejant » Fri Jul 19, 2019 1:03 am

uwestoehr wrote:
Thu Jul 18, 2019 10:00 pm
My aim was not to get a working sketch but to find a reproducible case for a strange thing I see frequently with trimming.
Ok, thanks for explaining that, and we can do our best to better pinpoint the problem so that our developers can help solve it.
uwestoehr wrote:
Thu Jul 18, 2019 10:00 pm
(The original sketch is the result of a DXF import
That explains a bit more and introduces a new variable. Personally it wouldn't bother me in the least if FreeCAD stopped supporting that closed source format, but that's a subject for a new topic.

uwestoehr wrote:
Thu Jul 18, 2019 10:00 pm
In my understanding the sketcher should work as expected no matter in which order the user set what constraint or not.
Ok. If I create an arc and a line segment in a new Sketch and Constrain them as you did in the original file, the Trim works for me. What happens if you do the Trim in the attached file?

What happens if you recreate the Sketch from scratch yourself and do the Trim?
20190718a-trim-issue.FCStd
(9.27 KiB) Downloaded 2 times



OS: Ubuntu 18.04.2 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.18.1.
Build type: Release
Python version: 3.6.7
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
User avatar
uwestoehr
Posts: 587
Joined: Sun Jan 27, 2019 3:21 am

Re: sketcher: fun with trimming

Postby uwestoehr » Fri Jul 19, 2019 11:15 am

bejant wrote:
Fri Jul 19, 2019 1:03 am
That explains a bit more and introduces a new variable. Personally it wouldn't bother me in the least if FreeCAD stopped supporting that closed source format, but that's a subject for a new topic.
Well, you never work alone. There are many CAD programs around and the most common file format is for 2D DXF and for 3D STEP. So without a DXF importer I would not be able to construct anything else than private hobby projects with FC.

bejant wrote:
Fri Jul 19, 2019 1:03 am
If I create an arc and a line segment in a new Sketch and Constrain them as you did in the original file, the Trim works for me. What happens if you do the Trim in the attached file?
This works fine. That is why I sent the more complex geometry because the problem appears only under certain circumstances which are not yet clear to me.
chrisb
Posts: 16946
Joined: Tue Mar 17, 2015 9:14 am

Re: sketcher: fun with trimming

Postby chrisb » Fri Jul 19, 2019 11:30 pm

I have tried to simplify the sketch and was able to reduce it just to the line and the arc. in the attached model it is the left pair.
Bildschirmfoto 2019-07-20 um 01.01.14.png
Bildschirmfoto 2019-07-20 um 01.01.14.png (11.88 KiB) Viewed 100 times
Then things got worse.
The pair in the middle was drawn first the arc, next the line. The rightmost pair was drawn first the line next the arc. The middle pair always works as expected.

If I
- load the file
- edit Sketch
- trim the upper part of the right pair

Then another situation is shown:
Bildschirmfoto 2019-07-20 um 01.12.17.png
Bildschirmfoto 2019-07-20 um 01.12.17.png (8.79 KiB) Viewed 100 times
If I
- undo the trimming
- remove the equality constraints
- reapply the trimming,
then the trimming sometimes works as expected.

This shows that an underconstrained sketch can show nondeterministic behaviour.
Attachments
trim-issue_cb.FCStd
(4.87 KiB) Downloaded 2 times
User avatar
uwestoehr
Posts: 587
Joined: Sun Jan 27, 2019 3:21 am

Re: sketcher: fun with trimming

Postby uwestoehr » Fri Jul 19, 2019 11:41 pm

chrisb wrote:
Fri Jul 19, 2019 11:30 pm
I have tried to simplify the sketch and was able to reduce it just to the line and the arc
Many thanks. With this simple example it is easier to play with. It seems there is no simple way to avoid this effect. I played a bit and cannot find one. But that the order of the creation is important (first line or arc) is a hint that something can be improved.
I guess, this case is more load for Abdullah's upcoming rainy days sessions :)

I think we should open an issue to document this case.
User avatar
bejant
Posts: 5728
Joined: Thu Jul 11, 2013 3:06 pm

Re: sketcher: fun with trimming

Postby bejant » Sat Jul 20, 2019 1:02 am

uwestoehr wrote:
Fri Jul 19, 2019 11:41 pm
I think we should open an issue to document this case.
Reported as issue #4066