← Back to team overview

yade-users team mailing list archive

Re: [Question #665569]: export the sphere in specific position with VTK format

 

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

    Status: Open => Answered

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

> export the sphere in specific position with VTK format
> I plan to export the txt format

please be consistent in your requirements :-)

> but it's failed

please always be as specific as possible (e.g. it gives this and that error, it does not save what it should...). In this case, I got
variable 'i' referenced before assignment
which is understandable, because in your function exportSelectedSpheres, "i" is used:
>  xCor = O.bodies[i].state.pos[0]
but python don't know what it is..

> I think it's difficult to make it true through this method

this should do what you want (although in the given setting, no sphere satisfy your condition and therefore no vtk file is saved)
###
vtk = export.VTKExporter("zdj")
def exportSelectedSpheres():
   def check(b):
      x,y,z = b.state.pos
      return isinstance(b.shape,Sphere) and 0<=x and x<=0.000150 and 0<=y and y<=0.00050 and -0.00003<=z and z<=0.00007
   ids = [b.id for b in O.bodies if check(b)]
   vtk.exportSpheres(ids=ids)
###

cheers
Jan

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