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.

Sunday, January 19, 2014

Helping a Boy Scout

My son is in the Boy Scout program, here in the US. I feel that it is a very good program. He has learned some very good skills and had some awesome adventures. We also end up working together on a lot of projects. One of those was helping one of his fellow scouts with his Eagle project. This scout wanted to help a local charitable organization that gives clothes to needy children around the area. The organization didn't have any work tables for sorting clothes or benches for their clients to sit on, while they were waiting outside the door.

The scout working on this project knows that I like to design and build things, so he contacted me about the project. He started by getting the requirements from the charity director and came back with dimensions. We discussed some general design ideas and what materials he wanted to use. The materials would be construction grade timbers and plywood (laminated sheet).

 I needed to make four different designs for these various tables and benches. There were three tables that needed to be different lengths and two benches that should be the same as each other. The tables were all very short, since they were going to be used for stacking boxes and clothes on. We wanted a similar design on all of them, since they were all going to the same place and it would make things easier for volunteers to assemble. After a group assembled one table, the next should be very familiar to them. We decided to make the benches look similar to the tables.

 I decided to use a combination of FreeCAD for design and DraftSight for dimensioned drawings. I like using FreeCAD for design, because I am comfortable with it and feel that it is very powerful. I could start with one design and then change just a few parameters to make it fit the requirements for the next table or bench. I could probably even dimension all the drawings for the project in FreeCAD, but I am much more comfortable doing that in DraftSight.

 Since we don't have an assembly workbench in FreeCAD yet- and I wanted all components to be related/driven by the table top, I did a sort of crude hack to keep everything in sync. I used PartDesign workbench with sketches and made a base sketch that represented the outside dimensions of the table or bench top for every set of components. The corners of the table top sketch were mirrored around X0 Y0 to give some consistency to my hack. I copied this same geometry  from the table top sketch  and pasted into one  sketch and changed it into construction geometry
I copied and pasted this base construction geometry into four other sketches- to mimic the table top.  Here is an example of the sketch construction:

(I am also working in inches on this project but chose not to change units in FreeCAD- so notice that the units in my sketch are in mm)

Within the sketches for everything, except the table top, I used additional construction geometry to space the padded part of the sketches away from the lip of the table top. This would typically be the over hang of the top and the thickness of the timber next to what I was working on:

One problem with this approach is that if I needed to change the length of the piece of furniture that I was working on, I had to change the construction geometry in several pieces to make this work. Since I didn't really care to code up a total parametric table in python, I thought that was a fair trade off. In the end, it wasn't a huge hassle to change the parameters for the 4 unique designs.

I did the components in groups:
1. table top -this was simple- make a sketch and pad it in a positive Z direction.
2. two long timbers for the frame - sketch their perimeters and pad in a negative Z direction.
3. two short cross timbers for frame - sketch their perimeters and pad in a negative Z direction.
4. all four legs - sketch their perimeters and pad in a negative Z direction.
5. two cross braces (mounted towards the floor on outside of legs) - move placement of the sketch to be lower than the table top and pad in a negative Z direction.
6. stretcher (mounted to the inside faces of the cross braces) - move placement of the sketch to be lower than the table top and pad in a negative Z direction.
7. The corner blocks were a little more difficult. They had to be sketched on a plane that was perpendicular to the table sketch. I ended up having to fudge on their locations a bit, but I survived :)

Here is a screenshot of all of the components put together:

In FreeCAD's Draft workbench there is a command to create a 2D projection of a 3D object called Shape2DView. I used that (with the help of a python script to speed up positioning) to create this:

These 2D views were then selected and exported as a *.DXF file for detailing in DraftSight.

We finished up construction earlier today, with the help of a lot of other scouts.