Saturday, 31 May 2014

FreeCAD: Vertex to Vertex Positioning Function

FreeCAD 0.14 is taking too long to be released and, if when you try to compile it, everything is a non-sense and you end up feeling frustrated and stupid (as happens to me every time), you may like this:

Frustration solved: Hamish Assembly2 workbench here

Vector to Vector translation function:

 

Code:

from FreeCAD import Gui

def V2V():
  MouseSel = Gui.Selection.getSelectionEx()
  ObjA_Name = MouseSel[0].ObjectName
  PointA = MouseSel[0].SubObjects[0].Point
  PointB = MouseSel[1].SubObjects[0].Point
  Vector = PointB - PointA
  Pos0 = App.ActiveDocument.getObject(ObjA_Name).Placement.Base
  Rot0 = App.ActiveDocument.getObject(ObjA_Name).Placement.Rotation
  MVector = Pos0 + Vector
  App.ActiveDocument.getObject(ObjA_Name).Placement = App.Placement(MVector, Rot0)

 To Use it:

Copy-Paste at FreeCAD command line the code above and then:

-Select a point of the object you want to move
-Select a point of another object where you want the previous one to be placed
-Call the function (write V2V() at command line and Enter)

And you're done!


With this you can save some time when placing objects without the assembly workbench. 


Bye!

Friday, 30 May 2014

FreeCAD: Perforated Sheets and HoneyComb

Perforated sheets are very useful and widely used in a lot of things. Yesterday I started to think about the algorithm and this is the result:



Simple circular holes at the moment. Circular and Hexagonal now!





The code is here

The function PSheet has 6 inputs, 4 mandatory and 2 optional:

L = Length of the base rectangle
H = Heigth of the base rectangle
W = Width of the base rectangle
R = Hole radius

The optional parameters are hole type (circle by default) and  "hole density" set as 1/5 by default.

To get the same as the above photo type after copy-paste:

PSheet(100, 100, 1, 4)

Yes, is slow to load. I will try to improve that, maybe doing a big sketch with all the holes, extruding them and substracting to the main plane.

Now everything is created with sketches. The speed has improved but not enougth to create big sheets. Almost all time is spent doing the recompute step, the last line of the script. I don't know how to speed up that :s
This is the graph of the needed time as a function of the sheet length (with heigth equal to length):


Just for curiosity and to see that if you want to create something bigger than an 800x800mm sheet, you will need more than 24 hours.

Honeycomb :

If you give enougth width to an hexagonal pattern you get a honeycomb like this one:


Honeycomb cores are very common in carboon-fiber structures.

That's all by now.

Thursday, 29 May 2014

Ecuation Solver: ESuite

I was surfing the web some time ago and I found this useful tool:

I think I should share it here because at my degree we are using a very similar program (Esuite could be called the open-source clone), basically to solve thermodynamic problems.

I've tested it with simple ecuations and seems to be a very interesting program for those who want a magical black-box that, simply, does its job. 

To use it in linux, I've downloaded the tar.gz package (no need to install)
Once you got it, uncompress and mark as executable the eSuite.jar file inside.
Finally, execute it with OpenJDK or Java and you're done!


Bye!

Sunday, 4 May 2014

FreeCAD: Work Features Release 1

UPDATED: Thanks to the community contributions, this work features project has been extended with more options and a nice gui. Find it here: http://www.freecadweb.org/wiki/index.php?title=Macro_WorkFeatures

This is the first release of the Work Features macro. It can do what is shown in the video plus few things more.



Is not finished and I have to update some functions, but to know how it works, the code is here.

How to use it: 

(I don't know exactly why, but the last part of this section has the fonts messed up, sorry for that)
At the moment, you need to copy and paste the code at the FreeCAD python terminal every time you open a new document. 
Yes, I know I need to improve this. Any help is appreciated.  ;)

Once you do that, you need to move by command line (need to improve here too) and these are the options:

-OriginObjects This is executed automatically at copy-paste, generates Origin and folders
-WorkPoint:
-MiddPoint # Select one or more edges and will place the middpoint
-Center # Select one or more circular edges and will place centerpoint
-FaceCenter # Select one or more faces and will place a point at geometrical center
-WorkAxis:
-TwoPoints # Select two points and will place an axis across
-CylinderAxis # Select a cylindrical face and will place its axis
-WorkPlane:
-AxisandPoint # Select one axis and point and will place a plane containing both
-ThreePoints # Select three points and will place a plane with the points inside
-PlaneandPoint # Select one plane and point and will place a parallel plane at point
The workflow is:
Select the needed objects for reference and then type the command.
For example, one command could be:
WorkPoint.FaceCenter()
to create a point at the center of the selected face.
or
WorkPlane.ThreePoints()
to create a plane across three points.
And that's all!
Tell me your experience with the macro or any suggestions you have :)
Bye!