Ask Your Question

Save a 3D in Sage as a '.stl' file

asked 2016-04-05 10:55:28 -0500

Cyrille Tago gravatar image

Hi Everyone,

I am trying to save a simple polyhedron, an icosahedron(center=(0,4,0)) as an STL file. I tried using

g= icosahedron(center=(0,4,0))'icosahedron.stl')

but I get the following error message:

 Error in lines 1-1
Traceback (most recent call last):
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/", line 904, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in <module>
  File "sage/plot/plot3d/base.pyx", line 1530, in (/projects/sage/sage-6.10/src/build/cythonized/sage/plot/plot3d/base.c:17931)
  File "sage/plot/plot3d/base.pyx", line 1591, in sage.plot.plot3d.base.Graphics3d.stl_ascii_string (/projects  /sage/sage-6.10/src/build/cythonized/sage/plot/plot3d/base.c:18510)
    faces = self.face_list()
 AttributeError: 'TransformGroup' object has no attribute 'face_list'

I also taugh of converting the '.wrl' extension to '.stl' but I am still having some problems with that. Can someone please help me to solve this problem? I will also appreciate if another approach to saving the file could be proposed.

Thank you for your help

edit retag flag offensive close merge delete


See - this is only supported for certain kinds of objects. I'm not sure if there is a ticket open for extending this.

kcrisman gravatar imagekcrisman ( 2016-04-06 10:03:43 -0500 )edit

See Trac #22144 for an enhancement of the STL situation.

FrédéricC gravatar imageFrédéricC ( 2017-01-12 15:01:40 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2016-09-05 14:50:36 -0500

FrédéricC gravatar image

Currently STL output is not implemented for groups of objects.

In your case, you can do (just unwrapping the group):

sage: g= icosahedron(center=(0,4,0))
sage: h=[u for u in g.all][0]
edit flag offensive delete link more


Hey, we should add this to the documentation, because people do ask this fairly often.

kcrisman gravatar imagekcrisman ( 2016-09-06 07:59:42 -0500 )edit

Starting from last beta (SageMath 7.6.beta3) you can also do :

sage: g= icosahedron(center=(0,4,0))
sage: g.all[-1].save('icosahedron.stl')
lb gravatar imagelb ( 2017-02-20 14:54:56 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-04-05 10:55:28 -0500

Seen: 702 times

Last updated: Sep 05 '16

Related questions