6
$\begingroup$

The following code generates a 3D graphic for a crystallographic structure. But when Tube is used to link the atoms, they are left out of the 3D printing previewer. Cylinder does generate the links, but crashes the Kernel when sent to a 3D service. Any ways to make the structure?

3D printing of structure (unit cells)

latposCePd20 = {{1.941555`, 1.49574903880332`, 1.14428425`}, {1.941555`, 9.38828496119668`, 3.4328527499999995`}, {0.`, 6.9377660388033195`, 1.14428425`}, {0.`, 3.9462679611966798`, 3.4328527499999995`}} latposRhPd20 = {{1.941555`, 4.48312467969212`, 1.14428425`}, {1.941555`, 6.400909320307879`, 3.4328527499999995`}, {0.`, 9.92514167969212`, 1.14428425`}, {0.`, 0.95889232030788`, 3.4328527499999995`}} aPd20 = 3.88311` bPd20 = 10.884034` cPd20 = 4.577137` select$radius$center[a_, r1_, r2_] := Module[{b = {1.941555`, 1.49574903880332`, 1.14428425`}}, If[r1 <= EuclideanDistance[a, b] <= r2, a, Nothing]] select$radius$relative[{b_, a_}, r1_, r2_] := Module[{}, If[r1 <= EuclideanDistance[a, b] <= r2, {b, a}, Nothing]] Ce$pos = select$radius$center[#, 0, 7.5] & /@ Flatten[ Table[ {i aPd20, j bPd20, k cPd20} + # & /@ latposCePd20, {i, -2, 2}, {j, -2, 2}, {k, -2, 2}], 3]; Rh$pos = select$radius$center[#, 0, 7.5] & /@ Flatten[ Table[ {i aPd20, j bPd20, k cPd20} + # & /@ latposRhPd20, {i, -2, 2}, {j, -2, 2}, {k, -2, 2}], 3]; tubes = Flatten[ Table[ select$radius$relative[{Ce$pos[[i]], Rh$pos[[j]]}, 0, 3.5], {i, 1, Length[Ce$pos]}, {j, 1, Length[Rh$pos]}], 1]; diagram3D = Graphics3D[ {Blue, Sphere[#, 2.5/3] & /@ Ce$pos, Red, Sphere[#, 1.8/3] & /@ Rh$pos, White, Tube[#, 0.2] & /@ tubes}, ViewPoint -> {20, 0, 0}, Boxed -> False] Printout3D[diagram3D] 

generates a graphic with unlinked spheres!

enter image description here

In the previewer (MacOSX 10.13.2 High Sierra MMA 11.2.0.0) I get this:

enter image description here

It crashes IMaterialise (says there is an error) and Sculpteo gives

enter image description here

$\endgroup$
4
  • $\begingroup$ I added the bug tag. Doesn't help you at the moment but maybe it raises the attention of some other users. $\endgroup$ Commented Dec 26, 2017 at 20:04
  • $\begingroup$ The code seems to work okay in 11.2 on Windows 10, this is the output $\endgroup$ Commented Dec 27, 2017 at 11:47
  • $\begingroup$ couldn't you come up with a smaller example to illustrate the problem? $\endgroup$ Commented Dec 27, 2017 at 17:09
  • $\begingroup$ It works for smaller unit cells select$radius$center[#, 0, 5.5] but not for these numbers select$radius$center[#, 0, 7.5] and higher... $\endgroup$ Commented Dec 28, 2017 at 0:21

1 Answer 1

2
$\begingroup$

Not an answer but an extended comment:

Which version of MMA are you using? I use 11.0.1 for macos and with

a = Printout3D[diagram3D]; Import[Cases[a, _File, \[Infinity]][[1]][[1]]] 

I obtain this:

enter image description here

However, Mathematica opens Xcode as previewer for that stl file and Xcode shows the model in white on white background so that it is hard to see...

$\endgroup$
12
  • $\begingroup$ On my computer, I don't get the tubes even after XCode installation! $\endgroup$ Commented Dec 26, 2017 at 19:48
  • $\begingroup$ So, I would say, this is a bug then. Please, report it to Wolfram Research. There have been several changes for MeshRegion between version 11.0.1 and 11.2, in particular for the function RegionUnion. Not all changes were for the better, though. I tried to use RegionUnion on your Spheres and Cylinders, and to apply DiscretizeRegion and Printout3D afterwards. But the result was shabby. In version 11.2, you can try to discretize the spheres and cylinders first and apply RegionUnion afterwards. (I cannot try that with version 11.0.1). $\endgroup$ Commented Dec 26, 2017 at 20:03
  • $\begingroup$ When I DiscretizeGraphics on only the tubes I get:Tube::opset: Option VertexNormals is not set in Options[Tube]. $\endgroup$ Commented Dec 27, 2017 at 7:51
  • $\begingroup$ Righty, that's why I suggested to use Cylinder. $\endgroup$ Commented Dec 27, 2017 at 7:53
  • $\begingroup$ With Cylinders, I cannot DiscretizeGraphics either it says: The function DiscretizeGraphics is not implemented for "the graphic". With the mouse over the error, I get: "Skeleton is not a Graphics3D primitive or directive". The number of cylinders in the little box appear incomplete. $\endgroup$ Commented Dec 27, 2017 at 10:56

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.