I just figured out a way of doing it from python with an operator_menu_enum and 
storing the value on a global variable, maybe not an ideal solution but seems 
to work. I think this goes beyond the scope of this mailing list, if you want I 
can give you the details in private.

On 22 Oct 2015, at 16:19, Alexander Romanov <[email protected]> wrote:

> 
> 
> On 22.10.2015 13:39, Francesc Juhe wrote:
>> On 22 Oct 2015, at 10:58, Alexander Romanov <[email protected]> wrote:
>> 
>>>>>> 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.
>> But in the end, what is needed to fix the issue is a way to store in 
>> SpaceNodeEditor an enum or a value that holds the selected ‘data source’ but 
>> there is no real connection between this value and the nodetree returned by 
>> NodeTree.get_from_context(), the scripted function that is in fact returning 
>> the nodetree that is being edited in the node editor.
>> 
>> Your proposal of using a set of items known to Blender is just limiting the 
>> amount of items available to NodeTree.get_from_context() to decide the 
>> appropriate nodetree that is returned to the editor.
>> Being able to set the items along with NodeTree.get_from_context() is much 
>> more versatile.
> You are right, here is the collision. Probably, your approach is more 
> correct.
>> 
>> What would be the final proposed list of items available to build this enum?
> Needed for Blend4Web:
> ID_OB, ID_SCE - are the most impotant
> ID_LA, ID_CA, ID_MA, ID_SPK - potentially useful This discussion aims to 
> provide such list.
> 
>> 
>>>>>> - 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
>>>> [email protected]
>>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>> -- 
>>> Alexander Romanov (Blend4Web Team)
>>> 
>>> _______________________________________________
>>> Bf-committers mailing list
>>> [email protected]
>>> http://lists.blender.org/mailman/listinfo/bf-committers
>> _______________________________________________
>> Bf-committers mailing list
>> [email protected]
>> http://lists.blender.org/mailman/listinfo/bf-committers
> 
> -- 
> Alexander Romanov (Blend4Web Team)
> 
> _______________________________________________
> Bf-committers mailing list
> [email protected]
> http://lists.blender.org/mailman/listinfo/bf-committers

_______________________________________________
Bf-committers mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-committers

Reply via email to