This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/release/scripts/startup/nodes/bparticle_nodes/custom_attributes.py
2019-12-22 11:10:54 +01:00

47 lines
1.5 KiB
Python

import bpy
from bpy.props import *
from .. base import SimulationNode, FunctionNode
from .. node_builder import NodeBuilder
class SetParticleAttributeNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_SetParticleAttributeNode"
bl_label = "Set Attribute"
attribute_type: StringProperty(
name="Attribute Type",
default="Float",
update=SimulationNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
builder.fixed_input("name", "Name", "Text", default="My Attribute", display_name=False)
builder.fixed_input("value", "Value", self.attribute_type)
builder.execute_output("execute", "Execute")
def draw(self, layout):
self.invoke_type_selection(layout, "set_type", "Select Type", mode="BASE", icon="SETTINGS")
def set_type(self, data_type):
self.attribute_type = data_type
class GetParticleAttributeNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_GetParticleAttributeNode"
bl_label = "Get Attribute"
attribute_type: StringProperty(
name="Attribute Type",
default="Float",
update=SimulationNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
builder.fixed_input("name", "Name", "Text", default="My Attribute", display_name=False)
builder.fixed_output("value", "Value", self.attribute_type)
def draw(self, layout):
self.invoke_type_selection(layout, "set_type", "Select Type", mode="BASE", icon="SETTINGS")
def set_type(self, data_type):
self.attribute_type = data_type