Sunday, April 27, 2014

A Parametric Vise in FreeCAD

This post is for Normand. I promised him that I would show this a long time ago.

In FreeCAD, you can create parametric objects with python scripting. What this means is you can create objects that change by altering their parameters. This makes it nice to create geometric objects similar to what you would find in the Draft workbench- rectangles, polygons, circles, and points are some of the parametric objects that Yorik has created. The Draft and Arch workbenches are pure python, so there are many examples of parametric objects to learn from.

A few months ago, I created a parametric milling machine vise, by importing *.step files from a well know vise manufacturer and worked them into some python scripting. When I first started playing with the script, I was copy/pasting it from my editor constantly, trying it out. This is fine for me to do, at first, when it was just one file to play with, but as the project got larger, it became a pain. I had added an *.svg file for the icon and split the *.step file in two. Things were starting to get a lot larger than my usual one page scripts, so it was time to make a small project out of it.
As the project got a little larger, I realized that this could be a pain for other folks to use, if I didn't clean it up and make it easy to install. I noticed that Yorik had made the dxf import/export part of his Draft workbench into an automatic download with FreeCAD, on the first instance of importing or exporting a DXF file. That looked like a good way to go for my script.

The small script that downloads the other files is here:

Copy and paste it into your FreeCAD python console or into the FreeCAD macro editor and run it with the green play button.

The vise looks like this:

That last image shows the parameter for the jaw opening- it's in metric and you can give it value up to 220 mm and the movable jaw of the vise will open up.

Have fun with it.