-
Notifications
You must be signed in to change notification settings - Fork 234
LowLevelNodeDetails
I'll say this again, the best place to look for objective information about this is to read the code of existing nodes. Start with simpler nodes. Anyone who has contributed to Sverchok has been able to understand the boilerplate stuff mentioned in the high level overview, most of the problems have come from being unfamiliar with Python. Having said that, there are a few things that might be helpful to explain.
You can reference a socket by index or name, you'll see we use whatever is convenient.
socket = self.inputs[socket_name] # by name
socket = self.inputs[0] # by index
data = socket.sv_get()
socket = self.outputs[socket_name] # by name
socket = self.outputs[0] # by index
socket.sv_set(data)
We often pass around multiple lists inside a socket stream, like [list1, list2, list3]
, each list can have a different length but should carry comparable data at the lowest level. For example: Never pass edges and polygons in a single socket stream. Pass either edges or polygons. There are several nodes with sockets labelled 'poly_edge', do not use those nodes as an example of good practice.
The main confusion we've seen people face is the nestedness of the input socket data, you can narrow down the level of nestedness by indexing:
data = socket_verts.sv_get() # don't unwrap (level 0)
data = socket_verts.sv_get()[0] # take first element (level 1)
data = socket_verts.sv_get()[0][0] # take first element of first element. (level 2)