[solved] Object disappears when changing Redo property

Hi all, I’m having a hard time finding what is going on when I change a property value in the redo panel.

Here’s where I’m stuck. I have a simple addon that takes a textured object:

And uses the remesh modifier, data transfer modifier, and some UV editing to produce a voxel version of the object:

When changing the octree depth after the fact though, it loses its UV information as if the Data Transfer part of the function is not working. However, I don’t get any error and according to a print statement it is indeed running.

One weird thing I’ve found: When I comment out lines 108-131, the mesh simply disappears. It’s not hidden or disabled, I’m still in Object mode, none of the mesh components are hidden in Edit mode, and I can see it in the outliner, but it’s otherwise gone. If I toggle into edit mode and back into object mode it comes back, but doing that in the function doesn’t seem to help. Any ideas would be appreciated!

class Voxelfy(Operator):
    bl_idname = "object.voxelfy"
    bl_label = "Voxelfy"
    bl_description = "Convert active object to voxelized mesh"
    bl_options = {'REGISTER', 'UNDO'}
    sourceName = bpy.props.StringProperty(
        name = "Source Object",
        options = {'HIDDEN'},
    targetName = bpy.props.StringProperty(
        name = "Target Object",
        options = {'HIDDEN'}
    voxelfyResolution = bpy.props.IntProperty(
        name = "Voxel Resolution", 
        default = 6, 
        min = 1, 
        max = 20, 
        description = "Octree Depth used for the Remesh modifier",
    def poll(cls, context):
        return context.object.select_get() and context.object.type == 'MESH' or context.object.type == 'CURVE'
    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)
    def execute(self, context):
        #set source and create target object
        self.sourceName = bpy.context.object.name
        source = bpy.data.objects[self.sourceName]
        bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
        bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'})
        bpy.context.object.name = source.name + "_voxelfied"
        self.targetName = bpy.context.object.name
        target = bpy.data.objects[self.targetName]

        #turn the target object into blocks
        target.modifiers["Remesh"].mode = 'BLOCKS'
        target.modifiers["Remesh"].octree_depth = self.voxelfyResolution
        target.modifiers["Remesh"].use_remove_disconnected = False
        bpy.ops.object.mode_set(mode='EDIT', toggle=False)
        bpy.ops.object.mode_set(mode='OBJECT', toggle=False)

        #transfer the source UV's to the target object
        target.modifiers["DataTransfer"].object = source
        target.modifiers["DataTransfer"].use_loop_data = True
        target.modifiers["DataTransfer"].loop_mapping = 'POLYINTERP_LNORPROJ'
        target.modifiers["DataTransfer"].data_types_loops = {'UV'}
        bpy.ops.object.modifier_apply(apply_as='DATA', modifier="DataTransfer")
        #reduce each face to a single color
        bpy.ops.object.mode_set(mode='EDIT', toggle=False)
        bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
        bpy.context.area.ui_type = 'UV'
        bpy.context.scene.tool_settings.use_uv_select_sync = False
        bpy.context.space_data.pivot_point = 'INDIVIDUAL_ORIGINS'

        count = 0
        while count < 100:
            bpy.ops.mesh.select_random(percent=count, seed=count)
            bpy.context.area.ui_type = 'UV'
            bpy.ops.transform.resize(value=(0.0001, 0.0001, 0.0001))
            count += 1

        #return to previous context
        bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
        source.hide_viewport = True
        return {'FINISHED'}

EDIT: I’ve updated the class and property names to conform to the 2.8 conventions, but that does not affect this issue.

Whatever it was seems to have been fixed in the latest build :tada: