-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update system - explanation #2770
Comments
Sverchok tree properties:
Calling Sverchok update events:
|
|
What is going on if during update event cause another update event: class MyCustomTree(NodeTree):
bl_idname = 'CustomTreeType'
bl_label = "Custom Node Tree"
bl_icon = 'NODETREE'
def update(self):
print('TREE UPDATE')
class TestNode(Node):
bl_idname = 'TestNode'
bl_label = 'Test node'
def init(self, context):
print(f'INIT NODE "{self.name}"')
print('ADD ANOTHER NODE FROM INIT')
self.id_data.nodes.new('TestNode2')
print('RETURN INIT METHOD AGAIN')
It proves that our freezing method of the tree is redundant. whole codeimport bpy
from bpy.types import NodeTree, Node, NodeSocket
class MyCustomTree(NodeTree):
bl_idname = 'CustomTreeType'
bl_label = "Custom Node Tree"
bl_icon = 'NODETREE'
def update(self):
print('UPDATE')
class TestNode(Node):
bl_idname = 'TestNode'
bl_label = 'Test node'
def init(self, context):
print(f'INIT NODE "{self.name}"')
print('ADD ANOTHER NODE FROM INIT')
self.id_data.nodes.new('TestNode2')
print('RETURN INIT METHOD AGAIN')
class TestNode2(Node):
bl_idname = 'TestNode2'
bl_label = 'Test node 2'
def register():
[bpy.utils.register_class(c) for c in [MyCustomTree, TestNode, TestNode2]]
def unregister():
for cls_str in ['MyCustomTree', 'TestNode', 'TestNode2']:
cls = bpy.types.NodeGroup.bl_rna_get_subclass_py(cls_str)
if cls:
unregister_class(cls)
if __name__ == "__main__":
unregister()
register()
[bpy.data.node_groups.remove(t) for t in bpy.data.node_groups if t.bl_idname == 'CustomTreeType']
tree = bpy.data.node_groups.new('Test', 'CustomTreeType')
bpy.data.screens['Layout'].areas[3].type = 'NODE_EDITOR'
bpy.data.screens['Layout'].areas[3].spaces[0].node_tree = tree
print('ADD FIRST NODE INTO TREE')
tree.nodes.new('TestNode') |
Creating new sockets will trigger redundant tree updates if
Creating them in other places will trigger nothing. |
Will try to describe what is going on:
Blender update events:
Sverchok update events:
Triggers of depsgraph_update_pre handler:
Reaction upon manipulation in node tree:
The text was updated successfully, but these errors were encountered: