addons-contrib: objects.link/unlink syntax update
[blender-addons-contrib.git] / io_scene_map / export_map.py
index 0660eb3..cce1f26 100644 (file)
@@ -386,6 +386,7 @@ def write_node_map(fw, ob):
 
 def split_objects(context, objects):
     scene = context.scene
+    view_layer = context.view_layer
     final_objects = []
 
     bpy.ops.object.select_all(action='DESELECT')
@@ -403,7 +404,7 @@ def split_objects(context, objects):
         ob.select_set(True)
 
         if ob.type == "MESH":
-            scene.objects.active = ob
+            view_layer.objects.active = ob
             bpy.ops.object.mode_set(mode='EDIT')
             bpy.ops.mesh.select_all(action='DESELECT')
             bpy.ops.mesh.select_mode(type='EDGE')
@@ -420,7 +421,7 @@ def split_objects(context, objects):
             for split_ob in split_objects:
                 assert(split_ob.type == "MESH")
 
-                scene.objects.active = split_ob
+                view_layer.objects.active = split_ob
                 bpy.ops.object.mode_set(mode='EDIT')
                 bpy.ops.mesh.select_mode(type='EDGE')
                 bpy.ops.mesh.select_all(action="SELECT")
@@ -476,6 +477,7 @@ def export_map(context, filepath):
     print("Map Exporter 0.0")
 
     scene = context.scene
+    collection = context.collection
     objects = context.selected_objects
 
     obs_mesh = []
@@ -656,7 +658,7 @@ def export_map(context, filepath):
                 print("\t\tignoring %s" % ob.name)
 
     for ob in obs_mesh:
-        scene.objects.unlink(ob)
+        collection.objects.unlink(ob)
         bpy.data.objects.remove(ob)
 
     print("Exported Map in %.4fsec" % (time.time() - t))