1
$\begingroup$

I'm working now on a plugin that includes NodeGroups and I want to make a Boolean Socket. I remember that in the older versions it was possible to do this, but in the Interface system, I didn't really find a way because it limits to very specific types of input when creating a Socket. So is there a way to do it?

$\endgroup$

1 Answer 1

1
$\begingroup$

In Blender 4.1 you can do

bpy.data.node_groups['NodeGroup'].interface.new_socket(
    name='My Socket',
    in_out='INPUT',
    socket_type='NodeSocketBool',
)

The easiest way to find out what enums you can pass for socket_type is to pass a wrong one and read the error message. Here you would get

TypeError: NodeTreeInterface.new_socket(): error with keyword argument "socket_type"
-  enum "X" not found in (
    'NodeSocketBool',
    'NodeSocketVector',
    'NodeSocketInt',
    'NodeSocketShader',
    'NodeSocketFloat',
    'NodeSocketColor'
)
$\endgroup$
3
  • $\begingroup$ Strange, What I get in the error show me just those ones: TypeError: NodeTreeInterface.new_socket(): error with keyword argument "socket_type" - enum "NodeSocketBool" not found in ('NodeSocketVector', 'NodeSocketShader', 'NodeSocketFloat', 'NodeSocketColor') $\endgroup$ Feb 7 at 11:57
  • $\begingroup$ Oh, I see that it works in 4.1, but not 4.0. $\endgroup$
    – scurest
    Feb 7 at 20:45
  • $\begingroup$ Alright, I'll upgrade soon $\endgroup$ Feb 8 at 20:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .