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
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Assembly 4 workbench

Post by Kunda1 »

Re: Documentation
Maybe worth creating a separate thread. There we could discuss more strategies..for example setting up Assembly 4 with thread on LGTM (see also LGTM on the wiki). Maybe having a CI service that checks PEP8 of the code and any PRs submitted against Assembly 4 etc...?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: Assembly 4 workbench

Post by OficineRobotica »

For the life of me, I've been triyng to wrap my head around this for hours but there's something that eludes me.
What I am triyng to do is to assemble the "Rod" component in a chain using as a skeleton the "masterSketch".

The "masterSketch" has a variable named "rotAngle" that can be animated and 3 LCS's maped to it's vetexes named "LCS_Start" , "LCS_Midle" and "LCS_End".

The "Rod" componet has 2 LCS's and 2 datum points corespondent to it's holes.
Given that i can create a assembly where "LCS_Rod1" of the "Rod" will follow "LCS_Midle" of the "masterSketch" how can i map "LCS_Rod2" of the "Rod" to follow the "LCS_End" of the master sketch? Or for that mater map the datum points inside the "Rod" to specific LCS's in the master sketch?
asm4.png
asm4.png (230.21 KiB) Viewed 2709 times
I'm pretty sure that there is a simple solution to this and i just can't see it but I'm convinced that tutorials will follow after people get the hang of A4. I want to do a video tut my self if i manage to get things correctly in here. Correct me if I'm wrong but the sketcher can provide us with a pretty solid kinematics/inverse kinematics engine through the help of masterSketch's
test1.FCStd
(23.48 KiB) Downloaded 48 times
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Post by Zolko »

OficineRobotica wrote: Thu Dec 19, 2019 10:55 am Given that i can create a assembly where "LCS_Rod1" of the "Rod" will follow "LCS_Midle" of the "masterSketch" how can i map "LCS_Rod2" of the "Rod" to follow the "LCS_End" of the master sketch?
If I understand correctly your problem, you can't.

BUT: that doesn't mean your toast.

What you cannot do, for mathematical reasons, is to superimpose 2 LCS from 2 elements: even though there might be a mathematical solution to the problem, the way it's presented cannot be solved (by a solver as primitive as that of Assembly4).

BUT: if I understand what you want to do, you don't actually want to solve THAT problem: what you really want is to have the second hole of 1 component aligned with the second hole of the other component. And THAT is something you can solve. The LCS of the first hole can be aligned in the direction of the second hole, and thus when aligning the 2 LCS — from the part and the master sketch — the 2 second holes will be co-aligned to within tolerances of the solver. Do you understand what I mean ?

Basically, Assembly4 can and does only co-align 2 LCS in 2 Parts. But that includes also the directions of these LCS, and not only the origin of the LCS ! If you can map the direction of this LCS to whatever second LCS you would want to specify, you can find a solution. Are you trying to make a chain following a profile ?
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: Assembly 4 workbench

Post by OficineRobotica »

BUT: that doesn't mean your toast
Thank you Zolko. In fact I realised what I was doing it all wrong. I was still thinking about the Assembly in the "traditional" kind of way , matching points in different bodies. This defeated the whole point of A4. What I really needed to do is to map the "LCS_Start" to the first edge of the masterSketch instead of the first vertex. This will give the orientation of the "Rod" ... matching the position of the second hole in the Rod with the position of the "LCS_Midle" . Then build up from there. everything animatable....wow. It opened a whole new world for me when talking assemblies.

With some clever associations between lcs'es and master sketch vertices we have kinematics also.

Thank you again
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Assembly 4 workbench

Post by vocx »

Zolko wrote: Thu Dec 19, 2019 8:54 am ...
The longer answer is: as you could see, I don't know how to do all the things that you're saying (or I'd have done it before), so If you have proposals please feel free to do so.
The basic PEP8 document that you will hear about a lot is this one: PEP 8 -- Style Guide for Python Code. Take your time to read it.

Also important is PEP 257 -- Docstring Conventions.

These two documents are the basis of good Python style, and most important libraries in the Python world follow these guidelines. If you use a Python focused editor like Spyder, it will automatically point things that can be improved in your code. Otherwise you can run an external tool like flake8, or pycodestyle, to point out where you can improve the code.

The previous documents are a bit too technical, so I prefer nicer documents that explain them.
* How to Write Beautiful Python Code With PEP 8
* Documenting Python Code: A Complete Guide

I could work through your code little by little, but since I'm busy looking into other parts of FreeCAD, I think you can change the style yourself also little by little, as you become familiar with Python recommendations. As I said, it's not extremely important, it's mostly about style. A library that complies with PEP8 immediately feels more familiar and easier to extend by Python programmers.

One thing that I will try to change is the naming style of methods and functions. Since the core of FreeCAD uses C++, many functions use the camelCase style. But Python dislikes this completely and prefers snake_case. If you already have public functions that must be kept, then I suggest using the snake_case convention but creating an alias to the previous name, like this.

Code: Select all

def snake_case:
    ...

snakeCase = snake_case
Then the same function can be called as snake_case() (official style) or snakeCase() (legacy style, which should be deprecated in the future).
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Assembly 4 workbench

Post by saso »

Few videos that show a related workflow in Creo. First one nicely shows the setup of an skeleton model, closely related to current Asm4 and how it can be, if needed later "upgraded" with 3d constraints. Next is a series of 6 videos showing a setup of a bit more complex skeleton model, some things are a bit specific to the Creo workflow but in general this should be reproducible in any parametric CAD... Reason for this videos, I feel that many unfortunately still don't quite believe and understand that Asm4 (and Part containers) are the right direction to do proper assemblies in FreeCAD.

https://www.youtube.com/watch?v=rxHTBj7Ukd8

https://www.youtube.com/watch?v=LDEBGTNPEkM
https://www.youtube.com/watch?v=vAJISCTo9KQ
https://www.youtube.com/watch?v=ykedSP1oqaY
https://www.youtube.com/watch?v=sJ5XTnvTkMk
https://www.youtube.com/watch?v=mA_Umoo-T8E
https://www.youtube.com/watch?v=Ynm3ldlEe_U
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Assembly 4 workbench

Post by vocx »

saso wrote: Fri Dec 20, 2019 2:28 pm ... I feel that many unfortunately still don't quite believe and understand that Asm4 (and Part containers) are the right direction to do proper assemblies in FreeCAD...
Please bump your other thread again. I'm not saying I agree or disagree with you, but I think the discussion is important. What I do ask you is to try to present the same point in a different way, or with a different approach, using Assembly4 if necessary, in order to drive your point. If you place your ideas in different threads spread all over the forum, then it won't get enough traction.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Assembly 4 workbench

Post by vocx »

Zolko wrote: Thu Dec 19, 2019 8:54 am ...
The longer answer is: as you could see, I don't know how to do all the things that you're saying (or I'd have done it before), so If you have proposals please feel free to do so.
https://lgtm.com/projects/g/Zolko-123/F ... Assembly4/

This is the report of the Assembly4 branch.

Please don't use

Code: Select all

from libAsm4 import *
This makes it very hard to know what is actually being imported and what not.

Use the proper function where needed.

Code: Select all

import libAsm4 as asm4

asm4.some_function()
asm4.SomeClass()
The report of LGTM reports a lot of unused libraries, so these should be removed.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: Assembly 4 workbench

Post by OficineRobotica »

After allot of trial and error, because of my inexperience with freeccad and A4, I managed to create a test model with A4. I'm so exited with the possibilities it opens and happy to learn that assembly and animation could become a reality in freecad.


  • Peek3.gif
    Peek3.gif (955.36 KiB) Viewed 2323 times
  • Peek4.gif
    Peek4.gif (613.05 KiB) Viewed 2323 times
This is the file for examining.
test7.FCStd
(456.09 KiB) Downloaded 100 times
While working with my model i made a list of considerations. They are from the point of view of a new comer to A4 so they might be used as the point of view of the typical user , not the programming savvy one that sees where a certain work flow might be mathematically impossible or not permitted by the inner workings of Freecad. These are in totally random order.

  • sketcher uses point while asm4 uses coma in fields, and that creates alot of confusion , if I write 12,04 in a value field in the sketcher and hit enter i get a 120.4 dimension screwing the whole sketch. The use of coma/point across freecad should be consistent.
  • permit selection by clicking in the 3d view when using the mating dialog for selecting the parent body. This would be a big speed up when working instead of scrolling the "Select part to attach to" dialog
  • in the model tree , if i put LCS's in a folder for organization, they are not seen anymore by the "model"(they do not apear any more in the mating dialog when importing a part in the assembly)
  • how do i delete a variable created with A4? it would be nice to have a subtree of variables under the "Variables" voice in the "Tre View"
  • If I use "insert link to external part" > chose my model > decide to abbort by hitting cancel from the "place linked part" dilog, the link is created none the less with no mapping. For me, an unexperienced user about the inner working of the workbench this creates confusion. The creation of the link should be aborted when hitting cancel.
  • The use of shape binders at any point in the creation process will slow the animation of the model by allot. I mean the Part Design shape binders. I still have to dig in to the use of A4 axis/point/plane shape binders.
  • the thing that i would love the most would be some tweeks to the animation dilog, features and some visual tweaks. What i found my self needing allot is a minimum and maximum value for my Variables. For example , in my model , if i start the animation at a 0 value the two clamps colide. I need a minimum of 10 and a maximum of 100. I really think that the A2Plus animation dialog is really well done and i would love to see it in A4. The value slider is a life saver for checking the assembly for collisions.
A2p_AnimationDialog.png
A2p_AnimationDialog.png (6.9 KiB) Viewed 2323 times
  • and talking about nice features to have. It would be nice to have a transform widget that can be added to the model the way an LCS can be aded(attached to some geometry). Clickeble in the 3d view. By dragging this widget the model would move in 3d space based on the remaining degrees of freedom. Sorry for the convoluted explanation but English is not my main language .
Sorry for the lengthy post but i didn't want to flood the thread with one thousandths entries.
P.S....I am planing some video tutorials but I want to get things right before instructing people in the wrong way.

I just wanted to say a big thank you to our small team of devs. I'm always impressed by the mountain of FREE work they are doing. Wish you all a Happy New Year.
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
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 »

OficineRobotica wrote: Mon Dec 30, 2019 9:47 am I managed to create a test model with A4.
Thank you for sharing your excellent model. There is much to be learned by reviewing other's models IMO.

A couple of comments and a question:

I notice that you are using a 'bottom-up' modelling approach for the assembly, i.e. all of the Parts are created at the global origin. You can only do this if all the drawings are available or if you know that all of the parts fit together beforehand. The alternative for a new assembly design is 'top-down' wherein each Part model is created in its proper location in the same file as defined by and external-referenced to a master sketch. It is the latter method that I am currently exploring with Assembly4 and about which I have much to learn as well.
OficineRobotica wrote: Mon Dec 30, 2019 9:47 am how do i delete a variable created with A4?
Right click Variables > Property panel >Show all then right click on the variable name> Remove property

I also notice that you have attached several LCS's to edges of the Parts. As you probably know, if you modify any of these parts it is likely it will blow-up the Model assembly. You can usually attach the LCS to the master sketch and use Attachment offset to move the part to its proper location. This is more robust with respect to Part changes but still sensitive to any design changes in the master sketch.

Question:
How did you obtain the Clamp2 mirror of Clamp in the Model assembly? I have been using the Part > Mirror of the Body which is quite convenient, but it is a bit awkward. It kicks the mirror out of the Part which must then be returned via drag and drop resulting in a out-of-scope warning. You can then attach the Part with its mirror to the assembly LCS, but I am not so sure that is how Zolko would recommend it to be done.
"It is a poor workman who blames his tools..." ;)
Post Reply