Ask Your Question
1

Problem with .stl and Graph

asked 2018-03-21 21:48:59 +0100

haaggen gravatar image

updated 2018-03-22 12:15:18 +0100

slelievre gravatar image

Hi everyone!

I have a problem with SageMath, and I need your help :).

I want to save my personal Graph from a list to a .stl file (.stl for 3d object representation, "stereolithography").

My code:

p = [[0,0,0],[1,2,3],[2,3,1],[2,1,0],[1,3,2],[3,2,1]]
points = PointConfiguration(p)
triang = points.triangulate()
triang.save('mygraph.stl')
triang.plot(axes=False)

When I try to save my file it's in the .sobj extension. (I research this extension and it's just an extension SageObject, so it's not useful for me). I want to draw a graph with a list of point and to convert them in a .stl file.

I already tried:

  • save the plot:

    triang.plot().save('mygraph.stl') # Fails as there is no attribute face_list
    
  • save the all[-1]:

    triang.all[-1].save('test.stl') # Fails as PointConfiguration don't have argument all.
    

I don't know what is the problem, so I ask for your help.

Thank you very much.

edit retag flag offensive close merge delete

Comments

Thank you for the edits you made to the question, it is now easier to read.

slelievre gravatar imageslelievre ( 2018-03-22 23:24:42 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-03-22 23:07:12 +0100

slelievre gravatar image

updated 2018-03-22 23:23:29 +0100

To reformulate:

  • you have a number of points in 3D space, given by their three coordinates,
  • you want to save the polyhedron with these points as vertices in STL format.

One way to do that is:

sage: p = [[0,0,0],[1,2,3],[2,3,1],[2,1,0],[1,3,2],[3,2,1]]
sage: P = Polyhedron(p)
sage: G = P.plot(aspect_ratio=1)
sage: G.all[-1].save('polyhedron.stl')

You need a recent enough version of Sage.

Basic export to STL was introduced around July 2015, and improved by allowing export to binary STL (faster for shapes with many faces) around February 2017. See the corresponding tickets:

edit flag offensive delete link more

Comments

Thank you very much, Sir !

That works !

haaggen gravatar imagehaaggen ( 2018-03-23 23:12:56 +0100 )edit

Happy 3D-printing, if that's the next step.

slelievre gravatar imageslelievre ( 2018-03-24 18:19:04 +0100 )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

Stats

Asked: 2018-03-21 21:48:59 +0100

Seen: 466 times

Last updated: Mar 23 '18