# Change an object's property's based on its name with python

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?

• I've provided an answer for you with script, screenshots and a .blend file – 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


• Also how would I add more settings to this particle system? – user32399 Jan 13 '17 at 2:42

You can do this using the below script:

import bpy

C= bpy.context
scene = C.scene

bpy.ops.object.select_all(action='DESELECT')
objname = 'Cube' ###### Add Name of object you want here ######
ob = bpy.data.objects[objname]
ob.select = True
scene.objects.active = ob