Importing STL files into FreeCAD

One of the light leaks in my leaky camera was because the lens mount had some mounting holes in it that I’m not using. These made for some thinly printed areas which let light in. I wanted to make a modified version of the part without the holes and with a slightly larger lens opening. The problem was that I only had the file as an STL file, not in something that can be edited using FreeCAD. However, it turned out to be quite easy to import the design and then convert it into a FreeCAD model. The first thing you do is use the import dialog to bring in the STL file, select the loaded mesh and switch to the Part workbench and use the commands Part->Create Shape from mesh and then Part->Covert to solid. After that you can work with the part as you would any other.

Remember to convert at the highest possible resolution

This is powerful magic, as it means you can take any STL mesh and work with it. I’ve put the procedure in the blog so that I know where to look when I need to do it again……

FreeCad Simulator is now on GitHub

FakeFreeCad.png

I’ve made this horrible hack to make it easier to debug my Python macros that run inside FreeCad and design little boxes. It means that I can use all the lovely debugging features of Visual Studio Code to find out why my code don’t work. The hack takes the form of a few simple Python objects that fake part of the FreeCad ones and allows your macros to run in any Python environment you fancy.

If you like the idea of writing Python code that produces physical artefacts you might want to take a look at it. You can find it on GitHub here.

FreeCAD is awesome

I’m starting to really like FreeCAD. I’ve used it for years, but I’ve been cheating in that I’ve used internal Python engine to run programs that design things. However, over the last few days I’ve hit up against things that are a bit hard to do programatically, so I’ve been investigating the tool itself. It’s awesome. I can now draw paths and then use those to create curvy objects like the pipe above, which also has a cutout for the BME280 environmental sensor. And then I found that FreeCAD also supports spreadsheets.

You can bind properties in your drawing to values in a spreadsheet. So, if I want to change properties in my drawing (perhaps increase the base thickness) I just change the value in the spreadsheet and the drawing is automatically updated. Dimensions in the drawing are mapped back to the spreadsheet cells. It’s wonderful.

Making bendy pipes with FreeCAD

Achievement unlocked. I now know how to make “bendy” things in FreeCAD. It’s actually not that hard once you work out what FreeCAD needs to know. Essentially you use one Sketch to define the path of the template and another (which should be at right angles to the path) to define the closed shape to be created. You can even add another closed shape at the end of the path and then have the shape smoothly change from one to the other. I’ve used this to create tapered tubes.

I’m doing this to make another Air Quality sensor. I want to send the air path round a curve that is too tight for pipe. I also want to add a “u-bend” so that it is harder for water to get into the sensor. I’m quite pleased with the above. Now I just have to figure out how to mount it in the case….

Python output in FreeCAD

This is one of those selfish blog posts I make to remind myself how to do something that I'm bound to forget. 

But, if you're using the FreeCAD designer to run Python programs to design robots (as I am) you might find it useful. If you want to be able to print messages from your program onto the report console in FreeCAD you can the following:

App.Console.PrintMessage('hello from the program\n')

For this to work you have to have the output window options in Preferences set to Redirect internal Python output to the report view, but if you do this works a treat. My design programs can now report on progress, which is nice. 

Incidentally, I've now got a lot of experience creating solid objects from Python code using FreeCAD. If anyone would like me to do a talk on this, let me know and we can sort this out.