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
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Assembly 4 workbench

Post by onekk »

bernard_01 wrote: Sun Sep 25, 2022 2:32 pm Now please show me some place in the system where I can see the internal name as you say and the label.
  1. Activate Part WB
  2. Select a thing in the treeview.
  3. "Right click" with the mouse
  4. Select "Send to Python Console"
  5. type the following in Python Console

Code: Select all

print("Name: ", obj.Name)
print("Label: ", obj.Label)
This should do the work.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
bernard_01
Posts: 47
Joined: Sun Mar 24, 2019 9:22 am

Re: Assembly 4 workbench

Post by bernard_01 »

onekk wrote: Sun Sep 25, 2022 3:39 pm
bernard_01 wrote: Sun Sep 25, 2022 2:32 pm Now please show me some place in the system where I can see the internal name as you say and the label.
  1. Activate Part WB
  2. Select a thing in the treeview.
  3. "Right click" with the mouse
  4. Select "Send to Python Console"
  5. type the following in Python Console

Code: Select all

print("Name: ", obj.Name)
print("Label: ", obj.Label)
This should do the work.

Regards

Carlo D.
That's an interesting thing to do. Many thanks.
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Post by Zolko »

bernard_01 wrote: Sun Sep 25, 2022 3:21 pm As we know, one can only have one model in each file. So I need one file per model. And my structure is a 5 axis robot where in fact on every subsequent level when moved, moves all other levels below it as expected!
a "Model" is actually an assembly, which means that you can have only 1 assembly per file, you're right. But yoy can have several Parts and Bodies per file. And you can attach parts to either the assembly or parts in that assembly. And parts can themselves be assemblies since they're only standard FreeCAD parts.

So what you should do is to make assemblies (Models) for each of your 5 axes (I guess that they're composed of more than 1 part), and assemble them in a single top-level assembly attaching each axis to the axis it really depends on. By "axis" I mean the sub-assembly containing only parts that move together. In your case, you'll going to need 6 files: the top level assembly and the 5 sub-assemblies of the 5 axis. The big advantage of FreeCAD over other CAD systems is that these 5 files of each axis can contain all the parts that make up the sub-assembly, and the sub-assembly (Model) itself. Or you can also put all the parts in separate files as is traditional on other CAD software.

What I'd suggest also is to create 5 variables corresponding to the commands of your 5 axes. So you assemble the first axis and attach it to the main assembly as you want, and offset it (by the AttachmentOffset) by the value of variable_1. Then you insert your second axis and attach it to axis 1, and offset it by the value of variable_2. Then you attach axis 3 to axis 2 by offsetting ... and so on. All in the main assembly

The cascading distribution of objects you're using in your architecture is not very helpful, that might "confuse" you.
try the Assembly4 workbench for FreCAD — tutorials here and here
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 »

To each his own, of course. That is the beauty of FreeCAD.
Only, experience tells.
bernard_01 wrote: Sun Sep 25, 2022 3:21 pm As to why I do not use the assembly containers - they have become obsolete in later versions of the software - they do not add value.
Maybe you missed the point about the default LCS. Assembly4 design suite is essentially a wrapper for PartDesign.

Besides, you will need part containers for sub-assemblies and imported .step files. For instance, I will put all purchased components (.step files) in a single Parts container in a single file which makes them nicely visible to Assembly4. I put all bodies that belong to a sub-assembly in one file so that necessarily limits the number in the file to something like 10-20 bodies. Otherwise, the tree gets unwieldy. It is also easier to share that way. You can still re-use each and every body in other assemblies.
bernard_01 wrote: Sun Sep 25, 2022 3:21 pm the standard animation will not do the trick
Try it, you might be as surprised as I was. But, then again, I am not a Python programmer.
"It is a poor workman who blames his tools..." ;)
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Assembly 4 workbench

Post by onekk »

bernard_01 wrote: Sun Sep 25, 2022 3:44 pm ...
You are welcome!

This is a copy of what you could obtain:

Code: Select all

>>> doc = App.getDocument("Unnamed")
>>> obj = doc.getObject("Line")
>>> shp = obj.Shape
>>> ### End command Std_SendToPythonConsole
>>> obj.Name
'Line'
>>> obj.Label
'Line1'
Note also the absence of print() statement, it work even in this way,.

When dealing with something that will return unknown data print() could be more readable, as it make some formatting.

Note also this:

Code: Select all

obj = doc.getObject("Line")
In this line FC is using the Name property to retrieve the object instance.
You have a proper code, the only thing that I don't like is the use of App, but if you remember that:

Code: Select all

App = FreeCAD
Gui = FreeCADGui
You are ready to use the "real module names".

Hope it helps

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Post by Zolko »

bernard_01 wrote: Sun Sep 25, 2022 3:21 pm You can imagine that If I build a robot, then the standard animation will not do the trick. I will use the web interface to animate it driven by an external program.
the easiest would be to use variables in the main assembly, and then all you need to do is change a variable and update the assembly. If you build your assembly correctly you can do that for 5 variables at a time, transparently. I've done this for a 2-axis laser-engraver:


LaserCutter.png
LaserCutter.png (393.86 KiB) Viewed 3466 times
Last edited by Zolko on Sun Sep 25, 2022 4:24 pm, edited 1 time in total.
try the Assembly4 workbench for FreCAD — tutorials here and here
bernard_01
Posts: 47
Joined: Sun Mar 24, 2019 9:22 am

Re: Assembly 4 workbench

Post by bernard_01 »

Zolko wrote: Sun Sep 25, 2022 3:47 pm
bernard_01 wrote: Sun Sep 25, 2022 3:21 pm As we know, one can only have one model in each file. So I need one file per model. And my structure is a 5 axis robot where in fact on every subsequent level when moved, moves all other levels below it as expected!
a "Model" is actually an assembly, which means that you can have only 1 assembly per file, you're right. But yoy can have several Parts and Bodies per file. And you can attach parts to either the assembly or parts in that assembly. And parts can themselves be assemblies since they're only standard FreeCAD parts.

So what you should do is to make assemblies (Models) for each of your 5 axes (I guess that they're composed of more than 1 part), and assemble them in a single top-level assembly attaching each axis to the axis it really depends on. By "axis" I mean the sub-assembly containing only parts that move together. In your case, you'll going to need 6 files: the top level assembly and the 5 sub-assemblies of the 5 axis. The big advantage of FreeCAD over other CAD systems is that these 5 files of each axis can contain all the parts that make up the sub-assembly, and the sub-assembly (Model) itself. Or you can also put all the parts in separate files as is traditional on other CAD software.

What I'd suggest also is to create 5 variables corresponding to the commands of your 5 axes. So you assemble the first axis and attach it to the main assembly as you want, and offset it (by the AttachmentOffset) by the value of variable_1. Then you insert your second axis and attach it to axis 1, and offset it by the value of variable_2. Then you attach axis 3 to axis 2 by offsetting ... and so on. All in the main assembly

The cascading distribution of objects you're using in your architecture is not very helpful, that might "confuse" you.
Thanks. Some good points made by you and others. There are some subtle differences between these approaches and I guess I will have to try some of them to learn them. I intuitively felt that FreeCAD has these advantages that you describe, which lead me to create fully nested models. And I might choose your approach eventually. One more thought: The distinction between internal name and label is somewhat blurred, because when these entities are created, the name is actually user-defined not internal because the user enters them. So there is a transition where a user-defined label/name becomes finally an internal name, solidified and only then that label distinction becomes critical. That is rather confusing at first.
bernard_01
Posts: 47
Joined: Sun Mar 24, 2019 9:22 am

Re: Assembly 4 workbench

Post by bernard_01 »

Stale child assembly

I have a nested assembly that I fail to animate. Please see the attached zip file.

My task is to rotate the middle part. The lowest member in the hierarchy should keep its position with respect to the middle part, rorate with it.

How to see what happens:

Open Z_AxisLinearArm.FCStd
Run commands:

Code: Select all

App.getDocument("A_Axis_RotationalArm").getObject("A_Axis_RotationalArmPart").AttachmentOffset=App.Placement(App.Vector(0.0,0.0,0.0),App.Rotation(45.0,0.0,0.0),App.Vector(0.0,0.0,0.0));
App.ActiveDocument.recompute();
The middle part A_Axis_RotationalArm rotates as expected.

But the lowest member in that hierarchy B_AxisTorch remains in its old position relative to Z_AxisLinearArm

There is an intriguing aspect here which is that LCS_B_AxisTorchPart has Attachment Support YZ_Plane001 which is a name that exists in two models A_Axis_RotationalArm and Z_AxisLinearArm so one guess is that perhaps this cannot be resolved properly.

As you can see, the LCS_B_AxisTorchPart does not move, it does not rotate with the model that it belongs to.

I don't really know how to solve this, so some insight would be appreciated.
Attachments
StaleChildAssembly.zip
(46.21 KiB) Downloaded 39 times
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Assembly 4 workbench

Post by onekk »

bernard_01 wrote: Tue Sep 27, 2022 2:03 pm ...
Try to see if my findings in:

https://forum.freecadweb.org/viewtopic. ... 24#p628824

Could help.

See however License terms if you use it for work.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
bernard_01
Posts: 47
Joined: Sun Mar 24, 2019 9:22 am

Re: Assembly 4 workbench

Post by bernard_01 »

bernard_01 wrote: Tue Sep 27, 2022 2:03 pm Stale child assembly
...
I have a nested assembly that I fail to animate.
...
Sorry for the inconvenience. I animated the wrong part. All good now. Thanks.
Post Reply