Creating exact 3D Models for 3D Printing with JavaScript and OpenJSCAD
I have this 3D Printed Spool Holder on the top of my Printrbot Simple Metal 3D Printerl that looks like this:
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
- All problems in 3D Printing can be solved by 3D Printing something
- The only things that 3D Printing people print is stuff to make their 3D printers work better.
- 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.
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)...
I then ran it through the Microsoft 3D Model Repair Service (a good idea to make sure all your designs are manifold and watertight).
Then into Repetier and sliced into G-Code (instructions to the printer on how to move) and printed it with OctoPrint on my OctoPi.
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.
About Newsletter
http://www.freecadweb.org/
The CAD exchange format is STEP by the way. STL is just a primitive format.
Daniel - Thanks!
Bryan - I will! I was really good at it 20-25 years ago.
Andrew - Good advice, I'll check it out.
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.
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
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.
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
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.
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.