import bpy
arm = bpy.data.armatures[bpy.context.active_object.name]  # type: ignore
drv = arm.driver_add('layers', 0)[0].driver

The error I receive here is: TypeError: this type doesn't support IDProperties

I'm working on an addon and isolated this part of the script as something I cannot figure out how to get working. This is run in EDIT_ARMATURE mode so the active object that is an armature is guaranteed.

I've also tried various other things like adding the driver to bpy.context.active_object, but then it complains that "layers" does not exist.

For context, I'm trying to create a driver that can toggle the visibility of an armature layer on or off based on a property. This can be done in Blender itself no problem, but I can't seem to get it working in Python.

Any guidance on properly adding a driver to the layers array of the armature is welcome.


1 Answer 1


I found my mistake. The bpy auto-complete module I was using type-annotated the result of add_driver() as a return type of List[FCurve] and was giving syntax errors without accessing the indexed result first with [0].

However it seems this must be an erroneous type annotation, as the [0] is not necessary, and I can access .driver directly on the return of the add_driver() function.

So my final line is drv = arm.driver_add('layers', 0).driver.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .