alonso_jamm wrote: ↑Mon Aug 24, 2020 4:07 am
The solver is "dumb," it barely knows anything about FreeCAD. The general way of how it works is: first it gets the current positions of the objects to be constrained; then it minimizes equations that represent the constraints using the initial values of the positions of the objects; and finally it sets the resulting values to the objects' placements. That is, the solver only knows how to get the placements and how to set them. It doesn't know anything about attachments which means that the solver won't work correctly if two objects are attached. For example, if LCS_2 is attached to LCS_1 and we have a constraint between LCS_2 and LCS_3, then the solver will try to set the position of LCS_2 to some calculated value (it will try to do this for example: App.ActiveDocument.LCS_2.Placement.Base.x = 3). Some sort of "attachment checker" is needed in order to have attachments work with the solver.
OK, I begin to understand.
In my mind, a typical workflow for constraints would be that of an assembly with 3 parts:
- parts 1 and 2 are attached in the assembly by master sketch and LCS
- part 3 is constrained on part1 and part2.
For example, part1 has a hole, into which part3 is inserted free to rotate. The orientation of that rotation is given by some reference in part2. For that, part3 would have an LCS that is attached to the corresponding LCS in part1, but with 1 DoF. This DoF is calculated with a constraint set on the reference LCS coming from part2. The simplest example would be a parallelogram.
My intuition was that is was easier to deal with 1 DoF, but after reading your method may-be it's better to have a solver do either nothing or all the calculations for a given part, but mixing them could be difficult. If the latter, we need to add all the different constraint types (colinear, coplanar ..).
Do I understand the principle correctly ?
In which case I propose to add a property to datum objects that tell what sort of placement they have :
Code: Select all
datum.addProperty('App::PropertyString', 'PlacementMethod', 'Attachment')
and this PlacementMethod can be Manual, ExpressionEngine, AttachEngine, SolverName. And the Solver would only deal with datum objects that have the PlacementMethod set correctly.
If we want to create a constraint on a datum that is in a part, we need to create a (virtual ?) clone of the datum inside the assembly (all it needs is an App::PropertyPlacement property, could be created as a property of the respective constraint), make the calculations with the clone, and attach the parts to that clone. Something like that. This "clone" is probably quite similar to the "Elements" stuff in Asm3.