how to change sphere color

Asked by Lei Hang on 2020-07-14

Dear all,

I am trying to change the color of spheres which radius is (0.05,0.075) to bule, but I'm failed. Please help me! The code is as following:
#
from yade import pack

O.bodies.append(geom.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))

sp=pack.SpherePack()
sp.makeCloud((0,0,0),(1,1,1),rMean=.05,rRelFuzz=.5)

sp.toSimulation()
#
Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2020-07-14
Last query:
2020-07-14
Last reply:
2020-07-14
Jan Stránský (honzik) said : #1

Hello,

> spheres which radius is (0.05,0.075)

this means "sphere, whose radius is in interval from 0.05 to 0.075"?

cheers
Jan

Lei Hang (h-stone) said : #2

Yes

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

> but I'm failed

next time please also provide info if / what you have tried

solution:
###
for b in O.bodies:
   if not isinstance(b.shape,Sphere): continue # skip facets
   r = b.shape.radius
   if r > 0.05 and r < 0.075:
      b.shape.color = (0,0,1) # set blue color
###

cheers
Jan

Lei Hang (h-stone) said : #4

Ok, Thank you! I will provide the information next time.

Lei Hang (h-stone) said : #5

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