"BodyBuilder", a PartDesign macro for assembling bodies

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

"BodyBuilder", a PartDesign macro for assembling bodies

Post by freedman »

I know there are a many folks that say we don't need another assembly tool but maybe we do :). Do we need one that you can learn in 5 minutes, one that works in PartDesign, one that uses Bodies, that's this one.
Look at it this way, if you don't like it you can delete the bindings and forget it in 10 minutes. :)

I think many times new users and some of us need a model with just a few parts held together, we don't need the full assembler that does everything, but this one might. The concept: It's very simple to use and the concept is simple. You 3D select a Body, then select a sketch from another Body, then click the button "Bind body to sketch" that's it. As long as the macro is running the Body origin will stay locked to the sketch origin. You can do as many bindings as you want. You can place the Bodies in Part containers, different Part containers, layered Part containers, no Part containers. You use the three dialog fields, Rotation, Z-Offset and Reversed to adjust the Body relative to the locked origin. There is also a tool to move the sketch origin.

Here is a pic of the dialog on the left and the the assembly code routine on the right. That is the entire assemble routine, all the other dialog code is for setting things up.

Once a Body to sketch binding is made I use the Description field in the tree view to show the binding data. These fields describe the binding and show the status of the binding. If you delete the binding the binding fields will be removed.
Over the next couple months I will add Sketch simulation. The user can create a simulation sketch and add it to the Body files, the Macro will use the sketch as input to control the body placement. This should be very flexible and cool.
Attachments
pda1.png
pda1.png (453.71 KiB) Viewed 3267 times
Last edited by freedman on Fri Sep 22, 2023 2:54 am, edited 3 times in total.
drmacro
Veteran
Posts: 8862
Joined: Sun Mar 02, 2014 4:35 pm

Re: Soon to release PartDesign Assembly

Post by drmacro »

Sounds like the way I use Part workbench Edit attachment... 8-)
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Soon to release PartDesign Assembly

Post by chrisb »

This sounds nice. Am I right with the following assumptions?
- If no Part containers are involved, your tool changes the body's Placement and not the Attachment offset
- If a sketch from a body from inside a Part container is linked to a body outside of the Part container, then the container's Placement is changed
- If both bodies live in the same container, then the body is moved.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Soon to release PartDesign Assembly

Post by freedman »

First, I do set to on, sync placement.
If no Part containers are involved, your tool changes the body's Placement and not the Attachment offset
That's correct. I don't add an Attachment offset.
If a sketch from a body from inside a Part container is linked to a body outside of the Part container, then the container's Placement is changed
The Body would move because it's placement is locked to the Sketch.
If both bodies live in the same container, then the body is moved.
If you move the Body with the Transform tool the Body will snap back to where it was. If you move the Sketch the Body will move to the new Sketch location.

Placements are calculated using global placement and take into account the Part Containers. I also use PropertyLinkHidden for dynamic data type so the Part containers as a whole can be moved/copied to another Doc and everything works. Still working on that to keep the 'Description text' correct.

It took me a while to understand that moving is global and Rotation,Zoffset and flip is done locally.
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Soon to release PartDesign Assembly

Post by freedman »

Thought I would post a video of my progress. As a trial here is a cam I made out of Bodies, this is what I used the check the Assembly functions. I exploded the cam out and then used the manual button to reassemble it. You can see in the pic the bindings, first line; Body003_lobe001 origin is connected to Sketch016 origin.
I have one more issue to address and I'm done. It appears to work really well. Normally someone might use just a few bindings, for instance just one for a box and a lid or maybe 3 or 4 to do a box, lid with a hinge.

The concept I'm using works with anything that has an Attachment offset (like a sketch), I will probably expand using sketches to LCS and Datum objects.

I can copy parts of the assembly into other Part containers or new documents and the bindings will stay valid. If copied into the same document all the sketch and body names will be updated to keep the bindings.

Have a good Thanksgiving for those in the states. :)
Attachments
GIF 11-23-2022 4-01-22 PM.gif
GIF 11-23-2022 4-01-22 PM.gif (728.31 KiB) Viewed 2885 times
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Soon to release PartDesign Assembly

Post by adrianinsaval »

aren't you reinventing the wheel? Isn't this more or less what asm4 does?
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Soon to release PartDesign Assembly

Post by freedman »

aren't you reinventing the wheel? Isn't this more or less what asm4 does?
I have done what Zolko (the ASM4 creator) started with and then moved on (he said). I'm sure he found the restrictions too great working with Bodies and decided to put everything in a Part container and use LCS's for connections. This is definitely the professional way to go but it requires more complexity, that's where my app. Part Design Assembly (PDA1) fills a void I believe.

I make assemblies directly in PartDesign with Bodies, I make assembly connections using origins, Body to Sketch. Using origins as connections makes the connection immune to topo-renaming. Using Bodies makes for a simpler tree which makes modeling simpler and faster by default. You might need to add a sketch for an origin reference or you might be able to use a current sketch. I also use the description field to view the Assembly.

I think many users want to try a little bit of everything FreeCAD has to offer, maybe they get a taste of Assembly and want to keep going to something more powerful. It's not really a big deal to change a few assembly connections so using this or that is minimal effort. You can learn my app. and make an assembly in just a few seconds, you can also delete all the connections in a few seconds and return the model to normal. Simple to use....
Thanks
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Soon to release PartDesign Assembly

Post by freedman »

I have a bit more more code to write: Here is a video of some shafts bound to slides, then the slides bound to a base pin. All objects were modeled separate and assembled with PDA. Notice as Bodies are selected the associated sketch is called out in the macro dialog and the description field. This is really fun.
Attachments
GIF_PDA2.gif
GIF_PDA2.gif (845.14 KiB) Viewed 2602 times
Lonfor
Posts: 133
Joined: Wed Mar 23, 2022 2:32 am

Re: Soon to release PartDesign Assembly

Post by Lonfor »

freedman wrote: Mon Dec 05, 2022 3:46 pm I have a bit more more code to write
If your Assembly would be able to insert external files and to show the file names in the Tree like A2plus does, plus the ability to access their individual Coordinate System to apply the restrictions, then I will definitively buy it.
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Soon to release PartDesign Assembly

Post by freedman »

If your Assembly would be able to insert external files and to show the file names in the Tree like A2plus does, plus the ability to access their individual Coordinate System to apply the restrictions, then I will definitively buy it.
I just made a version using the Object Label instead of the Name for connections. It looks like it could work so the tree sketch name/label could be used as an assembly connection name.
As far as external files, I was thinking the user would open a library Document full of parts, pick a part and copy/paste into the model, then connect it. This works currently and is very simple. Trying to link to external parts being edited and to keep track of updates is for full blown assembly, I prefer more of a in-context format where you edit what you have.

PDA doesn't have a bunch of constraints like A2Plus, there is one connection sketch and then you have dialog controls. Things get more complicated if there is dependent rotational linkage, like a car front suspension. I'm thinking about a different approach, sketch based simulations where the objects follow an additional sim-sketch. We shall see....
Thanks

Oh! Money back guarantee... :)
Post Reply