particle impot

Asked by Xue lihua on 2019-07-03

Hello, everyone.
I made a sample of the particles before the model was run. After the sample preparation, I want to import the particles through the example provided by script [1]. I ran the following three lines in the program:

#########################################

From Yade import export

VtkExporter = export. VTKExporter ('/tmp/vtkExporter Testing')

VtkExporter. exportSpheres (what = Dict (dist ='b. state. pos. norm ()')

#########################################

However, after the operation, the following errors occurred:

ValueError Traceback (most recent call last)
/usr/bin/yadedaily in <module>()
----> 1 vtkExporter.exportSpheres(what=dict(dist='b.state.pos.norm()'))

/usr/lib/x86_64-linux-gnu/yadedaily/py/yade/export.py in exportSpheres(self, ids, what, comment, numLabel, useRef)
    428 outFile.write("%g\n"%(b.shape.radius))
    429 # write additional data from 'what' param
--> 430 for name,command in what: # for each name...
    431 test = eval(command) # ... eval one example to see what type (float, Vector3, Matrix3) the result is ...
    432 # ... and write appropriate header line and loop over all bodies and write appropriate vtk line(s)

ValueError: too many values to unpack
#########################################
I would appreciate it if you could give me some advice.

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2019-08-11
Last query:
2019-08-11
Last reply:
2019-07-05
Xue lihua (1q12) said : #1

In addition, I would like to know how to operate if we import particles into my next model by using text format file input method. I'm open to all scripts that can be referenced.

Hi,
What is [1] and does it work? If yes, why don't you reproduce it?
Note that space in filename '/tmp/vtkExporter Testing' will be a problem.
Bruno

Xue lihua (1q12) said : #3

Thank you very much, Bruno. The links to the script [1] I mentioned are as follows. Thank you for pointing out the format problems. But I corrected it, and the same mistake still happened.
[1]https://gitlab.com/yade-dev/trunk/blob/master/examples/test/vtk-exporter/vtkExporter.py

Best Jan Stránský (honzik) said : #4

Hello,

'what' as a dict type was introduced recently. If you do not have (almost) newest Yade version, try passing a list instead:
what = [('dist', 'b. state. pos. norm ()')]

cheers
Jan

Xue lihua (1q12) said : #5

Thanks Jan Stránský, that solved my question.