Does someone know, why this simple script is not working?

import bpy

bpy.context.area.ui_type = 'PROPERTIES'

bpy.context.space_data.context = 'PARTICLES'



bpy.context.area.ui_type = 'TEXT_EDITOR'

It works every SECOND time and then it works always until I quit blender. Next time it works every second time again.

I'm thankful for help :) Try to get it since about a year...


Dont use operators for that. Add the particle system as a modifier instead:

import bpy

particles = bpy.context.object.modifiers.new("Some name", 'PARTICLE_SYSTEM')
# if you need to adjust it:
particles.particle_system.settings.count = 15

In case you wonder how you are supposed to know how to access the different settings - just type particles = bpy.context.object.modifiers.new("Some name", 'PARTICLE_SYSTEM') in the Python console and then you can use autocomplete function(ctrl+space after particles.particle_system.settings.) to find out what is available:

enter image description here

  • $\begingroup$ Thank you for the answer :) My big Problem is not the particle-System. I knew the way with the Modifier already. The Problem are the particle-SETTINGS. I couldn't find a way to ad the particle-settings in another way then with the "ops". $\endgroup$ – Andi Nov 14 '19 at 11:36
  • $\begingroup$ And now, I found out that your way is much better than the idea I had before. Thank you for your help! $\endgroup$ – Andi Dec 19 '19 at 17:37

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.