how to change sphere color

Asked by Lei Hang

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:
Last query:
Last reply:
Revision history for this message
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

Revision history for this message
Lei Hang (h-stone) said :
#2

Yes

Revision history for this message
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

Revision history for this message
Lei Hang (h-stone) said :
#4

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

Revision history for this message
Lei Hang (h-stone) said :
#5

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