# Revision history [back]

### Why does JMOL fail here?

Sorry, but I can't think of a good title for the question. I put together code for the Menger's Sponge (3d).

H = J = K = Graphics()
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if not((i==1 and j==1)or(i==1 and k==1)or(j==1 and k==1)):
H += cube().scale(1).translate(1/2+i, 1/2+j, 1/2+k)
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if not((i==1 and j==1)or(i==1 and k==1)or(j==1 and k==1)):
J += H.translate(3/2+3*i, 3/2+3*j, 3/2+3*k)
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if not((i==1 and j==1)or(i==1 and k==1)or(j==1 and k==1)):
K += J.translate(4.5+9*i, 4.5+9*j, 4.5+9*k)
#K.show()
K.save('Menger3.gif')


The code runs and creates the image of the 3rd iteration of Menger's sponge. But if I comment out: K.save('Menger3.gif') and uncomment K.show() then the code won't run. I get lots of errors like:

__main__:19: UserWarning: Duplicate name: 'obj_660992.pmesh'


after which I'm told

Traceback (click to the left of this block for traceback)
...
RuntimeError: Jmol failed to create file
'/tmp/tmpMSjmcm/.jmol_images/sage0-size500.jmol.png',


and I'm told to look at a temporary text file (which turns out to be empty).

So the questions are "Why does JMOL fail to create the third iteration of Menger's Sponge when I can view the image of it?", "How do I revise the code so JMOL won't fail?".

By the way, for the second iteration of Menger's Sponge, JMOL works.

### Why does JMOL fail here?

Sorry, but I can't think of a good title for the question. I put together code for the Menger's Sponge (3d).(3d) [EDIT: and ran it in a Sage notebook. I also tried it in a Sage Cell Server.]

H = J = K = Graphics()
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if not((i==1 and j==1)or(i==1 and k==1)or(j==1 and k==1)):
H += cube().scale(1).translate(1/2+i, 1/2+j, 1/2+k)
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if not((i==1 and j==1)or(i==1 and k==1)or(j==1 and k==1)):
J += H.translate(3/2+3*i, 3/2+3*j, 3/2+3*k)
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if not((i==1 and j==1)or(i==1 and k==1)or(j==1 and k==1)):
K += J.translate(4.5+9*i, 4.5+9*j, 4.5+9*k)
#K.show()
K.save('Menger3.gif')


The code runs and creates the image of the 3rd iteration of Menger's sponge. But if I comment out: K.save('Menger3.gif') and uncomment K.show() then the code won't run. I get lots of errors like:

__main__:19: UserWarning: Duplicate name: 'obj_660992.pmesh'


after which I'm told

Traceback (click to the left of this block for traceback)
...
RuntimeError: Jmol failed to create file
'/tmp/tmpMSjmcm/.jmol_images/sage0-size500.jmol.png',


and I'm told to look at a temporary text file (which turns out to be empty).

So the questions are "Why does JMOL fail to create the third iteration of Menger's Sponge when I can view the image of it?", "How do I revise the code so JMOL won't fail?".

By the way, for the second iteration of Menger's Sponge, JMOL works.

 3 retagged FrédéricC 4078 ●3 ●37 ●84

### Why does JMOL fail here?

Sorry, but I can't think of a good title for the question. I put together code for the Menger's Sponge (3d) [EDIT: and ran it in a Sage notebook. I also tried it in a Sage Cell Server.]

H = J = K = Graphics()
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if not((i==1 and j==1)or(i==1 and k==1)or(j==1 and k==1)):
H += cube().scale(1).translate(1/2+i, 1/2+j, 1/2+k)
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if not((i==1 and j==1)or(i==1 and k==1)or(j==1 and k==1)):
J += H.translate(3/2+3*i, 3/2+3*j, 3/2+3*k)
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if not((i==1 and j==1)or(i==1 and k==1)or(j==1 and k==1)):
K += J.translate(4.5+9*i, 4.5+9*j, 4.5+9*k)
#K.show()
K.save('Menger3.gif')


The code runs and creates the image of the 3rd iteration of Menger's sponge. But if I comment out: K.save('Menger3.gif') and uncomment K.show() then the code won't run. I get lots of errors like:

__main__:19: UserWarning: Duplicate name: 'obj_660992.pmesh'


after which I'm told

Traceback (click to the left of this block for traceback)
...
RuntimeError: Jmol failed to create file
'/tmp/tmpMSjmcm/.jmol_images/sage0-size500.jmol.png',


and I'm told to look at a temporary text file (which turns out to be empty).

So the questions are "Why does JMOL fail to create the third iteration of Menger's Sponge when I can view the image of it?", "How do I revise the code so JMOL won't fail?".

By the way, for the second iteration of Menger's Sponge, JMOL works.