Thursday 17 November 2016

FreeCAD: Bolts, nuts, washers..., one helping tool!


If you decide to add bolts, nuts, washers, etc, to your assembly, and it is somewhat complicated, you may end spending a lot of time placing this tiny parts all around the 3D space. At least, that has been happening to me from time to time. In this post I introduce you the tool I coded to deal with this situation:

def placeBolts():
  sel_obj = FreeCAD.Gui.Selection.getSelectionEx()[0].Object
  sel_edge = FreeCAD.Gui.Selection.getSelectionEx()[0].SubObjects[0]

  sel_edge_number = -1
  for edge in sel_obj.Shape.Edges:
    sel_edge_number += 1
    if (edge.CenterOfMass - sel_edge.CenterOfMass).Length < 0.001:
  parent_folder = None
  def findParentFolder():
    # find the group that sel_obj pertains to
    for obj in FreeCAD.ActiveDocument.Objects:
      if obj.TypeId == 'App::DocumentObjectGroup':
        for sub_obj in obj.Group:
          if sub_obj.Name == sel_obj.Name:
            return obj
    return None

  parent_folder = findParentFolder()
  if len( FreeCAD.Gui.Selection.getSelectionEx())  == 2:
    target_edges = FreeCAD.Gui.Selection.getSelectionEx()[1].SubObjects

  elif len( FreeCAD.Gui.Selection.getSelectionEx())  > 2:
    target_edges = []
    for i in xrange( len( FreeCAD.Gui.Selection.getSelectionEx() ) - 1 ):
      for sub_object in FreeCAD.Gui.Selection.getSelectionEx()[i+1].SubObjects:
        target_edges.append( sub_object )
  for edge in target_edges:
    # create new object in document
    new_obj = FreeCAD.ActiveDocument.addObject( 'Part::Feature', sel_obj.Name + '_copy' )
    # assign a shape to the created object
    new_obj.Shape = sel_obj.Shape.copy()
    # assign the view object to copy colors
    new_obj.ViewObject.ShapeColor = sel_obj.ViewObject.ShapeColor
    new_obj.ViewObject.LineColor = sel_obj.ViewObject.LineColor
    new_obj.ViewObject.Transparency = sel_obj.ViewObject.Transparency
    # move this object to a folder if selected object was in a folder
    if parent_folder:
      parent_folder.addObject( new_obj )
    # place the new object at the desired target
    VA = new_obj.Shape.Edges[sel_edge_number].Curve.Center
    VB = edge.Curve.Center
    DV = VB - VA
    new_obj.Placement.Base.x += DV.x
    new_obj.Placement.Base.y += DV.y
    new_obj.Placement.Base.z += DV.z

This function is called "placeBolts" and has no arguments. To use it, open the python terminal inside FreeCAD and copy-paste the code above, then continue reading.

How to select the objects to place:

In the picture there is a rectangular pad with 5 holes on which I want to place the washer (also present in the drawing):

First select the circular arc of the washer that is going to be in contact with the hole in the pad, like this (notice the thin circular edge selected at the bottom of the inner cylinder of the washer in the picture below):

Second select all the edges of the rectangular part that will be in contact with the washer.

Third, copy paste this line at they python terminal:


And its done!

The washers are placed at the selected positions and if the original washer which served as a model was inside a folder, the created copies will be appended within the same folder (this is gold when you are in a big assembly)


This tool works for circular edges only, but the vast majority of parts that could benefit from it have them (bolts, nuts, washers, threaded rods... ), so I do not consider it a big drawback.

I may include this as an auxiliary assembly tool in the exploded assembly workbench.

Have fun.


Monday 14 November 2016

Quick News

Hi, a lot of time has past since the last post, so here is a brief summary of what has happened under the hood:

- I have graduated in Mechanical Engineering

- I re-coded from scratch the Exploded Assembly workbench, now it is more useful, easy to use and has some basic assembly tools.

-The NickelChromium project (NiCr) has mutated (temporally) into a CNC mill that uses 3d printed linear guides with cheap ball bearings (accelerated video):

- I have launched my startup "Odyssey Robotics", which produces custom-made machinery and robots. (yes, I use FreeCAD to design them). This is one of my first projects, a vinyl lamination machine:

In conclusion, this and a bunch more of things have me separated from posting and working on previous projects (like sheet metal ), and it seems that is going to stay that way for some time.


Wednesday 30 December 2015


NiCr (read as 'nicrome') is the name of my CNC Hot Wire Foam Cutter, an OpenSource/OpenHardware project that I'm making public with this post.

The github repository:



As the name says, the machine cuts shapes from foam blocks, being the original intention to cut wing cores for lamination and molding.

I've composed a little video about it:

I'm opening this project in exchange of all the good things that the OpenSource world has given to me (I like to think about it as 'from the OpenSource to the OpenSource').


The NiCr project can be divided in three parts: Machine, Arduino and FreeCAD


The machine is the physical thing, and is being designed to be built from easy to find, easy to work with materials, like extruded aluminium tubes and simple bolted joints, taking into account a low budget and the DIY factor (only cut/drill/bend operations).

It features two CoreXY frames, easy-to-find Nema17 motors, and a spring tensor for the wire. The design is also very scalable and can, possibly, be applied to other type of machines.

The design has taken place between FreeCAD and the real world:

FreeCAD pictures:

Detail of the Nema17 stepper, X axis slider and belt pulleys

Machine assembled inside FreeCAD
Real world pictures:

Frame size

Slider on the X axis

First version of the cut-wire tensor


The machine movement is done with an Arduino Mega 2560 board and a Ramps shield, that, together with four stepper drivers (A4988), some limit switches and a power source form all the electronics.
The firmware is being developed specifically for this machine, you can see some of its parts in this links:


The shapes are created using FreeCAD existing tools and converted later to .nicr (similar to GCode) in a custom workbench.

This workbench features a parametric machine, a shape-to-path algorithm, trajectory planning and simulation tools.

Some pictures of the workbench:

Workbench and parametric machine

Cut path simulation result for three wings with different precision settings

Workbench demo video:

The result of the shape-to-path algorithm is a .nicr file that contains instructions similar to GCode and with this comes a question:
Why I have not used the path workbench (in development) and the existing GCode standard?
 Because this machine produces 2.5D shapes (could do '2.75D' with the addition of a fifth axis, to be studied) and the movement is very different to the movement of a 3D printer or mill, and by using 4 axis, someone can be mistaken and use the code for the wrong machine.
Anyway, it is going to be a documented language so export-import tools can be created if needed.


NiCr is in active development, at the moment I'm trying to achieve a basic stability and usability of the software before releasing (and some documentation too, maybe the hardest thing!).
Once I achieve that, the code and machine 3d parts will be uploaded to github (I have not decided the particular license yet) After a complete day of reading about licenses, I have chosen the GNU GPL.

I'll be updating this post with any news I have.
-> January 1, code uploaded to github:

By the way, have a happy 2016!