def upgrade_nodes(ng): ''' Apply prop_name for nodes in the node group ng for upgrade to compact ui and create nodes that we add to ''' old_nodes.load_old(ng) for node in [n for n in ng.nodes if n.bl_idname in new_socket_dict]: for in_out, s_type, name, pos in new_socket_dict[node.bl_idname]: s_list = getattr(node, in_out) if s_list: if name not in s_list: s_list.new(s_type, name) s_list.move(len(s_list)-1, pos) for node in [node for node in ng.nodes if node.bl_idname in upgrade_dict]: for s_name, p_name in upgrade_dict[node.bl_idname]: socket = node.inputs.get(s_name) if socket and not socket.prop_name: socket.prop_name = p_name for n in [n for n in ng.nodes if n.bl_idname in vertices_socket_upgrade]: for s_name, p_name, use_prop, default in vertices_socket_upgrade[n.bl_idname]: socket = n.inputs.get(s_name) if socket: if p_name: socket.prop_name = p_name elif use_prop: socket.prop = default socket.use_prop = True socket.prop_name = "" else: pass
def upgrade_nodes(ng): ''' Apply prop_name for nodes in the node group ng for upgrade to compact ui and create nodes that we add to ''' old_nodes.load_old(ng) for node in [n for n in ng.nodes if n.bl_idname in new_socket_dict]: print(node.name) for in_out, s_type, name, pos in new_socket_dict[node.bl_idname]: s_list = getattr(node, in_out) if name not in s_list: s_list.new(s_type, name) s_list.move(len(s_list) - 1, pos) for node in [node for node in ng.nodes if node.bl_idname in upgrade_dict]: for s_name, p_name in upgrade_dict[node.bl_idname]: socket = node.inputs.get(s_name) if socket and not socket.prop_name: socket.prop_name = p_name for n in [n for n in ng.nodes if n.bl_idname in vertices_socket_upgrade]: for s_name, p_name, use_prop, default in vertices_socket_upgrade[ n.bl_idname]: socket = n.inputs.get(s_name) if socket: if p_name and not socket.prop_name: socket.prop_name = p_name elif use_prop and not socket.use_prop: socket.prop = default socket.use_prop = True socket.prop_name = "" else: pass
def sv_post_load(scene): """ Upgrade nodes, apply preferences and do an update. """ for monad in (ng for ng in bpy.data.node_groups if ng.bl_idname == 'SverchGroupTreeType'): if monad.input_node and monad.output_node: monad.update_cls() else: upgrade_group.upgrade_group(monad) sv_types = {'SverchCustomTreeType', 'SverchGroupTreeType'} sv_trees = list(ng for ng in bpy.data.node_groups if ng.bl_idname in sv_types and ng.nodes) for ng in sv_trees: ng.freeze(True) try: old_nodes.load_old(ng) except: traceback.print_exc() ng.freeze(True) try: upgrade_nodes.upgrade_nodes(ng) except: traceback.print_exc() ng.unfreeze(True) addon_name = data_structure.SVERCHOK_NAME addon = bpy.context.user_preferences.addons.get(addon_name) if addon and hasattr(addon, "preferences"): pref = addon.preferences if pref.apply_theme_on_open: color_def.apply_theme() ''' unsafe_nodes = { 'SvScriptNode', 'FormulaNode', 'Formula2Node', 'EvalKnievalNode', } unsafe = False for tree in sv_trees: if any((n.bl_idname in unsafe_nodes for n in tree.nodes)): unsafe = True break # do nothing with this for now #if unsafe: # print("unsafe nodes found") #else: # print("safe") #print("post load .update()") # do an update ''' for ng in sv_trees: if ng.bl_idname == 'SverchCustomTreeType' and ng.nodes: ng.update()
def sv_post_load(scene): """ Upgrade nodes, apply preferences and do an update. """ set_first_run(False) # ensure current nodeview view scale / location parameters reflect users' system settings from sverchok import node_tree node_tree.SverchCustomTreeNode.get_and_set_gl_scale_info( None, "sv_post_load") for monad in (ng for ng in bpy.data.node_groups if ng.bl_idname == 'SverchGroupTreeType'): if monad.input_node and monad.output_node: monad.update_cls() sv_types = {'SverchCustomTreeType', 'SverchGroupTreeType'} sv_trees = list(ng for ng in bpy.data.node_groups if ng.bl_idname in sv_types and ng.nodes) for ng in sv_trees: ng.freeze(True) ng.sv_process = False try: old_nodes.load_old(ng) except: traceback.print_exc() try: dummy_nodes.load_dummy(ng) except: traceback.print_exc() ng.freeze(True) try: upgrade_nodes.upgrade_nodes(ng) except: traceback.print_exc() ng.unfreeze(True) ng.sv_process = True addon_name = data_structure.SVERCHOK_NAME addon = bpy.context.preferences.addons.get(addon_name) if addon and hasattr(addon, "preferences"): pref = addon.preferences if pref.apply_theme_on_open: color_def.apply_theme() for ng in sv_trees: if ng.bl_idname == 'SverchCustomTreeType' and ng.nodes: ng.update()
def sv_post_load(scene): """ Upgrade nodes, apply preferences and do an update. """ for monad in (ng for ng in bpy.data.node_groups if ng.bl_idname == 'SverchGroupTreeType'): if monad.input_node and monad.output_node: monad.update_cls() else: upgrade_group.upgrade_group(monad) sv_types = {'SverchCustomTreeType', 'SverchGroupTreeType'} sv_trees = list(ng for ng in bpy.data.node_groups if ng.bl_idname in sv_types and ng.nodes) for ng in sv_trees: ng.freeze(True) try: old_nodes.load_old(ng) except: traceback.print_exc() ng.freeze(True) try: upgrade_nodes.upgrade_nodes(ng) except: traceback.print_exc() ng.unfreeze(True) addon_name = data_structure.SVERCHOK_NAME addon = bpy.context.preferences.addons.get(addon_name) if addon and hasattr(addon, "preferences"): pref = addon.preferences if pref.apply_theme_on_open: color_def.apply_theme() for ng in sv_trees: if ng.bl_idname == 'SverchCustomTreeType' and ng.nodes: ng.update()