How to go from STL to SVG

Hi,

I’m not sure how useful this will be, but I was hoping to do some engraving of some 3D models. So, I made a little script that takes sliced gcode (specifically from Cura) and converts that into SVG for Easel.

Note: this isn’t intended to produce an accurate model. It is intended to help people produce SVG files for engraving.

the script is here:
Script:
Forward to gCodeToSVG

Website:
http://cuttingedgedata.com

I hope this is helpful for someone

Steve

7 Likes

Thank you so much!! I ran into the problem of loading STLs into Easel last summer, and went down the same rabbit hole that you did, but hit my stopping block of being able to convert the gcode into an SVG, as I did not have an intimate knowledge of gcodes, nor do I have much technical know-how in coding that file conversion. This is precisely what I needed, and I can’t thank you enough for making it!

Very Creative. Thank you for sharing this interesting tool.

im at the part where you save the gcode as an svg and it wont save one only html

Hi Chris,

You should be able to right click somewhere and “save as” svg. I’ll check it out tomorrow.

Phil,

While I agree that there are better tools for the job, saying that “any svg will never be a 3d model” is not quite accurate. Yeah, it was likely never intended to convey 3d info and is well suited to convey 2d info. However, Easel uses gray scale to produce depth. And SVGs can contain many shades of gray.

Again, I can think of better tools for the job and vcarve is a good one.

Cheers,

Steve

Hi Chris,

When you right click press “save page as”, the default name of the page shows as “gCodeToSVGMaker.php.html”. Simply change the name to the name of your project with an SVG at the end, like this “example.svg”.

Hi Phil,

I am agreeing with you that the combination of Easel and SVG is not the best way to get 3D results and I am sure we can both think of many examples where “many flat areas stacked” won’t achieve the desired result. However, lets think about how a 3D printer works. It prints many flat areas stacked. And the result is truly 3D. I think what you are saying is that, within the parlance of CNC routing, SVG can not be used to create 3D contours, because Easel does not support simultaneous movement of x, y AND z. I absolutely agree with you. However, one can still “push the limit” of what is possible by leveraging all 256 shades of gray to create topographical 2.5D reliefs that create 3D results with up to 256 discrete depths. Is it the best tool for the job? Nope. You are correct that vcarve is better. It is absolutely better for the professional or the person who is able to spend $349 and I even recommend it. On the other hand, some (and certainly not all) 3D surfaces lend themselves to being carved in relief.

Here is a 3D printed face:
18 AM

Here is the SVG of the model in gray scale after being sliced in CURA:
Pic of SVG

And here is Easel’s 3D preview of that:

It sure appears to be a 3D thing to me. But, did we get there via a 3D operation or successive 2.5D operations?

To me, I think it’s fun to push the limit of things to get results that people might not think are possible with certain tools or software. Anyway, all I was trying to do was create a free way for people to go from model to stepped SVG to get 3 dimensional reliefs. A few people are using it and that’s cool. For the people who are using Easel as their primary tool for gcode generation, this adds (pardon the pun) another dimension. Is it the best way to get 3D results, well, I admit that there are better. And like I’ve said, I agree with you that vcarve is good.

Cheers,

Steve

2 Likes

What was the cut time on that?

Hi Phil, Hi Chris,

Yeah, I think it is crazy long, as in many, many hours (depending on size) But, it’s better than hand carving, at least for me.

If one were to compare features and abilities between Easel and Vcarve, it would be easy to arrive at the reasonable conclusion that vcarve is pretty much the victor in every category. Except that Easel is free and browser based.

I like encouraging people to do more with less and try to go beyond the limits that is seemingly imposed by their limit to funds or technology. I’ve been a substitute teacher and occasionally I’ve subbed in “Project Make” classrooms. Most of the digital tools that students are exposed to or have access to are those that are free. Also, many of the computers that students have access to are things like chromebooks. So, vcarve is out for them.

This is an Easel site and I am committed helping people get the most out of Easel. For a free tool, Easel isn’t bad. We know it doesn’t do nearly as much as vcarve. Vcarve isn’t free (yet it is priced pretty well) but it is pretty awesome.

Cheers,

Steve

1 Like

I haven’t used it much, but have you guys tried Kiri:Moto?
Free, browser based, STL to cam. Has some additional cool features as well. There’s a thread on here somewhere started by the creator.

1 Like

I have now tried several different gcodes for different STL’s… none of them work. The code generator doesn’t seem to work correctly and EASEL can’t read it. I keep getting errors (basically HTML looking code that Easel doesn’t recognize). I’ve tried a handful of times and given up.
***To clarify, I’m using gcodes generated by Cura, as you mentioned in the video…

Hi Galen, I am sorry that you are having problems with this. I just tried to do this conversion and it all worked.

Step 1. Download a solid .STL from Thingiverse (or create your own.)

Step 2. Open .STL in CURA 15.04.4 . It MIGHT work in other versions of CURA but my script is looking for specific gcode wording.

Step 3. Save the gcode.

Step 4. From gCodeToSVG.html , select your gcode and upload, then set your parameters, then click on "process gcode. You should now see a page that starts with “<?xml version”

At this point, you can either:
Select all, copy, paste into a notepad, save as “MySVG.svg”

or

Do a File, save page as “MySVG.svg”

At this point you should now have a file called “MySVG.svg”

Make sure your computer did not append a .txt or somesuch. Make sure that the file is a dot svg.

Now test the SVG:
Open a file explorer or finder and locate the folder or directory where your “MySVG.svg” lives. You should now be able to open it in one of several ways:
Right click on it and select “open in browser” (or more specifically “open in firefox” or “open in chrome”
You can also try to right click and choose “open in Inkscape” or “open in Illustrator”
On my computer, if I have it set to view files as icons, I can see if the svg is ok without even opening, because the icon or tile is a small version of the image.

So, at this point you should have an SVG file. It should look like a grayscale image. If so, open in Easel.

Like I said, I tested the pipeline today, it works and Easel opened the resultant SVG.

If it doesn’t work for you, please let me know. I will TRY to be responsive. Some of my workdays are long, there is also a lot of dadding and family time. And I am frequently in places of poor connectivity. But let me know this works for you.

Sincerely

~Steve

Steve

I think it must be my version of Cura… I’ve got 14.07 I think. I had updated a few weeks back but that version didn’t work properly (in general) so I uninstalled it…

After trying this I’ve been attempting to set up Fusion to work with Xcarve but I’m not versed enough in the program. Le sigh…

I wish it were easier to have more than one version of cura installed simultaneously. I’ve got both a delta and cartesian printer. I tend to use CURA 15.04.4 for both, but I’d use a newer version for the delta, if I could have both. I actually do have a newer version of cura on a separate computer.

Anyway, when I cobble this together, I didn’t realize it would be so finicky that it would only work with one version of cura.

I do hope you find something that works.

All the best

Steve

I was able to flatten 3D models in OpenSCAD using the project (projection?) command and export them to cut using MakerCAM.

Tinkercad can export an SVG.

Neil,

You are right that Tinkercad can export SVG. Unless there is some functionality that I am unaware of, Tinkercad seems to do a great job of exporting an SVG that represents the perimeter of a solid model at the ground plane.

For example, if I open a model in Tinkercad like this:

And then export as SVG, I get this:
04 AM

That would be fine for cutting out a shape. If the goal is to cheaply (free) get a grayscale SVG to cut out a topography, I am not sure if Tinkercad can do that. So, I use CURA to slice the model into layers (because that’s what slicers do) and then the script just converts the layers (which are in the gcode that CURA makes) into shades of gray, like this:


And with that, Easel can use the shades of gray to produce depth, like this:
25 AM

There are likely better and easier ways to do this. As some have pointed out, there are CAM packages that include the functionality of importing STL and other 3D model files and producing 2.5D and or 3D tool paths for CNC use.

However, I was looking for a free and easy way to go from STL to SVG specifically for Easel, for myself and other Easel users.

Cheers,

Steve

1 Like

Perfect example of why I should at least skim the thread before posting. I even had a reply in this same thread back when I actually read it.
Anyway, @SteveMichel you’re exactly right. Tinkercad will not help with a 3d contour. I think blender and meshlab (or meshmixer, I get them confused) can produce heightmaps.

I got 15.04.4 so I could try again… and I got farther (no errors in code this time), but it still won’t open. Here is what Easel has to say:

"We can’t import this SVG
Your SVG contains objects that are not supported by Easel.

The file does not contain any objects.

Check out the SVG Import Guide for more help, or try the following tips:

Remove Images
Only vector paths are importable. Some vector programs like inkscape can embed images into an SVG. Make sure to remove any raster/image type object within your SVG.
Remove Gradients and Clip Paths
Only solid stroke and fill colors are meaningful for Easel. Advanced visual effects like clipping paths and gradients will not be imported correctly.
Export using SVG “Tiny”
Vector editors usually allow you to choose a type of SVG to export. To get the best results use “SVG Tiny” or “SVG Basic”. Do not use “SVG 2.0"”

(several hours later) I’m using a PC, so I don’t know if there’s an issue there… I have done things over a million times now… including rebuilding the STL and bringing it into BLENDER to reduce the poly count significantly, made sure the depth of the file wasn’t too extreme (since it’s mostly just a relief carve)… Uploaded that to the script-writer and still got the same error…

Hi Galen,

Please forgive the delay in getting back to you. Improvement is good, but not getting there is frustrating. I really am sorry. Ok, let’s figure this out.

I am going to ask some questions.

#1 - Does the SVG that you do create open? As in, forget Easel for a moment, can you open it in Firefox or any browser? Please take a screen shot and show me. If you would prefer not to share, that’s fine, just please confirm for me that you get a grayscale image similar to the one I have posted

#2 - Please reopen your STL in CURA. Don’t even worry about re-making the gcode. The question is this - How many layers are you trying to make? I don’t think I was explicit enough. I am pretty sure that more than 256 layers won’t work - My code is not in front of me, but, there are only 256 shades of gray. It is possible that my code barfs junk at additional layers.

#3 - Have you tried it with something simple? As in make a pyramid and save the STL. Open pyramid in CURA and adjust scale or layer height until there are 100 layers. Save gcode. Use script to convert gcode. Verify that SVG is an actual SVG by opening in browser. If it opens in browser, then try to open in Easel. If that works, then we can add complexity until we understand the problem.

Eventually I will understand why it isn’t working for you and this will help others. Since you are on a PC, that could be part of the issue, but it should be solvable. My script is running on a server, so it shouldn’t matter. But, CURA could be slightly different.

Let me know the answers to the above and I’ll keep thinking about it. I’m working hard on another project now and got plenty going on, but will try to help

Steve

1 Like