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

Alexander Romanov a.romanov at blend4web.com
Wed Oct 21 16:32:46 CEST 2015


On 21.10.2015 13:46, Francesc Juhe wrote:
> Sure, PointerProperty would be a great addition to the API but seems like a complicated issue.
> If it could accept filters then it can be used as a substitute for prop_search.
>
> Something like:
>    bpy.props.IDProperty(type=‘OBJECT’, subtype=‘CAMERA') # to link a camera an object
>
> or:
>    bpy.props.IDProperty(src=bpy.data.objects, filter=some_python_filter_func) # to link an ID from bpy.data.objects with filter
>
>
> In the end, I would be happy with the PointerProperty and being able to link to objects, node_groups or whatever.
>
> I proposed the NodeTree property just to be on par with internal node trees, they are not stored in bpy.data.node_groups, they are stored on the ID. But sure, a PointerProperty would work for solving issue (2) you mention.
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.
> 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"}

> - 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.
>
>
> On 21 Oct 2015, at 10:34, Alexander Romanov <a.romanov at blend4web.com> wrote:
>
>> Hi!
>> Not sure about another storage for nodetrees. I think, there should be
>> one storage for them and multiple storages for links.
>> But I agreewith Isaac about generalization. Here is some discussion
>> about PointerProperty https://developer.blender.org/T34766 . I think,
>> this is the way to go. And that is what I also was thinking about. There
>> are two separate issues : 1) Generalized nodetree editing through
>> Blender UI for a nodetree linked to any datablock.
>> (http://wiki.blender.org/index.php/Linking_Custom_Node_Tree_to_DataBlock) 2)
>> Make it possible to create links of any types with reference counting
>> through python PointerProperty. (https://developer.blender.org/T34766)
>> What do you think about PointerProperty?
>> On 21.10.2015 04:40, Isaac Weaver wrote:
>>> I like the idea of adding a new property type, but I wonder if it could be
>>> generalized to more ID types (Object, Scene, etc.)
>>>
>>> Maybe something like this:
>>>      bpy.props.IDProperty(subtype='OBJECT') # to store an object
>>>      bpy.props.IDProperty(subtype='SCENE') # to store a scene
>>>      bpy.props.IDProperty(subtype='NODE_TREE', type=NodeTreeType) # to store
>>> a node tree
>>>
>>> Would a property like this make sense?
>>>
>>> Thanks,
>>> ~ Isaac
>>>
>>> On Tue, Oct 20, 2015 at 1:58 PM, Francesc Juhe <fjuhec at gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> As the main developer behind the Mitsuba exporter I like your proposal.
>>>> It would greatly improve the current workflow.
>>>>
>>>> But I would also like to make another proposal.
>>>>
>>>> - Add to Blender a bpy.props.NodeTree(type=NodeTreeType) that can be
>>>> attached to ID. This way there is no need to fill the bpy.data.node_groups.
>>>>
>>>> - Add a function to NodeTreeType that can be called from blender or python
>>>> and returns a list of accepted data sources by that NodeTreeType. That way
>>>> the node editor can show the appropriate options to the user to select the
>>>> correct data source.
>>>>
>>>> What do you think? Possible?
>>>>
>>>> Cheers,
>>>> Francesc
>>>>
>>>>
>>>> On 07 Oct 2015, at 16:32, Alexander Romanov <a.romanov at blend4web.com>
>>>> wrote:
>>>>
>>>>> Hello everyone from Blend4Web Team!
>>>>> We're currently working with node trees in our node-based logic editor
>>>>> and we've noticed some
>>>>> shortcomings in python API. We have some ideas about improving API for
>>>>> custom node trees.
>>>>> Briefly, we want to make it possible to link custom node trees to
>>>>> datablocks such as Scene,
>>>>> Object, etc. Here is a link to the proposal:
>>>>> http://wiki.blender.org/index.php/Linking_Custom_Node_Tree_to_DataBlock
>>>>>
>>>>> I would like to discuss this with developers of addons which use custom
>>>>> node trees, such as Sverchok and Luxrender.
>>>>> _______________________________________________
>>>>> Bf-committers mailing list
>>>>> Bf-committers at blender.org
>>>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>> _______________________________________________
>>>> Bf-committers mailing list
>>>> Bf-committers at blender.org
>>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>>
>>> _______________________________________________
>>> Bf-committers mailing list
>>> Bf-committers at blender.org
>>> http://lists.blender.org/mailman/listinfo/bf-committers
>> -- 
>> Alexander Romanov (Blend4Web Team)
>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
> _______________________________________________
> 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