How can possible socket types be filtered in a custom node tree for group inputs and outputs? In node tree input/ output socket types is there a way to control which socket types appear? To test:
- Copy and paste the following code into Blender's text editor.
from bpy.types import NodeTree, NodeSocket, NodeSocketInterface
from bpy.utils import register_class, unregister_class
import nodeitems_utils
from nodeitems_utils import NodeCategory, NodeItem
class TestSocket(NodeSocket):
bl_label = "Example socket"
def draw_color(self,context,node):
return (0,.5,8,1)
def draw(self,context,layout,node,text):
layout.label(text=text)
class TestSocketInt(NodeSocketInterface):
bl_idname = "TestSocketInt"
bl_socket_idname = "TestSocket"
def draw_color(self,context):
return (0,.5,.8,1)
def draw(self,context,layout):
layout.prop(self,"hide_value")
class TestTree(NodeTree):
bl_label = "Test Tree"
bl_icon = "NODETREE"
classes = (TestTree,TestSocket,TestSocketInt)
cats = [NodeCategory('EXAMPLE','Example',items = [NodeItem('NodeGroupInput')])]
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
nodeitems_utils.register_node_categories('EXAMPLE_NODES', cats)
def unregister():
from bpy.utils import unregister_class
for cls in classes:
unregister_class(cls)
nodeitems_utils.unregister_node_categories('EXAMPLE_NODES')
if __name__ == "__main__":
register()