yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #24532
Re: [Question #694288]: Crop a specific range of the imported packing and distribute it to a specific position
Question #694288 on Yade changed:
https://answers.launchpad.net/yade/+question/694288
Status: Open => Answered
Jan Stránský proposed the following answer:
> Here's the MWE
IOError: [Errno 2] No such file or directory:
'mypacking.spheresisoCompression'
> for i in range(0,len(packing)):
do you need "i"? If not, it is more understandable and clean to iterate bodies directly
###
for b in packing:
if b.state.pos[1] > height and b.state.pos[1] < 2*height:
b.state.pos[0] = b.state.pos[0] + 5*thickness
...
###
> ### distribute it to desired position <-- not sure how to do this part
MWE (following OP):
###
# (0,0,0)-(5,5,5) packing
spheres = [sphere((x,y,z),.5) for x in range(6) for y in range(6) for z in range(6)]
# fitler (1,1,1)-(4,4,4)
def sphereWanted(b):
x,y,z = b.state.pos
return x >= 1 and x <= 4 and y >= 1 and y <= 4 and z >= 1 and z <= 4
spheres = [b for b in spheres if sphereWanted(b)]
# shift
for b in spheres:
b.state.pos += (9,9,9)
O.bodies.append(spheres)
###
cheers
Jan
--
You received this question notification because your team yade-users is
an answer contact for Yade.