How can I export Sphere packs to GTS or STL file?

Asked by S. Feng on 2020-02-25

Hi there,

I generated a sphere pack using the following codes.

import gts
from yade import pack'part.gts'))

I want to use this sphere pack as a geometry model for following FEM simulations. However, now I am facing a problem that I don't know how I can export these spheres into a GTS or STL file. Because I am a new-beginner on Yade, could you please help me with it? Thanks.


Question information

English Edit question
Yade Edit question
No assignee Edit question
Last query:
Last reply:
Jan Stránský (honzik) said : #1

have a look at recent discussion on this topic [1]


S. Feng (scfeng) said : #2

Thanks Jan,

The reference you posted seems to address my problem. However, when I tried to run the codes you provided in that discussion, something was wrong as follows,

Traceback (most recent call last):
  File "/usr/bin/yade", line 182, in runScript
  File "", line 95, in <module>
  File "", line 83, in spheres2stl
    triangles = [t.toStlFacet() for t in triangles]
  File "", line 39, in toStlFacet
    normal = minieigen2stl(normal)
  File "", line 36, in <lambda>
    minieigen2stl = lambda v: stl.Vector3d(*tuple(v))
AttributeError: 'module' object has no attribute 'Vector3d'

I searched on the Internet, but I failed to find a answer. Could you please provide any further help? Thanks.



S. Feng (scfeng) said : #3

Hi Jan,

I tried to ran commands :


However, all of these attributes were not found in module 'stl'. I guess the problem is my currently used stl package. I ran the command "pip install numpy-stl" to install the stl module. However, I have no idea how to solve this problem.

Jan Stránský (honzik) said : #4

as mentioned in [1] in a comment, the code was done using this stl package [2]. But I think with the other package it could be similar..


S. Feng (scfeng) said : #5

Hi Jan,

Thanks for your information.

I solved the problem by upgrading pip, and generated stl file successfully using your codes.

However, there is still one problem. The stl geometry used in most FEM softwares should be solid but not surfaces only. Namely, it is similar to mesh the spheres including their interior but not only their surfaces. Is there method to achieve this goal?



Jan Stránský (honzik) said : #6

> The stl geometry used in most FEM softwares should be solid but not surfaces only.

Both GTS ("GNU Triangulated Surface", [3]) and STL ("Standard Triangle Language", [4]) describe only the surface AFAIK.
And because the question explicitly mentioned GTS and STL, the answer too :-)

> Is there method to achieve this goal?

Of course. You have all necessary data (centers and radii of the spheres), you can do whatever you like, e.g.:
- create the bulk mesh "manually" (like "manual" surface triangulation in [1])
- use a dedicated meshing software
- ...

The right approach strongly depends on your needs ("following FEM simulations" nor "most FEM softwares" gives much information).
In any case, the topic now became not so much related to Yade and I am not sure if you can get the answer here.

I suggest to open a new question, explicitly mentioning the "solid mesh" (some people who could answer the "solid mesh" problem might have stopped following this thread expecting the "surface mesh" problem)



Can you help with this problem?

Provide an answer of your own, or ask S. Feng for more information if necessary.

To post a message you must log in.