In version 10.2 (perhaps going back to 10.0, but I cannot verify that), by default STL's are imported as MeshRegion
objects. Assuming that casefn
is a string representing the path to an STL file, you can see all the elements available for import from the file
Import[casefn, "Elements"]
(*{"BinaryFormat", "BoundaryMeshRegion", "Comments",
"CoordinateTransform", "FacetNormals", "Graphics3D",
"GraphicsComplex", "MeshRegion", "PolygonCount", "PolygonData",
"PolygonObjects", "Summary", "VertexData", "VerticalAxis"} )*
If you use the default MeshRegion
, then use TransformedRegion
with the *Transform
family of geometric transform functions to transform the region
case = Import[casefn, "STL"];
center = Mean /@ RegionBounds[case];
centered = TransformedRegion[case, TranslationTransform[-center]]
of course, you would use RotationTransform
for your problem, but shearing, scaling, reflection, and other geometric transforms are also available. Personally, I do not like the default appearance of MeshRegion
objects with edges displayed, so I use a different style
MeshRegion[Import[casefn, "STL"], PlotTheme -> "Polygons"]
Import[filename, "GraphicsComplex"]
, applyRotationTransform[]
/TranslationTransform[]
to the point list in the first argument ofGraphicsComplex[]
, and then exportGraphics3D[GraphicsComplex[newpoints, otherstuff]]
. $\endgroup$