3
$\begingroup$

When I create a cube, have it select and run the script

import bpy

selection = bpy.context.selected_objects

print(bool(selection[0].is_property_readonly))

it outputs "True".

I would have guessed that it outputs "False" but it does not. Why? My goal is to test if an object is linked from a different Blender file and because of that I cannot edit its name.

$\endgroup$

1 Answer 1

4
$\begingroup$

is_property_readonly is a method, and bool(method) return True

import bpy

print(bpy.context.selected_objects[0].is_property_readonly)

# >>>> <built-in method is_property_readonly of Object object at 0x000001F9CA43AE40>

Check if name is read only:

ob.is_property_readonly("name")
# >>>> True/False

To test whether an object is editable, you can use the following function

def is_library_editable(ob):
    if hasattr(ob, "library") and ob.library:
        return False
    if hasattr(ob, 'override_library') and ob.override_library and ob.override_library.is_system_override:
        return False
    return True

If something wrong, please point them out.

$\endgroup$
1
  • $\begingroup$ you can check if other properties are readonly as well, in this case is the "node" an imageTextureNode node.is_property_readonly('image') $\endgroup$
    – Lala_Ghost
    Commented May 21 at 13:50

You must log in to answer this question.

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