yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #27722
Re: [Question #701747]: differentiate between two material
Question #701747 on Yade changed:
https://answers.launchpad.net/yade/+question/701747
Status: Open => Answered
Jan Stránský proposed the following answer:
Hello,
"mat is b.mat" is what you are looking for.
Alternatively, if the materials O.materials.appended, you can use material ID:
### MWE
mat1 = FrictMat()
mat2 = FrictMat()
b1 = sphere((0,0,0),1,material=mat1)
b2 = sphere((0,0,0),1,material=mat2)
#
print(mat1 is mat1) # True
print(mat2 is mat2) # True
print(mat1 is mat2) # False
print(b1.mat is mat1) # True
print(b1.mat is mat2) # False
print(b2.mat is mat1) # False
print(b2.mat is mat2) # True
#
print(mat1.id) # -1
print(mat2.id) # -1
print(b1.mat.id) # -1
print(b2.mat.id) # -1
#
O.materials.append(mat1) # to assign id
O.materials.append(mat2) # to assign id
print(mat1.id) # 0
print(mat2.id) # 1
print(b1.mat.id) # 0
print(b2.mat.id) # 1
###
Cheers
Jan
--
You received this question notification because your team yade-users is
an answer contact for Yade.