Skip to content

Commit bb8df75

Browse files
committed
fix: set id_type before assigning Scene id in driver_namespace example
The drivers skill's driver_namespace worked example assigned var.targets[0].id = bpy.context.scene without first setting id_type='SCENE'. A SINGLE_PROP target id pointer defaults to OBJECT, so the bare assignment raises TypeError: DriverTarget.id expected a Object type, not Scene on both 4.5.10 LTS and 5.1.1. Added the id_type line (matching snippet driver-with-custom-function.py) and clarified the SINGLE_PROP prose. Verified: driver now attaches and location.z evaluates to [0.0, 2.425, 4.9985] across frames 1/50/100 on both builds. Signed-off-by: fOuttaMyPaint <TMhospitalitystrategies@gmail.com>
1 parent fa1f469 commit bb8df75

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎skills/drivers-and-app-handlers/SKILL.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fcurve.driver.expression = 'src_x * 2.0'
6969

7070
Common variable types:
7171

72-
- `'SINGLE_PROP'`: read any RNA property. Set `targets[0].id = some_id` and `targets[0].data_path = 'some.path'`.
72+
- `'SINGLE_PROP'`: read any RNA property. Set `targets[0].id = some_id` and `targets[0].data_path = 'some.path'`. The target id pointer defaults to the `OBJECT` type; to point at a non-object datablock (a Scene, Material, etc.) set `targets[0].id_type` first, e.g. `targets[0].id_type = 'SCENE'`, otherwise the `id =` assignment raises `TypeError`.
7373
- `'TRANSFORMS'`: read a transform channel. Set `transform_type` (`LOC_X`, `ROT_Y`, `SCALE_Z`, etc.).
7474
- `'ROTATION_DIFF'`: angle between two bones in radians.
7575
- `'LOC_DIFF'`: distance between two object locations.
@@ -107,6 +107,7 @@ fcurve.driver.type = 'SCRIPTED'
107107
var = fcurve.driver.variables.new()
108108
var.name = 't'
109109
var.type = 'SINGLE_PROP'
110+
var.targets[0].id_type = 'SCENE' # required before assigning a non-Object id
110111
var.targets[0].id = bpy.context.scene
111112
var.targets[0].data_path = 'frame_current'
112113

0 commit comments

Comments
 (0)