Help with randomizing object locations

hey everyone i need help with something im not sure if its possible in blender, but is there a way to randomize multiple objects location with each other like for example if i have four or five different objects in different locations and i want a seed value to randomize all objects locations by switching places with each other only swapping places but not changing the initial locations just randomly swapping all the objects together.

Select objects you want to move then go to Object > Transform > Randomize Transform. You have many options in the popup.
Edit: Swapping is not possible as far as I know, you’ll need some script for that.

yes i have tried that option its great but the swapping objects with each other is the most important part im looking for but cant find anything

Select all objects to swap and then use this script (in the scripting tab):

import bpy
import random as rnd

siz = len(bpy.context.selected_objects)
for x in range(99):
    id1 = rnd.randrange(0,siz)
    id2 = rnd.randrange(0,siz)
    if id1 == id2:
    tmp = bpy.context.selected_objects[id1].location.copy()
    bpy.context.selected_objects[id1].location = bpy.context.selected_objects[id2].location
    bpy.context.selected_objects[id2].location = tmp
1 Like

hey i wanted to ask is there a way i can learn scripting for someone who has zero knowledge in coding. i just want to learn enough to create some scripts in blender

well, you have to learn the very basics first
Once you know that, look at examples, learn to read documentation, and practice by starting small.

For example, look at that script. Do you understand what it’s doing? It’s kind of a brute force, simple method, since it just does ~99 random swaps regardless of how many items there are. Then, you can try to improve it by optimizing it (or adding features).

You can google for “blender python tutorial”, I’m sure you will find many examples. Python is rather simple compared to other languages, if you practice a bit you will catch it quickly. Here’s a good Python guide (not related to Blender, but still good for practice):

The only complicated part is knowing how to interact correctly with the Blender’s programming interface (API):