-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canonical way to hotswap the type of socket #261
Comments
yes, but without removing it should be alltogather socket type, i think |
changeable_socket is the canonical way but it should be updated to be future proof. It should use .bl_idname of the socket directly instead of encoding it to "s", "m" "v". It could also reconnect lost connections. |
Also input socket isn't needed, somewhat confusing def get_socket_type(node, inputsocketname):
if type(node.inputs[inputsocketname].links[0].from_socket) == bpy.types.VerticesSocket:
return 'v'
if type(node.inputs[inputsocketname].links[0].from_socket) == bpy.types.StringsSocket:
return 's'
if type(node.inputs[inputsocketname].links[0].from_socket) == bpy.types.MatrixSocket:
return 'm'
def get_socket_type_full(node, inputsocketname):
# this is solution, universal and future proof.
return node.inputs[inputsocketname].links[0].from_socket.bl_idname |
i'm not sure I get it. Of course i can code the socket change and reconnect in the long form, as I did in early version of the List Range Int. but say I have a node with
and i want to cast it to a |
in changeable_socket, should the params be called more appropriate 'old_socket_type, new_socket_type`, or (as you point out) ignore the current socket_type and be change_socket_input(self, name/id, new_socket_type [, new_name])
change_socket_output(self, name/id, new_socket_type [, new_name])
# new_name would be optional |
or change_socket_input(self, name/id, new_socket_type, new_name=oldname, keep_links=True)
change_socket_output(self, name/id, new_socket_type, new_name=oldname, keep_links=True)
# new_name would be optional, it would use oldname
# keep_links would default to True, set manually to False if you have some reason. |
Inputs socket of For output sockets I think name and sockets should be kept as stable as possible so I am against the name parameter change. (If needed we can supply a display name that can be changed.) It also made for different scenario than you need, mainly for the list operations where one input socket changes type of many outputs. So I think it should be updated for handling the scenario. In
Something like that |
is the move just to trigger update? |
oh, .move is socket move?.. |
New sockets get placed last. |
Yeah just a quick sketch... I wish move supported pythonic -1 indexing. We should suggest that to the developers also. Also keep the link collecting all connected sockets. Also when we change type here we might trigger a long series of type changes... Each causing a series of update events. |
#152 yeah. Maybe now is the time to stop adding new nodes and discuss that properly, I only have a vague understanding of how that should work. Will continue in other thread. |
I with Alex made stupid thing when called it StringsSocket |
Yeah, but since it carried the data in a string property it was logical at the time. Now we evolve :) |
any example code with preferred approach? List repeater uses
changable_socket
, but would be cool to do something likeself.outputs[0].changeto(VerticesSocket [,newname])
The text was updated successfully, but these errors were encountered: