Skip to content

Instantly share code, notes, and snippets.

@uwezi
Last active January 10, 2026 12:56
Show Gist options
  • Select an option

  • Save uwezi/b5ed221dd29b04020c73e3bedbe1ce94 to your computer and use it in GitHub Desktop.

Select an option

Save uwezi/b5ed221dd29b04020c73e3bedbe1ce94 to your computer and use it in GitHub Desktop.
[Import .stl mesh] Import an .stl file as a mesh into Manim. #manim #3D #stl #mesh
$fn=60;
difference()
{
sphere(r=1.5);
cylinder(h=4,r=1,center=true);
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import openstl
class importstl(ThreeDScene):
def construct(self):
self.set_camera_orientation(phi=30*DEGREES, theta=45*DEGREES, gamma=120*DEGREES)
stlobj = openstl.read(r"bilder\20251214_spherehole.stl")
obj = VGroup(
*[
Polygon(
*[vertex for vertex in poly[1:]],
fill_color=BLUE,
fill_opacity=0.3,
stroke_width=1,
)
for poly in stlobj
]
).center().scale_to_fit_width(5)
self.add(obj)
self.begin_ambient_camera_rotation(rate=0.5)
self.wait(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment