Is there a way to check whether or not a Blender RNA or ID property is "Read-only" in python?


Yes indeed there is. Here's a very simple example using a World datablock and the .is_property_readonly(*property*) function.

import bpy
scn = bpy.context.scene
wld = scn.world
for a_prop in wld.keys():
    if wld.is_property_readonly(a_prop) is True:
        print("The property, %s, is 'Read-Only'" % a_prop)

This code would produce the following output:

The property, cycles, is 'Read-Only'
The property, cycles_visibility, is 'Read-Only'

The function .is_property_readonly(*property*) will output a boolean value, either True or False.


The property itself will have an is_readonly property.

Test code run in the py console.

>>> for prop in C.object.bl_rna.properties:
...     if prop.is_readonly:
...         print("%s (%s)" % (prop.name, prop.identifier))
RNA (rna_type)
Users (users)
Is Updated (is_updated)
Is Updated Data (is_updated_data)
Is Indirect (is_library_indirect)
Library (library)
Preview (preview)
Type (type)
Mode (mode)
Local View Layers (layers_local_view)
Bounding Box (bound_box)
Proxy (proxy)
Proxy Group (proxy_group)
Material Slots (material_slots)
Modifiers (modifiers)
Constraints (constraints)

Not sure you can make custom ID properties ( eg obj["prop"]) read only.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.