def execute(self, context):
node = context.node
selected_object = context.object
# get attribute value and type
data_path = "bpy.data."+node.data_enum + "['"+node.data_item+"']"
data_path = eval(data_path)
try:
attribute = eval("data_path"+"."+node.attribute_property)
except:
attribute = None
if attribute is not None:
if isinstance(attribute, str):
node.inputs.new('NodeSocketString', node.attribute_property)
elif isinstance(attribute, bool):
node.inputs.new('NodeSocketBool', node.attribute_property)
elif isinstance(attribute, int):
node.inputs.new('NodeSocketInt', node.attribute_property)
elif isinstance(attribute, float):
node.inputs.new('NodeSocketFloat', node.attribute_property)
elif isinstance(attribute, mathutils.Color):
node.inputs.new('NodeSocketColor', node.attribute_property)
elif isinstance(attribute, mathutils.Vector):
node.inputs.new('NodeSocketVector', node.attribute_property)
elif isinstance(attribute, mathutils.Euler):
node.inputs.new('NodeSocketVector', node.attribute_property)
elif isinstance(attribute, mathutils.Quaternion):
node.inputs.new('NodeSocketVector', node.attribute_property)
elif len(attribute) == 4: # RGBA
node.inputs.new('NodeSocketColor', node.attribute_property)
return{'FINISHED'}
评论列表
文章目录