yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #11759
[Branch ~yade-pkg/yade/git-trunk] Rev 3555: add attrs parameter to export.textPolyhedra
------------------------------------------------------------
revno: 3555
committer: Jan Stransky <jan.stransky@xxxxxxxxxxx>
timestamp: Wed 2014-12-10 00:14:45 +0100
message:
add attrs parameter to export.textPolyhedra
modified:
py/export.py
--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'py/export.py'
--- py/export.py 2014-11-08 09:56:26 +0000
+++ py/export.py 2014-12-09 23:14:45 +0000
@@ -164,7 +164,7 @@
return countClumps,count
#textPolyhedra===============================================================
-def textPolyhedra(fileName, comment='',mask=-1, explanationComment=True):
+def textPolyhedra(fileName, comment='',mask=-1, explanationComment=True,attrs=[]):
"""Save polyhedra into a text file. Non-polyhedra bodies are silently skipped.
:param string filename: the name of the output file
@@ -199,7 +199,17 @@
count += 1
vertices = [b.state.pos + b.state.ori*v for v in b.shape.v]
surfaces = b.shape.GetSurfaces()
- f.write('%d %d %d\n'%(b.id,len(vertices),len(surfaces)))
+ strAttrs = ''
+ if attrs:
+ for cmd in attrs:
+ v = eval(cmd)
+ if isinstance(v,(int,float)):
+ strAttrs+=' %g'%v
+ elif isinstance(v,Vector3):
+ strAttrs+=' %g %g %g'%tuple(v[i] for i in xrange(3))
+ elif isinstance(v,Matrix3):
+ strAttrs+=' %g'%tuple(v[i] for i in xrange(9))
+ f.write('%d %d %d%s\n'%(b.id,len(vertices),len(surfaces),strAttrs))
f.writelines('%.8e %.8e %.8e\n'%(v[0],v[1],v[2]) for v in vertices)
f.writelines(' '.join(str(i) for i in surface)+'\n' for surface in surfaces)
f.close()