I’ve been porting an add-on from Blender 2.79 to 2.80 (although I am not a programmer, someone had to do this). Got most of the things sorted out except a few quality of life features.
This code below applies modifiers to the object(s) (selected mesh in Object mode), passes them to the functions that writes data into export file format and then deletes said objects. So I end up with empty scene (which isn’t what I want).
for object in bpy.context.selected_objects: if object.type == 'MESH': bpy.context.view_layer.objects.active = object object.select_set(True) if (self.option_copy): orig_mesh = object.data depsgraph = context.evaluated_depsgraph_get() object_eval = object.evaluated_get(depsgraph) meshes = [bpy.data.meshes.new_from_object(object_eval, preserve_all_data_layers=True)] bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Triangulate") for mesh in meshes: object_eval.data = mesh aseGeom += str(cGeomObject(object_eval)) object.data = mesh for mesh in meshes: bpy.data.meshes.remove(object.data) else: aseGeom = str( cGeomObject( object ) )
Can someone please modify this code so that modifiers are applied to the copy of the object, passed to the function, then the copy is deleted ? This way stuff gets exported and user ends up with intact scene.