2
$\begingroup$

I am trying to make a particle system through the blender script, but I am unable to do so. I do not know much about scripting in blender. This is what I have and could you tell me how I could create a system?

obj = context.active_object
if len(obj.particle_systems) == 0:
        obj.modifiers.new("part", type='PARTICLE_SYSTEM')
        bpy.ops.object.modifier_apply(modifier = "part")
$\endgroup$
1
$\begingroup$

It seems modifier_apply() only works for those modifiers that have an Apply button, but when you add a Particle System as a modifier the only button on the modifier is Convert, which calls bpy.ops.object.duplicates_make_real() , that's probably what you want instead of Apply.

Something like this:

import bpy

obj = bpy.context.active_object

if len(obj.particle_systems) == 0:
    obj.modifiers.new("part", type='PARTICLE_SYSTEM')
    part = obj.particle_systems[0]

    settings = part.settings
    settings.emit_from = 'VERT'
    settings.physics_type = 'NO'
    settings.particle_size = 0.1
    settings.render_type = 'OBJECT'
    settings.dupli_object = bpy.data.objects['Cube']
    settings.show_unborn = True
    settings.use_dead = True

    bpy.ops.object.duplicates_make_real()
$\endgroup$
  • $\begingroup$ Where can I find the different values for the settings? $\endgroup$ – user2888499 Dec 10 '15 at 22:34
  • 1
    $\begingroup$ hover over them with the mouse in the UI $\endgroup$ – zeffii Dec 10 '15 at 22: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.