Set subtype socket_type nodegroup input by python

I’m trying to add node group inputs by python
Since bl4.0 we now use interface and set socket_type. These consist of 4 types. Using NodeSocketFloat as socket_type works. But I can’t find info, understandable for me, how to set the subtype.

When I use the socket_type=“NodeSocketFloat”, the subtype is set to NONE and the min and max are inf. I would like to know how to set the subtype to factor or any of the other types

You need to set it in the interface. After creating the socket, you can access the socket of the node tree and change the subtype by setting a string enum:

node_tree.interface.items_tree['Min'].subtype = 'FACTOR'

# subtypes: ('NONE', 'PERCENTAGE', 'FACTOR', 'ANGLE', 'TIME', 'TIME_ABSOLUTE', 'DISTANCE', 'WAVELENGTH', 'COLOR_TEMPERATURE', 'FREQUENCY')
1 Like

Thanks!

I found that after 2-3 of googling. I did not understand how to apply the code by lookijg at the api.

Ps you show it for min only, the socket_type can’t be set at once by using subtype as a main setting?

If found this on projects.blender.org

metallic_socket = ng.interface.new_socket(“Metallic”, in_out =‘INPUT’, socket_type = ‘NodeSocketFloat’)
metallic_socket.subtype = ‘FACTOR’

Source