Assembly 4 workbench

Discussion about the development of the Assembly workbench.
Zolko
Posts: 234
Joined: Mon Dec 17, 2018 10:02 am

Assembly 4 workbench

Postby Zolko » Sun Mar 10, 2019 1:42 pm

Hello,

after a lot of brainstorming in the assembly without solver thread, and also some on the Assembly3 preview and New Assembly 4? threads, a new assembly workbench for FreeCAD has emerged, called sequentially in the list Assembly #4.

This thread starter will be updated if new versions of the workbench appear. The main development repository is https://github.com/Zolko-123/FreeCAD_Assembly4

Principle

The basic principle is the one from assembly without solver: FreeCAD's App::Part container serve as basic building blocs, that are inserted into each other using the App::Link interface of realthunder's LinkStage3 branch of FreeCAD.

The advantage of App::Link feature is that it's possible to link — exchange, insert — FreeCAD objects between files, seamlessly: a model in a file will appear in the tree of another model in another file, but the data is not copied across. This allows to create many instances of the same object without any overhead, allowing the creation of large assemblies. In other words, this is identical what other CAD systems do when speaking of assembly.

The particularity of Assembly 4 is that the placement of the inserted (linked) part is done by matching (superimposing) corresponding coordinate systems in the parent assembly and in the linked part: therefore, there must be at least 1 coordinate system in the assembly and 1 in the part. There can be many coordinate systems in each, and the user can choose which of these coordinate systems — in the assembly and in the part — shall be used. Contrary to some other assemblies, no mathematical solver, no geometrical constraints — planes, axes, parallelism, concentricity — are used.

Another particularity of Assembly 4 is that there is no difference between a part and an assembly: it's possible to mix datum objects, 2D sketches, 3D geometries and inserted parts at will. This feature can prove to be extremely powerful once a user gets used to it.

Installation

You can download the Assembly 4 workbench as a ZIP archive here: it must be extracted and placed in the ~/FreeCAD/Mod directory, where all other workbenches reside.

Please bear in mind that Assembly 4 is not compatible with stock FreeCAD v0.18. Pre-built binaries of realthunder's branch can be downloaded from his GitHub repository. (they are called FreeCAD-asm3-xxx but are compatible with Asm4)

You can use provided example assemblies to experiment with this workbench's features.


Asm4_wb1.png
Asm4_wb1.png (228.12 KiB) Viewed 2638 times

Usage
In order to insert a part in Assembly 4 (and App::Link in general), it needs to be open in FreeCAD. It also needs to be saved to disk, because the App::Link framework needs the file's path. Unfortunately, it seems that when creating a new part and saving it, the App::Link doesn't "see" the file's path. So the surest way to use this workbench is to have files created, saved, closed, and re-opened: this way, the App::Link always sees the files you need. The workflow is then the following:

  • create a new (empty) file
  • click on the "create Model" button: this creates an App::Part container with all the needed elements
  • save
  • close
  • re-open
The document is then ready to be used, as a part or as an assembly.

3D geometry

After the root App::Part container — called 'Model' in Assembly 4 — has been created , there are 2 ways to have 3D geometries in a part:
  • create a Body in the root 'Model' and use the PartDesign workbench as usually in this Body
  • copy an existing Body from an existing FreeCAD document into the 'Model'. This allows easy re-use of your existing FreeCAD designs
Assembly

In order to insert an Assembly 4 'Model' into another Assembly 4 'Model, use the command 'Insert External Part' : this will allow you to chose one part in any of the open documents, and will ask you the name under which the instance of the part shall appear in the assembly tree. It is important to note that this name must be unique in the tree. By default, the insert part dialog will propose the same name for the instance as the name of the document where the part is located, but you can choose any name of your liking. If you choose a name that already exists, FreeCAD will modify it to something unique (and which may be un-nice to you)

Once inserted, the instance is placed using the command 'Place an Instance' (or 'Move an Instance'). This will show a dialog in 2 columns: the left column shows all coordinate systems in the linked part that can be used to attach to part, and the right column shows all other parts in the assembly and their coordinate systems that can be used to attach the instance-to. Use the 'Show' button to pre-visualize where the part's going to be placed. 3 rotation buttons allow the instance to be rotated by steps of 90° around the 3 axes X, Y and Z

Only coordinate systems directly at the root of the 'Model' container can be used for attachment, and not, for example, coordinate systems from a Body in the part tree.

Nested assemblies

This workbench allows the assembly of assemblies: since there is no difference between parts and assemblies, the 'Insert External Part' allows to chose a part that has other parts linked to it. The only difference will be for the coordinate systems in the inserted assemblies: in order to be used with Assembly 4, a coordinate system must be directly in the root 'Model' container, meaning that a coordinate system inside a linked part cannot be used to attach the assembly to a higher-level assembly.

Therefore, in order to re-use a coordinate system of a part in an assembly, a coordinate system must be created at the root of the 'Model', and the placement of this coordinate system must be 'copied' over from the coordinate system that the user wants to use. This is done by inserting a coordinate system and using the 'Place LCS' command, which allows to select a linked part in the assembly and one of it's coordinate systems: the 2 coordinate systems — the one at the root of 'Model' and the one in the linked part — will always be superimposed, even if the linked part is modified, allowing the placement of the assembly in a higher level assembly using a linked part as reference. It sounds more complicated than it actually is.

————————————————

EDIT (2019.03.11): the git repository should now work as it's supposed-to

EDIT (2019.03.12): cosmetic change: moved actual Python code to Mod_Asm4: this is the directory to be moved/copied/linked inside ~/FreeCAD/Mod. Added some more examples to experiment
Last edited by Zolko on Tue Mar 12, 2019 1:15 pm, edited 2 times in total.
Zolko
Posts: 234
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Postby Zolko » Mon Mar 11, 2019 3:56 pm

Kunda1 wrote:
Mon Mar 11, 2019 11:06 am
I prefer to use git in a GUI interface, I learned it so much faster that way. I made a page on the wiki dedicated to it (though the app is proprietary, it is free to use for FOSS activities : Gitkraken
thanx for the info. I tried GitKraken, seemed to mostly work, but I didn't like the licensing. Looking at other Git clients, I found Guitar, opensource, native Qt based. Doesn't ask about any passwords, seems to work. May-be I'll get to git somehow ...
triplus
Posts: 8364
Joined: Mon Dec 12, 2011 4:45 pm

Re: Assembly 4 workbench

Postby triplus » Mon Mar 11, 2019 7:27 pm

GitHub has a rather good documentation. When it comes to tasks like forking, cloning, creating branches, pushing and keeping the fork in sync. Instructions usually don't involve any special GUI client. Therefore in my opinion best if you don't involve any GUI clients at first, maybe just a GUI tool like gitk, for browsing the history and changes.

P.S. If it is about your repository, basically you can get away with learning just the cloning, committing and pushing tasks first. And worry about the rest if and when the need arises.
Zolko
Posts: 234
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Postby Zolko » Mon Mar 11, 2019 8:31 pm

triplus wrote:
Mon Mar 11, 2019 7:27 pm
If it is about your repository, basically you can get away with learning just the cloning, committing and pushing tasks first
yep, that's what I have in mind also. There is this "staging" thing also. So for every change you have to do : stage → commit → push. I'm sure that with some imagination, they could have added some more intermediate steps: select → stage → queue → commit → stack → push ... grrrrrrrrr

There is another git client that seems not too bad: git-cola, written in Python3-Qt5 ... room for thoughts
triplus
Posts: 8364
Joined: Mon Dec 12, 2011 4:45 pm

Re: Assembly 4 workbench

Postby triplus » Mon Mar 11, 2019 9:14 pm

OK i won't discuss this further in this thread, as it's off topic.

Staging area is an area for preparing the commit. You don't always want to add all modified files from the working directory to the staging area. Therefore indeed you are able to select something specific, like an individual modified file and add just that to the staging area. You can do things like stashing staged and modified files from working directory for latter. And this things for sure aren't cons.
Zolko
Posts: 234
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Postby Zolko » Tue Mar 12, 2019 11:47 am

I've added a new example to the Assembly 4 repository. It's my previous V4 engine, but updated to the latest Asm4 workbench. It's actually much faster than before, I don't know what brought this speed increase. This one has assemblies of sub-assemblies saved in sub-directories, and some fancy constructions using sketches and linked datum points across documents.

Asm4_V4.gif
Asm4_V4.gif (952.67 KiB) Viewed 2399 times
triplus
Posts: 8364
Joined: Mon Dec 12, 2011 4:45 pm

Re: Assembly 4 workbench

Postby triplus » Fri Mar 15, 2019 10:58 pm

Such things for sure look impressive, but ATM we don't need that all that much. Castles are usually build stone by stone. Therefore please prepare a detailed tutorial, here in this thread, on how to assemble two such stones, using Assembly 4 workbench. And please add comments, on what you feel is missing, or could still improve in the future. That is, if we would add such way of Assembling to FreeCAD 0.19 or likely early in FreeCAD 0.20 development cycle. Currently therefore you are utilizing expression engine as a solver, LCS feature as an interface and Part::Link extensively. From user interaction point of view a dialog is provided.

Thanks.
Zolko
Posts: 234
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Postby Zolko » Sat Mar 16, 2019 11:59 pm

triplus wrote:
Fri Mar 15, 2019 10:58 pm
Castles are usually build stone by stone.
Thank-you for your comparison.

May-be I took the problem from the wrong edge, but what I wanted to show is that we can build "castles" with this method, therefore it was worth to invest some time and intelligence to be familiar with it.

As opposed to : "look, we can assemble 2 cubes, yoohey ! We can do assemblies"

But I think I understand your remark, and I'll try to provide more scolar examples
triplus
Posts: 8364
Joined: Mon Dec 12, 2011 4:45 pm

Re: Assembly 4 workbench

Postby triplus » Sun Mar 17, 2019 2:14 pm

Zolko wrote:
Sat Mar 16, 2019 11:59 pm
Thank-you for your comparison.
You're welcome.
May-be I took the problem from the wrong edge, but what I wanted to show is that we can build "castles" with this method, therefore it was worth to invest some time and intelligence to be familiar with it.

As opposed to : "look, we can assemble 2 cubes, yoohey ! We can do assemblies"
Well, but that is the point, isn't it? We are not after 1% being able to assemble in such way, the other 99% of people should be able to do that too.
But I think I understand your remark, and I'll try to provide more scolar examples
Thanks.
User avatar
bill
Posts: 365
Joined: Fri Jan 09, 2015 9:25 pm

Re: Assembly 4 workbench

Postby bill » Wed Mar 20, 2019 11:32 am

Zolko wrote:
Tue Mar 12, 2019 11:47 am
I've added a new example to the Assembly 4 repository. It's my previous V4 engine, but updated to the latest Asm4 workbench. It's actually much faster than before, I don't know what brought this speed increase.
Speed increase, probably because of your short circuited firing-order! :lol: :lol: :lol:

It would be a bit more aesthetic if cylinders 3 and 4 fired separately!