Fix identity node replacement for Blender 2.93

This commit is contained in:
Moritz Brückner 2021-07-03 22:49:19 +02:00
parent 4e19ddfeb0
commit a6ec652d5f

View file

@ -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,