[Bf-committers] List the nodes of Frame with API

Lukas Tönne lukas.toenne at gmail.com
Wed Jan 9 17:16:03 CET 2013


Small fix/addition:
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53686

You can detach a node simply by setting node.parent = None

On Wed, Jan 9, 2013 at 5:08 PM, Lukas Tönne <lukas.toenne at gmail.com> wrote:
> I have now made the parent property writeable in the RNA.
>
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53685
>
> * It will perform a sanity check internally when setting, to avoid
> infinite recursion when setting a node as its own ancestor (i.e. the
> supposed parent frame is already attached to the child frame on some
> level).
> * It also checks for the Frame node type, which is currently the only
> node allowing attachment (in the future there may be more node types
> using this feature).
> * If the node was attached to another frame before it will be detached
> safely and then reattached to the new frame
>
> On Sun, Jan 6, 2013 at 10:00 PM, Bartek Skorupa (priv)
> <bartekskorupa at bartekskorupa.com> wrote:
>> I was dealing with this issue when working on "Nodes Efficiency Tools": http://projects.blender.org/tracker/index.php?func=detail&aid=33543&group_id=153&atid=467
>> In the current version I don't set parents, but I certainly will want to be able to do it.
>>
>> The workaround I came up with is as follows:
>>
>> Say you have a node 'frame'. It has children. Say we have a list of them and it's a list called 'children'.
>> Now we want some node outside this frame to be "parented" to it. (Let's call it 'my_node')
>> What I'd do would be:
>> Remove 'frame', but first I'd store it's name, label and maybe some other parameters, then select all of it's children (for node in children: node.select = True), plus 'my_none' (my_node.select = True) and use bpy.ops.node.join() operator.
>> This will create new FRAME node and all of the selected nodes will become its children. Then you may set some previously stored parameters of removed 'frame'.
>> When using operators for nodes you have to mind the context, so it will not work from the console level or simple scripts run from text editor.
>>
>> This is however a workaround and I'd really appreciate if it was possible to simply say node.parent = frame
>>
>> Bartek Skorupa
>>
>> www.bartekskorupa.com
>>
>> On 6 sty 2013, at 19:25, Fabio Russo <ruesp83 at gmail.com> wrote:
>>
>>> Excellent! : D
>>> But this only allows me to read the relationship, if I instead want to set
>>> up the relationship? How do I? Parent is read only
>>>
>>>
>>> 2013/1/6 Lukas Tönne <lukas.toenne at gmail.com>
>>>
>>>> Nodes have a "parent" pointer that defines the hierarchy. When you
>>>> have a frame node called "frame", the list of attached nodes consists
>>>> of all nodes whose parent is "frame":
>>>>
>>>> node_tree = frame.id_data
>>>> children = [node for node in node_tree.nodes if node.parent == frame]
>>>>
>>>> On Sun, Jan 6, 2013 at 1:17 PM, Fabio Russo <ruesp83 at gmail.com> wrote:
>>>>> I'm back with some more questions regarding the nodes!
>>>>> I'm trying to improve the addon Compositing Presets, so do not call me
>>>>> annoying :P
>>>>> My new question is how do I know which nodes are located above the frame
>>>>> node via API?
>>>>>
>>>>> Thank you very much,
>>>>> ruesp83
>>>>> _______________________________________________
>>>>> 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
>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers


More information about the Bf-committers mailing list