[Bf-committers] Python Access to some properties of nodes
Dan Eicher
dan at trollwerks.org
Sat Dec 22 02:49:20 CET 2012
On Fri, Dec 21, 2012 at 4:52 AM, Lukas Tönne <lukas.toenne at gmail.com> wrote:
> # List of connected (Node, NodeSocket) pairs for 'socket':
> input_sockets = [(link.from_node, link.from_socket) for link in
> socket.id_data.links if link.to_socket == socket]
> output_sockets = [(link.to_node, link.to_socket) for link in
> socket.id_data.links if link.from_socket == socket]
>
Somewhat off topic...
Looking at this code I'm starting to think that maybe it was a mistake to
expose Node.links instead of having it as a property on the sockets
themselves, it would make the code a lot clearer and it isn't like you can
really do anything with the links independent of the sockets they're
assigned to.
It may even be better to totally abstract away the NodeLinks too, maybe
socket.links just return a list of (Node, NodeSocket) tuples -- have to
think on this a bit more though since it would probably require
sub-classing NodeSocket into NodeInputSocket, NodeOutputSocket so you'd
know if the returned node/socket pair was an input or output for the node.
Would also clean up node.links.new(add?) a bunch.
Dan
More information about the Bf-committers
mailing list