Ask Your Question
2

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

asked 2016-04-05 17:55:28 +0200

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))
g.show()
g.save('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/sage_server.py", 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 sage.plot.plot3d.base.Graphics3d.save (/projects/sage/sage-6.10/src/build/cythonized/sage/plot/plot3d/base.c:17931)
    outfile.write(self.stl_ascii_string())
  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

Comments

See http://trac.sagemath.org/ticket/7744#... - 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 17:03:43 +0200 )edit

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

FrédéricC gravatar imageFrédéricC ( 2017-01-12 22:01:40 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2016-09-05 21:50:36 +0200

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]
sage: h.save('icosahedron.stl')
edit flag offensive delete link more

Comments

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

kcrisman gravatar imagekcrisman ( 2016-09-06 14:59:42 +0200 )edit
2

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 21:54:56 +0200 )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

Stats

Asked: 2016-04-05 17:55:28 +0200

Seen: 1,712 times

Last updated: Sep 05 '16