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

enter image description here

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.

  • 2
    $\begingroup$ Can you be a bit more specific, please? $\endgroup$ – Samoth Mar 21 '16 at 23:36
  • $\begingroup$ i add my script $\endgroup$ – 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 -

example tooltip

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.

  • $\begingroup$ 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? $\endgroup$ – saded Mar 22 '16 at 15:53
  • $\begingroup$ 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. $\endgroup$ – sambler Mar 23 '16 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.