I'm currently creating some script to automate a cloth rig setup.
In the process I'm adding a custom float property to an empty and use it in a driver. It's a concept I wish to reuse for other purposes but had not figured out how to have that completely (and automatically) working yet. Unless I manually modify the custom property value in the UI and then update the driver dependencies, the driver will not pick the custom float property.
Here is an example that assume you have a Cube and a Sphere in the scene.
import bpy source_obj = bpy.data.objects["Cube"] source_prop = "influence" source_obj[source_prop] = 1.0 target_obj = bpy.data.objects["Sphere"] target_prop = "location" axis_index = 2 driver = target_obj.driver_add(target_prop, axis_index).driver v = driver.variables.new() v.name = "var" v.type = "SINGLE_PROP" v.targets.id = source_obj quote = "\"" v.targets.data_path = "[" + quote + source_prop + quote + "]" driver.expression = "var"
If you run that you will see that the driver don't work.
If you then go modify the value of the custom property through the UI by selecting the Cube and setting the influence value to 0.5 for example.
Then go update the Sphere driver dependencies (and I really just mean pressing the Update Dependencies button), it then work as intended.
Does anybody know what I need to do to have that working programmatically without having to touch the UI? (In the case I want to add, let's say 300 custom floats).
bpy.ops.wm.properties_edit() is what is triggered when you edit the property, but if you try to add that to your script it will give you an error: Direct execution not supported.
You can apparently add properties to a whole class, but it's not what I want to do. I want to add custom property to specific empty only.
I'm using Blender 2.8 by the way