Export the model as stl format

Asked by zhao dejin

Hi,
      I'm a new yade user. I plan to make a model and the export format is STL,but I can't find the effective way to export it. Could anyone give me a clue of what is going on?
Thanks a lot in advance.
   ZDJ

*******code *********
# !/usr/bin/python
# -*- coding: utf-8 -*-

###########################
# IMPORT MODULES
###########################

from yade import export
from yade import pack
from yade import qt

###########################
# DEFINE MATERIALS
###########################

steel=FrictMat(young=2.06e11,poisson=0.29,density=7861,frictionAngle=0.0,label='steel')
O.materials.append(steel)

###########################
# DEFINE PRED & MAKECLOUD
###########################

# create lower plank
plank=O.bodies.append(geom.facetBox(center=(0.0125,0.025,0),extents=(0.0125,0.025,0.00125),wire=False))
sp=pack.SpherePack()
sp.makeCloud((0,0,0.00125),(0.025,0.05,0.008),rMean=0.0006,rRelFuzz=0.5)
sp.toSimulation(color=(0.8,0.8,0.8),material='steel')

# create aabbwalls and delete the -z & +z walls
walls=aabbWalls(oversizeFactor=1.0)
O.bodies.append(walls)
O.bodies.erase(walls[4].id) # delete wall in -z axis
O.bodies.erase(walls[5].id) # delete wall in +z axis

###########################
# ENGINES
###########################
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),
]

O.dt=0.8*PWaveTimeStep()
# O.step()

qt.View()
qt.Controller()

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

> the export format is STL,but I can't find the effective way to export it

Why do you want/need to export your model to STL?
I am not very familiar with STL format, but according to [1] it represents solids as their triangulated surface.
Since your model is full of spheres, the choice of export format does not make sense to me and that you cannot find any effective way is the consequence..

If you insist on STL, you can triangulate surface of each sphere and do the export of these triangulations. A problem, according to further usage of the export, could be overlapping spheres.. Alternatovely you can use some standard export of spheres and do the triangulation/STL conversion as a postprocessing.

cheers
Jan

[1] https://en.wikipedia.org/wiki/STL_(file_format)

Revision history for this message
zhao dejin (515jingege) said :
#2

  HI, Jan
     Thanks for your answers, the reason I insist on STL is that I need import this model to a FEM software to compute ,but that software can import STL file noly. A few hours ago, there are someone told me that maybe I can obtain STL finally by import VTK into paraview first. I will tried it later.

  Thanks again.

  ZDJ

Revision history for this message
Jan Stránský (honzik) said :
#3

Thanks for more info. I think a good approach is to export spheres in a standard way and then convert this file to STL.
Than the question would become "how to triangulate spheres and save it in STL" and independent on Yade.
good luck
Jan

Revision history for this message
Klaus Thoeni (klaus.thoeni) said :
#4

Hi, here my thoughts:

1. export your packing as txt (r,x,y,z)
2. export a sphere with radius r=1 as STL from e.g. Meshlab (you can specify the subdivision level, i.e., how fine you want your mesh)
3. use the in step 2 generated sphere as a template
4. write a script that reads your txt file and generates STL-spheres according to your template, i.e., apply a translation and a scale to your coordinates of the template
5. the same script should then also write the new STL file with all spheres.

HTH
Klaus

Revision history for this message
Anton Gladky (gladky-anton) said :
#5

Hi,

you can use export.gmshGeo [1] to export spheres in geo-file. It can be than
imported into the GMSH, which is a three-dimensional finite element mesh generator [2].

Generated mesh exports in any available format, including STL,

[1] https://github.com/yade/trunk/blob/master/py/export.py#L894
[2] http://gmsh.info/

Cheers,

Anton

Revision history for this message
zhao dejin (515jingege) said :
#6

Hi, Jan/Klaus/Anton
  I'm so sorry to reply your e-mail so late and Thanks for your suggestion, I will try them later.
  Thanks again.

  Zhao dejin

Can you help with this problem?

Provide an answer of your own, or ask zhao dejin for more information if necessary.

To post a message you must log in.