First time here? Check out the FAQ!

Ask Your Question
2

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

asked 9 years ago

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

Preview: (hide)

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 ( 9 years ago )

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

FrédéricC gravatar imageFrédéricC ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 8 years ago

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')
Preview: (hide)
link

Comments

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

kcrisman gravatar imagekcrisman ( 8 years ago )
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 ( 8 years ago )

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: 9 years ago

Seen: 1,792 times

Last updated: Sep 05 '16