I'm trying to drive the Lens property (focal length) of a camera with a custom property, to constrain it to a range (in this case, between 70 and 200mm). When this value goes from 70 to 200, I also want to be able to move an Empty that the camera is targeted to slightly up and down in Z (when the camera is at 70mm the vertical framing is right, but when it goes to 200 the empty is too low so the top of the subject is cropped out of frame).
I've added a custom property on the camera called "Zoom" - Blender gives its full data path as bpy.data.cameras["Cam_tight"]["Zoom"]
. Adding a driver to the focal length property, set to Scripted Expression with values as below, doesn't work. (I can't even paste anything into the Path box, I have to type the path in manually.) What am I doing wrong? (I'm on 2.93.2 fwiw.)
Prop
already indicatesCam_tight
as the target object (and so already has a reference to the target object), you should only need to give the name of the property itself, like:["Zoom"]
rather thanbpy.data.cameras["Cam_tight"]["Zoom"]
$\endgroup$Copy Data Path
on the"Zoom"
custom property and paste it into the driver'sPath
section, I believe you'll get exactly["Zoom"]
. This is how I normally build similar drivers $\endgroup$