How to count the number of spheres and how to change the color of the facet

Asked by Wang Haijiang

hello all

How does the following code count the number of spheres and how to change the color of the facet

##########################
from yade import pack
import gts, os.path, locale

surf=gts.read(open('2222.gts'))
surf1=gts.read(open('1111.gts'))
if surf.is_closed():
 pred=pack.inGtsSurface(surf)
 aabb=pred.aabb()
 dim0=aabb[1][0]-aabb[0][0]; radius=dim0/100. # get some characteristic dimension, use it for radius
 O.bodies.append(pack.regularHexa(pred,radius=radius,gap=radius/4.))
 for b in O.bodies:
  b.shape.color = (0,191/255.,1)
 #surf.translate(0, 0, -(aabb[1][2] - aabb[0][2])) # move surface down so that facets are underneath the falling spheres
O.bodies.append(pack.gtsSurface2Facets(surf1,wire=True))

#####################################
look forward to your reply

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
Best Jan Stránský (honzik) said :
#1

Hello,

> How does the following code count the number of spheres
> how to change the color of the facet

please read [1] (point 5) and next time please open separate question for separate problem

> How does the following code count the number of spheres

the code does not count anything

> how to change the color of the facet

###
for b in O.bodies:
    if isinstance(b.shape,Facet):
        b.shape.color = someColor
        # b.shape.wire = False # maybe?
###

Cheers
Jan

[1] https://www.yade-dem.org/wiki/Howtoask

Revision history for this message
Wang Haijiang (ksr945) said :
#2

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