Dimension Reference Error Detection and Correction

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
wandererfan
Veteran
Posts: 6238
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Dimension Reference Error Detection and Correction

Post by wandererfan »

After git commit b9fa9cb33e, TechDraw now attempts to detect situations where a dimension's reference (ex Edge5) points to a different piece of geometry after a recompute.

Autocorrection of references is optionally available, controlled by a preference setting. In phase 1, an exact match to the original geometry must exist for autocorrection to take place. Phase 2 will use partial matches.

A big THANK YOU to @aapo and @user1234 for their awesome testing help.
aapo
Posts: 612
Joined: Mon Oct 29, 2018 6:41 pm

Re: Dimension Reference Error Detection and Correction

Post by aapo »

Big thanks for coding the error correction system! This newly merged feature, and especially the further improvements currently under development are going to make maintaining TD drawings much much easier in the future. Of course, there'll still be room for improvement, but this is already going to be a small step and the expected further additions a big step towards the level of TNP mitigation that commercial CAD systems offer. :D

EDIT: There are couple of things that need careful planning about the next level of the TechDraw TNP mitigation:
  • Changing the drawing scale obviously changes the positions and lengths of all edges. You've probably already thought about this, but this needs a specific logic to scaling handler to insert a scaling factor to expected edge positions upon a detected scale change
  • Changing the ISO Count in the View data chops the edges into shorter segments. This is a problem because one edge may suddenly became five edges, or vice versa, and their relations to each other needs to be updated somehow. The "ownership" of a dimension connected to an edge may suddenly be expected to be split for two edges. This probably needs to be handled by finding the vertices (which are in the original positions), and converting an edge dimension to vertices dimension, with the vertices located in two different edges. And vice versa. Complicated, but feasible.
user1234
Veteran
Posts: 3261
Joined: Mon Jul 11, 2016 5:08 pm

Re: Dimension Reference Error Detection and Correction

Post by user1234 »

I only complied it and said "works". No need to thank me.

@wandererfan : many thanks for working on it!


Greetings
user1234
aapo
Posts: 612
Joined: Mon Oct 29, 2018 6:41 pm

Re: Dimension Reference Error Detection and Correction

Post by aapo »

Those wanting to test the 1st phase changes without compilation, you'll be able to find the test versions from weekly-builds, where the currently most recent versions (32457) contain this TechDraw TNP mitigation 1st phase code. It's already pretty great, if you e.g. add holes into your model (see gif).

Weekly builds for testing: https://github.com/FreeCAD/FreeCAD-Bund ... kly-builds

In the gif video, you'll see that I have a dimensioned model of a PartDesign object where the tip is set to the first feature without holes. The dimensioned drawing looks quite basic, but look what happens (or rather, doesn't happen!) when I set the PartDesign object tip to the last feature that has couple of holes in the structure: The TechDraw dimensions stay where they are, and don't jump around! If I'd do the same with any older versions, the dimensions would be all over the place after the geometry change. Then, when I dimension one of the new holes, and go backwards by removing the holes, all the other dimensions stay where they should, and I have just this one lonely ghost dimension without its hole. It reminds me that I used to have a hole there that doesn't exist any more, and then I can easily remove the superfluous ghost dimension.

So, this is pretty great already, but note that this doesn't work if you change the bounding box around your object, i.e. if you grow or shrink your outer edges in any direction, the 1st phase mitigation code may go haywire. But, this is still a great step forwards, because with careful experimenting it's possible to manually handle these cases to at least some degree: First, carefully enlargen (shrink) your object without adding or removing any geometrical elements, refreshing TechDraw, and only then messing with the geometry, but this time without growing or shrinking the outer edges you'll be able to work around dimension shuffling already.

20230324-TD-TNP-mitigation-1st-phase-example-video-01.gif
20230324-TD-TNP-mitigation-1st-phase-example-video-01.gif (928.25 KiB) Viewed 1310 times

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.21.0.32457 (Git)
Build type: Release
Branch: master
Hash: 85216bd12730bbc4c3cbf8f0bc50416ab1556cbb
Python 3.10.9, Qt 5.15.8, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: English/United Kingdom (en_GB)
Installed mods: 
  * Assembly4 0.12.4
  * CurvedShapes 1.0.4
  * Curves 0.5.12
  * fasteners 0.4.19
  * fcgear
  * fcgear.bak
  * OpticsWorkbench 1.0.9
  * sheetmetal 0.2.58
Attachments
20230324-TD-TNP-mitigation-1st-phase-example.FCStd
(48.19 KiB) Downloaded 38 times
domad
Veteran
Posts: 2029
Joined: Mon Jun 22, 2020 12:16 pm

Re: Dimension Reference Error Detection and Correction

Post by domad »

Greetings to the Community!
The mitigation is starting to bear fruit, the animated gif proves the right direction taken, a big thank you (!) to @wandererfan for the continuous and tireless improvement work. :)
The other gif shows incorrect operations for the redefinition (link to the model) of the dimension in axonometric using different procedures. :(
Attachments
20230324-TD-TNP-mitigation-1st-phase-example_domad.FCStd
(71.02 KiB) Downloaded 34 times
TD-TNP-mitigation.gif
TD-TNP-mitigation.gif (772.29 KiB) Viewed 1154 times
errors_links.gif
errors_links.gif (883.21 KiB) Viewed 1154 times
aapo
Posts: 612
Joined: Mon Oct 29, 2018 6:41 pm

Re: Dimension Reference Error Detection and Correction

Post by aapo »

domad wrote: Sat Mar 25, 2023 2:24 pm The other gif shows incorrect operations for the redefinition (link to the model) of the dimension in axonometric using different procedures. :(
Yes, WandererFan's algorithm for TNP mitigation concerns only 2D geometry, which is flattened from 3D model -> 2D drawing by OCCT routines. Because axonometric data is linked to the 3D geometry, it'll be affected by TNP problems as long as realthunder's algorithm is not merged. So, realthunder's TNP mitigation patches do not really help TechDraw, and WandererFan's algorithm does not really help with axonometric 3D references.

However, the Good News is that apparently both systems are going to be merged, and together they should (maybe) fix the axonometric case, too! Let's wait and see :D
User avatar
wandererfan
Veteran
Posts: 6238
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Dimension Reference Error Detection and Correction

Post by wandererfan »

domad wrote: Sat Mar 25, 2023 2:24 pm The other gif shows incorrect operations for the redefinition (link to the model) of the dimension in axonometric using different procedures. :(
I broke the 3d dims. :oops: https://github.com/FreeCAD/FreeCAD/pull/9053 should put things back together.
peanuts_rats.gif
peanuts_rats.gif (5.86 KiB) Viewed 1079 times
User avatar
wandererfan
Veteran
Posts: 6238
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Dimension Reference Error Detection and Correction

Post by wandererfan »

aapo wrote: Sat Mar 25, 2023 5:41 pm Yes, WandererFan's algorithm for TNP mitigation concerns only 2D geometry, which is flattened from 3D model -> 2D drawing by OCCT routines.
The error detection and correction algo works for 3d dimensions also. It doesn't know about projection or hidden lines. It just compares the current referenced shape with the saved copy.
User avatar
wandererfan
Veteran
Posts: 6238
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Dimension Reference Error Detection and Correction

Post by wandererfan »

git commit 20e44eba50 should fix the problem with 3d dims.
Post Reply