ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 10 Mar 2015 13:09:16 +0100Transferring 3D plotshttps://ask.sagemath.org/question/26075/transferring-3d-plots/I want to export 3D plots from Sage in some 3D format or other (NOt just a single png frame)
This script produces a jMol file for me. (I am on cloud.sagemath)
> from sage.interfaces.jmoldata import JmolData 3 sage: JData = JmolData() 4
> u,v = var('u v') 5 f_x = u 6 f_y =
> cos(1*v) 7 f_z = sin(3*v) 8
> img=parametric_plot3d([f_x, f_y, f_z],
> (u, 0, 0.6), (v, 0, 6*pi),
> color='blue', mesh=1, frame=False) 9
> img.save('myfile.png') 10
> img.export_jmol('thisjmol') 11 img 12
The file produced is about 20K or so but if I try to open it via JMol standalone viewer I just get black.
Mind you if I try the example jmols I also get black.
My end point is to get the 3D view into a 3D package such as Blender but to start with I need to get my 3D image out of sage.
Any idea of where I am going wrong?
Sun, 08 Mar 2015 18:56:45 +0100https://ask.sagemath.org/question/26075/transferring-3d-plots/Comment by FrédéricC for <p>I want to export 3D plots from Sage in some 3D format or other (NOt just a single png frame) </p>
<p>This script produces a jMol file for me. (I am on cloud.sagemath)</p>
<pre><code>> from sage.interfaces.jmoldata import JmolData 3 sage: JData = JmolData() 4
> u,v = var('u v') 5 f_x = u 6 f_y =
> cos(1*v) 7 f_z = sin(3*v) 8
> img=parametric_plot3d([f_x, f_y, f_z],
> (u, 0, 0.6), (v, 0, 6*pi),
> color='blue', mesh=1, frame=False) 9
> img.save('myfile.png') 10
> img.export_jmol('thisjmol') 11 img 12
</code></pre>
<p>The file produced is about 20K or so but if I try to open it via JMol standalone viewer I just get black.</p>
<p>Mind you if I try the example jmols I also get black.</p>
<p>My end point is to get the 3D view into a 3D package such as Blender but to start with I need to get my 3D image out of sage.</p>
<p>Any idea of where I am going wrong?</p>
https://ask.sagemath.org/question/26075/transferring-3d-plots/?comment=26080#post-id-26080There is a ticket waiting to help export 3D plots : http://trac.sagemath.org/ticket/7744
but it has been waiting since a long time.Sun, 08 Mar 2015 20:12:58 +0100https://ask.sagemath.org/question/26075/transferring-3d-plots/?comment=26080#post-id-26080Answer by tmonteil for <p>I want to export 3D plots from Sage in some 3D format or other (NOt just a single png frame) </p>
<p>This script produces a jMol file for me. (I am on cloud.sagemath)</p>
<pre><code>> from sage.interfaces.jmoldata import JmolData 3 sage: JData = JmolData() 4
> u,v = var('u v') 5 f_x = u 6 f_y =
> cos(1*v) 7 f_z = sin(3*v) 8
> img=parametric_plot3d([f_x, f_y, f_z],
> (u, 0, 0.6), (v, 0, 6*pi),
> color='blue', mesh=1, frame=False) 9
> img.save('myfile.png') 10
> img.export_jmol('thisjmol') 11 img 12
</code></pre>
<p>The file produced is about 20K or so but if I try to open it via JMol standalone viewer I just get black.</p>
<p>Mind you if I try the example jmols I also get black.</p>
<p>My end point is to get the 3D view into a 3D package such as Blender but to start with I need to get my 3D image out of sage.</p>
<p>Any idea of where I am going wrong?</p>
https://ask.sagemath.org/question/26075/transferring-3d-plots/?answer=26082#post-id-26082There used to be a way to save the 3D scene with the `spt.zip` extension but is seems currently broken:
sage: img.save('/path/to/file.spt.zip')
AttributeError: 'OutputSceneJmol' object has no attribute 'jmol'
What you can do, if you do not have many plots, is to view them with jmol and then export them.
**EDIT**
- From the Sage command-line, it is on the top of the window, you can export in `.spt` format from the jmol applet : `FILE > Export > Write State`
- From the Sage notebook, click on the circular arrow (bottom left of the image) to let jmol start, then right click on the image, you will get a menu: with `File > Save` you can export as a `JVXL` isosurface, from `File > Export`, you can export as `VRML` and `X3D` 3D models.
Sun, 08 Mar 2015 23:16:23 +0100https://ask.sagemath.org/question/26075/transferring-3d-plots/?answer=26082#post-id-26082Comment by nerak99 for <p>There used to be a way to save the 3D scene with the <code>spt.zip</code> extension but is seems currently broken:</p>
<pre><code>sage: img.save('/path/to/file.spt.zip')
AttributeError: 'OutputSceneJmol' object has no attribute 'jmol'
</code></pre>
<p>What you can do, if you do not have many plots, is to view them with jmol and then export them.</p>
<p><strong>EDIT</strong></p>
<ul>
<li><p>From the Sage command-line, it is on the top of the window, you can export in <code>.spt</code> format from the jmol applet : <code>FILE > Export > Write State</code></p></li>
<li><p>From the Sage notebook, click on the circular arrow (bottom left of the image) to let jmol start, then right click on the image, you will get a menu: with <code>File > Save</code> you can export as a <code>JVXL</code> isosurface, from <code>File > Export</code>, you can export as <code>VRML</code> and <code>X3D</code> 3D models.</p></li>
</ul>
https://ask.sagemath.org/question/26075/transferring-3d-plots/?comment=26134#post-id-26134I can't see the sage command line that you speak of. I am using cloud.sagemath though. I have managed to get jmol import of three.js objects to work. I think that in the screen rendering, three.js is involved.Tue, 10 Mar 2015 13:09:16 +0100https://ask.sagemath.org/question/26075/transferring-3d-plots/?comment=26134#post-id-26134Comment by tmonteil for <p>There used to be a way to save the 3D scene with the <code>spt.zip</code> extension but is seems currently broken:</p>
<pre><code>sage: img.save('/path/to/file.spt.zip')
AttributeError: 'OutputSceneJmol' object has no attribute 'jmol'
</code></pre>
<p>What you can do, if you do not have many plots, is to view them with jmol and then export them.</p>
<p><strong>EDIT</strong></p>
<ul>
<li><p>From the Sage command-line, it is on the top of the window, you can export in <code>.spt</code> format from the jmol applet : <code>FILE > Export > Write State</code></p></li>
<li><p>From the Sage notebook, click on the circular arrow (bottom left of the image) to let jmol start, then right click on the image, you will get a menu: with <code>File > Save</code> you can export as a <code>JVXL</code> isosurface, from <code>File > Export</code>, you can export as <code>VRML</code> and <code>X3D</code> 3D models.</p></li>
</ul>
https://ask.sagemath.org/question/26075/transferring-3d-plots/?comment=26092#post-id-26092I updated my answer since the answer depends on how jmol was opened.Mon, 09 Mar 2015 15:12:30 +0100https://ask.sagemath.org/question/26075/transferring-3d-plots/?comment=26092#post-id-26092Comment by nerak99 for <p>There used to be a way to save the 3D scene with the <code>spt.zip</code> extension but is seems currently broken:</p>
<pre><code>sage: img.save('/path/to/file.spt.zip')
AttributeError: 'OutputSceneJmol' object has no attribute 'jmol'
</code></pre>
<p>What you can do, if you do not have many plots, is to view them with jmol and then export them.</p>
<p><strong>EDIT</strong></p>
<ul>
<li><p>From the Sage command-line, it is on the top of the window, you can export in <code>.spt</code> format from the jmol applet : <code>FILE > Export > Write State</code></p></li>
<li><p>From the Sage notebook, click on the circular arrow (bottom left of the image) to let jmol start, then right click on the image, you will get a menu: with <code>File > Save</code> you can export as a <code>JVXL</code> isosurface, from <code>File > Export</code>, you can export as <code>VRML</code> and <code>X3D</code> 3D models.</p></li>
</ul>
https://ask.sagemath.org/question/26075/transferring-3d-plots/?comment=26087#post-id-26087How do I access the context menu in the jmol applet?Mon, 09 Mar 2015 13:38:31 +0100https://ask.sagemath.org/question/26075/transferring-3d-plots/?comment=26087#post-id-26087