1

This snippet can be run from Text Editor to get an idea of what I mean.

import bpy

nt = bpy.data.materials['Material'].node_tree
nodes = nt.nodes

a = nodes.new('ShaderNodeBsdfDiffuse')
a.location = 0, 0

b = nodes.new('ShaderNodeBsdfDiffuse')
b.location = 200, 0

f = nodes.new('NodeFrame')
f.location = -200, 0

a.parent = f
b.parent = f

That produces this initially.

enter image description here

only when i move the mouse inside the nodeview does the Frame update its visual representation.

enter image description here

I would love some suggestions. The code/Operator that we execute in Sverchok has the NodeView context and an edit_tree if that helps.

zeffii
  • 39,634
  • 9
  • 103
  • 186
  • Have you tried to update your scene or tag your area – J. Bakker Feb 03 '18 at 10:25
  • If the operator is executed within the right context, it will update automatically (without any issues), even without tagging the area to redraw: https://gist.github.com/p2or/b92d0859c68ac78673a2d0bedb2af09f Is your actual goal, running that from the text editor or another area? – p2or Feb 03 '18 at 14:48
  • @p2or i think your snippet works because you are calling bpy.ops.node.add_node(bl_idname), my script builds an entire nodetree using nodes.new(bl_idname), which doesn't have the same scene update behaviour. – zeffii Feb 03 '18 at 15:15
  • Updated the gist using new(). Does that work for you? @zeffii – p2or Feb 03 '18 at 15:22
  • Ahh, now I get it. Updated the gist again. I think in this case adding context.area.tag_redraw() (as @J.Bakker suggested) does the trick @zeffii – p2or Feb 03 '18 at 15:35
  • weird. that doesn't snap the frame either. (until i move the cursor over the frame... which is the behaviour I started out with) . haha.. sorry I must be thick or something :) – zeffii Feb 03 '18 at 15:45
  • You are right, that doesn't help updating the UI neither. For now I can't find a better way than adding bpy.ops.node.select_all() at the end... (updated again) @zeffii – p2or Feb 03 '18 at 15:55

0 Answers0