Interesting Tech Projects
Software Engineering
Using Alibre Design for 3D Printing of Multi-Part Projects
Mar 13th
The easiest way to design projects that involve multiple parts in Alibre Design is to create and edit parts inside an assembly workspace. This allows the edges and cross-sections of one part to be reused in another part which is very useful.
However for 3D printing there is a downside – creating a part inside an assembly results in that part being orientated the same way in the part workspace as it in the assembly workspace. For 3D printing we want a specific side face down on the XY plane. That choice of side depends on the part.
So we have taken advantage of the tools and features that Alibre Design offers but we now have parts that are not orientated correctly for printing. They can be rotated in Alibre Design by creating a new assembly just for that part but there must be an easier way.
The following screenshot illustrates the problem. The circular panel is in an assembly and orientated the way we need it to check that everything fits together.
Opening the part in it’s own workspace shows the orientation.
Exporting and slicing this part as it is results in the following g-code.
So how can we make this easier, especially if we have an assembly with lots of parts? By using an add-on for Alibre Design.
I’ve updated my AD Assembly Exporter utility that I have previously written about. It can now automatically rotate STLs when they are exported so that the desired face is aligned with the XY plane.
First you must choose the face that will be placed on the print bed.
- Edit the part
- Right-click on the face and choose Insert Plane..
.
- Click on OK
- In the Design Explorer right-click on the new plane and choose Rename
- Enter the name “Bottom”
Now save the part and open the assembly containing it, if it wasn’t already open. Repeat this for all parts in the assembly that will be printed.
Run AD Assembly Exporter, click on the STL tab and choose the option to rotate using the “Bottom” plane.
Then click on Generate STLs. Here is the new g-code output:
Using Alibre Design for Multi-color and Multi-material 3D Printing Part II
Feb 27th
Previously I wrote about my little utility that allows exporting properly positioned STLs from Alibre Design so they can be imported into a slicing program for multi-color printing. This is fine for use with the RepRapPro slicer but perhaps not with other slicers.
Slic3r is a very popular, fast and flexible slicing program and now it also supports printing multi-color objects. The file format chosen by it’s author is AMF – Additive Manufacturing File. It is essentially a way to group STL files together into a single object and specify different colors or materials for various parts.
I’ve now updated my exporter utility to support saving Alibre Design assemblies directly to this format:
When an assembly is opened the application obtains the colors used by the parts in the assembly. It is then possible to assign the colors to extruders on the 3D printer. For example in this image black is the body of the object and has been assigned to the primary extruder. It’s necessary to choose which slicing program is being used as there isn’t a standard way of mapping colors to extruders. In particular Slic3r currently has several limitations so by choosing Slic3r the application will stop you from making invalid choices.
Once generated the AMF file can be loaded directly into Slic3r and sliced. Here is the g-code output shown in Repeiter-Host:
Note that the colors don’t match the Alibre Design assembly because Repetier-Host uses it’s own coloring scheme to represent the different extruders. For example blue is always the first extruder.
Now the object is ready to be printed. The estimated print time for this example is five hours and 45 minutes.
Ray Tracing (Rendering) with Alibre Design PE
Feb 15th
The Professional and Expert versions of Alibre Design come with a ray tracer called Keyshot but the Personal Edition of Alibre Design does not. However it is easily possible to use the free and very powerful Blender to generate ray traces of your 3D models.
First you must design the parts in Alibre Design and put them together into an assembly. For example here is an assembly showing a pyramid stacked on top of a cube.
Now use my free utility AD Assembly Exporter to export the assembly as a set of STL files. You can download the utility from here. More details on using it can be found in my previous post on 3D printing with Alibre Design.
Next install and run Blender.
Press Delete to delete the default cube. Then go to File -> Import -> STL and choose the STL files that were generated. They will appear in the view in the same positions as they were in the assembly in Alibre Design.
Optionally you can select all the STLs and press ‘S’ to scale them down as they may be a bit large. Now you can assign materials, add lights, position the camera, etc. to render the scene.
Using Alibre Design for Multi-color and Multi-material 3D Printing
Feb 14th
When you wish to print out a part on a 3D printer the workflow is simple – design the part, export to STL and print it. This is fine when you are only printing with a single material or color. Becoming increasingly popular and affordable are 3D printers that support printing with two or three colors/materials at once, such as the Prusa Mendel from RepRapPro. How can Alibre Design be used for this scenario?
In general the easiest way to allocate different colors/materials to a part is to design that part using multiple smaller pieces. Each piece is assigned a color/material for printing. Alibre Design has a very flexible and easy to use way of grouping parts together called an assembly. What we would need therefore is a way of exporting multiple STLs from an assembly preserving their relationships to one another.
For example, suppose we have a cube and a pyramid and we wanted to place the pyramid on top of the cube and print it in a different color to the cube. We would design the cube and pyramid as two parts then use an assembly to stack the pyramid on top of the cube. Now we need to export the two STLs preserving their position relative to the same origin. This would allow the 3D slicing software to know to stack the pyramid on top of the cube. This is where the problems start.
Alibre Design supports exporting an assembly to a single STL. It merges all the parts together and produces a single object. Information about the individual parts is lost, so this is not usable for our purposes. If you export an individual part or you hide/suppress parts in an assembly then Alibre Design exports the STL using the position and origin in the part file not the assembly, causing the position information to be lost.
An additional problem is the units used in STL files are not defined. If you create a part using centimeters then Alibre Design exports an STL that uses centimeters. Likewise if you create a part using inches then the STL uses inches. The problem is that most, if not all, 3D slicing software assumes the units are millimeters. Solving this for a single part is easy – simply change the units used to millimeters before exporting. However an assembly can be made from multiple parts that all use different units. Regardless of the units chosen for the assembly the STL export will always use the units the part was designed with.
There is one more issue that needs to be addressed. When creating an assembly parts become rotated but the final positions may not be the best for 3D printing. Consider the lid for a box. When creating the assembly it will be rotated so the top is facing upwards but the optimal orientation for printing is probably for the top to be facing downwards onto the build surface. Currently the easiest way to rotate an assembly is to place it into a new assembly as a sub-assembly. This creates an unnecessary extra file and step to perform.
Fortunately Alibre Design has an easy to use API that allows these problems to be solved and I present here my free utility with an exciting name: AD Assembly Exporter.
To use start the application and Alibre Design and open an assembly. In the assembly you can optionally hide/suppress parts you do not want to export. The name of the assembly will be shown in the title bar of the AD Assembly Exporter application. Enter the desired settings and click on the Generate STLs button.
The utility supports forcing the units in STLs to millimeters and rotation around an axis. The STL export options match those found in Alibre Design so please see the Alibre Design manual for a description of what they do. Sub-assembly nesting is supported.
Only open one assembly at a time when using the utility. It will export the first assembly found from your open Alibre Design sessions.
Please note that this software is provided “as-is”. More details can be found in the license shown during installation.
Click here to download AD Assembly Exporter (now called WizoPrint)
Setting Up A PC for Android Development
Nov 16th
The steps are confusing, the requirements many and it entails reading multiple web pages then fitting the jigsaw together. Here are the exact steps I took to set my Windows PC up for development with Android.
- Download “Eclipse IDE for Java Developers“.
- Extract the files using 7-zip and then copy to C:\Program Files\Eclipse
- Download and install the Oracle JDK (Standard Edition)
- Download and install the Android SDK
- At the end of the installation choose to run the SDK manager.
- Check/Tick Android 2.3.3 then then click on the Install button.
- Download and install the ADT Plugin using these steps. Note that the instructions say that a “Welcome to Android Development” window will appear. It won’t. Ignore that.
- In Eclipse go to Window -> Customize Perspective…
- Click on the Menu Visibility tab
- Expand File and then New and check/tick Android Application Project
- Click on OK
- In the main Eclipse window click on the icon to go to the workbench.
- Follow the first lesson
Reversing PHP’s mktime
Jul 6th
mktime takes a set of six integers and creates a UNIX timestamp. Surely there is a better way of reversing it than this?
$timestring = date("Y-m-d H:i:s", $time); preg_match('/(\d+)\-(\d+)-(\d+) (\d+):(\d+):(\d+)/', $timestring, $matches); $year = $matches[1]; $month = $matches[2]; $day = $matches[3]; $hour = $matches[4]; $minute = $matches[5]; $second = $matches[6];
Python CAD Scripting
Jun 24th
FreeCAD supports Python as a scripting language which allows the creation of 3D parts based on variables. This is great for building libraries which support customizable part creation.
As a first attempt I created the following test script. When executed in FreeCAD 0.13 it creates a rod 10mm x 10mm x 50mm with a notch in it. It then removes a cube measuring 4mm x 4mm x 4mm from one end.
Here is what the hierarchy looks like:
And here is the script:
import FreeCAD, FreeCADGui, Part App = FreeCAD doc = App.activeDocument() rodbasepts = list() rodbasepts.append(App.Vector(0, 0, 0)) rodbasepts.append(App.Vector(0, 10, 0)) rodbasepts.append(App.Vector(10, 10, 0)) rodbasepts.append(App.Vector(10, 0, 0)) rodbasepts.append(App.Vector(6, 0, 0)) rodbasepts.append(App.Vector(6, 2, 0)) rodbasepts.append(App.Vector(4, 2, 0)) rodbasepts.append(App.Vector(4, 0, 0)) rodbasepts.append(App.Vector(0, 0, 0)) rodbase = Part.makePolygon(rodbasepts) rodbasefilled = Part.Face(rodbase) rod = rodbasefilled.extrude(App.Vector(0, 0, 50)) #rod.Placement = App.Placement(App.Vector(10, 0, 0), App.Rotation(0, 0, 0, 1)) rodpart = doc.addObject("Part::Feature", "rod") rodpart.Shape = rod cubebasepts = list() cubebasepts.append(App.Vector(0, 0, 0)) cubebasepts.append(App.Vector(0, 4, 0)) cubebasepts.append(App.Vector(4, 4, 0)) cubebasepts.append(App.Vector(4, 0, 0)) cubebasepts.append(App.Vector(0, 0, 0)) cubebase = Part.makePolygon(cubebasepts) cubebasefilled = Part.Face(cubebase) cube = cubebasefilled.extrude(App.Vector(0, 0, 4)) cubepart = doc.addObject("Part::Feature", "cube") cubepart.Shape = cube cut = doc.addObject("Part::Cut", 'Rod minus cube') cut.Base = rodpart cut.Tool = cubepart rodpart.ViewObject.hide() cubepart.ViewObject.hide() doc.recompute()
To use create a new Part and then copy and paste the script into the Python Console inside FreeCAD.
Radio Controlled Aircraft for Stroke Victims
Oct 23rd
This post introduces my open source radio control project. It allows an RC aircraft to be controlled from a Wii Nunchuk, i.e. with one hand! Videos will be posted when they are available but so far it is working great in the flight simulator and with a stationary aircraft.
All documentation, source files and binary files are available for free from this site, so you can build your own. Be sure to read the disclaimer before you start however.
I would love to hear your success stories using this modular system!
Creating Package Installers for MonoMac
Sep 25th
When developing applications with Mono/MonoMac it is very useful to create an installer that bundles Mono with your application. MonoMac includes a utility for creating an installer but unfortunately it is bug ridden and limited. Here are the steps that work for me.
Note: make sure you have Xcode installed.
- Delete any existing bundle. For example MyApplication.app. This is important because if the bundle already exists when you try to create it MonoMac will give you the cryptic error message “Unhandled error in packaging”
- In MonoDevelop go to Project -> Create Mac Installer… and choose to only create a bundle
This should create a bundle with a name like MyApplication.app - Start PackageMaker by going to Spotlight and searching for it. It can also be found in /Developer/Applications/Utilities.
- Drag your bundle MyApplication.app to the left hand side of PackageMaker.
- Select the package, click on “Components” and uncheck “Allow Relocation”
- Build and run the installer
You may or may not want to uncheck the option to allow relocation. On your development Mac if you don’t uncheck this then the installer will find a version of your application inside your MonoDevelop solution and overwrite it rather than putting it into /Applications. This makes it appear as if the installer didn’t work. On non-development Macs this option allows the application to be overwritten even if the user has moved it after installing an older version.
Global Objects With MonoMac
Sep 24th
When developing for C# and using Windows Forms creating and using global objects is trivial:
public static class Program { public static Foo MyFoo = new Foo(); static void main() { Main = new MainForm(MyFoo); } }
The same can’t be said for MonoMac. The mistake is to equate the static MainClass class as being the same as the WinForms Program class in the example shown.
The solution is to put the global class instantiation inside the NSApplication delegate. MonoMac creates this automatically and calls it AppDelegate. The above example becomes:
public partial class AppDelegate : NSApplicationDelegate { MainWindowController mainWindowController; public Foo MyFoo = new Foo(); public AppDelegate () { } public override void FinishedLaunching (NSObject notification) { mainWindowController = new MainWindowController(MyFoo); mainWindowController.Window.MakeKeyAndOrderFront(this); } }