Another approach to assembly solver (A2plus)

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Post by kbwbe »

Turro75 wrote: Wed Dec 18, 2019 9:42 pm I'm facing a quite slower importing of complex shapes, I wonder if multithreading the conversion from shape to shell could speed up that process or, as alternative approach, the rewriting of those functions as C code.
Hi Turro,
there should be no changes in master branch which have slowed down the imports. Do you register that importing got slower or are you importing bigger shapes bigger than before ?

> Multiprocessing/Multithreading: May be better, i have to check how good this works with FC.
> C-code: Sure faster, but i have no idea about implementing it into FC.

Additional:
I am working on a big update within the devel branch. A2plus creates "xxx.a2p" files during importing of files. The files contain all resulting work of an import process (shape, colours, toponames) and speed up a second time import by factor 3-4.
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
Turro75
Posts: 179
Joined: Mon Aug 15, 2016 10:23 pm

Re: Another approach to assembly solver (A2plus)

Post by Turro75 »

kbwbe wrote: Thu Dec 19, 2019 7:50 am
Hi Turro,
there should be no changes in master branch which have slowed down the imports. Do you register that importing got slower or are you importing bigger shapes bigger than before ?

> Multiprocessing/Multithreading: May be better, i have to check how good this works with FC.
> C-code: Sure faster, but i have no idea about implementing it into FC.

Additional:
I am working on a big update within the devel branch. A2plus creates "xxx.a2p" files during importing of files. The files contain all resulting work of an import process (shape, colours, toponames) and speed up a second time import by factor 3-4.
Hi Kbwbe,

Yes I'm talking about complex objects with many curved surfaces which creates tons of faces.

by analyzing a2p_muxassembly.py it looks like the slowness is mainly caused by Part.Makeshell(faces), other iterations look such as creating the faces list so I don't expect a big improvement in parallelizing them. Am I wrong?

Regarding C code.... rewriting the workbench in C IMHO requires too much work compared to the benefit, it would be interesting writing complex calculation task in a .dll and .so and importing it in python, it could be helpful in replacing some numpy or placement complex iterations within the solver (if any).

threading across cores is quite easy in python, from https://docs.python.org/3/library/multiprocessing.html

Code: Select all


from multiprocessing import Pool

def f(x):
    return x*x

if __name__ == '__main__':
    with Pool(5) as p:
        print(p.map(f, [1, 2, 3]))
        
        
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Post by kbwbe »

Hi Turro,
Turro75 wrote: Thu Dec 19, 2019 5:29 pm Yes I'm talking about complex objects with many curved surfaces which creates tons of faces.

by analyzing a2p_muxassembly.py it looks like the slowness is mainly caused by Part.Makeshell(faces), other iterations look such as creating the faces list so I don't expect a big improvement in parallelizing them.
I am not quit sure, but Part.Makeshell(faces) cannot be parallelized, as OCC is only using one core/process. Please tell me if i am wrong.
Turro75 wrote: Thu Dec 19, 2019 5:29 pm Regarding C code.... rewriting the workbench in C IMHO requires too much work compared to the benefit,
Yes...

Turro75 wrote: Thu Dec 19, 2019 5:29 pm it would be interesting writing complex calculation task in a .dll and .so and importing it in python, it could be helpful in replacing some numpy or placement complex iterations within the solver (if any).
1) I do not have any experience in interfacing python with C/C++, that's my problem
2) The ".dll" and ".so" files would have to be compiled for each OS, probably by the user. Using pure python is much more easy for many users.
Turro75 wrote: Thu Dec 19, 2019 5:29 pm threading across cores is quite easy in python
I know, i have been working with that on other projects.

Are you using the toponaming option of A2plus? Using this needs some computation time.
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Post by kbwbe »

Hi people,

A2plus V0.4.33 has a new feature (thanks to a user request). Now you can click a part and move it around under rule of all constraints.

Have a look at this video:
phpBB [video]


Have fun.

Merry christmas to all,
Klaus

P.S: Find the assembly attached (for your own experiments)
Attachments
asm-viergelenk.FCStd
(21 KiB) Downloaded 90 times
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
Christoph
Posts: 55
Joined: Fri Jul 08, 2016 9:02 pm

Re: Another approach to assembly solver (A2plus)

Post by Christoph »

kbwbe wrote: Sun Dec 22, 2019 12:55 pm Hi people,

A2plus V0.4.33 has a new feature (thanks to a user request). Now you can click a part and move it around under rule of all constraints.
I'm impressed, thank you very much creating this feature!
dan-miel
Posts: 391
Joined: Thu Sep 13, 2018 12:29 am
Location: Spokane WA. USA

Re: Another approach to assembly solver (A2plus)

Post by dan-miel »

kbwbe wrote: Sun Dec 22, 2019 12:55 pm A2plus V0.4.33 has a new feature (thanks to a user request). Now you can click a part and move it around under rule of all constraints.
kbwbe:
I haven't tried this yet but it is something that I wanted to ask for but, again a but, the animations were so slow I never dreamed that this would be possible. Fantastic!

Dan
User avatar
roerich_64
Veteran
Posts: 1465
Joined: Thu May 21, 2015 7:00 pm
Location: Ostfriesland

Re: Another approach to assembly solver (A2plus)

Post by roerich_64 »

Hi Klaus,

Also from me: thank you for the new future:-)

Have a nice Christmas with your family and a happy new year:
IMG-20191222-WA0001.jpg
IMG-20191222-WA0001.jpg (174.55 KiB) Viewed 2189 times
Bests
Walter
Die Liebe wird siegen, denn sie ist unzerstörbar :) ;)
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Another approach to assembly solver (A2plus)

Post by uwestoehr »

kbwbe wrote: Sun Dec 22, 2019 12:55 pm A2plus V0.4.33 has a new feature
Documented: A2plus_Workbench#Dragging
Attachments
A2p_example-for-dragging-animation.FCStd
A2p_example-for-dragging-animation
(20.04 KiB) Downloaded 2668 times
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Post by kbwbe »

A2plus function "importPart" has been broken today for a short time on master branch. Please update to new version V0.4.34a
Sorry!
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
Syres
Veteran
Posts: 2898
Joined: Thu Aug 09, 2018 11:14 am

Re: Another approach to assembly solver (A2plus)

Post by Syres »

Using v0.4.35, when deleting constraints I was occasionally getting the following error in the Report View but not consistently:

Code: Select all

Traceback (most recent call last):
  File "C:\Users\JPS\AppData\Roaming\FreeCAD\Mod\A2plus\a2p_viewProviderProxies.py", line 126, in getIcon
    FreeCAD.ActiveDocument.getObject(self.constraintObj_name).Type
<class 'AttributeError'>: 'NoneType' object has no attribute 'Type'
I modified my a2p_viewProviderProxies.py file at line 124 from:

Code: Select all

    def getIcon(self):
        return a2plib.A2P_CONSTRAINTS_ICON_MAP[
            FreeCAD.ActiveDocument.getObject(self.constraintObj_name).Type
            ]
to:

Code: Select all

    def getIcon(self):
        if FreeCAD.ActiveDocument.getObject(self.constraintObj_name).Type != None:
            return a2plib.A2P_CONSTRAINTS_ICON_MAP[
                FreeCAD.ActiveDocument.getObject(self.constraintObj_name).Type
                ]
and the error hasn't reappeared since.

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19060 (Git)
Build type: Release
Branch: master
Hash: 72065b0d3960ec9b4aa90cce1a6e810e8bab68c4
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
Post Reply