1
$\begingroup$

Hello Blender community!

I'm trying to generate random positions for a set of objects. I've got 3 objects (cone, cylinder, cube) with a variable of 3 colors (blue, red, yellow), which makes 3x3=9 objects to randomly arrange. The idea is to make the NINE DIFERENTS OBJECTS to appear with a RANDOMIZED POSITION. I used an Instance on Points node with a Collection Info that links to a collection containing my nine objects. I added a Random Value to link it to the Instance Index of the Instance on Points node.

Here's the problem: no matter what data I enter, it seems impossible to randomly generate a grid containing all 9 objects at the same time. Even with the Random Value seed, there's always one, two or three objects that repeat (see attached photo).

enter image description here

Does anyone have a solution ? Or is there none? Thanks a million!

$\endgroup$
2
  • 2
    $\begingroup$ Well, Random Value generates random values, but this does not mean that they are not repeated. What may help you here is to shuffle the indices before instantiation. ...like this: blender.stackexchange.com/questions/283165/… $\endgroup$
    – quellenform
    Commented Nov 7, 2023 at 1:46
  • $\begingroup$ Thank you for your answer @quellenform ! You’re right ! I’ve found this thread before posting my question, but as a geometry nodes novice I gave up $\endgroup$
    – Dataratata
    Commented Nov 7, 2023 at 16:48

2 Answers 2

3
$\begingroup$

Previously answered here: Geometry Nodes: How to randomize/shuffle indices in 'Distribute Points on Volume'?

For clarity here is purely Geometry Nodes solution for your case.

enter image description here

Remove half randomly selected points and add them again. This will shuffle the indexes and you can play with the Random Value node Seed parameter to get a variant you like.

$\endgroup$
1
  • $\begingroup$ That's brilliant and it works PERFECTLY ! Thank you so much :) $\endgroup$
    – Dataratata
    Commented Nov 7, 2023 at 20:44
0
$\begingroup$

Well, I finally found a solution but using a script thanks to the following tutorial: https://www.youtube.com/watch?v=q2Q6tKUz-PM

Here's the script:

import bpy
from copy import copy 
from random import shuffle

objSources = bpy.context.selected_objects
objTargetsTransform = [[copy(objSource.location), copy(objSource.rotation_euler)] for objSource in objSources]
shuffle (objTargetsTransform)

for objSource, objTargetTransform in zip(objSources, objTargetsTransform) :
    objSource.location = objTargetTransform [0]
    objSource.rotation_euler = objTargetTransform [1]

It works great! (see attached photo)

enter image description here

Otherwise, I'm sure it can be done using geometry nodes, but I don't have the skills at the moment to find/understand how. If anyone wants to share a solution from my case, that would be great !

$\endgroup$

You must log in to answer this question.

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