realthunder / FreeCAD_assembly3

Experimental attempt for the next generation assembly workbench for FreeCAD
GNU General Public License v3.0
884 stars 74 forks source link

Unable to add constraints when using Assembly3 (due to overconstraining) #1201

Open troetter opened 2 years ago

troetter commented 2 years ago

I've been trying to create a simple assembly of a few 3d printed parts and some off-the-shelf bearings and fasteners. I've encounter numerous frustrating issues that I don't understand the reasons behind. I'm using the freecad-realthunder snap with version string "2022-02-13-gce7fe6dc" on Fedora 35.

I have attached a zip with three files. In 'slide_assy' I'm trying to assemble bodies from the other two files. The current issue is that I want to add an instance of a washer and constrain it with an axial and a planar alignment.

Step by step, reproducible on my end:

  1. Open 'slide_assy' document
  2. Switch to Assembly 3 wb
  3. Open 'cots' document
  4. With 'Assembly' under 'slide_assy' enabled, drag 'Wiberger-din125_8-4' into 'Assembly'
  5. Select left-most hole surface in 'SlidePart1'
  6. Ctrl select inner surface of washer
  7. Press 'Create "AxialAlignment" constraint'

The error reported is:

18:28:12  173.603949 <asm3.sys> system.py(244): auto relax constraint (slide_assy#AxialAlignment001) slide_assy#Constraint002 between (slide_assy#SlidePart2) slide_assy#Link001 and (slide_assy#SlidePart1) slide_assy#Link, 2
18:28:12  373.365058 <asm3.main> assembly.py(3918): solver exception when auto recompute
Traceback (most recent call last):
  File "/snap/freecad-realthunder/8/usr/Mod/Assembly3/freecad/asm3/solver.py", line 110, in __init__
    self.system.solve(group=self.group,reportFailed=reportFailed)
  File "/snap/freecad-realthunder/8/usr/Mod/Assembly3/freecad/asm3/sys_slvs.py", line 70, in solve
    raise RuntimeError(reason)
RuntimeError: inconsistent constraints

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 535, in _catch
  File "/snap/freecad-realthunder/8/usr/Mod/Assembly3/freecad/asm3/solver.py", line 412, in solve
    return _solve(*args,**kargs)
  File "/snap/freecad-realthunder/8/usr/Mod/Assembly3/freecad/asm3/solver.py", line 382, in _solve
    Solver(assembly,reportFailed,dragPart,recompute,rollback)
  File "/snap/freecad-realthunder/8/usr/Mod/Assembly3/freecad/asm3/solver.py", line 113, in __init__
    raise RuntimeError(translate('asm3', 'Failed to solve {}: {}').format(
RuntimeError: Failed to solve slide_assy#Assembly: inconsistent constraints

While trying to create this assembly I have encountered numerous similar issues, where it is impossible to add a constraint. Sometimes it has worked if I first move the newly linked part before trying to add the constraint. Other times it has worked if I link the part, save and close all files and restart before trying to add any constraints. I haven't found a pattern however, and I haven't found anything that works in this particular case.

throttle_testbed.zip

realthunder commented 2 years ago

You are over constraining your assembly. The solver is kind of sensitive to this problem.

There are 6 degree of freedom (DOF) between any two components, 3 translational and 3 rotational. An axial constraint removes 2 translational and 2 rotational DOF, while the plane alignment removes 1 translational and 2 rotational DOF which are the same 2 removed by axial constraint. You can use only one PlaneCoincident constraint to do the job. If you do not need the rotational DOF of the washer, you can completely fix the washer by using the AttachmentConstraint.

You can find some more description of constraint and other help info here

ksnip_20220318-160549

troetter commented 2 years ago

I've noticed that over constraining is an issue much more often in FreeCAD/Assembly 3 than I'm used to from other tools. Indeed, the PlaneCoincident constraint is rather different from other tools I've used in that the centers are relevant. My thought would be to use the PlaneAlignment and AxialAlignment together since it's more like what I'm used to, and in my opinion shows the design intent much more clearly.

However, I don't understand how over constraining would be the issue in this case. The issue occurs when I try to add the first constraint between the two bodies. Surely there can be no over constraining then?

troetter commented 2 years ago

I did not notice until now that this issue had been transferred here. I see also that "due to overconstraining" has been added to the title. I still don't understand how I can be overconstraining when I'm trying to add the first constraint to the newly added part.

luzpaz commented 2 years ago

@troetter please open a thread on the Freecad forum asking for orientation around this.