In [1]:
"""
A demonstration of mesh-plane cross-sections, commonly referred to
as "slicing" in the context of 3D printing.
"""
Out[1]:
'\nA demonstration of mesh-plane cross-sections, commonly referred to\nas "slicing" in the context of 3D printing.\n'
In [2]:
import trimesh
import numpy as np
from shapely.geometry import LineString
%pylab inline
%config InlineBackend.figure_format = 'svg'
%pylab is deprecated, use %matplotlib inline and import the required libraries.
Populating the interactive namespace from numpy and matplotlib
In [3]:
# load the mesh from filename
# file objects are also supported
mesh = trimesh.load_mesh('../models/featuretype.STL')
In [4]:
# get a single cross section of the mesh
slice = mesh.section(plane_origin=mesh.centroid, 
                     plane_normal=[0,0,1])
In [5]:
# the section will be in the original mesh frame
slice.show()
Out[5]: