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.

listOfCuboids=Table[Cuboid[{x+dx,0,0},{x,f[x],f[x]}],{x,Subdivide[a,b,n]} ]

For the original problem that I'm trying to model, the code is as such.

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]}]

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. enter image description here

  • $\begingroup$ You never defined solids2. You only defined listOfPrisms. Even then, your list is not a well-defined Region; you may have some luck with RegionUnion. As an aside, please note that your AppendTo 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$
    – MarcoB
    Feb 15, 2019 at 23:20
  • $\begingroup$ Does Printout3D[ RegionUnion @@ BoundaryDiscretizeGraphics /@ First[solid2], "cuboids.stl"] work for you? If so I'll make this an answer. $\endgroup$
    – Greg Hurst
    Feb 16, 2019 at 1:29
  • $\begingroup$ That does not work. It says that "The cell Prism[{1, 2, 5, 4}] is degenerate. $\endgroup$ Feb 16, 2019 at 1:34
  • 1
    $\begingroup$ It also says BoundaryDiscretizeGraphics: The graphics primative Prism[{etc.}] is not valid. Among a few other erros. $\endgroup$ Feb 16, 2019 at 1:34
  • 1
    $\begingroup$ We must be running different versions. The first prism is degenerate. Does RegionUnion @@ BoundaryDiscretizeGraphics /@ Rest[First[solid2]] work? $\endgroup$
    – Greg Hurst
    Feb 16, 2019 at 2:39

1 Answer 1


We can manually drop the degenerate case:

solid2 = RegionUnion @@ BoundaryDiscretizeGraphics /@ Rest[listOfPrisms]

Printout3D[solid2, "prisms.stl"]["Status"]
  • $\begingroup$ Thanks again. 3D printing them now. $\endgroup$ Feb 16, 2019 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.