I do have a problem with exporting 3D graphics out of Mathematica into a binary stl file. In the 3d graphic there is a 3d disk, which is not originally contained in the mathematica function pool, but I found a very helpful code here in the forum.

(How to draw a Circle in 3D on a sphere)

disk3D[centre_: {0, 0, 0}, radius_: 1, normal_: {0, 0, 1}, 
angle_: {0, 2 Pi}] := 
Polygon[Map[RotationTransform[{{0, 0, 1}, normal}, centre]][
If[First@Differences@angle >= 2 Pi, #, Append[#, centre]] &[
Map[Append[#, Last@centre] &][
SortBy[#, N[ArcTan @@ (# - Most@centre)] &] &[
MeshCoordinates[DiscretizeRegion[Circle[Most@centre, radius, angle]]]]]]]]

In addition to the disk there is another Graphics3D figure, but when I try to export them as a whole it only exports the disk into the stl file. Here is my code:

B1 = Graphics3D[disk3D[ {0, 0, 0}, 1, {0, 0, 1}, {0, 2 Pi}]]
H1 = Graphics3D[{CapForm[None], 
Tube[{{0, 0, 1}, {0, 0, 2}}, {1, 0.5}]}]
Test = Show[H1, B1]
Export["Test.stl", Test, {"STL", "BinaryFormat" -> False}]

Can someone help me? Thanks!

  • $\begingroup$ Your code produces an errormessage: Tube::opset: Option VertexNormals is not set in Options[Tube]. Thus, you need specify the VertexNormals for your Tube inside the H1. $\endgroup$ – Rom38 Nov 15 '17 at 11:30
  • $\begingroup$ Yes, I know that. But if I leave the disk out of my export, it works. So I guess that this is not the solution for my problem at all. $\endgroup$ – Benedikt Nov 15 '17 at 11:38
  • $\begingroup$ I guess, the VertexNormals has a certain default settings but MMa fails with these defaults in case when you combines two different graphics. The combined graphics has an empty vertex list and, therefore, you have an error-message. $\endgroup$ – Rom38 Nov 16 '17 at 9:06

Your Answer

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

Browse other questions tagged or ask your own question.