Categories
3D modeling 3d printing FLOSS

Lithophane creator for 3d printing

I wrote an OpenSCAD script to make it easier to create a lithophane for the 3d printer. There are a lot of lithophane models of photos to be found on Printables, a community hub for 3d printing, but none that I could find offered the possibility to easily add your own photo to the model. Luckily OpenSCAD has a Customizer. The Customizer provides an easy to use graphical user interface (GUI) to change an existing model in OpenSCAD. It is therefore not necessary for the user to change the code.

Example of a lithophane created in OpenSCAD

The small OpenSCAD script revolves around the Surface() command. This command reads heightmap information from text or image files. Alpha channel information of the image is ignored and the height for the pixel is determined by converting the color value to grayscale. The invert boolean parameter inverts the color value of the image if set to true. Below is the module that handles the Surface() command and determines the thickness of the model.

module place_image(img,th,inv) {
        //import the image and scale it to the desired height and width and adjust the thickness.
        scale([1, 1, th])
        surface(file = img, invert = inv, convexity=3, center=true);
}

The script, example photos and an example stl file can be found on Printables here: https://www.printables.com/model/293702-lithophane-creator.

The lithophane model can be created in five steps described below.

  1. Download OpenSCAD. For this your need the free and open source program OpenSCAD which is available for OSX, Windows and Linux. Start OpenSCAD and load the .scad file available here together with the sample negatives photos below. Easiest is to have the .scad file and the negatives in the same folder or map. Now use the Customizer to create you .stl file. 
  2. Make a negative of your photo. If you start with a jpg file you need to convert it to a png file first. Before loading your png file into OpenSCAD you need to make a negative of the photo first. There are many ways to do this but I use Imagemagick, a command line tool for Linux, Windows, Mac OSX, and others. To create a negative file type: convert -negate foo.png inverted_foo.png on the command line.  To create a negative png file and reduce it 20 percent type: convert -negate -resize 20% foo.jpeg inverted_foo.png. (If you rather use a GUI instead of the command line you can also use GIMP, yet another free and open source program. Download GIMP for OSX, Windows or Linux. Open the original photo. Next select Colors and then Invert in the menu.)
  3. Use the Customizer. The Customizer has the option to change the background. This is important to select. If the background of your original photo is mostly white or lightly coloured choose ‘light’. If it’s mostly dark choose ‘dark’. In addition enter the height and width in pixels of your photo.
  4. Render and save the .stl file. To create an .stl press F6 or select Design/Render in the menu. It’s important to know that rendering takes longer when the image is larger. I found that a a 200×200 pixels photo takes a few minutes to render. Since the resolution of the 3d printer is limited it’s probably needless to go beyond 40.000 pixels.
  5. Slice and print. Make sure that the photo is placed in the upright position as shown in one of my photos on Printables (see link above).

The script in this blog post provides a flat model of a photo. If you want to have a curved model take a look at this blog post of mine: https://homehack.nl/a-curved-3d-printed-lithophane-in-openscad/

Categories
3D modeling 3d printing

A curved 3d printed lithophane in OpenSCAD

How can I wrap a flat surface around a cylinder in OpenSCAD. This was a question I asked myself. OpenSCAD doesn’t provide a ready made method so we need to write our own. Luckily we don’t have to invent the wheel here, others have done that already. Justin Lin has written a very handy tutorial on his website Openhome.cc how to wrap a text around a cylinder.  In this project I took it a step further and wrapped a png image over part of a cylinder resulting in a curved image.

3D printed curved lithophane

It seemed like fun to combine this technique of wrapping with the 3D print of a lithophane. A lithophane is an engraved image on translucent material. Many 3D printers have already produced lithophanes sometimes with stunning results. For this experiment I’ll use white PLA because it  has excellent translucent properties.

Now first let me explain the basics on how to wrap a 2D image around a cylinder. First we create a circle out of triangles. These triangles are then extruded to segments to form a cylinder.  Next all segments of the cylinder are lined up in a row and the image is place on the far side but just within the limits of the segments. When we intersect the image with every individual segment and return the segments to their original position in the cylinder, a curved image emerges (see images below).

If you want to know more please watch my video below. In this video the OpenSCAD script is explained and demonstrated. Also is shown how to import the stl file in Cura and what settings are used.

Here you can download with an example file of a curved lithophane:

If you want to use your own png file change the surface command in the OpenSCAD file to include your own png file. Make sure to also change the height and width according to the imported png image in px. Prerender and render can take some time so it’s recommended to use a fast PC. And the larger the png the longer it takes.

A circle created out of triangles
The extruded triangles form a cylinder
The segments are lined up in a row
Image placed on the far side of the triangles
The triangles returned to their original positions
The image intersected with the triangles and returned to their original position.
Categories
3D modeling 3d printing open source programming

Peddle wheel boat (3D printed)

I found an example on Thingiverse, a rubber band powered boat with two peddle wheels, but it has two problems. First of all the author only provides .stl files and second the design is a bit flawed. I therefore decided to design the boat from scratch with the 3d CAD program OpenSCAD. With OpenSCAD I’m not only able to edit my models quickly, I’m also able to share the OpenSCAD script allowing other to use and change it. Links to the downloadable files can be found here: https://my.hidrive.com/share/pyilt3itb8

Assembled Paddle Wheel Boat.

The Paddle Wheel Boat that I created consists of four parts: the boat, the shaft and two peddles. The main change of the boat that I designed is the position of the shaft. It’s been shifted to the middle of the boat providing more balance. I also enforced the attachment point of the rubber band to the boat making it impossible to break it.

The redesigned Paddle Wheel Boat with shifted position of the shaft and enforced attachment point for the rubber band.

I also increased the size of the paddles enabling the boat to move faster. The shape of the paddles are rounded instead of square improving the dynamics of the paddles through the water. A problem with the old design is that the rubber band has to be fixed to the shaft with some tape. Not a very elegant solution. I added a square hole to the design of the shaft. The rubber band can be inserted through the hole and fixed to the shaft. No tape needed.

Simple square hole in the shaft. The rubber band fits right through the hole making it easy to fix it to the shaft.

Changes to the models are easily made. The OpenSCAD script is simple and the result of a change can be reviewed immediately by pressing F5. E.g to move the shaft to the back of the boat can be achieved by just one simple change in the script.

Just four parts, the boat, shaft and two peddles, are needed to make the boat. If you don’t want to make changes to the design just download the provided .stl files and open them in your favourite slicer. After printing the Peddle wheel boat can be assembled and tested. Have fun.

All printed parts plus the rubber band.
Categories
3D modeling 3d printing open source programming

OpenSCAD parametric hook

Writing a script for a simple hook in OpenSCAD is easy but I wanted to do something more and make a parametric hook. With parametric I mean that a user can easily adjust the script by changing some variables to make your own hook.

To make it even easier the script makes use of the Customizer of OpenSCAD. This means that users don’t have to tinker with the code but can adjust the values of the variables with a easy to use panel on the right side of the GUI of OpenSCAD called the Customizer. (If you don’t see the Customizer in OpenSCAD go to the menu bar and click on Windows and then Customizer).

Screenshot of the script with the Customizer on the right side.
Smaller hook with chamfer
Larger hook with fillet

Aside from changing the dimensions I also added the possibility to add a fillet or a chamfer to the hook. And I added the option to change the radius of the hook and the diameter of the screw holes.

If you’re interested here is an explanation of some parts of the code. The fillet of the cube shaped parts of the hook is created with the fillet module. Within this module I simply intersect a cylinder with radius r1 and a cube of the desired length l.

module fillet(l,r1) {
    intersection() {
        cube([l,l,l]);
        cylinder(h=l, r=r1, $fn=50);
    }
}

In the module roundedCube the thus created fillet pieces are positioned in a such a way that the hull command shapes them to the desired filleted cube.

module roundedCube(l,w,h,r1) {
    d = 2 * r1;
    translate([r1,r1,0])
    hull() {
        rotate([0,0,180]) fillet(l,r1);
        translate([0,w-d,0]) rotate([0,0,90]) fillet(l,r1);
        translate([h-d,0,0]) rotate([0,0,270]) fillet(l,r1);
        translate([h-d,w-d,0]) rotate([0,0,0]) fillet(l,r1);
    }
}

I published the OpenSCAD script (.scad) and some example hooks (.stl) on Prusaprinters. You can download it here:

https://www.printables.com/model/91734-parametric-hook-with-source-file

EDIT: V1.1 of the OpenSCAD file (.scad) has the option to add a countersunk to the screw holes.

Categories
3D modeling 3d printing open source

Solvespace: involute gear

We first need to create a involute of a circle in Solvespace to get a better understanding of an involute gear. This video will be followed by another where we create an involute gear and a third where we adjust the gear in Solvespace.

I’ve used version 2.3 in this video but v3.0 should work fine too for this tutorial. This is a series in progress. I will at least make one more video to demonstrate how one gear drives another in Solvespace.

First video tutorial: Involute of a Circle in Solvespace. Before creating an involute gear we first need to understand how to create an involute of a circle.

Second video tutorial: To create an involute gear we only need three parameters, the module which determines the length of the teeth, the number of teeth and the pressure angle. With these parameters we can determine the Pitch Circle, Addendum Circle or Top Circle, Dedendum Circle or Root Circle and the Base Circle. With these circles and the pressure angle the shape of the teeth can easily be created in Solvespace.

Third video tutorial: This is the third video in a series about creating an involute gear in Solvespace. If we want to adjust the module, number of teeth or pressure angle of an existing gear in Solvespace we don’t have to start from scratch. We can take an existing gear and change one of the three parameters. This will save us a lot of time. However this change must be done following a procedure that I’ll demonstrate. Other wise Solvespace will give us the error message ‘unsolved constraint’.

Solvespace is an open source, parametric, 3D CAD program that is lightweight and easy to use. It is available for GNU/Linux, OSX and Windows. In Solvespace the user applies geometrical constraints to a sketch and the program’s solver calculates the result (comparable to the FreeCAD part design workbench).

Solvespace is open source (GPLv3 license) and is available for Window, OSX and Linux. Originally developed by Jonathan Westhues and currently maintained by Paul Kahler and others. It can be downloaded here: http://solvespace.com/download.pl

The idea for this video comes from the JustThinkering channel on YT who made a video Involute Gears in Solvespace (https://www.youtube.com/watch?v=i6tDWJsNsok).

Categories
3D modeling open source programming

OpenSCAD: Polygon and polyhedron

OpenSCAD allows the user to create complex shapes with the polygon function for 2D and polyhedron for 3D. Polygon and polyhedron both accept a list of 2D and 3D coordinates (points) respectively as parameters. A functions can generate a list of points eliminating the need to manually created these lists. This property can be used to create shapes that are impossible with the 2D and 3D shapes that are build-in in OpenSCAD. In this blog post I’ll show how to create functions for some simple 2D shapes and explain how to manipulate the functions make more complex shapes with them.

Shapes created with functions and polygon in OpenSCAD

Creating a 2D shape

To create a circle with a radius of 20 in OpenSCAD we just have to type

circle(20);

However OpenSCAD doesn’t allow us to reshape this build-in function to for instance an ellipse. Alternatively we can write a function that generates a list of points needed for a circle and then use polygon with the points as parameter to draw the circle. The function uses the trigonometric formulas, x = r cos φ and y = sin φ, to convert polar coordinates to Cartesian coordinates.

function circle(radius) = [for (phi = [1 : 1 : 360]) [radius * cos(phi), radius * sin(phi)]];
polygon(circle(20));

When F5 is pressed a circle is drawn however the x,y coordinates of this circle are available to us. By adding echo(circle(20)); to our script the list of points is printed in the console. The circle function can easily be altered thus gaining a new shape. An example is shown below.

function circle(radius) = [for (phi = [0 : 1 : 720]) [radius * cos(phi/2), radius * sin(phi)]];
color("red") polygon(circle(20));
Shape create with x = r cos(φ/2) and y = r sin(φ)

Now let’s take a look at the syntax of the function. Every function generates a value and in this case it is a list of points. In OpenSCAD a list of points in a two-dimensional space is represented by [[x1,y1],[x2,y2],[x3,y3],…] where all x’s and y’s are numbers. In this case of the circle function the point are generated in a for loop. The loop begin at 0 and ends at 720 with a step of 1. The radius * cos(phi/2) and radius * sin(phi) calculate each x,y coordinate for every given phi.

The ellipse, a generalization of the circle, can now easily be created by slightly changing our function.

function ellipse(r1, r2) = [for (theta = [0 : 1 : 360]) [r1 * cos(theta), r2 * sin(theta) ]];
color("cyan") polygon(ellipse(120,80));

a second parameter is added. r1 is the radius in the x-direction and r2 is the radius in the y-direction. If r1 is equal to r2 a circle is drawn.

Ellipse created with the code above

Conclusion

OpenSCAD allows the user to create complex 2D shapes using functions that generate lists of points This list is used as the argument in the polygon function of OpenSCAD. Every shape can be generated as long as the mathematical expressions are known and can be translated to OpenSCAD script. This opens up a world of possibilities.  The same is true for 3D shapes but instead of polygon the polyhedron function of OpenSCAD should be used. This however is a topic for a future blog entry.

Caveat: List comprehensions as shown in the functions of this  article are only possible with OpenSCAD v2015.03 and above.

OpenSCAD is open source (GPLv2 license) and is well maintained by Marius Kintel et al. Besides the stable releases for Windows, OSX and Linux, development snapshots are available. I recommend using these development snapshots since they have all the latest features. 

A special thanks to Xavier Faraudo who explained the advantages of functions in OpenSCAD to me.

Click here to watch the video if the video below doesn’t play: https://peertube.linuxrocks.online/w/7NfsT6STabJ341ViP1eoMR

Categories
3D modeling open source social

I’m leaving YouTube

Last May I received a new Terms of Service request from YouTube. In this request I had to grant YouTube the right to monetize my videos. In other words when I agree, YouTube can insert ads in the videos. This is the final straw for me with YouTube and Google.

Click here if the the video doesn’t run in your browser: https://peertube.linuxrocks.online/w/egFYuCEYwTCGNLiA58v7F7

I’ve created this YouTube channel with tutorials about open source 3D CAD programs and never had any intention to monetize the channel. So I definitely don’t want YT to monetize it for me.

My goal has been to inspire people to use open source software instead of proprietary software and judging by the number of views and reactions I’ve been mildly successful with that. I had over 200.000 views with my tutorials and more than 1100 subscribers. Not much for YouTube of course but keep in mind that the channel was about open source 3D CAD. Very much a niche market

I’ve put up with all YouTube’s privacy invading policy and data mining because of the popularity of YouTube. YouTube has a near monopoly when it comes to video sharing and has a huge worldwide audience. So to reach my audience with my video tutorials it made sense to use YouTube.

However where does one draw the line. I’ve created the video tutorials believe it or not with a lot a sweat and blood. And it’s important that I keep sovereignty over these videos. So whether ads will be part of the video is up to me and not YouTube. This leaves me no other alternative than to delete all my videos (except this one).

Luckily I’ve already had found an alternative home for my tutorials. It’s called PeerTube. PeerTube is video sharing software but contrary to YouTube, it is open source. In addition it’s also decentralized and federated.

This means that anyone can create a PeerTube server and host videos. These servers can connect to each other and share the videos between them (federation). As a result there is no single owner of the network. If the server that I joined fails or I don’t like the policy on that server I can either upload my videos to another server or even start my own.

I already have some content on PeerTube and I’ll upload new videos to PeerTube. However it’s unlikely that I’ll upload my older videos to it. I figure that they are less relevant anyway. I’ll put a link in the description to the new home of my videos and I hope to see you there.

I hope to see you on PeerTube and keep using open source software.

Here is a link to the new home of my 3D CAD videos: https://peertube.linuxrocks.online/video-channels/homehack/videos

If your interested in the network protocol behind PeerTube and other decentralized services here is link to a post that I wrote about it: https://homehack.nl/activitypub-the-secret-weapon-of-the-fediverse/

Lastly a link to a post that I wrote about the other problems that I had with YouTube: https://homehack.nl/activitypub-the-secret-weapon-of-the-fediverse/

Categories
3D modeling 3d printing open source

My videos remastered on PeerTube

I wrote earlier about my move from YouTube versus PeerTube. My new videos will appear on both platforms but I’m also remastering my old Solvespace videos. These videos were all 720p which isn’t ideal for a tutorial. Having most of the material of the videos available I’m recreating them in 1080p. When I’m done I’ll only upload these HD videos to PeerTube. The videos take a lot of time to create and I’m currently very busy so the videos appear irregularly but whenever I have time I’ll make them.

The latest video that I remastered is about the Geneva Drive. A wonderful project to design and 3d print. I redid part of the screen recording because either the original was gone or wasn’t good enough. For this video I used the latest version of OpenShot (v2.5.0) but I’m unfortunately still having issues with this video editor. For the next video I’ll return to Shotcut which is currently my favourite free and open source editor. Here is a link to the video if you want to see it on PeerTube.

When I tried to embed a PeerTube video here I found that the WordPress embed block is not suitable for this purpose. Apparently PeerTube is not (yet) whitelisted by WordPress. Also it appears that iframe tags, my other option, are blocked by WordPress because of security reasons. That’s a bummer.

Categories
3D modeling 3d printing

The BQ Hephestos2 (3D printer), nine months later

Introduction

It’s been nine months since I received and assembled my BQ Hephestos 2 printer and I think it’s time to share some of the experiences that I had with it. For those who don’t know the Hephesthos 2 it’s a 3D-printer that is based on the Prusa i3 design with a thick steel frame and almost all metal parts. It’s not cheap but it’s a well designed, high quality 3D-printer with a large printbed. It does have it’s shortcomings but more of that later.

Categories
3D modeling

Switching from FreeCAD to Solvespace?

Introduction

For my current project, a laser engraver, I initially choose FreeCAD as my 3D CAD program. I had some excellent experiences with it so it was the obvious choice for me. However contrary to previous work this project required a lot of CAD assembly. This is where I became frustrated with FreeCAD. Assembly in the current version (0.16) just isn’t well implemented unnecessarily extending my time spent with FreeCAD. The next version of FreeCAD (0.17) will have a separate assembly workbench but I wasn’t willing to wait for it’s final release.

When reading the Hackaday website I came across Solvespace. Given the problem that I have with FreeCAD I was immediately interested. Solvespace is a parametric modeler just like FreeCAD. The interface looks archaic which put me off a little at first but I found it surprisingly easy to work with. The last month I worked with Solvespace v2.1 and I want to share the experience that I had with the program.

The Solvespace GUI looks archaic but is easy to work with.

Working with Solvespace

Solvespace is a lightweight program. It loads fast and runs very smooth on my aging iMac (5 years old). I have encountered an occasional crash with Solvespace however FreeCAD appears to be more prone to crashes on my iMac. I also noticed a small delay in Solvespace while dragging parts around in a complex assembly.

The Solvespace user interface is static throughout the program whether working in a 2D sketch, an extrude or an assembly. The GUI and the keyboard shortcuts don’t change throughout the program. This means for instance that constraints can be applied the same way in 2D and 3D making it easy to work with Solvespace. FreeCAD on the other hand has a dynamic user interface with multiple workbenches each having a different tool bar and functionality. I found that each FreeCAD workbench has it’s own learning curve making it harder to learn than Solvespace. With all these workbenches however FreeCAD offers much more functionality than Solvespace

Solvespace allows the model to be dynamically manipulated as long as it’s not fully constraint, both in 2D and 3D. This can be very helpful while studying a model or looking for its best shape. This is impossible in FreeCAD or OpenSCAD where a model can only be changed by entering other discrete values for the parameters (not to be confused with the animation options in OpenSCAD and FreeCAD).

Assembly in Solvespace is very easy often taking only a few mouse clicks. Two parts must be oriented and constrained to the same direction. A point of each part is selected and the parts are connected at the selected points. That’s it. This method works fast and I haven’t encountered any problem with it. When working in an assembly of multiple files a change made in one of the files propagates to the assembly. This is a very powerful features when working with complex models because it’s creates a consistent environment where it’s sufficient to make a change once instead of keeping track of multiple files. Apparently FreeCAD has a similar feature but getting it to work is far from trivial for me.

The laser engraver that I’m working on. It’s a rather complex project mith multiple parts but assembly is real easy in Solvespace.

Other 3D CAD programs offer functionality like chamfer and fillet. Solvespace doesn’t have this and that’s a shortcoming. Often chamfer and fillet are used for aesthetics and if necessary I can do without that however if you do need them regularly Solvespace isn’t for you. It also impossible to extrude along a path a functionality that is for instance used to create a thread. Creating a true thread is therefore impossible however if it is able to mimic a thread by drawing a sawtooth sketch and revolve it.

I 3d-printed numerous models that I had designed with Solvespace. I exported the models as .stl files and used Cura to create the nessecay G-code before printing them. I encountered no problems with this workflow and all prints came out as expected. I therefore conclude that Solvespace is a good companion for 3d-printers as long as the shortcomings of the program are taken into account.

Support

Community support is very important in open source software.  Whether you’re a beginner, intermediate of experienced user it’s vital to be able to get help. This can be tutorials, forums, irc or mailing list. Solvespace has support although it’s not as abundant as with FreeCAD. This is probably due to the smaller user base of Solvespace. The Solvespace tutorials are good but they are few in number and the documentation is adequate but not as polished as FreeCAD’s.

An active development of the program is also important not only for bug fixing but also with new features in new releases. Solvespace has a small but active developers team which is fine but it also makes the project vulnerable. If the main developer decides to abandon the project the user is left empty handed. FreeCAD appears to be having a much larger group of active developers decreasing the chance that the project will be abandoned.

Solvespace’s forum is a good place to post questions about the program. Replies are quick and to the point.

Conclusion

I really like Solvespace, it’s lightweight, pretty stable and easy to use (especially if the user is familiar with the concept of sketching with geometric constraints). I was able to create my models very quickly. I used the keyboard shortcuts often. They are easy to learn because they are limited in number and are consistent throughout the program. Besides the limitations such as fillet, chamfer and extrude along path, Solvespace lacks a lot of the nice-to-have (or need-to-have for some) features that are available in FreeCAD such as the path-, arch- and drawing workbench. This may not be a problem for many more casual users because Solvespace is focused on geometric constraint solving and assembly.

Solvespace is a good addition to the existing open source 3D CAD programs such as OpenSCAD and FreeCAD. It’s not a FreeCAD replacement because it lacks a lot of the features that come with FreeCAD. However if you want to try a truly free 3D CAD program but are intimidated by FreeCAD because of it’s steep learning curve and OpenSCAD because of programmers-like approach certainly should give Solvespace a try.


I made a series of video tutorials and CAD challenges. You can find them on YouTube PeerTube with the links below: