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

2017-02-28 Thread Jan Stránský
Question #497350 on Yade changed:
https://answers.launchpad.net/yade/+question/497350

Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Tina,
I have tried your code and did not face any problem..
please be more specific on "the *.stl only contains some triangles".
The code is sopposed to save surface of the polyhedron as a set of
triangles. Are some triangles missing? Or did you expect some other output?
I don't use stl myself, but according to [1], "In practice, however, all
facets are simple triangles.". Probably it would be possible to save each
face as a polygon, not only triangles..
cheers
Jan

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

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #478785]: Export VTK files to txt files

2017-02-28 Thread Yor1
Question #478785 on Yade changed:
https://answers.launchpad.net/yade/+question/478785

Yor1 posted a new comment:
Hello Jan and Bruno,

Finally i use these lines in the recorder to obtain the text files
peridically :

if (O.iter%1000==302):
  f = open(str(O.iter)+'_data_spheres', 'w')
  for b in O.bodies:
if (type(b.shape)==Sphere):
  f.write('{} {} {} {} {} {} {} {} {} {} {} 
{}\n'.format(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.state.vel[0]*0.1*utils.PWaveTimeStep(),b.state.vel[1]*0.1*utils.PWaveTimeStep(),b.state.vel[2]*0.1*utils.PWaveTimeStep(),b.state.vel[0],b.state.vel[1],b.state.vel[2],s[b.id][0,0],s[b.id][1,1],s[b.id][2,2]))
  print f  

I use this condition "if (O.iter%1000==302)" because my vtk files are
enumerated like this : 40302, 41302, 42302 etc ...

Best regards.
Jabrane

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

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


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

2017-02-28 Thread Tina Asia
Question #497350 on Yade changed:
https://answers.launchpad.net/yade/+question/497350

Status: Answered => Open

Tina Asia is still having a problem:
Hi,

Jan, I have tried your code, but the *.stl only contains some triangles,
My code is as follows (My YADE is the latest vision):

from yade import polyhedra_utils
from yade import export
from yade import plot
from yade import qt

gravel = PolyhedraMat()
gravel.IsSplitable = True
gravel.strength = 7.9e6
gravel.density = 2678#kg/m^3
gravel.young = 5.98e7 #Pa
gravel.poisson =0.3
gravel.frictionAngle = 0.5 #rad

#create a polyhedron
poly=polyhedra_utils.polyhedra(material=gravel,size=(0.05,0.05,0.05),seed=1)
O.bodies.append(poly)
poly.state.pos=(0,0,0.025)

def polyhedra2stl(stl): # stl is string file name, e.g. 'test.stl'
# get triangles
trisCoords = []
for b in O.bodies:
if not isinstance(b.shape,Polyhedra): # skip non-polyhedra bodies
continue
vs = [b.state.pos + b.state.ori*v for v in b.shape.v] # vertices in 
global coords
trisIds = b.shape.GetSurfaceTriangulation() # "triangles" in one array
l = len(trisIds) / 3
trisIds = [trisIds[3*i:3*i+3] for i in range(l)] # triangles as array 
of three indices
for t in trisIds:
trisCoords.append([vs[i] for i in t]) # triangles as coords of its 
vertices
# generate content of stl file, see [1]
lines = ['solid polyhedra']
for v1,v2,v3 in trisCoords:
n = (v2-v1).cross(v3-v1)
lines.append('facet normal {} {} {}'.format(n[0],n[1],n[2]))
lines.append(' outer loop')
for v in (v1,v2,v3):
lines.append(' vertex {} {} {}'.format(v[0],v[1],v[2]))
lines.append(' endloop')
lines.append('endfacet')
lines.append('endsolid polyhedra')
# write to file
with open(stl,'w') as f:
f.writelines(l+'\n' for l in lines)

polyhedra2stl('tina.stl')

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

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #482687]: make doc error

2017-02-28 Thread hjz
Question #482687 on Yade changed:
https://answers.launchpad.net/yade/+question/482687

hjz posted a new comment:
Well, when I saw a new folder-sphinx was generated in the doc/sphinx
folder, I thought simply that I was successful.  There was not a pdf
file generated indeed.  I would try again with the xelatex compiler.

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

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


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

2017-02-28 Thread Tina Asia
Question #497350 on Yade changed:
https://answers.launchpad.net/yade/+question/497350

Status: Answered => Open

Tina Asia is still having a problem:
Hi,

Thanks Jan, I tried some methods to convert *.txt to *.stl, but all
failed, Can you give me a help?

Thanks in advance,

Tina

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

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


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

2017-02-28 Thread Jan Stránský
Question #497350 on Yade changed:
https://answers.launchpad.net/yade/+question/497350

Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Tina,
you can do it "manually" if you know how to write .stl or .gts format. It
is not (yet) implemented inside Yade.
cheers
Jan

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

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp