yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #12674
[Branch ~yade-pkg/yade/git-trunk] Rev 3867: added x_y_z_r_attrs format to ymport.textExt
------------------------------------------------------------
revno: 3867
committer: Jan Stransky <jan.stransky@xxxxxxxxxxx>
timestamp: Wed 2016-05-25 00:46:05 +0200
message:
added x_y_z_r_attrs format to ymport.textExt
modified:
py/ymport.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/ymport.py'
--- py/ymport.py 2016-05-18 23:33:31 +0000
+++ py/ymport.py 2016-05-24 22:46:05 +0000
@@ -8,13 +8,14 @@
from minieigen import *
-def textExt(fileName,format='x_y_z_r',shift=Vector3.Zero,scale=1.0,**kw):
+def textExt(fileName,format='x_y_z_r',shift=Vector3.Zero,scale=1.0,attrs=[],**kw):
"""Load sphere coordinates from file in specific format, returns a list of corresponding bodies; that may be inserted to the simulation with O.bodies.append().
:param str filename: file name
- :param str format: the name of output format. Supported `x_y_z_r`(default), `x_y_z_r_matId`
+ :param str format: the name of output format. Supported `x_y_z_r`(default), `x_y_z_r_matId`, 'x_y_z_r_attrs'
:param [float,float,float] shift: [X,Y,Z] parameter moves the specimen.
:param float scale: factor scales the given data.
+ :param list attrs: attrs read from file if export.textExt(format='x_y_z_r_attrs') were used ('passed by refernece' style)
:param \*\*kw: (unused keyword arguments) is passed to :yref:`yade.utils.sphere`
:returns: list of spheres.
@@ -41,6 +42,12 @@
elif (format=='id_x_y_z_r_matId'):
pos = Vector3(float(data[1]),float(data[2]),float(data[3]))
ret.append(utils.sphere(shift+scale*pos,scale*float(data[4]),material=int(data[5]),**kw))
+
+ elif (format=='x_y_z_r_attrs'):
+ pos = Vector3(float(data[0]),float(data[1]),float(data[2]))
+ s = utils.sphere(shift+scale*pos,scale*float(data[3]),**kw)
+ ret.append(s)
+ attrs.append(data[4:])
else:
raise RuntimeError("Please, specify a correct format output!");