# Rotate multiple objects randomly at 90 degree intervals

Blender 2.8

I'm creating a wall tile pattern made of large square tiles.

Like this:

Is there a way to rotate multiple objects randomly at 90 degree intervals?

I'm familiar with "Randomize Transform" in the F3 menu, but it rotates at any angle between.

I'm only interested in random 90, 180, or 270 degree rotations.

Cheers.

• I am unsure as to why you want 90, 180, or 270 degree transforms. Those tiles look like they could all be randomly rotated 5 - 10 degrees from the vertical. For example, I got this result: imgur.com/a/5FuQvTQ by just randomizing transforms a tiny bit. – person132 Aug 29 '19 at 23:27
• @person132 That's a good alternative, but I want the back of each tile to be flat against the back wall so you can't see behind them. In my case, the back of each tile is flat and the front of each tile is slanted. Each tile is identical but rotated at an interval of 90 on Y axis only. – gatzkerob Aug 29 '19 at 23:53
• @person132 irl those tiles look like they were being layed at 90degree intervals. This is an interesting project and I am sure there is a simple solution – hatinacat2000 Aug 30 '19 at 0:22
• I just updated by solution. Using my script is viable because it takes almost no time at all to select even a hundred of these one-by-one and just tile the result – hatinacat2000 Aug 30 '19 at 20:06

Well, I gave it a shot, but all I could manage was to rotate entire selection by whatever angle (value) is used. I am not iterating over individual meshes. If somebody can tweak this, I'm sure it would work:

import bpy
import random
from datetime import datetime
import math
import mathutils

for obj in bpy.context.selected_objects:
random.seed(datetime.now())
bpy.ops.transform.rotate(value=randnum, orient_axis='Z', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)


Change 90 to 45 and you will see what I mean. Scripts are accessible in 2.8 from the Scripting tab.

EDIT: Actually , selecting each panel one at a time, hovering the cursor over the script panel, and pressing "ALT"+"P" (which runs the script on the selected tile) takes less than a second. Doing this with each of these hundred panels took less than 100 seconds. The result looks like what you want and the time is reasonable if you want to tile a hundred or fewer panels on a wall:

Note: You will see if you open the .blend file, but each of these tiles is a copy of a scaled down cube with two vertices moved down slightly. This ensures the back of the tiles are flush with the wall. You can move them down further (or the other two up) if you want a more dramatic slope. But you will need to delete the other 99 and generate, then apply the arrays again. That will only take a few seconds though.

Heres what I would do:

Step 1: make the tiles with an array:

Step 2: Separate the tiles.

After applying the modifiers, you can select the whole thing in edit mode and use P > By loose parts to make them all separate objects.

Then, make sure to set each new objects origin to its geometry. You can do this all at once by selecting them all, going into edit mode, and using origin to geometry from the search menu.

Step 3: Randomize

Step 4: Align Back faces

You said you wanted the backs to all be flat.

Select all of them

go into edit mode

Select one back face and use select similar > normal and then increase the threshold to get all the back faces.

Scale them to 0 on the z axis and they will all be flat.

Step 4: Render

Here is what I got quickly, but im sure you can make a much nicer one.

• Excellent workaround - only problem is, the edges of the tiles will have angled gaps between them as a result of the "Randomize" step. I'm looking for a solution that will leave the edges of the tiles perpendicular to the back of the tile. It's looking like I'll need to use Python for this one - a little over my head but I'll see what's out there. – gatzkerob Aug 30 '19 at 3:11
• I ended up just splitting the tiles into four random groups and rotating them at 90, 180, and 270, then joined them into a single object. There's a nice feature to select random groups of objects by percentage. I went with Poliigon's "Cast Iron" texture - may change it later.. Final result: i.imgur.com/U1MD6lA.jpg – gatzkerob Aug 30 '19 at 5:08