Assembly 2 workbench for FreeCAD v0.15

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
hamish
Posts: 72
Joined: Wed Nov 12, 2014 7:08 am

Assembly 2 workbench for FreeCAD v0.15

Postby hamish » Wed Nov 26, 2014 1:09 pm

Hi Everyone,

I have written an assembly workbench for FreeCAD v0.15, which I am posting here for everyone's perusal.
The assembly2 wb is available together with a detailed description at
https://github.com/hamish2014/FreeCAD_assembly2

I realize that there is mostly likely heavy development on FreeCAD's inbuilt assembly wb, which i could have just used for my assembly needs.
However since FreeCAD provides such an excellent environment for building custom wbs, I decided to rather write my own wb exactly tailored to my needs.
Writing the assembly2 wb furthermore gave me a chance to play around with the maths behind CAD assembly codes, math which I have always wondered about...

Hope someone else finds the assembly2 wb useful
danielfalck
Posts: 395
Joined: Fri Oct 07, 2011 8:58 pm
Location: Beaverton,Oregon, USA
Contact:

Re: Assembly 2 workbench for FreeCAD v0.15

Postby danielfalck » Thu Nov 27, 2014 11:48 pm

I have been using this today and have found it to have some features that I like. I wasn't able to get any of the constraints to work and I do have numpy and scipy installed. But, I really like the import part and reload part commands that you have. That has been very useful for me today. Just being able to import FreeCAD objects into my assembly file and being able to reload them after I have edited them in their original file is very nice.
I did comment out lines 61 through 64 (the lines that randomly place the part on import) in importPart.py because since I couldn't get assembly constraints to work, I prefer to know where my parts are located to begin with.

Good job.
danielfalck
Posts: 395
Joined: Fri Oct 07, 2011 8:58 pm
Location: Beaverton,Oregon, USA
Contact:

Re: Assembly 2 workbench for FreeCAD v0.15

Postby danielfalck » Fri Nov 28, 2014 12:37 am

This was the error that I got when trying to constrain two planes on two parts that had been imported using your new commands:

Code: Select all

creating planeConstraint01
assembly2solver parsing planeConstraint01
violated constraints: planeConstraint01
objects associated to these constraints: Unnamed_import01, block2_import01
repective connectivety [1, 1] 
variableManager.getValues() [6.84337598002, 3.18146, 93.4783563956, 0.0, 0.0, 0.0]
{'imode': 9, 'smode': 'Iteration limit exceeded', 'fOpt': nan, 'iter': 161, 'xOpt': [nan, nan, nan, nan, nan, nan]}
{'imode': 9, 'smode': 'Iteration limit exceeded', 'fOpt': nan, 'iter': 161, 'xOpt': [nan, nan, nan, nan, nan, nan]}
{'imode': 9, 'smode': 'Iteration limit exceeded', 'fOpt': nan, 'iter': 161, 'xOpt': [nan, nan, nan, nan, nan, nan]}
{'imode': 9, 'smode': 'Iteration limit exceeded', 'fOpt': nan, 'iter': 161, 'xOpt': [nan, nan, nan, nan, nan, nan]}
{'imode': 9, 'smode': 'Iteration limit exceeded', 'fOpt': nan, 'iter': 161, 'xOpt': [nan, nan, nan, nan, nan, nan]}
{'imode': 9, 'smode': 'Iteration limit exceeded', 'fOpt': nan, 'iter': 161, 'xOpt': [nan, nan, nan, nan, nan, nan]}
{'imode': 9, 'smode': 'Iteration limit exceeded', 'fOpt': nan, 'iter': 161, 'xOpt': [nan, nan, nan, nan, nan, nan]}
UNABLE TO SOLVE ASSEMBLY CONSTRAINTS. Info:
  optimization algorithm could not minimize the norm of constraint errors
    optimization algorithm used  : scipy.optimize.fmin_slsqp (Sequential Least SQuares Programming)
    optimization warning message : Iteration limit exceeded
    imode: 9
    smode: Iteration limit exceeded
    fOpt: nan
    iter: 161
    xOpt: [nan, nan, nan, nan, nan, nan]
UNABLE TO SOLVE ASSEMBLY CONSTRAINTS. refer to the Report View window for info

hamish
Posts: 72
Joined: Wed Nov 12, 2014 7:08 am

Re: Assembly 2 workbench for FreeCAD v0.15

Postby hamish » Fri Nov 28, 2014 5:45 am

Hi danielfalck, glad you found the wb useful :)

Regarding the constraint solver breaking down, please pm FreeCAD assembly file with the parts already imported and the constraints setup. I will then see if i can fix the bug.
jmaustpc
Posts: 9556
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Assembly 2 workbench for FreeCAD v0.15

Postby jmaustpc » Fri Nov 28, 2014 6:19 am

Hi Hamish
Can I offer you a tip on using Git? :) Its best to keep you "master" branch in your repository in sync with official FreeCAD master, and then do all your development in a branch.

Jim
looo
Posts: 2741
Joined: Mon Nov 11, 2013 5:29 pm

Re: Assembly 2 workbench for FreeCAD v0.15

Postby looo » Fri Nov 28, 2014 11:27 am

very intuitive! worked perfect on first try.
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Assembly 2 workbench for FreeCAD v0.15

Postby yorik » Fri Nov 28, 2014 12:33 pm

Once again, amazing work hamish! Now I am getting afraid, what will be the next workbench that you will attack ;)
hamish
Posts: 72
Joined: Wed Nov 12, 2014 7:08 am

Re: Assembly 2 workbench for FreeCAD v0.15

Postby hamish » Sat Nov 29, 2014 5:14 am

lol, thanks yorik. Do not think of them as attacks but rather as suggestions for the next version of FreeCAD...

Also thank jim for git the advice, but i will leave things as they are for the moment, falling quite far behind with my work ...
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Assembly 2 workbench for FreeCAD v0.15

Postby yorik » Sat Nov 29, 2014 1:49 pm

hamish wrote:Do not think of them as attacks but rather as suggestions for the next version of FreeCAD...
Of course, only joking. But it's always cool to see someone else think over a problem in a new way and solve it in a simple manner...
abdullah
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

Re: Assembly 2 workbench for FreeCAD v0.15

Postby abdullah » Sat Nov 29, 2014 4:41 pm

I gave it a try. It is quite intuitive. I had problems though trying to align to circular faces to their corresponding axes... probably I did not dedicate enough time to it... looking forward for more!! :-)