Assembly 4 workbench

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Post by Zolko »

project4 wrote: Wed Oct 21, 2020 5:24 am There is no python trick to access the sub-sub-assembly variables at all?
You can "copy" the value of a variable from a sub-assembly to the assembly, by creating a corresponding variable in the assembly Model, and assigning to it the value of the variable in the sub-assembly:

Code: Select all

<<totoDoc>>#Variables.toto * 2
where <<totoDoc>> is the document and toto the variable name.

But you cannot assign a value to a variable in a sub-assembly based on a variable in the top-level assembly: that would create circular dependencies. But: you can create a MasterVariable that you import in the top-level assembly and the sub-assemblies, copy over the values you need, and then set the variable of the MasterVariable from within the top level assembly:

Code: Select all

App.ActiveDocument.getObject('totoLink').LinkedObject.getObject('Variables').toto = 15.00
where totoLink is the link name (to the Asm4 Model in the document totoDoc) and toto the variable name. Thus, when you change the value of the variable toto, it will cascade through the entire assembly.
try the Assembly4 workbench for FreCAD — tutorials here and here
mgeismann
Posts: 8
Joined: Wed Oct 21, 2020 5:07 am

Re: Assembly 4 workbench

Post by mgeismann »

Zolko wrote: Wed Oct 21, 2020 7:33 am
mgeismann wrote: Wed Oct 21, 2020 5:20 am I attached a file to demonstrate the issue: master:Vertex7 and master:Vertex8 do exist (verified via Selection View) but I cannot chose them while attaching an LCS.
the sketch "master" has only 4 vertices, Vertex7 doesn't exist, not anymore than Vertex8. The reason that LCS_7 doesn't report an error is that its MapMode is Deactivated.

Code: Select all

>>> len(master.Shape.Vertexes)
4
>>> 
I re-downloaded the file and made the attached screenshot: Vertex7 and Vertex8 are selected and clearly exist (I don't know how FreeCAD decides the numbering, more logically would be Vertex5 and so on).

Any idea?

Edit: forgot to attach the screenshot
Attachments
non-accesible-vertices.png
non-accesible-vertices.png (23.38 KiB) Viewed 3142 times
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Post by Zolko »

mgeismann wrote: Wed Oct 21, 2020 10:26 am Any idea?
There is a forum for general Help on FreeCAD, your question is not assembly related.
try the Assembly4 workbench for FreCAD — tutorials here and here
mgeismann
Posts: 8
Joined: Wed Oct 21, 2020 5:07 am

Re: Assembly 4 workbench

Post by mgeismann »

Zolko wrote: Wed Oct 21, 2020 10:44 am
mgeismann wrote: Wed Oct 21, 2020 10:26 am Any idea?
There is a forum for general Help on FreeCAD, your question is not assembly related.
Alright, thanks!
User avatar
ppemawm
Veteran
Posts: 1240
Joined: Fri May 17, 2013 3:54 pm
Location: New York NY USA

Re: Assembly 4 workbench

Post by ppemawm »

Zolko wrote: Wed Oct 21, 2020 8:28 am I wouldn't have splitted the sub-assemblies like that. I'd put in a sub-assembly only rigid structures, that don't deform/move. So, the rotor would be one such sub-assembly, and not all rotating parts.

Does that make sense ?

Thanks for your comments.

Yeah that makes more sense. I.e. all of the parts that rotate as a unit should be in one sub-assembly file. In my case, that would be four separate sub-assembly files: main rotor, working piston shaft, flywheel shaft, and the tail rotor. I think I can easily rework my files so will try that in the next several days. Then I should be able to apply the rotation variable to each of the attachment offset of the sub-assembly links in the top-level assembly file.
"It is a poor workman who blames his tools..." ;)
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: Assembly 4 workbench

Post by aapo »

ppemawm wrote: Tue Oct 20, 2020 3:31 pm I have now broken up that assembly file into several sub-assemblies as you have suggested and certainly agree that the assembly model tree is better organized and easier to work with. I can animate the sub-assemblies in the separate files, but this does not seem possible at the top assembly file. Or, at least I do not know how.
That is indeed a tough nut to crack, and I have tried to wrestle with it with different ideas for a few times already. As pointed out by many forum members, the root of the problem is the need for circular dependencies between the (sub)assemblies, which violate the (mathematically correct) requirement for DAGs. To overcome the problem, I believe there are several not fully satisfactory methods, one of which is using a global mastersketch in the main assembly file, which e.g. Zolko suggested, and which works reasonably well, but unfortunately then you'd lose the idea of modularity (i.e., all the animated movements within the subassemblies must be re-created at the main assembly level). So, that works, but it's hardly optimal, as the true power of modularity of the subassemblies is lost, as their animation is not truly modular (although the geometry and assemblies continue to be).

The other method is to make everything (main assembly and subassemblies) depend on a third-party structure (e.g. spreadsheet or variable table in a separate file). The file containing the third-party structure does not contain anything else but the animation variables, so that it does not need to depend on any other file, particulary there does not need to be a dependency to the (sub)assemblies. Of course, all the (sub)assemblies depend on this variable file, which is totally fine, as there won't be circular dependencies in the DAG. However, the problem with this method (at least for me) has been that I haven't been able to animate such a structure with Asm4 workbench; I've tried e.g. deleting the "Variables" container from the main assembly and replacing it with a link to the "Variables" in the special file, but this doesn't seem to work. Of course, animating such a system with Python macro works, but it'd be nice to get such (or similar) funtionality to work with the official Asm4 workbench.

Note that even the 2nd method is not truly optimal, as all the variables in the special "variable" file would not be modular in the sense that subassemblies would depend on them, and the subassemblies could therefore not be fully independent from the main system; although it would be rather easy to re-use the subassemblies in another model by just re-pointing the variable links to somewhere else. Notwithstanding that, I think the best way to keep a fully modular system would be to introduce "link variables" into the main assembly; i.e. variables in the main assembly that could be just links to variables in subassemblies. When the main assembly animator would access such a link, it would actually access and modify the sub-assembly variable through the link. Note that this would not create a circular dependency, as the link would make the main assembly to depend on the sub-assembly, but not vice versa. Also, during run-time modification of the variable, it would be the variable of the sub-assembly that would be changed by the animator workbench, so no circular dependency there either. This would keep the animation and the part re-usability as fully modular. However, I have no idea how easy or hard it would be to add such a "link variable" to the Asm4 variable system, but that would be the Holy Grail of Asm4 animation, IMHO.

Is there any way this capability could be accommodated in the top assembly file in Assembly4?
That is an interesting question, and I'm kind of hoping that Zolko is considering to enhance his workbench into that direction, somehow.
heron
Posts: 307
Joined: Mon Apr 20, 2020 5:32 pm

Re: Assembly 4 workbench

Post by heron »

Hello,
I am also with this animation issue in sub-assemblies. I have gone through cyclical dependencies, which if you save and reopen the file leaves it completely broken :o .

Zolko wrote: Wed Oct 21, 2020 8:53 am You can "copy" the value of a variable from a sub-assembly to the assembly, by creating a corresponding variable in the assembly Model, and assigning to it the value of the variable in the sub-assembly:
This would be fine if the animate assembly tool allowed you to select variables from the sub-assembly. Also I think that you can also assign variables from one sub-assembly to another without creating cyclical dependencies, therefore it would be perfect.

Zolko wrote: Wed Oct 21, 2020 8:53 am you can create a MasterVariable that you import in the top-level assembly and the sub-assemblies, copy over the values you need, and then set the variable of the MasterVariable from within the top level assembly:
Code: Select all

App.ActiveDocument.getObject('totoLink').LinkedObject.getObject('Variables').toto = 15.00
Tried this and it works fine. Thank you.
Both workarounds allow us to modify the value of the variable and recalculate the assembly, but not animate it, or I am missing something.
RDA
Posts: 34
Joined: Tue Oct 06, 2020 6:55 am

Re: Assembly 4 workbench

Post by RDA »

Hello,

I have tried googling and trying out stuff but cant figure out is there a way to link LCS from a body to a model. Im sure there is but not quite sure what exactly I am even searching for terminology wise.

So I am trying to attach a part into a subassembly and I didnt find a way to use any of the subassemblys bodies LCS's, so I tried if I could make an LCS to the subassembly and link it to one of the bodies LCS's.

Example_Assembly
-Model
-Body1
-Body2
-LCS1
-LCS2<---Link these
-Body3
-LCS1
-LCS2
-LCS3 <--- Link these

I could then:
- make a new assembly
- Insert a link to Example_assembly
- Insert a link to part_1
- Attach part_LCS1 to Example_Assembly LCS3

I did not find a way to attach directly to Body2 LCS2
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Post by Zolko »

RDA wrote: Sun Oct 25, 2020 8:15 pm So I am trying to attach a part into a subassembly and I didnt find a way to use any of the subassemblys bodies LCS's, so I tried if I could make an LCS to the subassembly and link it to one of the bodies LCS's.

Example_Assembly
-Model
-Body1
-Body2
-LCS1
-LCS2<---Link these
-Body3
-LCS1
-LCS2
-LCS3 <--- Link these

I did not find a way to attach directly to Body2 LCS2
There is a button for that: import datum. In the Model, select LCS2 of Body2, and click import datum: it will create an LCS in the Model and attach it to the placement of LCS2, and you can then use the resulting Model as subassembly in a higher level assembly. The LCS2 in the Model will always follow the placement of LCS2 in Body2, so if you modify your design the placement of the subassembly will follow.

But you can also do it by hand: select your LCS3 (must be in the Model tree) and click "Place Datum" and it will allow you to select datums in bodies of your assembly, the same way as you attach parts into an assembly.
try the Assembly4 workbench for FreCAD — tutorials here and here
RDA
Posts: 34
Joined: Tue Oct 06, 2020 6:55 am

Re: Assembly 4 workbench

Post by RDA »

Zolko wrote: Mon Oct 26, 2020 9:01 am There is a button for that: import datum. In the Model, select LCS2 of Body2, and click import datum: it will create an LCS in the Model and attach it to the placement of LCS2, and you can then use the resulting Model as subassembly in a higher level assembly. The LCS2 in the Model will always follow the placement of LCS2 in Body2, so if you modify your design the placement of the subassembly will follow.

But you can also do it by hand: select your LCS3 (must be in the Model tree) and click "Place Datum" and it will allow you to select datums in bodies of your assembly, the same way as you attach parts into an assembly.
Worked like a charm!

Thank you sir, not only for the help but also for the nice program.
Post Reply