6
$\begingroup$

I have been searching for the answer pretty much everywhere. The forum holds some similar questions, but I cannot derive a solution though. The problem is the following.

When I create one sphere and then use Graphics3D, I can export it in STL format without any problems. When I create a sequence of spheres from a tool path that is loaded, I can correctly visualize it with Graphics3D, but when I try to convert it into STL format, I receive the error

Export::nodta: Graphics3D contains no data that can be exported to the STL format.

as already reported in other questions. What is wrong with my idea?

My code is the following:

path = Import["C:\\Program Files\\MATLAB\\R2012a\\bin\\pos.mat"]
{{{1., 1., 2.}, {2., 1., 2.}, {3., 1., 2.}, {4., 1., 
   2.}, {5., 1., 2.}, {6., 1., 2.}, {7., 1., 2.}, {8., 1., 2.}, {9., 
   1., 2.}, {10., 1., 2.}, {11., 1., 2.}, {12., 1., 2.}, {13., 1., 
   2.}, {14., 1., 2.}, {15., 1., 2.}, {16., 1., 2.}, {17., 1., 
   2.}, {18., 1., 2.}, {19., 1., 2.}, {20., 1., 2.}, {21., 1., 
   2.}, {22., 1., 2.}, {23., 1., 2.}, {24., 1., 2.}, {25., 1., 
   2.}, {26., 1., 2.}, {27., 1., 2.}, {28., 1., 2.}, {29., 1., 
   2.}, {30., 1., 2.}, {30., 1., 2.}, {30., 2., 2.}, {30., 3., 
   2.}, {30., 4., 2.}, {30., 5., 2.}, {30., 6., 2.}, {30., 7., 
   2.}, {30., 8., 2.}, {30., 9., 2.}, {30., 10., 2.}, {30., 11., 
   2.}, {30., 12., 2.}, {30., 13., 2.}, {30., 14., 2.}, {30., 15., 
   2.}, {30., 16., 2.}, {30., 17., 2.}, {30., 18., 2.}, {30., 19., 
   2.}, {30., 20., 2.}, {30., 21., 2.}, {30., 22., 2.}, {30., 23., 
   2.}, {30., 24., 2.}, {30., 25., 2.}, {30., 26., 2.}, {30., 27., 
   2.}, {30., 28., 2.}, {30., 29., 2.}, {30., 30., 2.}, {30., 30., 
   2.}, {29., 30., 2.}, {28., 30., 2.}, {27., 30., 2.}, {26., 30., 
   2.}, {25., 30., 2.}, {24., 30., 2.}, {23., 30., 2.}, {22., 30., 
   2.}, {21., 30., 2.}, {20., 30., 2.}, {19., 30., 2.}, {18., 30., 
   2.}, {17., 30., 2.}, {16., 30., 2.}, {15., 30., 2.}, {14., 30., 
   2.}, {13., 30., 2.}, {12., 30., 2.}, {11., 30., 2.}, {10., 30., 
   2.}, {9., 30., 2.}, {8., 30., 2.}, {7., 30., 2.}, {6., 30., 
   2.}, {5., 30., 2.}, {4., 30., 2.}, {3., 30., 2.}, {2., 30., 
   2.}, {1., 30., 2.}, {1., 30., 2.}, {1., 29., 2.}, {1., 28., 
   2.}, {1., 27., 2.}, {1., 26., 2.}, {1., 25., 2.}, {1., 24., 
   2.}, {1., 23., 2.}, {1., 22., 2.}, {1., 21., 2.}, {1., 20., 
   2.}, {1., 19., 2.}, {1., 18., 2.}, {1., 17., 2.}, {1., 16., 
   2.}, {1., 15., 2.}, {1., 14., 2.}, {1., 13., 2.}, {1., 12., 
   2.}, {1., 11., 2.}, {1., 10., 2.}, {1., 9., 2.}, {1., 8., 2.}, {1.,
    7., 2.}, {1., 6., 2.}, {1., 5., 2.}, {1., 4., 2.}, {1., 3., 
   2.}, {1., 2., 2.}, {1., 1., 2.}}}
a = Ball[path, 3];
b = Graphics3D[a]

volume = Export["contorno.stl", b]

Export::nodta: Graphics3D contains no data that can be exported to the STL format.
$Failed

Do you have some useful suggestions? I would be very grateful since this problem is an obstacle to my thesis work.

$\endgroup$
  • $\begingroup$ Please include the version of Mathematica you are using. I get a different error when I execute your code in 11.1.0 $\endgroup$ – bobthechemist Jun 25 '17 at 23:58
  • 1
    $\begingroup$ Are you trying to use the export file for 3D printing? $\endgroup$ – Jose Enrique Calderon Jun 26 '17 at 1:06
5
$\begingroup$

Exporting in STL appears to require BoundaryDiscretizeGraphics, which is not implemented for the composition of Graphics3D elements you are trying to produce. A workaround is to discretize each ball individually prior to combining them into one object and then exporting. This works for me:

o = BoundaryDiscretizeGraphics[Ball[#, 3], MaxCellMeasure -> 0.5] & /@ 
   path[[1]] // Show
Export["test.stl", o]

enter image description here

Adjust MaxCellMeasure to something useful for you, being mindful that the rendering time becomes quite significant.

Does it 3D print?

I don't know, because I haven't actually printed it. However, the object loads without error into my slicing program and it appears to generate a printable object.enter image description here

$\endgroup$
  • $\begingroup$ Has anyone verified if this is acceptable for 3d printing? I'm afraid this has just put the discrete surface sets in sequence and so may not work (Of course the OP never did answer what he wants it for ) $\endgroup$ – george2079 Jun 26 '17 at 19:50
  • 1
    $\begingroup$ @george2079 see my edit - I think the answer is yes. $\endgroup$ – bobthechemist Jun 27 '17 at 0:32
0
$\begingroup$

this "almost" works but unfortunately has put some strange artifacts at the inside corner. I'll leave it, maybe playing with mesh refinement options can fix that.

Graphics3D[
 MeshPrimitives[
  BoundaryDiscretizeRegion[RegionUnion[Ball[#, 3] & /@ path[[1]]]], 2]]
Export["test.stl", %];
Import["test.stl"]

enter image description here

$\endgroup$
0
$\begingroup$

Thanks for the replies. I solved the problem throught two actions mainly: - i used sphere instead of ball - instead of giving "path" as location to the graphics3d, i gave directly the output of the path, that is the list of all positions. Now no more errors, i can export it in STL successfully. I need to have STL object of this geometry and other more complex geometries later on, to use a collision detection library. I won't Print them, it was just one of the easiest way to get a feasible format.

$\endgroup$
  • $\begingroup$ If you would like to post your own answer (which is encouraged at this site), then please provide the details, for example some code. Otherwise, it is best to make this statement a comment. $\endgroup$ – bobthechemist Jun 27 '17 at 1:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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