Re: [Yade-users] [Question #706850]: Clumping can't give color to each layer

2023-06-01 Thread Huan
Question #706850 on Yade changed:
https://answers.launchpad.net/yade/+question/706850

Status: Answered => Solved

Huan confirmed that the question is solved:
Thanks but I solve it via using this:
# set color
for index, layer in enumerate(O.bodies):
if not isinstance(layer.shape, Sphere):
continue
if index % 2 == 0:
layer.shape.color = (1, 1, 1)  # white color
else:
layer.shape.color = (0.5, 0, 0)  # navy-blue color

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #706850]: Clumping can't give color to each layer

2023-05-31 Thread Jan Stránský
Question #706850 on Yade changed:
https://answers.launchpad.net/yade/+question/706850

Status: Open => Answered

Jan Stránský proposed the following answer:
Hello,

> sphere_obj.color = color

sphere_obj.shape.color = color # [1]

Cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Shape.color

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


[Yade-users] [Question #706850]: Clumping can't give color to each layer

2023-05-30 Thread Huan
New question #706850 on Yade:
https://answers.launchpad.net/yade/+question/706850

I try to change color for each sphere layer, but it doesn't seems to work. I 
want to give layer that is divisible by 2 to be brown and layer that isn't 
divisible by two as white.
--The method I tried that 
doesn't work---
# Check if the sphere is within the clump limit
if abs(xi) <= clumpLimit and abs(yi) <= clumpLimit and 
math.sqrt(xi**2 + yi**2) <= diameter/2:
# Move spheres in layers 2, 4, 6, and 8 in x and y axes by 2mm
if layer % 2:
xi += 0.002
yi += 0.002
color = (1, 1, 1) # white
else:
color = (0.647, 0.165, 0.165) #brown
sphere_obj = sphere([xi, yi, zi + z_offset], radius_clump)
# Assign material properties to the sphere
sphere_obj.material = clump_plate
# Assign color
sphere_obj.color = color
bodyList.append(O.bodies.append(sphere_obj))
---
 My Code ###
import random
import math
from yade import geom, pack, utils, plot, ymport, export
import numpy as np

# Define cylinder with funnel parameters
center = (0, 0, 0)
diameter = 0.102
height = 0.18

# create cylindrical body with radius 0.102 m and height 0.064 m
cylinder = geom.facetCylinder(center=center, radius=diameter/2, height=height, 
segmentsNumber=80, wallMask=6)

# add cylinder to simulation
O.bodies.append(cylinder)

# plate properties
clump_plate = CohFrictMat(density = 7500, label = 'clump_plate')

# add properties
O.materials.append(clump_plate)

# clumping parameters
bodyList = []
zi = 0.1
radius_clump = 0.00221
clumpLimit = (diameter/2)  - 0.005
# layer and offset condition
num_layers = 8
z_offset_increment = 0.00128


for layer in range(num_layers):
z_offset = layer * z_offset_increment # Adjust the z-coordinate based on 
the layer

for xi in range(-50, 51, 4):
xi = xi / 1000
for yi in range(-50, 51, 4):
yi = yi / 1000

# Check if the sphere is within the clump limit
if abs(xi) <= clumpLimit and abs(yi) <= clumpLimit and 
math.sqrt(xi**2 + yi**2) <= diameter/2:
# Move spheres in layers 2, 4, 6, and 8 in x and y axes by 2mm
if layer % 2:
xi += 0.002
yi += 0.002
sphere_obj = sphere([xi, yi, zi + z_offset], radius_clump)
# Assign material properties to the sphere
sphere_obj.material = clump_plate
bodyList.append(O.bodies.append(sphere_obj))

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp