Embedding assembly in FreeCAD's various uses

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Roland
Posts: 333
Joined: Fri Aug 21, 2015 2:20 pm

Embedding assembly in FreeCAD's various uses

Post by Roland »

Dear Assemblers,

I am not a coder, but rather a user who is quite dependent upon the successful development of FreeCAD. (representing a Micro SME, developing some innovative chemical processes).

Let me share some experience regarding assembling and FreeCAD. It could be quite relevant for the development of Assembly.

Assembly is not only a toolbench for viewing & developing how parts interact, it also produces results that are to be elaborated further. For example into construction drawings and instructions. For example into Fuses that are to be analyzed further with FEM of CFD.

The only assemblers with which I have experience is with Assembly 2 (Hamish) and with A2+ (kbwbe). In the first place, I want to give great credit to kbwbe for his A2+ WB and the support that he gives to users like me. And the level of this WB seems to be adequate to analyze the interaction of parts in the 3D space (in terms of shaping things).

In my case, however, I demand more than that from an assembler. Here is my recent experience:
  • I was not able to make proper construction drawings from A2+ assemblies. I cannot analyze the exact reasons behind this issue. The TechDraw developer Wandererfan looked at the documents and can explain more about the technical background.
  • For a CFD analysis, I needed to connect and fuse a number of bodies that together form a merged body through which a gas is flown. I intended to use A2+ WB to place all the elements in the correct position, and thereafter to fuse ('Union' in Part WB) them into a continuous gaseous body. This failed. Several undesired faces were built by 'Union' that actually blocked the gas flow. I succeeded with the job by using the original bodies as designed in Part Design, align them on the right position (just providing the coordinates in the Data Tab). The fuse command thereafter created a flawless body ('Check Geometry' in Part WB). Closer observation of the combined action of A2+ & Part operations (including 'Cut' etc.) learned me that upon a boolean operation, cylinders / circles did not remain cylinders but rather were changed into splines.
Could this be the result of how A2+ determines the locations of the various parts? Creating solutions in which faces are not placed at the exact angles? After all, splines could be the result from inaccurate angles.

I do not know how A2+ actually operates, but I read from the output report that it creates mathematically inexact solutions. For example a result like this is reported to me:

Code: Select all

TARGET   POS-ACCURACY :1e-05
REACHED  POS-ACCURACY :6.159146846645095e-06
TARGET  SPIN-ACCURACY :1e-05
REACHED SPIN-ACCURACY :9.80911239371031e-06
SA SPIN-ACCURACY      :4.90455619685548e-06
That is quite accurate, but it is not exact.

Now note that our parts as resulting from Parts and Part Design WBs are built up of properties that are mathematically exact. An assembler WB should not necessarily lose that exactitude.

This brings me to some more general questions:
  • Would it be possible to conceive an FC assembly WB using similar approaches / solvers as used in the Sketcher WB?
  • Would this be sufficient for TechDraw to deal with assemblies?
  • Would this also help creating geometrically valid solids for CFD and FEM analyses?
Please consider, and curious to hear your view.

Roland
User avatar
adrianinsaval
Veteran
Posts: 5551
Joined: Thu Apr 05, 2018 5:15 pm

Re: Embedding assembly in FreeCAD's various uses

Post by adrianinsaval »

Computers are inherently inexact, everything is an aproximation. More so when using numerical methods to obtain a solution for the position of objects. It's just like CFD, the solution is an proximation using a numerical method that stops when it meets a certain tolerance. Note that Sketcher is just the same, the solution is not exact, it is bellow a certain tolerance (a small one for sure). Assembly 4 is probably the closest you can get to an exact position as it doesn't use numerical methods but evaluates expressions but all the same, the sketches themselves are not always exact.
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Embedding assembly in FreeCAD's various uses

Post by Zolko »

Roland wrote: Mon May 04, 2020 10:26 am was not able to make proper construction drawings from A2+ assemblies. I cannot analyze the exact reasons behind this issue. The TechDraw developer Wandererfan looked at the documents and can explain more about the technical background
TechDraw works with Assembly 4:

https://forum.freecadweb.org/viewtopic.php?f=20&t=40363

I didn't experiment much with it, but you can have views and dimensions. I didn't try sections

For a CFD analysis, I needed to connect and fuse a number of bodies that together form a merged body through which a gas is flown.

Please consider, and curious to hear your view.
This actually also works with Assembly 4: if you assemble objects from different parts, and then, in the assembly, select a link and choose "Convert to solid" from the Part WB, it will create a solid at the place where the link is. If you're using Bodies from PartDesign, you have to create a clone or a copy (because Part says that it's already a solid). Then, you can fuse (boolean unite) the exported solids to get a single solid. Now, I didn't check whether you can make a mesh on such a solid.

tubes_fusion.png
tubes_fusion.png (320.85 KiB) Viewed 2396 times
try the Assembly4 workbench for FreCAD — tutorials here and here
wsteffe
Posts: 461
Joined: Thu Aug 21, 2014 8:17 pm

Re: Embedding assembly in FreeCAD's various uses

Post by wsteffe »

I needed to connect and fuse a number of bodies that together form a merged body
I have a very similar requirement in a design flow which involves EmCAD (an electromagnetic modeler I am developing).
Acutally in my case the adjacent bodies are not fused but are imprinted to assure that a common face and common edges are shared among them. In example if there are two cubes with two contacting (but different) faces, these faces are split so that the common part (intersection of two faces) becomes shared in the generated structure. This operation is performed inside of the EmCAD code using functions offered by the OpenCascade library.

I have tested all this stuff with several projects defined (for what concerns the geometry) inside of Catia V5.
I have experienced that a shared subface is always generated when two parts are subjected to a face touching constraint.
This means that, in Catia V5, the touching constraint is exact or at least it is affected by an en error that is smaller than OCC tolerance.
Same experience also with other commercial CADs.

So my conclusion is that there is something wrong if FreeCAD A2, A2+ introduces a large gap between faces that are supposed to be in contact.
User avatar
wandererfan
Veteran
Posts: 6321
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Embedding assembly in FreeCAD's various uses

Post by wandererfan »

A4 and manual assemblies work in subsequent operations (Booleans, Hidden Line Removal, etc), where A2P assemblies sometimes don't (I can't speak to A3). Here are drawings of the same pieces assembled by various methods.

A2P assembly:
DeckelBodenA2PMissingLines.png
DeckelBodenA2PMissingLines.png (63.78 KiB) Viewed 2302 times
A4 assembly:
DeckelBodenAsm4AllLines.png
DeckelBodenAsm4AllLines.png (31.61 KiB) Viewed 2302 times
Manual placement adjustment:
DeckelBodenPlacementAllLines.png
DeckelBodenPlacementAllLines.png (60.78 KiB) Viewed 2302 times
Here a Body and its imported version:
BodyVsA2P.png
BodyVsA2P.png (25.77 KiB) Viewed 2302 times
As far as I can tell, this is not unique to TechDraw. Joining the components of the A2P examples above into a Compound in PartWB gives a number of self intersection errors.
CompoundGeomErrorsArrows.png
CompoundGeomErrorsArrows.png (416.29 KiB) Viewed 2302 times
I don't have any answers, but I suspect @wsteffe is on the right track.
wsteffe
Posts: 461
Joined: Thu Aug 21, 2014 8:17 pm

Re: Embedding assembly in FreeCAD's various uses

Post by wsteffe »

It is understandable that A4 works well considering that its constraints are based on exact formulas instead of an approximate numerical solver. I will give it a try in the future.

I am still planning to switch from commercial CAD to FC but I am waiting to see a few more improvements. One of them being the merging of topo-naming.
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Embedding assembly in FreeCAD's various uses

Post by Zolko »

wsteffe wrote: Tue May 05, 2020 11:24 am It is understandable that A4 works well considering that its constraints are based on exact formulas instead of an approximate numerical solver.
that's one of the reasons, another one is that Asm4 uses standard bare-bones FreeCAD objects that have been debugged in the 0.19 development cycle (App::Part, App::Link, PD::Body, Part::Solid...). Whereas A2+ imports shapes from objects with its own parser and algorithm, if I understand correctly.
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Embedding assembly in FreeCAD's various uses

Post by Kunda1 »

kbwbe wrote::bell:
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
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Embedding assembly in FreeCAD's various uses

Post by kbwbe »

Kunda1 wrote: Tue May 05, 2020 2:57 pm
There are several topics here in the thread. I will try to answer them as far as possible.
Roland wrote: Mon May 04, 2020 10:26 am 1) ... That is quite accurate, but it is not exact.
2) ... I was not able to make proper construction drawings from A2+ assemblies.
3) ... and thereafter to fuse ('Union' in Part WB) them into a continuous gaseous body. This failed.
All of these things belong together.

At 1): As @adrianinsaval wrote:
'''
Computers are inherently inexact, everything is an aproximation. More so when using numerical methods to obtain a solution for the position of objects. It's just like CFD, the solution is an proximation using a numerical method that stops when it meets a certain tolerance. Note that Sketcher is just the same, the solution is not exact, it is bellow a certain tolerance (a small one for sure).
'''
A2plus is using it's own solver. It is written in pure Python and therefore can only make use of a limited calculation power. In consequence a compromise between speed (responsiveness of the WB) and accuracy had to be found. So A2plus stops calculation if deviation of position and angles are both better than 1e-5. It can be changed within one or two lines in the code, but then solving times will increase. A2plus is showing the results within the report view, so that everyone knows what is going on and what he is doing. Usually for standard technical applications this accuracy is good enough and practicable.

At 2): TechDraw is using core features of OCC, to generate projection of lines and hidden lines. Obviously the required accuracy of OCC seems to be much higher than the solving accuracy of A2plus. So for e.g. small deviations of mating faces are recognized as intersections or in opposite as small gaps. Techdraw gets problems with this ( i guess) and therefore it's line generation in some cases fails. I have really no idea at moment how to improve this situation. (Except rewriting the solver in C++ which gains a factor in speed about 50-100 what could be invested in higher accuracy) All geometries are existing within the data of A2plus, but not all can be handled by OCC's line projection.

At 3): Very similar to point 2): OCC struggles with accuracy and recognizes intersections or gaps.
wandererfan wrote: Tue May 05, 2020 1:00 am A4 and manual assemblies work in subsequent operations (Booleans, Hidden Line Removal, etc), where A2P assemblies sometimes don't (I can't speak to A3). Here are drawings of the same pieces assembled by various methods.
I think my explanations above refer to this topic. A4 is working without solver and with placements. Therefore tolerances are small.
Zolko wrote: Tue May 05, 2020 12:46 pm ... Whereas A2+ imports shapes from objects with its own parser and algorithm...
A2plus is a direct successor of A2. Nothing else. It is working by same principle and is importing compound shapes (for now). It is using it's own import algorithm to enable it's builtin support for topo-naming, as long there is no "official" way to use such functionality.
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
wsteffe
Posts: 461
Joined: Thu Aug 21, 2014 8:17 pm

Re: Embedding assembly in FreeCAD's various uses

Post by wsteffe »

kbwbe wrote: Tue May 05, 2020 8:20 pm rewriting the solver in C++
This would surely be beneficial but I.M.O, the solver times could also be improved with an intelligent pre-processing applied in advance of the brute force solver. This suggestion is based on the following consideration:

Most mechanical assemblies are built by imposing constraints subsets which fully constraint a solid part with respect to another such as in the following example:
1) insert and anchor part A
2) Insert part B and fix it with respect to part A...
3) Insert part C and fix it with respect to part A or to part B.

This is not always the case but it is quite probable that in a typical assembly it is possible to identify several part couples (A, B), (B,C) which are fully constrained.

Let us suppose that we have found that B is fully constrained with respect of A.
Then, for a fixed position of A, it is possible to find (in example trough the numerical solution of a system of order 6) the corresponding position of part B. For being fully constrained A+B may be regarded as a single solid. The position of A and the position of B may then be expressed as the initial fixed position +3 translations +3 rotations. In this way the 12 degree of freedom which, in the original system, define the positions of solids A and B are replaced by 6 degree of freedom associated with the position of A+B.

The identification of a fully constrained couple leads to a reduction of 6 to the dimension of the assembly problem.
If the assembly includes several fully constrained couples this strategy will permit to achieve a strong reduction of the problem complexity.
Post Reply