1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Have you tried to update your scene or tag your area $\endgroup$ – J. Bakker Feb 3 '18 at 10:25
  • $\begingroup$ If the operator is executed within the right context, it will update automatically (without any issues), even without tagging the area to redraw: gist.github.com/p2or/b92d0859c68ac78673a2d0bedb2af09f Is your actual goal, running that from the text editor or another area? $\endgroup$ – p2or Feb 3 '18 at 14:48
  • $\begingroup$ @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. $\endgroup$ – zeffii Feb 3 '18 at 15:15
  • $\begingroup$ Updated the gist using new(). Does that work for you? @zeffii $\endgroup$ – p2or Feb 3 '18 at 15:22
  • $\begingroup$ 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 $\endgroup$ – p2or Feb 3 '18 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.