First of all, I want to mention that I'm quite new to programming with Python and Blender.
Now, I wanted to know how I can create (or remove) a new socket in a custom nodetree considering the new "Items Tree" structure in Blender 4.0.
As far as I know, in Blender 4.0 the structure of the nodetree changed (due to the UI enhancement, which is great by the way). Now it appears to have a new "Items Tree" section, and each socket can be either input or output.
I'm trying to do this through bpy.data
In the past, I could create a new input or output with a function (New, or Remove, if I remember correctly) but now I don't know how to do it.
This is something I tried but the console says "AttributeError: bpy_prop_collection: attribute "new_socket" not found"
new_socket = bpy.data.node_groups['My nodegroup'].interface.items_tree.new_socket('NodeSocketFloat', 'My new Float Socket')
The part of the documentation that I'm referring to is this. But really, I never understood very well the Python API documentation.
Any hints on this will be appreciated!