Example #1
0
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()
Example #2
0
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()
Example #3
0
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()
Example #4
0
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()
Example #5
0
 def update_theme(self, context):
     color_def.rebuild_color_cache()
     if self.auto_apply_theme:
         color_def.apply_theme()
Example #6
0
def apply_theme_if_necessary():
    if get_param("apply_theme_on_open", False):
        color_def.apply_theme()
        print("applied theme.")
Example #7
0
 def update_theme(self, context):
     color_def.rebuild_color_cache()
     if self.auto_apply_theme:
         color_def.apply_theme()