← Back to team overview

yade-users team mailing list archive

Re: [Question #657893]: Creating an animation of interactions using VTKExporter and Paraview

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hello,

1) the idea of VTKExporter is that one instance remembers how many times
it did the export, saves the data using that info and paraview then
recognize it as a sequence

PyRunner(command='intexp()',iterPeriod=100),
…
vtk = export.VTKExporter(someBase) # e.g. someBase could be "output"
def intexp ():
   vtk.exportInteractions(what=[('forceN','i.phys.normalForce.norm()')]) # using this one 'vtk' instance, not creating each time the new one

2)
you can define a function to produce a valid empty vtk file:
##
def vtkEmptyFile():
   fName = vtk.baseName+'-intrs-%04d'%(vtk.intrsSnapCount)+'.vtk'
   with open(fName,'w') as f:
      f.writelines(l+"\n" for l in (
         "# vtk DataFile Version 3.0",
         "empty file",
         "ASCII",
         "",
         "DATASET POLYDATA",
         "POINTS 0 double",
         "LINES 0 0",
      ))
   vtk.intrsSnapCount += 1
...
def intexp ():
   if len([i for i in O.interactions]) == 0:
      vtkEmptyFile()
   else:
      vtk.exportInteractions(...)
##

cheers
Jan

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