Creating a mold can be a good alternative to expensive and time consuming 3d printing. This week, I created a mold of a 3d model of Cambridge city.
I started by writing some code for generating a 3D model that is suitable for Partworks 3D software. To generate the 3D model of Cambridge, I took the help of Mathematica, and some geographical shape files that are freely available from the MA government site.
I began by loading the files into Mathematica and finding the bounding boxes.
SetDirectory[NotebookDirectory[]]
shp = Import["CityBoundary.geojson", "JSON"];
bd = shp[[1, 2, 1, 1, 2, 2, 2, 1]];
minx = Min[bd[[;; , 1]]]
miny = Min[bd[[;; , 2]]]
maxx = Max[bd[[;; , 1]]]
maxy = Max[bd[[;; , 2]]]
bd
locates the boundary information in the hierarchical data strucutre loaded into Mathematica.
Next, I scaled up all the numbers to lie between 0 and 100.
newyscale = (100/(maxx - minx))*(maxy - miny)
Then we add some spice by loading the locations of the street lights and overlay them on the same image.
ld = Import["StreetLights2010Flyover.geojson", "JSON"];
lds = ld[[1, 2, ;; , 1, 2, 2, 2]];
Next we rescale the lat, long values to stay between 0 and 100.
bds = Table[{Rescale[bd[[i, 1]], {minx, maxx}, {0, 100}],
Rescale[bd[[i, 2]], {miny, maxy}, {0, newyscale}]}, {i, 1,
Length[bd]}];
ldss = Table[{Rescale[lds[[i, 1]], {minx, maxx}, {0, 100}],
Rescale[lds[[i, 2]], {miny, maxy}, {0, newyscale}]}, {i, 1,
Length[lds]}];
Then we generate a binary image out of the datasets.
rst = Rasterize[Graphics[Polygon[bds]], ImageSize -> 500]
bim = Binarize[rst]
rst2 = Rasterize[Graphics[Table[{Black, Disk[ldss[[i]], 0.1]}, {i, 1, Length[ldss]}]], ImageSize -> 500]
bim2 = Binarize[rst2]
In the same way I generated the 3D model for my data bracelet, I generate the 3D model using the binary images.
bimd = ImageData[bim];
bimd2 = ImageData[bim2];
gt = Table[If[bimd[[i, j]] == 0, {EdgeForm[Black], Black, Cuboid[{i, j, 0}, {i + 1, j + 1, 50}]}, {}], {i, 1, Length[bimd]}, {j, 1, Length[bimd[[1]]]}];
gt = Select[gt, # != {} &];
gt2 = Table[If[bimd2[[i, j]] == 0, {EdgeForm[Black], Black, Cuboid[{i, j, 0}, {i + 1, j + 1, 55}]}, {}], {i, 1, Length[bimd2]}, {j, 1, Length[bimd2[[1]]]}];
g3d = Show[Graphics3D[gt], Graphics3D[gt2]];
Export["g3d_all_55height.stl", g3d]
Using the Desktop Shopbot, I cut out the wax block given to us. The details (street light position) did not come out precisely, although I was not expecting too much from the 3/8 endmill anyway.
Making the mold from the provided material took overnight.