← Back to team overview

yade-users team mailing list archive

Re: [Question #238406]: List spheres' diameters/radii

 

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

Jan Stránský posted a new comment:
Hi Nguyen,

you have to exclude non-spherical particles from the loop:

a=open('radius.txt','w')
for i in O.bodies:
  if not isinstance(i.shape,Sphere): continue # after this line, only
spheres continue the loop and are written to the file
  a.write('%d %f \n'%(i.id, i.shape.radius))
a.close()

cheers
Jan



2013/10/31 Nguyen N.G. Hien <question238406@xxxxxxxxxxxxxxxxxxxxx>

> New question #238406 on Yade:
> https://answers.launchpad.net/yade/+question/238406
>
> Hello everybody,
>
> I have a sphere pack (6 walls around a sphere pack) and I want to list all
> the spheres's ID + Radius into a file, how can I do it?
>
> Here is what I'm imagining:
>
> import numpy, os, math, pylab
> from yade import utils, pack
>
> a=open('radius.txt','w')
> for i in O.bodies:
>   a.write('%d %f \n'%(i.id, i.shape.radius))
> a.close()
>
> That gave me:
>   AttributeError: 'Box' object has no attribute 'radius'
> and I'm stuck here. Can you give me some advices?
>
> Thanks in advance.
>
> Ref:
>
> https://yade-dem.org/doc/yade.wrapper.html?highlight=radius#yade.wrapper.Sphere.radius
>
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp
>

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.