0
$\begingroup$

I am registering a global variable and I need it to be ignored by UNDO and I need functionality like:

do some operators

get some information from the operations

add the information to the variable

undo to before the operators

keep the information in the variable

import bpy


class test_vars(bpy.types.PropertyGroup):
    val_1 = bpy.props.StringProperty(
        name = "val_1",
        description = "1",
        default = "")


class DoSomethingWithVal(bpy.types.Operator):
    bl_idname = "test.dosomethingwithval"
    bl_label = "test"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        # do something
        pass

        return {'FINISHED'}


def register():
    bpy.utils.register_class(DoSomethingWithVal)
    bpy.utils.register_class(test_vars)
    bpy.types.Scene.do_something_vars = bpy.props.PointerProperty(type = test_vars)


def unregister():
    bpy.utils.unregister_class(DoSomethingWithVal)
    del bpy.types.Scene.do_something_vars


if __name__ == "__main__":
    register()

is it possible?

$\endgroup$
2
  • 1
    $\begingroup$ Possibly Related Maybe file io would be simpler. ie save to a file. A getter / setter on the Scene property to read / write to file. Should be immune to blender's undo. $\endgroup$
    – batFINGER
    Commented Mar 1, 2018 at 18:00
  • $\begingroup$ Wow, why didn't I think of that. Thank you so much that is genius. $\endgroup$
    – Way2Close
    Commented Mar 2, 2018 at 3:18

0

You must log in to answer this question.

Browse other questions tagged .