operators.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:blender-scripts 作者: vincentgires 项目源码 文件源码
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'}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号