I wrote a script that creates a custom property in the World panel. It then creates a driver on the object color that's driven by this custom property, but it doesn't recognize the data path as valid until I interact with the custom property slider in the viewport.
I have tried code to redraw all UI panels, among other things. Clicking the "update dependencies" button doesn't work. Nothing seems to make the custom property accessible/visible to Blender except interacting with it and then clicking in the driver so the data path is magically recognized as valid.
I need the custom property to exist on the World panel in the UI, with the slider, exactly as shown. I realize there are other ways to create custom properties, but I need this specific result for my workflow.
import bpy context = bpy.context # Create new custom prop new_custom_prop = "test_prop" context.scene.world[new_custom_prop]=1.0 my_world = context.scene.world id_props = context.scene.world.id_properties_ui(new_custom_prop) id_props.update( soft_min=0, soft_max=1, ) obj = context.active_object # Add drivers to object color d = obj.driver_add('color',0) d.driver.type = "AVERAGE" var1 = d.driver.variables.new() var1.targets.id_type = 'WORLD' var1.targets.id = context.scene.world var1.targets.data_path = "[\""+new_custom_prop+"\"]"