# Create 3D objects from 2D image and export as a 3D model

I want to create 3D objects from 2D image and export it as a "3ds" file (or "obj").

I tried:

img=Import["https://i.imgur.com/orbbFG4.png"]


With[{mesh = ImageMesh[ColorNegate[img]]}, RegionProduct[mesh, Line[{{0.}, {55}}]]]


Export["RamF.3ds", %]


but there is an error message

I also tried

Export["RamF.obj", %]


it works, but there is a problem when I tried to import it into the Blender or Unity3D.

As far as I can see, the problem is the Prism primitive that is used to construct the 3D form. I'm using your original code

m3 = With[{mesh = ImageMesh[ColorNegate[img]]},
RegionProduct[mesh, Line[{{0.}, {55}}]]
]


Now, we can inspect how the 3D text is built:

With[{mp = MeshPrimitives[m3, 3]},
Manipulate[
Graphics3D[mp[[1 ;; i]], PlotRange -> RegionBounds[m3]],
{i, 2, Length[mp]}
]
]


You see, every little piece is a prism. Basically, Mathematica creates a triangularized version of your text surface and extends it into the z-axis by turning it into a 3D prism.

Converting a Prism into a set of Polygons is, however, really easy. Simply turn the bottom, the top, and all the sides into a polygon.

toPolygons[Prism[{a1_, a2_, a3_, b1_, b2_, b3_}]] := Polygon[
{{a1, a2, a3}, {b1, b2, b3}, {a1, b1, b2, a2},
{a2, b2, b3, a3}, {a3, b3, b1, a1}}]


Using this function, you can export it to a 3D format

Export["~/tmp/f.3ds", Graphics3D[toPolygons /@ MeshPrimitives[m3, 3]]]


import it into blender and it will work: