欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

使用JavaScript和OpenJSCAD创建用于3D打印的精确3D模型

程序员文章站 2022-07-13 08:27:44
...

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

我在Printrbot Simple Metal 3D Printerl的顶部有一个3D打印的线轴支架,如下所示:

使用JavaScript和OpenJSCAD创建用于3D打印的精确3D模型

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.

它的工作原理非常好,非常适合我的RioRand通用PLA细丝阀芯。 但是,今天我去了Fry's Electronics买了一些灯丝,它们只有小的Makerbot线轴。 它们很便宜,所以我买了两个。 当我回到家时,我注意到线轴上的Kong很大。 完全不适合我的线轴支架。

This brings us to..

这把我们带到了..

3D打印的三个规则 (The Three Rules of 3D Printing)

  1. All problems in 3D Printing can be solved by 3D Printing something

    3D打印中的所有问题都可以通过3D打印解决
  2. The only things that 3D Printing people print is stuff to make their 3D printers work better.

    3D打印人员唯一能打印的东西就是使他们的3D打印机更好地工作的东西。
  3. See rules 1 and 2.

    参见规则1和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.

因此,我需要为我的3D打印机安装适配器(我有将近一周的经验,所以请放心),并打开Tinkercad.com进行创建。 有人推荐Tinkercad作为进行快速设计的出色HTML5网站。

使用JavaScript和OpenJSCAD创建用于3D打印的精确3D模型

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.

我迷上了这个应用程序。 我无法找到一种方法来制作两个圆柱体,并将它们简单地居中放置。 您可以将它们微移,但不能将它们相对于自己的中心居中。 我实际上发现论坛帖子可以追溯到2012年,团队成员说:“是的,我们需要该功能”,但无法弄清楚。 这是一个可爱的应用程序,我的孩子们喜欢它,但是我觉得如果您想要绝对的精确度,那么可能不适合。 然后我意识到,也许这个3D模型更多是数学问题,而不是建模问题。

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).

现在,我意识到自己有偏见,并且我是一名程序员,但是通过一小组数字卡尺和出色的OpenJSCAD文档,我能够在仅10分钟的黑客攻击和仅7到12行JavaScript中创建我的适配器(取决于关于如何计算)。

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)...

从这里我下载了STL(对象的3D描述)...

使用JavaScript和OpenJSCAD创建用于3D打印的精确3D模型

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

然后,我通过Microsoft 3D模型修复服务来运行它(一个很好的主意,以确保您的所有设计都是流线型和防水的)。

使用JavaScript和OpenJSCAD创建用于3D打印的精确3D模型

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

然后进入Repetier并切成G代码(有关如何移动打印机的说明),并在OctoPi上使用OctoPrint其打印出来

使用JavaScript和OpenJSCAD创建用于3D打印的精确3D模型

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.

我显然不是3D设计人员或建模人员,而且我显然对CAD工具没有耐心,无法让我键入直接数字。 我知道这应该是31毫米的直径,请不要强迫我用鼠标“盯着它”。 OpenJSCAD的概念和执行给我留下了深刻的印象。 当然,OpenJSCAD是OpenSCAD (“程序员Solid 3D CAD建模器”)JavaScript实现,因此,我还将探索他们的软件和令人惊叹的图库! 如果您要创建规则性更高,机械性更差的东西,那么显然可以使用OpenJSCAD或OpenSCAD。



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!

赞助商:非常感谢Amyuni本周赞助了feed! 用于.NET的Amyuni PDF Converter and Creator使您仅需几行代码即可集成强大的PDF功能。 使用行业公认的技术生成和处理优化的PDF。 立即切换!

关于斯科特 (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.

斯科特·汉塞尔曼(Scott Hanselman)是前教授,前金融首席架构师,现在是演讲者,顾问,父亲,糖尿病患者和Microsoft员工。 他是一位失败的单口相声漫画家,一个玉米种植者和一本书的作者。

使用JavaScript和OpenJSCAD创建用于3D打印的精确3D模型
使用JavaScript和OpenJSCAD创建用于3D打印的精确3D模型
使用JavaScript和OpenJSCAD创建用于3D打印的精确3D模型
About   关于 Newsletter 时事通讯
Hosting By 主持人
使用JavaScript和OpenJSCAD创建用于3D打印的精确3D模型

翻译自: https://www.hanselman.com/blog/creating-exact-3d-models-for-3d-printing-with-javascript-and-openjscad