I am attempting to model a cross section problem from Calculus II using the general slicing method. Below is the working code to generate the "slices" of the defined problem; however, I would like to export this to an STL file to 3D print it. I have created a working code for another problem that has squares as cross sections. I've attached the working code that will export the STL code as wanted.
n=10
a=-2
b=2
dx=(b-a)/n
f[x_]:=(4-x^2)^0.5
listOfCuboids=Table[Cuboid[{x+dx,0,0},{x,f[x],f[x]}],{x,Subdivide[a,b,n]} ]
solid=Graphics3D[listOfCuboids]
Printout3D[solid,"cuboids.stl"]
For the original problem that I'm trying to model, the code is as such.
n=10
a2=0
b2=4
dy=(b2-a2)/n
g[y_]:=y^(0.5)
listOfPrisms=Table[Prism[{{0,y,g[3*y]}, {-g[y],y,0}, {g[y],y,0}, {0,y+dy,g[3*y]}, {-g[y],y+dy,0}, {g[y],y+dy,0}}],{y,Subdivide[a2,b2,n]}]
solid2=Graphics3D[listOfPrisms]
Printout3D[solid2,"prisms.stl"]
However, this code does not export to an STL file and the report of the output says it could not discretize or export the file. Any help would be appreciated.
Thanks to the previous comments for helping me to improve the code.
Final Update Here is an image of the 3D print! Thanks again all who helped.
solids2
. You only definedlistOfPrisms
. Even then, your list is not a well-definedRegion
; you may have some luck withRegionUnion
. As an aside, please note that yourAppendTo
code is quite inefficient; try instead:listOfPrisms = Table[ Prism[{{0, y, g[3 y]}, {-g[y], y, 0}, {g[y], y, 0}, {0, y + dy, g[3 y]}, {-g[y], y + dy, 0}, {g[y], y + dy, 0}}], {y, Subdivide[0, 4, 10]} ]
, which will achieve the same, but faster. $\endgroup$Printout3D[ RegionUnion @@ BoundaryDiscretizeGraphics /@ First[solid2], "cuboids.stl"]
work for you? If so I'll make this an answer. $\endgroup$RegionUnion @@ BoundaryDiscretizeGraphics /@ Rest[First[solid2]]
work? $\endgroup$