Loading

STL to OpenSCAD converter

by Riham, published

STL to OpenSCAD converter by Riham Mar 16, 2013
0 Share
Download All Files

Thing Apps Enabled

Open in Customizer Order This Printed View All Apps

Contents

Use This Project

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

37341Views 4162Downloads

Summary

This is a small web page that will convert your STL files to OpenSCAD files, it supports both ASCII STL and Binary STL files.
The best thing about this is that instead of just embedding your stl files in the OpenSCAD you can actually make them part of it, which means they can be used with Customizer.

Please report all bugs to me, or just feel free to fix the bugs yourself, the JSFiddle is available publicly, you can fork it and make any changes

How to use:

1- Go to https://jsfiddle.net/Riham/yzvGD/
2- click on choose file
3- upload and wait for processing to finish
4- download the new openscad file

**This was tested only on Chrome - several people have left comments saying it doesn't work on other browsers, unfortunately I haven't had a chance to make it work on other browsers, but you can use the standalone version provided by fma at http://www.thingiverse.com/thing:64709

All Apps

Customizer is the easiest way to take great 3D printable designs and make them your own. Make your OpenSCAD designs infinitely more valuable by empowering the community to customize them.

App Info Launch App
Customizer Thing App

3D Print your file with 3D Hubs, the world’s largest online marketplace for 3D printing services.

App Info Launch App

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Print through a distributed network of 3D printing enthusiasts from across the US, at a fraction of the cost of the competitors. We want to change the world for the better through technology, an...

App Info Launch App

Quickly Scale, Mirror or Cut your 3D Models

App Info Launch App

3D Print a wide range of designs with Treatstock. Easy to use tools to get the perfect result. The global 3D printing network that connects you with high-quality and fast working print services nea...

App Info Launch App

I uploaded a simple STL file but nothing is happening. No load percentage bar. I'm using Google Chrome web browser on Windows 10 computer. Do I have to click on "Run" in the top left corner or click on "Download!"? Neither makes a difference. Clicking on "Run" seems to remove my uploaded file.

Update: the "http" link works in the Microsoft Edge web browser and the upload percentage bar appears. Unfortunately, the program only converts the STL file into an extremely large polyhedron (difficult to customize) object OpenSCAD file.

In latest chrome browser it is blocking some things because they are trying to be pulled in from insecure site. Got it to work by going to http://jsfiddle.net/Riham/yzvGD/ instead of https://jsfiddle.net/Riham/yzvGD/ Notice no HTTPS in link.

I clicked on your link but it automatically changed back to https.

Update: the "http" link works in the Microsoft Edge web browser and the upload percentage bar appears. Unfortunately, the program only converts the STL file into an extremely large polyhedron (difficult to customize) object OpenSCAD file.

Doesn't seem to work at all even in chrome I click load file, then run and nothing happens if I lcick download I just get no file.

Me, too. It's quite disappointing.

I'm not sure, I understand what it is capable of. When having created an STL file from the very simple

cube([10, 10, 10]);

and feeding it to the converter, I'm getting

module object1(scale) {polyhedron(
points=[[0,10,10],[10,0,10],[10,10,10],[10,0,10],[0,10,10],[0,0,10],[0,0,0],[10,10,0],[10,0,0],[10,10,0],[0,0,0],[0,10,0],[0,0,0],[10,0,10],[0,0,10],[10,0,10],[0,0,0],[10,0,0],[10,0,10],[10,10,0],[10,10,10],[10,10,0],[10,0,10],[10,0,0],[10,10,0],[0,10,10],[10,10,10],[0,10,10],[10,10,0],[0,10,0],[0,0,0],[0,10,10],[0,10,0],[0,10,10],[0,0,0],[0,0,10] ],
faces=[[0,1,2],[3,4,5],[6,7,8],[9,10,11],[12,13,14],[15,16,17],[18,19,20],[21,22,23],[24,25,26],[27,28,29],[30,31,32],[33,34,35]]);}

object1(1);

as a result. What it the use of that compared to a trivial

import("cube.stl", convexity=3);

?

Jan 8, 2017 - Modified Jan 8, 2017
Riham - in reply to tmssngr

Hi tmssngr, the problem with importing stl to scad using import this way is that you can't make changes to the object, but when you have the polyhedron you can do that, you can even make the object customizable

It would be nice if the tool was smart enough to detect simple shapes like a cube and just used the cube function - maybe some time in the future :)

This is excellent. Thank you!

Great! Amazing!. Very usefull to me.
But, would be possible you provide the boundary coordinates of the object (max and minimum x, y and z). It could help us to make translation and centering on simetrical objects.
Thanks in advance.

Hi araripe, looks like someone already did this work in one of the remixes:
http://www.thingiverse.com/thing:1285084

stl2scad
by joshuaf
Mar 1, 2016 - Modified Mar 1, 2016

You can use http://jsfiddle.net/roha/353r2k8w/embedded/result/ to get a prompt that contain the scad sourcecode.
This work for me at firefox browseras you can see at http://www.thingiverse.com/thing:1383325

stl2scad online - convert stl to scad
by roha

Thanks Roha!

Thank you so much! It worked perfectly to change a heart and hook I made in Blender to make a little Valentine project I did for my kids "Customizer-able". I did change "triangles" to "faces" after the fact. Thanks for sharing this!

Feb 15, 2016 - Modified Feb 15, 2016
Riham - in reply to VickyTGAW

Cool! glad it worked for you Vicky! I finally changed triangles to faces.

Amazing job!
To avoid deprecation warnings in OpenSCAD, you should change line 150 of the JS by replacing "triangles" with "faces".

Thank you! I made the change

Amazing, thanks a lot ...

Thanks, Glad you liked it :)

this is awesomee, thankyou so much! but...I'm having the same problem as wurtle38
It seems that the file created is huge, I copied the script into word and it crashed after it counted page 5000+ Yet the model i'm trying to convert isn't very complicated. Few spheres though. Is there a way to reduce the amount of faces in the scad script?

Hey Alanna, sorry you are having trouble with the tool. Do you have the same problem with the standalone version by fma (http://www.thingiverse.com/thing:64709)?

What the tool does is basically convert each polygon from the stl format to the open scad format, the number of polygons and dimensions should remain the same, it is not smart enough to optimize unfortunately, but I am wondering if it is just a few spheres if it would be easier for you to just use OpenScad Sphere function directly (details here http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids) ?

How big is the stl file?

Have been looking for this for a long time, Thanks!!

I don't know if I'm doing something wrong. it did download a file as "FromSTL" but causes openscad to crash when I try to open it, so I tried open with notepad and that crashed as well, I used Chrome on windows 7

hmm.. that error does not happen with other openscad files.... what could be wrong?

Does it fail to open the converted file? What happens if you just open openscad and then copy and paste the file content?

it was an error from m$ visual c++ runtime lib :-(

worked fine in chrome... thou openscad now throws a funny runtime error.... will try and reinstall openscad

Tried this on IE10 and like others nothing happens.... hmm... chrome could be a temp fix, but it should relly run with any browser...
only reason i dont have chrome is that i have given up on the browser war.. everybody says to use this and this... i would end up with 10 browsers :-D

Sorry about that, I haven't tested it on IE, but there is also a standalone version (see remixes) that might be easier to use.

I haven't tried this yet, but if it works (more reliably than STL import into Sketchup, which frequently fails) then you have just made sharing models easier! Thanks!! :-)

Thank you so much! Now I can finally add rafts to tricky models.

I was thinking about how cool something like this would be for Customizer today. Looks like you've already made it! Nice work, I'm looking forward to using it in the future.

Glad you liked it:)

can't download once i upload a file. the link looks like blob:http://fiddle.jshell.net/linky_stuff_herehttp://fiddle.jshell.net/linky... Clicking on it does nothing in my browser. Trying to remove the "blob:" before the http gives me a 404.

Which browser are you using? I tested this only using Chrome

Riham - in reply to

Awesome! Thanks!
Do you mind if I add a link to it?

Please, do :o)

The link does not seem to work any longer

Could you please try again now?

Thanks for the STL reader, I already adapted it.

The problem is in ASCII STL reader, following line #89

for (o = 0; 0 < obects.length; 0++) { // 0 instead of o

should be

for (o = 0; o &lt; objects.length; o++) {

Wow, I must have been really low on caffeine, I fixed the bug, thanks

ah, there is more on the ascii reader to debug, the match of 'solid' creates too many matches, match for 'endsolid', and iterate from o = 1 onward.

best also adjust your vpatt, replace '(-?\d+.?\d*)' by simply (\S+), as numbers can be also 1.0383E+01, which you don't fetch.

Not sure I want to go with \S+ as it will accept invalid chars as well, I think I will allow the E only - thanks for the tip

Permit 'e' and 'E', as I saw some format 1.0234e-01 as well.

Looks great, but I can't make it work neither :o( Nothing happen when I select a file...

Riham - in reply to

Sorry about that, I tested it with a few random files - If you send me the file I will debug it for you, my email is riham at http://outlook.comoutlook.com

I don't think it is a problem with stl file; I suspect the browser. I'm using firefox 10.0. I will try to make a standalone version, in python.

Riham - in reply to

That might be it, I used Chrome for testing

Download after convert wasn't working for me. There is a link but nothing downloads.

That probably means the conversion failed, would you like to send me the file to debug or point me to it?

this is awesome, now i can make my gs3 case truly customizeable.

Thanks, let me know how it went when you try it :)

Top