From a6ec652d5f3ba14d46b07665365e027b15d4cb56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Br=C3=BCckner?= Date: Sat, 3 Jul 2021 22:49:19 +0200 Subject: [PATCH] Fix identity node replacement for Blender 2.93 --- blender/arm/logicnode/replacement.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/blender/arm/logicnode/replacement.py b/blender/arm/logicnode/replacement.py index d062a7bc..99585f13 100644 --- a/blender/arm/logicnode/replacement.py +++ b/blender/arm/logicnode/replacement.py @@ -61,28 +61,27 @@ class NodeReplacement: """ in_socks = {i: i for i in range(len(node.inputs))} out_socks = {i: i for i in range(len(node.outputs))} - props = {} - i = 0 - # finding all the properties fo a node is not possible in a clean way for now. - # so, I'll assume their names start with "property", and list all the node's attributes that fulfill that condition. - # next, to check that those are indeed properties (in the blender sense), we need to check the class's type annotations. - # those annotations are not even instances of bpy.types.Property, but tuples, with the first element being a function accessible at bpy.props.XXXProperty - property_types = [] - for possible_prop_type in dir(bpy.props): - if possible_prop_type.endswith('Property'): - property_types.append(getattr(bpy.props, possible_prop_type)) + # Find all properties for this node + props = {} possible_properties = [] for attrname in dir(node): + # We assume that property names start with 'property' if attrname.startswith('property'): possible_properties.append(attrname) + for attrname in possible_properties: + # Search in type annotations if attrname not in node.__annotations__: continue - if not isinstance(node.__annotations__[attrname], tuple): + + # Properties must be annotated with '_PropertyDeferred', see + # https://developer.blender.org/rB37e6a1995ac7eeabd5b6a56621ad5a850dae4149 + # and https://developer.blender.org/rBc44c611c6d8c6ae071b48efb5fc07168f18cd17e + if not isinstance(node.__annotations__[attrname], bpy.props._PropertyDeferred): continue - if node.__annotations__[attrname][0] in property_types: - props[attrname] = attrname + + props[attrname] = attrname return NodeReplacement( node.bl_idname, node.arm_version, node.bl_idname, type(node).arm_version,