Scott Hanselman

Creating exact 3D Models for 3D Printing with JavaScript and OpenJSCAD

February 1, '15 Comments [18] Posted in 3D Printing | Musings
Sponsored By

I have this 3D Printed Spool Holder on the top of my Printrbot Simple Metal 3D Printerl that looks like this:

Printrbot Simple Metal

It works great and fits my RioRand generic PLA Filament spool exactly. However, I went down to Fry's Electronics to get some filament today and all they had was small Makerbot spools. They were cheap, so I got two. When I got home I noticed that the hole in the spool is HUGE. It totally won't fit my spool holder.

This brings us to..

The Three Rules of 3D Printing

  1. All problems in 3D Printing can be solved by 3D Printing something
  2. The only things that 3D Printing people print is stuff to make their 3D printers work better.
  3. See rules 1 and 2.

So, I needed an adapter for my 3D Printer (which I have nearly a week of experience with, so fear me) and opened up Tinkercad.com to create it. Someone recommended Tinkercad as a great HTML5 website for doing quick designs.

image

I got lost in this app. I couldn't find a way to make two cylinders and simply center them within each other. You can nudge them around but can't center them against their own centers. I actually found forum posts going back to 2012 with members of the team saying "yes, we need that feature" but couldn't figure it out. It's a lovely app and my kids enjoy it but I feel like if you want absolute precision this may not be the place. Then I realized that perhaps this 3D Model was more of a math problem than a modeling problem.

Now I realize I'm biased, and I am a programmer, but with a small set of digital calipers and the excellent OpenJSCAD documentation I was able to create my adapter in just 10 minutes of hacking and just 7 to 12 lines of JavaScript (depending on how you count).

function main() {
return union(
difference(
cylinder({h: 40, r:26, center:true}),
cylinder({h: 40, r:15.5, center:true})
),
difference(
cylinder({start: [0,0,0], end: [0,0,24], r1: 52.5, r2: 26, fn: 50}).translate([0,0,-44]),
cylinder({start: [0,0,0], end: [0,0,24], r1: 32.5, r2: 15.5, fn: 50}).translate([0,0,-44])
)
).translate([0,0,45]);
}

From here I downloaded my STL (the 3D description of the object)...

OpenJSCAD

I then ran it through the Microsoft 3D Model Repair Service (a good idea to make sure all your designs are manifold and watertight).

Repetier

Then into Repetier and sliced into G-Code (instructions to the printer on how to move) and printed it with OctoPrint on my OctoPi.

image

I'm clearly not a 3D designer or modeler and I apparently don't have the patience for CAD tools that won't let me type in a direct number. I KNOW this should be 31mm in diameter, don't force me to use a mouse to "eyeball it." I was thoroughly impressed with the concept and execution of OpenJSCAD. Of course, OpenJSCAD is a JavaScript implementation of OpenSCAD, the "Programmers Solid 3D CAD Modeler" so I'll be exploring their software and amazing gallery as well! If you're creating anything with regularity that's more mechanical and less organic, OpenJSCAD or OpenSCAD is the way to go, clearly.


Sponsor: Big thanks to Amyuni for sponsoring the feed this week! Amyuni PDF Converter and Creator for .NET enables you to integrate powerful PDF functionality with just a few lines of code. Generate and process optimized PDFs with industry proven technology. Switch Now!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Sunday, 01 February 2015 11:30:38 UTC
You can align the centers of two objects in Tinkercad by selecting both, then using "Adjust" (top toolbar) / "Align" and then selecting the middle "node" for both X & Y axes. It'll move both objects to be middle-aligned. It took me a while to figure it out, but once you see it, it's pretty obvious :).
John
Sunday, 01 February 2015 12:37:43 UTC
A more advanced free CAD application is FreeCAD:
http://www.freecadweb.org/

The CAD exchange format is STEP by the way. STL is just a primitive format.
Sunday, 01 February 2015 20:04:46 UTC
I suggest you dig up a copy of AutoCAD. There's a reason it's dominated for like 30 years now.
Sunday, 01 February 2015 20:15:06 UTC
This is my favorite feature of SketchUp - you can just draw something, then punch in the exact dimensions you want.
Andrew
Sunday, 01 February 2015 22:15:58 UTC
John - Doh!
Daniel - Thanks!
Bryan - I will! I was really good at it 20-25 years ago.
Andrew - Good advice, I'll check it out.
Scott Hanselman
Monday, 02 February 2015 05:31:22 UTC
I use AutoCAD everyday at work, and it's great. There are edge cases where using something else makes sense.

Last year, I had a mobile printed at Shapeways for my niece and her parents. It consisted of four structures that were a union of 600 convex hulls of pairs of spheres. This was a way of building an arbitrary wireframe mesh. AutoCAD refused to do the union, but OpenSCAD soldiered through it.
Pete Smith
Monday, 02 February 2015 08:47:29 UTC
Mr Hanselman,

I once answered a question ot one you blogs about whether to apply Xaml, SVG, and HTML5 and recommended all methods are best. I also provided a link to Off-Screen site at the time or as was suggested Off-Scream developing, which was good, but the idea has evolved over time, and thought you might find my presentation supporting your topic interesting, since you have quite the technology knowledge base, but I'm trying to look at a rather simple method of design as a World start-up standard based through named shapes.

The concept is being considered for 3D Printing as slide deck, where not complete deck needs to published for virtual web design but selected slides connected for publication. The algorithm is incredibly simple and can work with any technology. It is mind boggling somewhat because it might be a little 2 to the N but alas right now it's 360 radian to 255. Radian also have to be normalized to the exact point, if a requirement of 3D Printing.

The method is at the home page address, at Azure, sure wish Azure or BizSpark membership would provide me with carte blanch at Azure for continued experimenting, since I'm an out of pocket developer, but in any case, take a look at the method, if you would. If you would like to reach me for ideas about the concept and how it is evolving or feedback, I'd like to invite you or anyone who wants to take a look and will answer any questions about possible method evolution. The method is open technology, for anyone to learn.
Thank you, for the opportunity to write at your blog, respects for your work.
peterbisson@outlook.com


Monday, 02 February 2015 08:49:26 UTC
Thought home page link would show in blog. If interested in the above, plsase link to: http://inteckness.azurewebsites.net/
Monday, 02 February 2015 10:01:52 UTC
All this is fine and well... But if the reason you bought uncompatible filament was that you were out of filament... Wouldn't the adapter be hard to make? ;)
Christian W
Monday, 02 February 2015 10:15:31 UTC
I am mechanical engineer.

AutoCAD is not good for 3D. A simple to learn but professional CAD software is Dassault Solidworks. When wanting to use Autodesk tools Inventor is the tool for 3D modelling.
Monday, 02 February 2015 18:05:47 UTC
Scott,
Thanks for all of your recent posts on 3D printing. My son and I have the exact same Printrbot model (heated bed on the way) and an unused Raspberry Pi sitting around and you were right, we've REALLY enjoyed Octoprint! We are having one recurring error though that has ruined a few prints. Did you ever experience a SerialException in Octoprint, and if so, how did you solve it?

Unexpected error while reading serial port: SerialException: 'device reports readiness to read but returned no data (device disconnected or multiple access on port?)' @ comm.py:_readline:987
Loren
Tuesday, 03 February 2015 09:55:37 UTC
Or you can find some more 3D models on this search engine http://www.yobi3d.com
Tuesday, 03 February 2015 18:07:55 UTC
I had the same reaction you did when trying to work with other CAD programs. "I'm I programmer, can't I just tell it where to put the piece and how big to make it?" And then I discovered OpenSCAD and have loved it. I've been designing (or replicating) small ship models and it has been working wonderfully. Here's a "family picture" of the models I've made to date. The large one is about 5 3/8 inches tall.

I love how you can design a piece, turn it into a function, then put it in a for() loop and make multiple copies looping over position and/or rotation. That's how I do the engines and some of the other features that are repeated on the models. It doesn't work for more organic type objects but for more mechanical type things, it is great.
Saturday, 07 February 2015 02:30:41 UTC
That knob you made better go to 11 or it is against the law.
MikeS
Thursday, 12 February 2015 17:52:08 UTC
We solved all of our issues with stability with Octoprint (earlier question) by improving the power supply to the pi. Even though the brick I was using claimed to be 1500 milliamps, it couldn't keep up when the pi was being pushed. Heated bed kit required upgrading to ATX power supply which now powers pi, USB hub and printer. Plenty of power == rock-solid printing.
Loren
Sunday, 15 February 2015 07:58:31 UTC
Loren - I saw that issue also and for me it was a bad USB cable. I swapped it out.
Scott Hanselman
Tuesday, 24 February 2015 03:15:56 UTC
I had some Makerbot spools too and didn't like how they sat on this spool holder but then I realized I could hang them on the filament guide arm vertically. I might try making a remix too though, just for the practice. I'm one step behind you all the way :)
Monday, 02 March 2015 20:09:07 UTC
Scott,

Similar to OpenJSCAD, TinkerCad allows you build your own 3-D models using javascript that you can share with the community. You need to create a design, unhide the tool bar on the right, open the "Shape Generators", open "Your Shape Generators" and click on "New Shape Generator"

-Sev
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.