addons-contrib: objects.link/unlink syntax update
[blender-addons-contrib.git] / io_scene_map / export_map.py
index 5c310f7..cce1f26 100644 (file)
@@ -386,11 +386,12 @@ 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')
     for ob in objects:
-        ob.select = True
+        ob.select_set(True)
 
     bpy.ops.object.duplicate()
     objects = bpy.context.selected_objects
@@ -400,10 +401,10 @@ def split_objects(context, objects):
     tot_ob = len(objects)
     for i, ob in enumerate(objects):
         print("Splitting object: %d/%d" % (i, tot_ob))
-        ob.select = True
+        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")
@@ -442,7 +443,7 @@ def split_objects(context, objects):
                 bpy.ops.object.mode_set(mode='OBJECT')
             final_objects += split_objects
 
-        ob.select = False
+        ob.select_set(False)
 
     print(final_objects)
     return final_objects
@@ -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))