I've added PropertyGroup with CollectionProperty of custom type and define operator for adding/removing items to this property. And User list (bpy.types.UIList) to check changes in this CollectionProperty.

Everything works fine, but undo functionality work with this operator, except changes for adding/removing CollectionProperty items. I wonder is this bug, or i should check my code?

Partial code for PropertyGroup(is this to complex data for UNDO?):

class FaceGroupsPropGroup(bpy.types.PropertyGroup):
    reg_index = 2

    def register(self):
        bpy.types.Mesh.face_groups = bpy.props.CollectionProperty(
            name="Face groups",
            description="Face groups",
        self.fusion_mstates = bpy.props.CollectionProperty(type=FusionStates)

        bpy.types.Mesh.fgroup_active_index = bpy.props.IntProperty(name="Active index",

        bpy.types.Scene.fgroups_live = bpy.props.BoolProperty(default=False)
        bpy.types.Scene.fg_smooth_iterations = bpy.props.IntProperty(min=0)
        bpy.types.Scene.fg_fatten = bpy.props.FloatProperty()
        self.name = bpy.props.StringProperty(name="Name", default="Group")
        self.wm = bpy.props.FloatVectorProperty(name="World matrix", size=16, subtype='MATRIX')

        self.color = bpy.props.FloatVectorProperty(name="Color",
                                                   subtype='COLOR_GAMMA', min=0.0, max=1.0,
                                                   default=[0.0, 0.0, 0.0], update=self.on_color_update)

        self.strokes_ids = bpy.props.IntVectorProperty(name="Strokes", size=6, default=(0, 0, 0, 0, 0, 0))
  • $\begingroup$ Code example for this are bit complex i can make simple one, if needed. Also, i have same problem with undo for changing data per-edge in its layer(added with :bm.edges.layers.int.new("TempLayer")) $\endgroup$ – Yurii Sivalnev Sep 27 '18 at 5:34
  • $\begingroup$ I have also experienced this problem with PropertyGroup and was not able to find a solution $\endgroup$ – patmo141 Nov 30 '19 at 17:29

Your operator should define bl_options = {"UNDO"}:

class MyOperator(bpy.types.Operator):
    bl_options = {"UNDO"}

See https://docs.blender.org/api/2.79/bpy.types.Operator.html?highlight=bl_options#bpy.types.Operator.bl_options

  • 1
    $\begingroup$ Could be some issues without using register also bl_optons = {'REGISTER', 'UNDO'} $\endgroup$ – batFINGER Sep 27 '18 at 11:45
  • $\begingroup$ this flag already theire, as i`ve wrote undo works for operator. But only partially - it do not undo property changes. $\endgroup$ – Yurii Sivalnev Sep 27 '18 at 13:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.