2
$\begingroup$

I have 3 objects of varying lengths which I want to distribute in random order to a grid or matrix of certain dimensions. If I do the basic matrix distribute then the meshes overlap. Please see the image below for clarification

Method of distribution is not important just that the objects do not overlap(only one dimension varies ) and that there are N of them in a row or a column. Would appreciate your help.

$\endgroup$

1 Answer 1

2
$\begingroup$

you can do it with these 2 nested loops:

enter image description here

result:

enter image description here

How it works:

The inner loop (calculate x positions) calculates the x positions by reassigning the currentX value in the loop by just adding the size of each object.

The outer loop just calls the inner loop for each y line and give it the right y-value.

$\endgroup$
2
  • $\begingroup$ This is exactly what I needed! Thank you very much it works perfectly! $\endgroup$
    – Bokikibo
    Dec 20, 2021 at 23:28
  • $\begingroup$ You are welcome 🤗 $\endgroup$
    – Chris
    Dec 21, 2021 at 4:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .