Categories
Uncategorized

3D (STL) to 2D (SVG)

Back in 2015 I used Rhino to convert 3D files into 2D vector files that could be used in illustrations, instructions, etc. You can see what I’m talking about in 2D to 3D to 2D. Sadly, Rhino is not cheap, and I do not have access to it. Instead I would often do fake versions of this technique in OpenSCAD, which you can see in Enclosure Prototyping.

Well, thanks to Trammell Hudson, I can throw all that away! Checkout this post plotter.vision – STL to SVG and then go to plotter.vision and give it a spin.

The code is available on GitHub, and my favorite part is in the README:

I’m not a javascript programmer, so this is probably not very well written.

And yet… It exists, and it works. It may not be perfect, but the great thing about open source is that it can be improved by others in the future.

I’ve included a few results in this posts of things I’ve modeled in OpenSCAD. I think they turned out well and I can see using this tool in the future. Thanks, Trammell!

See Also: STL to SVG

Categories
Uncategorized

STL to SVG

Sometimes I need a 2D vector version of something that is a 3D model. Here’s how I do it. First, if there is an STL file, I load that into OpenSCAD.

For this model I wanted a top view so I could use the hole pattern to laser cut a mounting plate.

I select Show Axes because I’m gonna need that later…

The axes will show the center of the canvas, and luckily our model is centered…

Change the view from Perspective to Orthogonal

If you don’t know the difference between perspective view and orthogonal view, do some research I guess. (I probably learned about them in 7th grade drafting class.) Otherwise, switch between the views and it should make sense…

Okay, next I view the object from the front. Looks good!

I then add the translate command so that I can move the object in 3D space, and I lower it down, in this case 10mm, because the center line is where it will be cut.

The line projection(cut=true) then cuts a slice at the zero point in the Z axis… But we’re not done yet.

(Oh, if you choose cut=false you’ll just get the whole object, not a slice at a specific cross section of it.)

Here we can see what it looks like at an angle, which might make a bit more sense…

Let’s switch from orthogonal back to perspective view… Not required, but I’ll do it anyway.

Back to the top view… and now with the projection you can see the slice we took from the 3D model.

The next step is important… we need to Render the file! You can’t export the SVG file until you render your model.

The model will change… in this case you can see the shapes are now green with red outlines.

And now we can Export as SVG. (You could also use DXF if you need to, though that’s a garbage format I tend to avoid.)

Here’s the SVG open in Inkscape. Brilliant! I can now add to it, and my hole pattern is spaced properly for the mount I want to make. Excellent.

See Also: 3D (STL) to 2D (SVG)

Categories
Uncategorized

3D Printing a Sifter

sifter-3d-printed

I needed a sifter to remove some small pebbles from concrete mix, so I designed and 3D printed one. Now, like many things that get 3D printed, you don’t always get it right the first time. After testing the sifter I decided it needed larger holes, so. I started on version 2.

inkscape-drawing

For version 1 I used Inkscape to quickly create a grid of circles (using the clone feature) and then differenced them from a circle. Once I had this done I exported as a DXF file and used that within OpenSCAD to create the bottom of the sifter. I added a ring and Bob’s your uncle. I use this Inkscape/DXF/OpenSCAD/extrude method sometimes, because it seems like the right way to do things, or because it’s pretty fast. But it’s not always the best.

The problem with the Inkscape/DXF/OpenSCAD/extrude method is that you have to go back to Inkscape and redo your DXF file if you want to make changes or tweak the design. This may not be an issue for many designs, but for some, I want the flexibility to easily change things.

openscad-holes

So for the next version I redid the holes portion of the design in OpenSCAD. The great advantage here is that you can very easily tweak things like the size of the holes, and the hole spacing, and automagically see how it looks. (Note: in the image above you’re seeing the positive “solids” of the holes. In the final file I differenced them from another solid object to make them “holes” in the design.)

While the method of doing it all within OpenSCAD has advantages, the one way it suffers is when it comes to render time. I should note that in OpenSCAD you can choose how “smooth” circles are by applying a number between 1 and 200. It basically sets how many “sides” a circle has. You can typically use 100 and circles will look pretty circular, but you can also drop the number down to 6 for hexagons, 8 for octagons, etc. That said, at a setting of 100 rendering the sifter took nearly 15 minutes on my 6 year old MacBook Pro. Changing the circles to hexagons with just 6 sides took about one minute to render.

This is where The Cloud™ should save us, right? But while there are various versions of OpenSCAD running on public servers, no one is running a version that worked properly. And since OpenSCAD is a niche piece of open source software, I don’t know if this will change. But since there is a command line interface to OpenSCAD, maybe I can do complex renders on one of my more powerful computers. (Anyway, I’m getting off-topic, so let’s continue.)

openscad-sifter

Hey, it’s a sifter! Yes, I designed and 3D printed a sifter. I often design things and then print them overnight so I have them the next day. 3D printing is awesome, but it’s often not fast. I did consider trying to make a sifter plate with a drill press, and then I remembered I had a laser cutter, and considered using that, but ultimately I was not in a hurry and 3D printing one seemed like a good idea.

tinkercad

Speaking of good ideas, I’ve been looking at Tinkercad recently, and while I wanted to be convinced it wouldn’t be easy to do what I wanted, it actually was pretty easy to do what I wanted, so I redesigned my sifter using Tinkercad. The smart duplication feature made it fairly simple.

While I’m a bit more impressed with Tinkercad than I thought I would be, I still have the problem I had with Inkscape, that if I want to tweak some values, I need to redo work. In fact, I have to pretty much create a whole new model. For simple designs, this isn’t a huge deal, but it is a bit of a pain.

What’s a bigger pain is the fact that while I will always have copies of Inkscape and OpenSCAD to use, Tinkercad (and the files I create with it) may disappear. Tinkercad is own/run by Autodesk, and while it’s a great tool for beginners to get started with 3D modeling (without having to install any software) ultimately I’m concerned for its long-term existence (like any hosted/cloud service.)

I can easily edit the OpenSCAD files I created seven years ago, which is something that is important to me. That said, I do want to explore other software, because reasons, you know?

Categories
Uncategorized

BlocksCAD

When it comes to 3D modeling for the majority of the 3D printing I do, I tend to turn to OpenSCAD. OpenSCAD is known as “The Programmers Solid 3D CAD Modeller”, and it’s free software available for Linux/UNIX, Windows and Mac OS X. Yeah, you create objects by writing code. It’s weird, but so am I.

If you’re one of those cloud-loving weirdos (who also uses Chrome) you can also opt to use OpenSCAD.net, which is a (blah) “browser-based” version of OpenSCAD. Sort of. It definitely has it’s usefulness (Chromebooks!) but anytime I can download and install an open source application, I’ll opt for that route.

Now, once you get used to OpenSCAD (assuming you want to) you can refer to the cheat sheet or read the entire OpenSCAD manual. But suppose you don’t exactly want to write code, or you aren’t good at it yet… Perhaps BlocksCAD can help.

Functions

BlocksCAD puts a “blocks” interface on top of OpenSCAD. You may have seen this block-thing in use with Scratch. It’s a good way to teach kids how programming works. (There’s an Arduino-ish block application call mBlock that works with the Makeblock robots. And yes, there’s lots more scratch blocks stuff out there.)

Blocks

I took a model I made in OpenSCAD last week and recreated it in BlocksCAD. It took quite a bit longer (probably because I can write code fairly quickly) but the results were good. The blocks really help show the structure of things. For anyone whose had to remember bracket placement, semicolons (and tabs & indents if you care about readable code) the blocks interface hides all of those things. Again, possibly a good thing for beginner coders.

Code

In BlocksCAD you can toggle between the blocks interface and seeing the code. This is great, as you can see the code that gets created by the blocks. Note that you cannot edit the code in the code view. This is (slightly) annoying, but I can understand why this decision was made.

There are things that BlocksCAD doesn’t support, but the basics are there. (I’d love to see comments added.) The basics are enough to get a beginner (child or adult) started with building blocks into a program that generates a 3D model. Sweet!

Share

You can also easily share the models you create. (Okay, that’s probably the one nice feature about a browser/cloud-based thingy.) You might notice from the image above that the holes are weird looking, as in, not very round. What’s going on?

Rod Holder

Here’s the original model that I created in OpenSCAD running on my computer. Note that the round holes are super-round! I get them round by adding the line:

$fn = 100;

to the top of my code. The $fn thing controls the number of facets used to generate an arc. It’s the difference between a round circle and a low-resolution circle consisting of x number of flat sides. (You can also use the $fn to allow you to quickly render models by setting the number low, and then raising the number before you do your final render.)

Rod Holder

Here’s what I got when I copied the code from the “code view” of BlocksCAD and pasted it into OpenSCAD and rendered it. Blah! Low-resolution holes. If I added my $fn = 100; line it rendered what I really wanted.

STL

Okay, so I also downloaded an STL file from BlocksCAD and it looked like this. Hmmm, much better quality than the low-resolution version I got from the code I copied. So what’s up? Well…

When you render objects in BlocksCAD there’s a “smooth” option with Low, Medium, and High settings. So, if you choose the High setting, you get a much better model. The code view doesn’t show whatever the $fn/facet setting is for the model, but it must be adding it when it does the render. Makes sense.

BlocksCAD has a few quirks, but I think it’s a great concept. While I’d love to see a downloadable version, I hope Einsteins Workshop continues to provide the web-based offering for those who want to use it.

Categories
Uncategorized

2D to 3D to 2D

Parts

There comes a time when every designer who designs things in two dimensions that get assembled into something that has three dimensions wants to have a diagram with some… dimensions.

Above is a dimensional illustration of the parts of the mount for the shaft for the machine I am building.

If I were to provide assembly instructions I’d probably want such a drawing. Here are some notes on the process, so I can do it again next time.

Parts in Inkscape

In Inkscape, each piece must be an object. The ‘holes’ cannot be separate objects, but must be cut out (differenced) from the main object. (This is the same method needed when bringing a 2D drawing into OpenSCAD, so nothing new there.)

Sadly, Rhino cannot import SVG files. (Mini-rant: I’m always surprised at the number of applications that do not support SVG. The SVG specification has been an open standard from the WC3 since 1999!) Rhino can import PDF files, so export your Inkscape file as a PDF. Your PDF should be a vector PDF, by default. Inkscape should do the right thing unless you’ve done something silly to your file. (Which is possible, I’ve done it.)

Parts in Rhino

Our vector file is now in Rhino! Double-check to make sure each line/object did not get doubled-up. I’ve had it happen a few times but could not conclusively determine what causes it. It may be the width of the stoke of the objects in Inkscape.

You can now extrude your object(s) in Rhino. I make them the height of the material I am using. Oh, I’ll be laser cutting these pieces with 4.45mm acrylic. YMMV.

Solids in Rhino

Change the view in Rhino from wireframe to solid and you’ll see your new 3D object(s)…

Extruded in Rhino

Make sure the holes are really holes! If not, re-read the part above about objects and holes and such. You need to difference any cut out things!

Make2D in Rhino

Now you can move your new object(s) because the original vector lines we imported in are probably sitting right underneath them. Swing your object(s) into the view you want… get that angle just right, and then choose “Make 2-D Drawing” from the “Dimension” menu.

2D from 3D

You should now have a 2D version of your 3D object. Rhino should also select it by default, so you can use the “Export Selection” menu to save it out as… A DXF file. :( Sadly, Rhino cannot export as an SVG or vector PDF, or even an EPS file. Rhino can export as an Illustrator file (.ai) but Inkscape cannot open those. The AI file it exports starts with “%!PS-Adobe-3.0” which is probably a format from that was popular in the 1990s.

3D/2D in Inkscape

Anyway, we can certainly import that DXF file back into Inkscape and work with it, and make it look like a nice vector drawing. Mostly. Sort of. I mean, if you want to just fill it with a color or change the stroke, it’s not quite that easy. If you just want a line drawing that isn’t too fancy, mission accomplished!

Oh, and not that I want to turn Inkscape in a 3D application, but I could see great value in being able to extrude and change the view angle of a vector drawing… maybe through an extension?

Note: Lots of comments about this post are on Facebook.