Strategies for creating 3D text
What are some other strategies for creating 3D text in an efficient manner?
Here's one way, using MeshRegion[]
functionality:
RegionProduct[DiscretizeGraphics[Text[Style["Hello", Bold, FontFamily -> "Calibri"]],
_Text, MaxCellMeasure -> 0.1],
MeshRegion[{{0}, {4}}, Line[{1, 2}]]]
RegionProduct[DiscretizeGraphics[Text[Style["I", FontFamily -> "Source Code Pro"]], _Text,
MaxCellMeasure -> 0.1],
MeshRegion[{{0}, {2}}, Line[{1, 2}]]]
With a bit more work, we can take a similar approach to J.M.'s answer to build a water tight model with a base.
text = BoundaryDiscretizeGraphics[Text["Hello"], _Text]
elongate[{a_, b_}] := With[{d = 0.05 (b - a)}, {a - d, b + d}]
full = DiscretizeGraphics[Rectangle @@ Transpose[elongate /@ RegionBounds[text]]]
diff = RegionDifference[full, text]
etext = RegionProduct[RegionBoundary[text], Line[{{0.}, {2.}}]]
final = DiscretizeGraphics @ Show[
etext,
RegionProduct[text, Point[{2.}]],
RegionProduct[diff, Point[{0.}]],
RegionProduct[full, Point[{-1.}]],
RegionProduct[RegionBoundary[full], Line[{{-1.}, {0.}}]]
]
The only defects here are misoriented faces (which can be fixed with RepairMesh
), but this is indeed a water tight model:
FindMeshDefects[final]
I'm posting a second answer because this method is completely different from my first answer.
Another way to make 3D printable text is with ImageMesh
:
hello = Rasterize[Graphics[{Text[Style["Hello", Bold, 60]]}], "Image"];
text = ColorNegate[ImagePad[ImageCrop[hello], 6, White]];
stack = Image3D @ Join[
ConstantArray[text, 20],
ConstantArray[ColorConvert[ConstantImage[1, ImageDimensions[text]], "RGB"], 5]
];
ImageMesh[stack, Method -> "DualMarchingCubes"]