# Pure Python script: create a particle system from Python script in 2.9 [duplicate]

My application should run on a headless server, thus I cannot rely on Blender GUI, and I need a stand-alone python script.. I have been looking all over the place for an example of the creation on a particle system in pure Python API, but all the examples either assume the GUI usage or are not up to date with the API. Can someone provide a minimal snippet for the creation of a particle system in Python?

Thanks, Simon

check this out:

To make this work, create a cube and a cylinder. Then select the cube. Then run the script.

import bpy

obj = bpy.context.active_object
obj.modifiers.new("example", type='PARTICLE_SYSTEM')

particles = bpy.data.particles["ParticleSettings"]

particles.count = 5
particles.render_type = 'OBJECT'
particles.instance_object = bpy.data.objects["Cylinder"]
particles.particle_size = 0.15
particles.emit_from = 'FACE'