[Bf-committers] Link custom node trees to datablocks.

Alexander Romanov a.romanov at blend4web.com
Thu Oct 22 10:58:44 CEST 2015

On 21.10.2015 20:35, Francesc Juhe wrote:
> On 21 Oct 2015, at 16:32, Alexander Romanov <a.romanov at blend4web.com> wrote:
>> There is a problem of backward compatibility. You need to think
>> carefully and not to break existing Addons if you want to remove custom
>> trees from bpy.data.node_groups. In any case, it will be a low-level
>> pointer. As I understand internal nodes are stored in specified
>> datablocks such as Material, Scene... And they are ina hard hierarchical
>> relationship. Internal nodetree depends onits parent datablock. You can
>> choose this parent datablock from a collection like bpy.data.Materials,
>> but can't reuse its nodetree by some another datablock. In the case of a
>> custom nodetree it is useful to have a possibility to reuse a nodetree.
>> So, maybe it would be more accurate to have access to custom nodetrees
>> from, say, bpy.data.custom_node_trees, but it works fine now for
>> bpy.data.node_groups.
> Yes, you are right about compatibility and reusability of node_groups in the current format. Ok, don’t think more about it.
> Being able to link to data with a proper IDPointerProperty is the way to go.
>>> As for issue, (1) Generalized nodetree editing, I think this could work:
>>> - Add a property to SpaceNodeEditor to hold the custom nodetree type.
>>> - Add a function registered on NodeTreeType that returns a list of accepted data sources.
>> I think, it would looks like:
>> class MyNodeTree(bpy.types.NodeTree):
>>      bl_idname ='MyNodeTree'
>>      bl_source_types = {"OBJECT", "WORLD", "MATERIAL”}
> I was thinking on a function like the one accepted by EnumProperty that returned items (sequence of string tuples or a function) – sequence of enum items formatted: [(identifier, name, description, icon, number), …]
> I think it would be more versatile for custom node trees.
I think that the "parent" datablocks types should be defined in blender 
kernel likeit was doneforAnimData. Thus there is a countable set of 
types. Each type has general meaning for all custom nodetrees. So it 
seems that is no need to move this work into scripting.
>>> - Add appropriate draw code on space_node.py to draw the data source icons provided by the function and storing it on the SpaceNodeEditor property.
>>> - NodeTreeType then uses the property to know the data source selected on the Node Editor.
>>> I wanted to try to make a patch for this but haven’t had the time yet, I think this issue is not as difficult as the other.
>> if you start before melet me know, please. Iwill also informyou.
>>> In the Mitsuba Addon I am reusing SpaceNodeEditor.shader_type to select between world and object data source and works ok.
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers

Alexander Romanov (Blend4Web Team)

More information about the Bf-committers mailing list