Python and particle system I have been using this code to add a new particle system and create a name for it... I need help to choose the particle type "HAIR" and set other parameters.. This script does not work because the [part.001] keeps changing and going up. It will only work once when creating the first name.
I will need one particle system, so I can apply the code on other objects as well. It is a bit confusing.
The MBall is used as a particle to cover the entire surface of an object.

import bpy

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

bpy.data.particles["part"].type = 'HAIR'

bpy.data.particles["part"].count = 15000
bpy.data.particles["part"].use_advanced_hair = True
bpy.data.particles["part"].render_type = 'OBJECT'
bpy.data.particles["part"].instance_object = bpy.data.objects["Mball"]
bpy.data.particles["part"].particle_size = 0.15
bpy.data.particles["part"].emit_from = 'FACE'
bpy.data.particles["part"].distribution = 'RAND'
'
Python console code.

Add a particle system to the context object, Note the reference returned ps if the system names this system "part.001" it will be ps.name

&gt;&gt;&gt; ob = C.object
&gt;&gt;&gt; ps = ob.modifiers.new("part", 'PARTICLE_SYSTEM')
&gt;&gt;&gt; ps.name
'part'


another

&gt;&gt;&gt; ps = ob.modifiers.new("part", 'PARTICLE_SYSTEM')
&gt;&gt;&gt; ps.name
'part.001'


The newly created particle system in the objects particle system collection

&gt;&gt;&gt; psys = ob.particle_systems[ps.name]


psys.settings is a pointer to the particle settings stored in bpy.data.particles referred to by this particle system.  Notice it has the name "part.001" but we haven't used the name to find it at all, only a reference and pointer

&gt;&gt;&gt; psys.settings
bpy.data.particles['part.001']


Use this pointer to set some properties (as in question code)

&gt;&gt;&gt; psys.settings.count = 10000
&gt;&gt;&gt; psys.settings.type = 'HAIR'


Can use this to set to a predefined set of settings, in this example a previously defined group of settings named "Wooble"

&gt;&gt;&gt; psys.settings = D.particles['Wooble']
&gt;&gt;&gt;