Cut a spider web into a 3D-printable bowl with Python (manifold3d)

Title: Cut a spider web into a 3D-printable bowl with Python (manifold3d)

标题:使用 Python (manifold3d) 将蜘蛛网切割成可 3D 打印的碗

A spider web is mostly a 2D drawing. A 3D-printable bowl is a 3D shape. The trick in this post is to draw the web as a flat CrossSection, extrude it straight down, and subtract it from a bowl shell. The same trick works for any pattern: leaves, stars, bats. Everything uses manifold3d and plain Python.

蜘蛛网主要是一个二维图形,而可 3D 打印的碗是一个三维形状。本文的技巧在于将蜘蛛网绘制为一个平面的 CrossSection(横截面),将其垂直向下挤出,然后从碗壳中减去它。同样的技巧适用于任何图案:叶子、星星、蝙蝠。所有操作都使用 manifold3d 和纯 Python 完成。

  1. A bowl from two spheres A shallow bowl is a spherical cap. For a cap of rim radius Rb and height H, the sphere radius is Rs = (Rb^2 + H^2) / (2 H).

  2. 由两个球体构成的碗。浅碗是一个球冠。对于边缘半径为 Rb、高度为 H 的球冠,球体半径为 Rs = (Rb^2 + H^2) / (2 H)。

  3. Draw the web in 2D A thread is a thin rectangle rotated to an angle. Spokes run from the centre. Each ring is a polygon with a small inward kink on every segment, so the threads sag like a real web.

  4. 在二维中绘制蜘蛛网。蛛丝是一个旋转到特定角度的细长矩形。辐条从中心向外延伸。每一圈都是一个多边形,每个线段上都有一个小向内的弯曲,这样蛛丝就会像真实的蜘蛛网一样下垂。

  5. Cut it through the bowl The holes are everything inside the rim that is not thread. holes = CS.circle(46, 128) - web bowl = shell - holes.extrude(H + 10).translate([0, 0, -3]) bowl = max(bowl.decompose(), key=lambda m: m.volume()) # drop loose bits

  6. 将其切割穿过碗。孔洞是边缘内所有非蛛丝的部分。holes = CS.circle(46, 128) - web;bowl = shell - holes.extrude(H + 10).translate([0, 0, -3]);bowl = max(bowl.decompose(), key=lambda m: m.volume()) # 去除松散部分。

Because the cut goes straight down, the threads on the steep sides look slightly flattened and thicker. That is fine for a bowl and gives the web depth.

由于切割是垂直向下的,陡峭侧面的蛛丝看起来会稍微扁平且变厚。对于碗来说这没问题,并且赋予了蜘蛛网深度感。

Gotchas Every thread must touch the hub or the rim. A thread that touches nothing becomes a loose piece, and decompose throws it away. Manifold has no .intersect method. Use ^ for intersection, + for union and - for difference. Keep thread width at 2.4 mm or more for a 0.4 mm nozzle (six perimeters is overkill, but anything under 1.6 mm snaps).

注意事项:每一根蛛丝都必须接触中心或边缘。不接触任何东西的蛛丝会变成松散的碎片,而 decompose 会将其丢弃。Manifold 没有 .intersect 方法。请使用 ^ 表示交集,+ 表示并集,- 表示差集。对于 0.4 毫米的喷嘴,请保持蛛丝宽度在 2.4 毫米或以上(六层壁厚虽然过度,但低于 1.6 毫米的蛛丝容易断裂)。

Swap the web for 26 leaf shapes placed at the golden angle (137.508 degrees, radius 6 + 40 * sqrt((i + 0.5) / n)) and you get a fall leaf bowl from the same code. I have not test printed these yet. The renders look right and the meshes are one manifold solid. The finished spider web bowl and the leaf bowl are on Cults3D.

将蜘蛛网替换为以黄金角(137.508 度,半径 6 + 40 * sqrt((i + 0.5) / n))放置的 26 个叶片形状,你就可以用同样的代码得到一个秋叶碗。我还没有测试打印这些模型。渲染效果看起来很正确,网格也是单一的流形实体。成品蜘蛛网碗和叶子碗已发布在 Cults3D 上。