# add parameters (Grid, Random…) with python

I created a script to generate the mesh (spheres, cubes, ...), but I must add parameters existing in the particles menu as Grid, random, ...

are you help me how to add this in my menu panel

How can add the selected yellow portion in particles menu to my script is to create different distributions.

• Can you be a bit more specific, please? – Samoth Mar 21 '16 at 23:36
• i add my script – saded Mar 22 '16 at 13:22

After you add your sphere with bpy.ops.mesh.primitive_uv_sphere_add() the new sphere will be the active object which you can get through bpy.context.active_object, you can then add a particle modifier to it and adjust the settings which you can access through the particle modifier.

bpy.ops.mesh.primitive_uv_sphere_add(size = size, location = location)
obj = bpy.context.active_object

ps = obj.modifiers.new(name='particles',type='PARTICLE_SYSTEM')
pset = ps.particle_system.settings

pset.emit_from = 'FACE' # VERT FACE VOLUME
pset.use_emit_random = True
pset.use_even_distribution = True
pset.distribution = 'JIT' # JIT RAND GRID


To adjust other properties you can use the tooltips to find the property name to use -

And if you don't know what values can be used for enumerated options like distribution you can find them in blender's API documentation.

• I add this lignes in my script, but nothing has changed, for example, in particles settings, when i choose Volume + Grid, i obtain distribution periodic (or Regular), how to use it? – saded Mar 22 '16 at 15:53
• This question is about adjusting the particle settings using python, if your script now adds a particle system and adjusts the settings then this has been answered. If you want an explanation of what a setting or combination of settings do you should ask another question for that. – sambler Mar 23 '16 at 13:38