[Bf-funboard] Custom NodeTree and NodeSocket feature request

Francesc Juhe fjuhec at gmail.com
Wed Feb 11 12:15:49 CET 2015

Hi again,

I have been exploring ways to implement the ability to set the type to custom NodeSocket and first I tried to add it to rna_NodeSocket_register but from what I understand of the code, the python properties are registered after this function is run and found no way to detect a python default_value and set the socket type according to the type of the property.

Is it possible that the following code or something similar is added to rna_def_node_socket to allow python to set the type of the socket?

+++ ./bf_blender/blender/source/blender/makesrna/intern/rna_nodetree.c
@@ -6462,6 +6462,14 @@
 	RNA_def_property_flag(prop, PROP_REGISTER);
 	RNA_def_property_ui_text(prop, "ID Name", "");
+	prop = RNA_def_property(srna, "bl_type", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "typeinfo->type");
+	RNA_def_property_enum_items(prop, node_socket_type_items);
+	RNA_def_property_enum_default(prop, SOCK_FLOAT);
+	RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+	RNA_def_property_ui_text(prop, "Type", "Data type");
+	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
 	/* draw socket */
 	func = RNA_def_function(srna, "draw", NULL);
 	RNA_def_function_ui_description(func, "Draw socket");

In the current code, custom NodeSocket are of type ‘VALUE’ (SOCK_FLOAT). As there are some parts of code that do different things depending on socket type this causes issues like different UI for float vector sockets.


On 18 Jan 2015, at 21:02, Francesc Juhe <fjuhec at gmail.com> wrote:

> Hi everyone,
> I would like to ask if it’s possible to add two features to custom NodeTree and NodeSocket.
> First, I think it could be great if custom NodeTree had a way to define a ‘foreach_nodeclass()’ function from python to somehow tell the Node menu creator what nodes are compatible with the current socket.
> Second, it could also be useful to be able to set the type of custom NodeSockets and for it to be saved with the scene. Currently the type can be set from python but only after it’s created on the Node init function and every time the scene is loaded the previous type is lost and it defaults to ‘VALUE’ making it difficult to work with custom NodeSockets with no default_value. ‘hide_value’ has the same issue, it can be set from python on the Node init() but is not saved.
> Thank you very much,
> Cheers,
> Francesc

More information about the Bf-funboard mailing list