Add driver to Particle Setting

Hello Blender users!

I’m trying to add a Driver using python on a Particle Settings’s parameter, the “display_step” for example.
To add a driver I use:

  pa1 = bpy.data.particles["ParticleSettings.001"]
  pa2 = bpy.data.particles["ParticleSettings"]

  path = "display_step"
  d = pa1.driver_add(path).driver


  v = d.variables.new()
  v.name = path
  v.targets[0].id = pa2.id_data
  v.targets[0].data_path = path

  d.expression = v.name

But I get an error on the “v.targets[0].id = pa2.id_data”:

TypeError: bpy_struct: item.attr = val: DriverTarget.id expected a Object type, not ParticleSettings

But when I inspect a Driver I made by hand on this parameter:

pa = bpy.data.particles["ParticleSettings.001"] 
d = pa.animation_data.drivers[0].driver
v = d.variables[0]
print("target_id:", v.targets[0].id )
print("target_data:", v.targets[0].data_path)

I get:

target_id: <bpy_struct, ParticleSettings(“ParticleSettings”) at 0x7f8a111c0408>
target_data: display_step

So the problem seems to be: I need to assign a ParticleSettings to v.targets[0].id but I can’t because it wants an Object :sweat_smile:

Does someone know how to work around this?
Thx a lot :pray: