Node Group, add Socket of specific type

bpy.ops.node.tree_socket_add(in_out=‘IN’)Add an input or output socket to the current node tree
[TABLE=“class: docutils field-list”]
[TR=“class: field-odd field”]
[TH=“class: field-name, bgcolor: #EEDDEE, align: left”]Parameters:[/TH]
in_out (enum in [‘IN’, ‘OUT’], (optional)) – Socket Type
[/TR]
[/TABLE]

How must this command look like if i want to specify a Socket Type?

There is this (optional) which should do what i want, but i can’t figure out how this command has to look like.

it must be something like:

bpy.ops.node.tree_socket_add(in_out=‘IN’, ‘VECTOR’)

Here’s what i got:

import bpy



class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Layout Demo"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'NODE_EDITOR'
    bl_region_type = 'UI'
    bl_context = "UI"




    def draw(self, context):
        
      
        self.layout.operator("node.function")
        return{'finished'}


class SCENE_PT_layout(bpy.types.Operator):
    bl_idname = "node.function"
    bl_label = "Make Mesh"


    def execute(self, context):  
        
        bpy.ops.node.tree_socket_add(in_out='IN', 'VECTOR')


def register():
    bpy.utils.register_class(LayoutDemoPanel)




def unregister():
    bpy.utils.unregister_class(LayoutDemoPanel)




if __name__ == "__main__":
    register()



I am not using this feature myself in HiveGUI, but I suspect that it must be a subclass or instance of bpy.types.NodeSocket

Hey thanks, was probably a bit late yesterday :wink:

i figured that it either needs to be
bpy.ops.node.tree_socket_add(in_out=‘IN’, type=‘VECTOR’)
bpy.ops.node.tree_socket_add(in_out=‘IN’, bpy.types.NodeSocket…)

thats crap…

how must i put this (optional)) – Socket Type

into

bpy.ops.node.tree_socket_add(in_out=‘IN’)

if this (optional) would be for example bpy.types.NodeSocketFloat

???

Or is actually anybody working on making NodeGroups usable? Means: specify what kind of NodeSocket is added, instead of active one or the one you drag there… It really is a joke how it works right now…

Thanks Lukas Toenne for the help (on irc)

here how it can be done:


        space = context.space_data
        edit_tree = space.edit_tree
        inputs = edit_tree.inputs
        outputs = edit_tree.outputs

        inputs.new(type="NodeSocketColor", name="Color")

note: this must be run from context Node_Editor