← Back to team overview

yade-users team mailing list archive

Re: [Question #497350]: Export a polyhedron into a *.stl or * .gts file

 

Question #497350 on Yade changed:
https://answers.launchpad.net/yade/+question/497350

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Tina,
thanks for clarification :-) you have several options here, using existing
answers of this question:
(ymport.stl returns list of facets, it cannot be used as a predicate for
randomDensePack. For this case, you have to use pack.inGtsSurface)
###############
import gts
facets = ymport.stl('tina.stl')
surf = gts.Surface()
for f in facets:
  vs = [f.state.pos + f.state.ori*v for v in f.shape.vertices]
  gtsvs = [gts.Vertex(v[0],v[1],v[2]) for v in vs]
  es = [gts.Edge(gtsvs[i],gtsvs[j]) for i,j in ((0,1),(1,2),(2,0))]
  face = gts.Face(es[0],es[1],es[2])
  surf.add(face)
surf.cleanup(1e-6)
assert surf.is_closed()
pred = pack.inGtsSurface(surf)
sphs = pack.randomDensePack(pred,radius=0.001,spheresInCell=500)
O.bodies.append(sphs)
###############

cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.