Assembly solver and recompute system

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Assembly solver and recompute system

Post by DeepSOIC »

Hi!
The recent talks around Hamish's assembly2 drove me into thinking on how could I upgrade his/write my own assembly workbench. And I got stuck on a question, that I think applies to any assembly workbench in general, be it official FC assembly, or add-on one.

Here's the deal.
Let's consider a naiive organization:

Code: Select all

+ Part
+ Part001
+ Assembly container
   + instance of Part
   + instance001 of Part
   + instance of Part001
   + constraint
   + constraint001
Let's say instances have Placements, that are updated when assembly is solved. So, Assembly depends on instances (because it constains them), yet instances depend on assembly because its placements must come from assembly solver.
Thinking further, I come to a conclusion that everything contained in Assembly is a big dependency rat's nest , a blob, where everything links to and depends on everything. That is, lots of dependency loops.

The only way to solve it I've come up so far is to collapse Assembly into a single object, and instances and constraints are embedded into it, similarly to how a sketch contains all its geometry and constraints inside and doesn't expose them to document dependency graph. I can't say I really like this approach.

Any ideas?
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Assembly solver and recompute system

Post by ickby »

The way you show wont work, only referencing stuff in a "group" with real parts outside of it will make too much problems. IMHO asembly must be a special kind of origin group, hence a local coordinate system. It controls every object in its CS, hence all parts and all Assemblies (which are than subassemblies). Constraitns are than used to recalculate the positions of all Parts in the local CS. That is at least how the official assembly workbench will work.
Last edited by ickby on Fri Sep 30, 2016 4:00 pm, edited 1 time in total.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Assembly solver and recompute system

Post by triplus »

The way i understand the issues involved and potential solutions (thoughts mainly focused on Assembly2 WB). What i fell must be said before i go further:
  • PartDesign NEXT main purpose is to create a part.
  • PartDesign NEXT or Assembly2 won't resolve topological naming issue.
What you therefore should care about is the resulting part with its topology (faces, edges and vertices). I guess Draft Clone best describes it. Installing Assembly2 WB and inserting a few Part Primitives should therefore be your playground for a while. That was the original idea in that video made a few years back (and i guess in Assembly2)?

Stuff like assembly container and position in local CS... This all sounds like Assembly3 material to me. Nothing wrong with that just saying. ;)
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Assembly solver and recompute system

Post by Jee-Bee »

DeepSOIC wrote:Assembly depends on instances (because it constains them), yet instances depend on assembly because its placements must come from assembly solver.
Can you explain this part?? In my feeling an assembly doesn't care about what happens in the part. the assembly only have only constrains between the parts (or sub assemblies). if part change it breaks and you have to fix this.
The relations of the parts in assemblies only exist in assemblies not in the parts...
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Assembly solver and recompute system

Post by DeepSOIC »

ickby wrote:The way you show wont work
Of course it won't, that's what this post is all about.
I'm curious to know, what is your (or official) proposed structure? Like this?

Code: Select all

+ Assembly container
   + Part
   + Part001
   + constraint
   + constraint001
Assembly depends on Part, Part001, constraint, constraint001. Any change to them will cause Assembly to recompute. When recomputing Assembly, the actual solver will do its work, and the result of solving are placements, that will be written to Part.Placement and Part001.Placement. So far so good...

The problems start when I will try to link to Part from somewhere else (be it use a value of its Placement in an expression, or extracting a placed subsolid from the assembly for some kind of geometry operation).

Oh, maybe whenever I use a Part that is in some Assembly, I must also introduce an artificial dependency of the linking object on Assembly object?
That might even work, actually...
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Assembly solver and recompute system

Post by ickby »

DeepSOIC wrote:
ickby wrote:The way you show wont work
Of course it won't, that's what this post is all about.
Hehe, point taken ;)
DeepSOIC wrote: The problems start when I will try to link to Part from somewhere else (be it use a value of its Placement in an expression, or extracting a placed subsolid from the assembly for some kind of geometry operation).

Oh, maybe whenever I use a Part that is in some Assembly, I must also introduce an artificial dependency of the linking object on Assembly object?
That might even work, actually...
In general it will be forbidden to link from a local CS to another local CS for normal links, this is something we already discussed (there will be special link properties for which this is allowed). Expression of course are a different thing... don't know actually. But you always need to consider this: Changing the Placement of a part wont change any of its childs. Their shapes stay completely untouched, as their position in the local CS stays the same, only the local CS position in its parent CS changes. Hence they are not recomputed in any way.

I think one problem that remains is howto use global CS information for example in expressions. But for this some special CS traversal operations are needed anyway, hence any recompute logic should be incorporated in this.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Assembly solver and recompute system

Post by DeepSOIC »

ickby wrote:I think one problem that remains is howto use global CS information for example in expressions.
I think there is no problem with expressions, as long as assemblies are not involved. For assemblies, it becomes necessary to hack the recompute system to solve the assembly before reading out Placement value of Part. That's what bugs me at the moment.

And, as noted by triplus, I indeed want to try to roll out such a system as a python addon (codename assembly3 ;) ).
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Assembly solver and recompute system

Post by ickby »

A general question: If you hack this, why not directly in c++? There is no value of using python to implement what would mimic the standard implementation 1 to 1. Just make the solver integration as flexible as needed to use hamishs solver.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Assembly solver and recompute system

Post by DeepSOIC »

I have a strong feeling that I will have to mess with C++ to some extent to make a Py assembly workbench. In particular, I want instance objects, and I'm afraid I will have to create one in C++. Then I would want to extend selection system, to make it possible to figure out the whole path to selected element (like Assembly->Instance003->Part005->Body002.Edge1). And I still struggle to understand, how to deal with multiple instances of a single object.
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Assembly solver and recompute system

Post by ickby »

But all this is all planned and needed anyway, so I would recommend to start doing it in the core system :) . We could discuss ideas howto do it, IMHO a good starting point is jriegels old branch and porting the new recompute structure to master (when extensions code is introduced, it is essential). with this is would be easy to add all needed selection enhancements to the doc objects
Post Reply