realthunder wrote: ↑Mon Dec 31, 2018 12:06 am
If you actually try to code your idea of a LCS only assembly, you'll soon find yourself in trouble with dependency mess. If you walk through the chain of LCS pairs, you'll find loops in very simple assemblies.
Zolko wrote: ↑Sun Dec 30, 2018 1:54 pm
In fact, FreeCAD's AttachEngine is used for this purpose.
Supposed, for example, that I have an assembly, a part, each having 2 LCS, and I want to attach — using your App::Link framework — the part by one of its LCS to the assembly, twice, once on each LCS. Would it be possible to do it today ?
That's how PartDesign body builds on, attaching sketch to existing body feature, and then create new feature. It works well because the body is supposed to produce fixed geometries, and you are actually building those geometries along the way, whereas in assembly, the parts are already built, possibly from different people. AttachEgnine are in src/Mod/Part/App/Attacher.h/cpp.
Soooooooooooooo ............ "
show me the code", as a famous kernel maintainer once said. I
did actually code my assembly: one Part with 3 LCS, and one Assembly with 7 LCS, and the Part is inserted 6 times on 6 LCS of the assembly, attached at one of its 3 LCS (of the part). It is surprisingly easy, once you know how to do it, and I think that the assembly workbench without solver is not that far away. I used my own compiled FreeCAD from the LinkStage3 branch by realthunder, and I'v also tested the result with the AppImage he has provided.
I first created a Part in PartDesign, with 3 LCS (the thig was to make it assymetric) :

- Part+LCS_0.png (175.82 KiB) Viewed 971 times
It's important that the LCS are in the Body container, or else they are not "mounted" during lining.
Then an Assembly, with a sketch having a hexagon, and 6 LCS at each corner, using different MapModes (translation, OXY, OYZ...) :

- Assembly+Sketch.png (162.01 KiB) Viewed 971 times
It's all parametric of course: if you modify the hexagon, the LCS all move with it as they should. I then inserted an App::Link, assigned the correct Document:
Code: Select all
App.getDocument('Assembly').addObject('App::Link','Part_1')
FreeCAD.getDocument("Assembly").getObject("Part_1").LinkedObject = (App.getDocument('Part').getObject('Body'),'')
...and here comes the magic: you can place the linked part where the (target) LCS in the assembly is, and multiplying it by the inverse of the placement where the (attachment) LCS is in the part:
Code: Select all
App.getDocument("Assembly").Part_1.Placement = App.getDocument("Assembly").LCS_1.Placement.multiply( App.getDocument("Part").LCS_1.Placement.inverse() )
The first LCS_1 is the target LCS in the Assembly, the second LCS_1 is the attachment LCS in the Part (yes, I realized later that I could have chosen better names, sorry, but you get the thing). And you do that for all 6 links:
Code: Select all
App.getDocument("Assembly").Part_1.Placement = App.getDocument("Assembly").LCS_1.Placement.multiply( App.getDocument("Part").LCS_1.Placement.inverse() )
App.getDocument("Assembly").Part_2.Placement = App.getDocument("Assembly").LCS_2.Placement.multiply( App.getDocument("Part").LCS_1.Placement.inverse() )
App.getDocument("Assembly").Part_3.Placement = App.getDocument("Assembly").LCS_3.Placement.multiply( App.getDocument("Part").LCS_2.Placement.inverse() )
App.getDocument("Assembly").Part_4.Placement = App.getDocument("Assembly").LCS_4.Placement.multiply( App.getDocument("Part").LCS_0.Placement.inverse() )
App.getDocument("Assembly").Part_5.Placement = App.getDocument("Assembly").LCS_5.Placement.multiply( App.getDocument("Part").LCS_1.Placement.inverse() )
App.getDocument("Assembly").Part_6.Placement = App.getDocument("Assembly").LCS_6.Placement.multiply( App.getDocument("Part").LCS_2.Placement.inverse() )
And all 6 Parts are placed where they should be:

- Assembly+Parts.png (198.12 KiB) Viewed 971 times
You can see that for Part_3 attached to LCS_3, the LCS are perfectly aligned:

- Part_3+LCS.png (169.81 KiB) Viewed 971 times
I've done the same thing in SolidWorks to cross-check:

- Assembly_SolidWorks.png (290.7 KiB) Viewed 971 times
So what's the catch ? Well, the Parts (the Links) are placed by Placement, not by attachment, therefore when I change the size of the hexagon, the LCS all follow (because
they are placed by attachment) but the parts remain where they have been placed. I need to re-run the placement commands to have them get to their new/correct position.
(I can't attach the FreeCAD files I used for this, I'll do it in another post) The Part weights 32kB, and the Assembly 13kB.