How can I test if an attribute is read only
From the code below I am getting
AttributeError: bpy_struct: attribute “OBJECT_OT_duplicate” from “OBJECT_OT_duplicate_move_linked” is read-only
def map_operator_from_shortcut(op, idtype,keymap_item):
for prop in dir(keymap_item.properties):
if prop in idtype.bl_rna.properties and not prop.startswith("_") and prop not in {"bl_rna", "rna_type",""}:
attr = getattr(keymap_item.properties, prop,None)
if hasattr(op,prop) and getattr(op,prop) != attr :
print("Setting in ", op, " ", prop, " to ", attr)
setattr(op,prop,attr)
return op
That’s right, don’t put a try/except block inside a loop you are going to call a million times, instead wrap the entire loop with one - this way, it needs to be set up just once. But it also depends on the use case…