# Is it possible to have a particle randomly rotate around a single axis?

I'm creating a particle system with particles set to display as a plane with an image on it. I'm trying to get the particles to rotate randomly, as in some rotate clockwise and some rotate counterclockwise, while still being able to face the camera, as they are duplicating a plane. All my attempts to understand the rotation system are in vain, I can get them to rotate to a single direction, but both "Random" sliders aren't constrained to the axis I want. They don't seem to obey the initial orientation I set. Any ideas?

It it possible to modify certain properties of particles with Python.

I only managed to modify particles that are alive as their properties seem to be overwritten as they are born. But if the properties are set after a frame change, i.e. as soon as new particles are born, this method works.

The following script registers a handler that inverts the angular velocity of half of the new particles after every frame change. I'm not familiar with a way to trigger the handler during baking, but caching the animation and using “Current Cache to Bake” works.

import bpy
from math import floor
from random import random

ps = bpy.data.objects['Cube'].particle_systems['ParticleSystem']

def refreshNow(val):
current_frame = bpy.context.scene.frame_current
for p in ps.particles:
if current_frame == floor(p.birth_time) and random() < .5:
p.angular_velocity *= -1
p.prev_angular_velocity *= -1
bpy.context.scene.update()
return val

def my_handler(scene):
refreshNow(0)

def register():
bpy.app.handlers.frame_change_post.append(my_handler)

if __name__ == "__main__":
register()