I have an object in my scene named cube. Is it possible to add a particle system to that object with python by using its name?

  • $\begingroup$ I've provided an answer for you with script, screenshots and a .blend file $\endgroup$ – Tak Jan 13 '17 at 2:35

Yes. Objects are in the datablock bpy.data.objects:

obj = bpy.data.objects['Cube']
particles = obj.modifiers.new("myparticles", type="PARTICLE_SYSTEM")

#once you have the modifier, you can adjust its settings
particles.particle_system.settings.particle_size = 1.0
#and other properties
particles.particle_system.vertex_group_density = mygroup

More info: ParticleSystem ParticleSettings

| improve this answer | |
  • $\begingroup$ Also how would I add more settings to this particle system? $\endgroup$ – user32399 Jan 13 '17 at 2:42
  • $\begingroup$ Added more info to answer. $\endgroup$ – cmomoney Jan 13 '17 at 2:52

You can do this using the below script:

import bpy

C= bpy.context
scene = C.scene

objname = 'Cube' ###### Add Name of object you want here ######
ob = bpy.data.objects[objname]
ob.select = True
scene.objects.active = ob


enter image description here

A .blend file can be downloaded from here:

| improve this answer | |

Your Answer

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