Change Mask and Color of a ClumpCloud

Asked by Nicola on 2020-11-13

Dear all,

I need to change the mask of a clump cloud to make it invisible respect other elements. I tried two (SOLUTION 1 and 2) ways but didn't work. I don't get errors but changes aren't applied.
Here's the cloud generation and the trials.
I don't know if could help, but this section is inside a function, user called ( def Fill() ).

### CODE
# r1,r2,r3 are only float numbers.

    c1=SpherePack([((0,0,0),.5*r1),((0.5*r1,0,0),.7*r1),((r1,0,0),.5*r1)])
    c2=SpherePack([((0,0,0),.3*r3),((.2*r3,0,0),.3*r3),((0,0,.2*r3),.3*r3),((.2*r3,0,.2*r3),.3*r3)])
    c3=SpherePack([((0,0,0),.5*r2),((.3*r3,0,0),.5*r2),((0,0,.3*r3),.5*r2),])
    c4=SpherePack([((0,0,0),.25*r3)])

    sp=pack.SpherePack()
    sp.makeClumpCloud((.05,.8,.05),(1.95,4.5,.95),[c1,c2,c3,c4],periodic=False)
    sp.toSimulation()
    O.bodies.updateClumpProperties(discretization=20)

## SOLUTION 1

     for b in O.bodies:
            if b.isClump:
                b.mask=2
                b.shape.color=[0,1,0] # just to visualize

## SOLUTION 2

    clumps=[]
    for i in O.bodies:
        if isinstance(i.shape,Clump):
            clumps+=[i.id]

    for i in clumps:
           O.bodies[i].mask=2
           O.bodies[i].shape.color=[0,1,0] # just to visualize

#########
Thanks for the help.

Regards,

Nicola

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2020-11-14
Last query:
2020-11-14
Last reply:
2020-11-13

This question was reopened

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

Hello,

masking / coloring clump itself basically has no effect (as you observed).
Try to apply the changes to its members [1].

cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Clump.members

Nicola (nicolamarigo) said : #2

Thank you Jan for the advice, however I've tried in some ways but I couldn't get the result.
Do you mind explicitly tell me what I need to code?

thanks,
Nicola

Nicola (nicolamarigo) said : #3

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

Jan Stránský (honzik) said : #4

> I've tried in some ways but I couldn't get the result. Do you mind explicitly tell me what I need to code?

please, firstly do not mind explicitly tell us what code you have tried.

for future reference, a MWE:
###
sphs = [s1,s2,s3,s4,s5] = [sphere((x,0,0),.5) for x in range(5)]
clump1id,ids = O.bodies.appendClumped((s1,s2))
clump2id,ids = O.bodies.appendClumped((s3,s4,s5))
clumpIds = (clump1id,clump2id)
colors = ((1,0,0),(0,0,1))
for color,i in zip(colors,clumpIds):
 b = O.bodies[i]
 ids = b.shape.members.keys()
 for j in ids:
  O.bodies[j].sha
###

cheers
Jan