Need to random arrange small object within bounds of a larger object

Need to random arrange small object within bounds of a larger object

ASQUEOBSFJ2
Explorer Explorer
239 Views
1 Reply
Message 1 of 2

Need to random arrange small object within bounds of a larger object

ASQUEOBSFJ2
Explorer
Explorer

Hi! I need to fill the equivalent of a fish tank with beads. What's a good script to do this with? I can't find one that does what I need. I'm working in the 2016 version, thanks!

0 Likes
240 Views
1 Reply
Reply (1)
Message 2 of 2

leeminardi
Mentor
Mentor

The following is a simple script that will randomly fill a box with an object.

Create a box bigger than your "fish bowl" and then delete the ones outside.

leeminardi_0-1677808791308.png

-- fills the volume defined by a box with objects
-- select the object to fill the box first then
-- select a box object
n = 30 -- number of objects to fill box
obj =  selection[1]
b = selection[2]
xdim = b.width
ydim = b.length
zdim = b.height
x1 = b.pos.x - xdim/2.
x2 = b.pos.x + xdim/2.
y1 = b.pos.y - ydim/2.
y2 = b.pos.y + ydim/2.
z1 = b.pos.z 
z2 = b.pos.z + zdim
for i = 1 to n do
(
	o = copy obj  
--	o =  instance obj  -- use this for instances
	o.pos = [(random x1 x2 ),(random y1 y2), (random z1 z2)]
)

 

lee.minardi
0 Likes