diff --git a/add_dimension.py b/add_dimension.py
index 090f16f2f992442b3958768fa0c28f6ad45b2c8c..08b6e0975d4ae6e8e05592d9f62d1248b1e69b52 100644
--- a/add_dimension.py
+++ b/add_dimension.py
@@ -1770,7 +1770,7 @@ def createCurve(vertArray, self, align_matrix):
     bpy.ops.object.select_all(action='DESELECT')
     DimensionCurve.select_set(True)
     DimensionText.select_set(True)
-    bpy.context.scene.objects.active = DimensionCurve
+    bpy.context.view_layer.objects.active = DimensionCurve
     bpy.context.scene.update()
 
     DimensionCurve.Dimension_Name = self.Dimension_Name
diff --git a/add_mesh_castle/Castle.py b/add_mesh_castle/Castle.py
index 465e9c2281cef641796fcfd798219c1339a1e4dc..343e218fc268a18f7bf302cc1ed77328c7bfdf9c 100644
--- a/add_mesh_castle/Castle.py
+++ b/add_mesh_castle/Castle.py
@@ -1724,7 +1724,7 @@ class add_castle(bpy.types.Operator):
             cDomeObj.parent = castleObj  # Connect to parent
 
         castleObj.select_set(True)
-        context.scene.objects.active = castleObj
+        context.view_layer.objects.active = castleObj
 
         return {'FINISHED'}
 
diff --git a/add_mesh_clusters/__init__.py b/add_mesh_clusters/__init__.py
index 971171e0ac6d10dbfb6250d60c36d3bf693f34b0..ef2a29a08557fb640cf66b58bda31f38ca584d45 100644
--- a/add_mesh_clusters/__init__.py
+++ b/add_mesh_clusters/__init__.py
@@ -351,7 +351,7 @@ def DEF_atom_draw_atoms(prop_element,
                             location=(0,0,0), rotation=(0.0, 0.0, 0.0),
                             layers=current_layers)
 
-    ball = bpy.context.scene.objects.active
+    ball = bpy.context.view_layer.objects.active
     ball.scale  = (radii[int(prop_radius_type)]*prop_scale_radius,) * 3
 
     ball.active_material = material
@@ -362,7 +362,7 @@ def DEF_atom_draw_atoms(prop_element,
     # SELECT ALL LOADED OBJECTS
     bpy.ops.object.select_all(action='DESELECT')
     new_atom_mesh.select_set(True)
-    bpy.context.scene.objects.active = new_atom_mesh
+    bpy.context.view_layer.objects.active = new_atom_mesh
 
     return True
 
diff --git a/add_mesh_space_tree/__init__.py b/add_mesh_space_tree/__init__.py
index cf77a43783ac7bc2c10020aff5037ff48d30eef9..6938100b81220ec6fd3b696547749441f08d7aa0 100644
--- a/add_mesh_space_tree/__init__.py
+++ b/add_mesh_space_tree/__init__.py
@@ -569,7 +569,7 @@ def createGeometry(tree, power=0.5, scale=0.01, addleaves=False, pleaf=0.5,
     for ob in bpy.context.scene.objects:
         ob.select_set(False)
     base.select_set(True)
-    bpy.context.scene.objects.active = obj_new
+    bpy.context.view_layer.objects.active = obj_new
     bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
 
     timings.add('createmesh')
@@ -613,9 +613,9 @@ def createGeometry(tree, power=0.5, scale=0.01, addleaves=False, pleaf=0.5,
         obj_leaves = bpy.data.objects.new(mesh.name, mesh)
         base = bpy.context.scene.objects.link(obj_leaves)
         obj_leaves.parent = obj_new
-        bpy.context.scene.objects.active = obj_leaves
+        bpy.context.view_layer.objects.active = obj_leaves
         bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
-        bpy.context.scene.objects.active = obj_new
+        bpy.context.view_layer.objects.active = obj_new
 
     timings.add('leaves')
 
diff --git a/amaranth/render/meshlight_select.py b/amaranth/render/meshlight_select.py
index 00c30717f23edee53d3940074cf462730d82930d..b7c7c8863ad37dd659e6239877186e9a8067dfbd 100644
--- a/amaranth/render/meshlight_select.py
+++ b/amaranth/render/meshlight_select.py
@@ -40,9 +40,9 @@ class AMTH_OBJECT_OT_select_meshlights(bpy.types.Operator):
         for ob in context.scene.objects:
             if utils.cycles_is_emission(context, ob):
                 ob.select_set(True)
-                context.scene.objects.active = ob
+                context.view_layer.objects.active = ob
 
-        if not context.selected_objects and not context.scene.objects.active:
+        if not context.selected_objects and not context.view_layer.objects.active:
             self.report({"INFO"}, "No meshlights to select")
 
         return {"FINISHED"}
diff --git a/amaranth/scene/debug.py b/amaranth/scene/debug.py
index 4226e9ac84b8f151b41a356fbe4903a2fe998b20..50461feb985889fd9cf48489354e4a5b874d19ea 100755
--- a/amaranth/scene/debug.py
+++ b/amaranth/scene/debug.py
@@ -322,7 +322,7 @@ class AMTH_SCENE_OT_amaranth_object_select(Operator):
 
         bpy.ops.object.select_all(action="DESELECT")
         obj.select_set(True)
-        context.scene.objects.active = obj
+        context.view_layer.objects.active = obj
 
         return {"FINISHED"}
 
diff --git a/cmu_mocap_browser/makehuman.py b/cmu_mocap_browser/makehuman.py
index 7c8d84324c9e8f154b5dcff05399a2aef2e39ac9..381d598164e4afb9b633a5f50efe8700a91c1751 100644
--- a/cmu_mocap_browser/makehuman.py
+++ b/cmu_mocap_browser/makehuman.py
@@ -96,7 +96,7 @@ class CMUMocapAlignArmatures(bpy.types.Operator):
 
         # clear frame poses, leave source selected
         for o in self.dst, self.src:
-            context.scene.objects.active = o
+            context.view_layer.objects.active = o
             bpy.ops.object.mode_set(mode='POSE')
             bpy.ops.pose.select_all(action='SELECT')
             bpy.ops.pose.rot_clear()
@@ -237,7 +237,7 @@ class CMUMocapTransferer(bpy.types.Operator):
         DPB = self.dst.pose.bones
         self.set_inverses()
         context.scene.frame_set(0)
-        context.scene.objects.active = self.dst
+        context.view_layer.objects.active = self.dst
         bpy.ops.object.mode_set(mode='POSE')
         bpy.ops.pose.select_all(action='DESELECT')
         for sb, db, cc in [
diff --git a/io_atomblend_utilities/io_atomblend_utilities.py b/io_atomblend_utilities/io_atomblend_utilities.py
index 71f6c5c6a64588dd3ebe0befe3de39e1e291030a..0d9fd122f1c64c7a891754c96e31a52ef51b3be3 100644
--- a/io_atomblend_utilities/io_atomblend_utilities.py
+++ b/io_atomblend_utilities/io_atomblend_utilities.py
@@ -319,7 +319,7 @@ def modify_objects(action_type,
                                                'Sticks_Cylinder' in atom.name or
                                                'Stick_Cylinder' in atom.name):
 
-        bpy.context.scene.objects.active = atom
+        bpy.context.view_layer.objects.active = atom
         bpy.ops.object.mode_set(mode='EDIT', toggle=False)
         bm = bmesh.from_edit_mesh(atom.data)
 
@@ -339,7 +339,7 @@ def modify_objects(action_type,
             v.co[1] = ((v.co[1] - center[1]) / radius) * radius_new + center[1]
 
         bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
-        bpy.context.scene.objects.active = None
+        bpy.context.view_layer.objects.active = None
 
     # Replace atom objects
     if action_type == "ATOM_REPLACE_OBJ" and "Stick" not in atom.name:
@@ -453,14 +453,14 @@ def separate_atoms(scn):
         # duplication, move the new object onto the positions
         bpy.ops.object.select_all(action='DESELECT')
         atom.children[0].select_set(True)
-        bpy.context.scene.objects.active = atom.children[0]
+        bpy.context.view_layer.objects.active = atom.children[0]
         bpy.ops.object.duplicate_move()
-        new_atom = bpy.context.scene.objects.active
+        new_atom = bpy.context.view_layer.objects.active
         new_atom.parent = None
         new_atom.location = location
         new_atom.name = atom.name + "_sep"
 
-    bpy.context.scene.objects.active = atom
+    bpy.context.view_layer.objects.active = atom
 
 
 # Prepare a new material
@@ -636,7 +636,7 @@ def draw_obj(atom_shape, atom):
             rotation=(0, 0, 0),
             layers=current_layers)
 
-    new_atom = bpy.context.scene.objects.active
+    new_atom = bpy.context.view_layer.objects.active
     new_atom.scale = atom.scale + Vector((0.0,0.0,0.0))
     new_atom.name = atom.name + "_tmp"
     new_atom.select_set(True)
@@ -676,7 +676,7 @@ def draw_obj_special(atom_shape, atom):
                                         location=atom.location,
                                         rotation=(0.0, 0.0, 0.0),
                                         layers=current_layers)
-        cube = bpy.context.scene.objects.active
+        cube = bpy.context.view_layer.objects.active
         cube.scale = atom.scale + Vector((0.0,0.0,0.0))
         cube.name = atom.name + "_F2+-center"
         cube.select_set(True)
@@ -710,7 +710,7 @@ def draw_obj_special(atom_shape, atom):
                                         location=atom.location,
                                         rotation=(0.0, 0.0, 0.0),
                                         layers=current_layers)
-        cube = bpy.context.scene.objects.active
+        cube = bpy.context.view_layer.objects.active
         cube.scale = atom.scale + Vector((0.0,0.0,0.0))
         cube.name = atom.name + "_F+-center"
         cube.select_set(True)
@@ -731,7 +731,7 @@ def draw_obj_special(atom_shape, atom):
                                         location=(0.0, 0.0, 0.0),
                                         rotation=(0.0, 0.0, 0.0),
                                         layers=current_layers)
-        electron = bpy.context.scene.objects.active
+        electron = bpy.context.view_layer.objects.active
         electron.scale = scale
         electron.name = atom.name + "_F+_electron"
         electron.parent = cube
@@ -767,7 +767,7 @@ def draw_obj_special(atom_shape, atom):
                                         location=atom.location,
                                         rotation=(0.0, 0.0, 0.0),
                                         layers=current_layers)
-        cube = bpy.context.scene.objects.active
+        cube = bpy.context.view_layer.objects.active
         cube.scale = atom.scale + Vector((0.0,0.0,0.0))
         cube.name = atom.name + "_F0-center"
         cube.select_set(True)
@@ -788,7 +788,7 @@ def draw_obj_special(atom_shape, atom):
                                         location=(scale[0]*1.5,0.0,0.0),
                                         rotation=(0.0, 0.0, 0.0),
                                         layers=current_layers)
-        electron1 = bpy.context.scene.objects.active
+        electron1 = bpy.context.view_layer.objects.active
         electron1.scale = scale
         electron1.name = atom.name + "_F0_electron1"
         electron1.parent = cube
@@ -798,7 +798,7 @@ def draw_obj_special(atom_shape, atom):
                                         location=(-scale[0]*1.5,0.0,0.0),
                                         rotation=(0.0, 0.0, 0.0),
                                         layers=current_layers)
-        electron2 = bpy.context.scene.objects.active
+        electron2 = bpy.context.view_layer.objects.active
         electron2.scale = scale
         electron2.name = atom.name + "_F0_electron2"
         electron2.parent = cube
diff --git a/io_directx_bel/import_x.py b/io_directx_bel/import_x.py
index 6d3cecfdfb7fc69b02b6d4cddef068ba4e9b2228..7c7bb6413d654dc80b5f2cd125c29a98a1e62278 100644
--- a/io_directx_bel/import_x.py
+++ b/io_directx_bel/import_x.py
@@ -593,7 +593,7 @@ BINARY FORMAT
             arm = bpy.data.objects.new(armname,armdata)
             bpy.context.scene.objects.link(arm)
             arm.select_set(True)
-            bpy.context.scene.objects.active = arm
+            bpy.context.view_layer.objects.active = arm
             bpy.ops.object.mode_set(mode='EDIT')
             parent_matrix = Matrix()
 
diff --git a/io_mesh_xyz/import_xyz.py b/io_mesh_xyz/import_xyz.py
index 07640a05c97c86ddd9ddfd7d0f94f30777b65ee8..d6804f816edf3316bc336539f856d9980b2c67c2 100644
--- a/io_mesh_xyz/import_xyz.py
+++ b/io_mesh_xyz/import_xyz.py
@@ -638,7 +638,7 @@ def import_xyz(Ball_type,
                             enter_editmode=False, location=(0, 0, 0),
                             rotation=(0, 0, 0), layers=current_layers)
 
-        ball = bpy.context.scene.objects.active
+        ball = bpy.context.view_layer.objects.active
         ball.scale  = (atom.radius*Ball_radius_factor,) * 3
 
         if atom.name == "Vacancy":
@@ -661,7 +661,7 @@ def import_xyz(Ball_type,
         obj.select_set(True)
     # activate the last selected object (perhaps another should be active?)
     if obj:
-        bpy.context.scene.objects.active = obj
+        bpy.context.view_layer.objects.active = obj
 
 
 
@@ -673,7 +673,7 @@ def build_frames(frame_delta, frame_skip):
     for element in STRUCTURE:
 
         bpy.ops.object.select_all(action='DESELECT')
-        bpy.context.scene.objects.active = element
+        bpy.context.view_layer.objects.active = element
         element.select_set(True)
         bpy.ops.object.shape_key_add(True)
 
diff --git a/io_scene_cod/export_xanim.py b/io_scene_cod/export_xanim.py
index 39fdef2f345d258ab6e068f1e5cf3f14f57cef88..0e11ce04e273f40bc88dd6590aca374822b05132 100644
--- a/io_scene_cod/export_xanim.py
+++ b/io_scene_cod/export_xanim.py
@@ -52,7 +52,7 @@ def save(self, context, filepath="",
         last_mode = 'OBJECT'
 
         if bpy.data.objects:
-            context.scene.objects.active = bpy.data.objects[0]
+            context.view_layer.objects.active = bpy.data.objects[0]
         else:
             return "Nothing to export."
 
diff --git a/io_scene_cod/export_xmodel.py b/io_scene_cod/export_xmodel.py
index 5ad05add11c25690e38f97fd8e7fdf872362ce1e..47c8ca9cb157618b19a67ab8474b5e8b08cc0026 100644
--- a/io_scene_cod/export_xmodel.py
+++ b/io_scene_cod/export_xmodel.py
@@ -54,7 +54,7 @@ def save(self, context, filepath="",
 
         for ob in bpy.data.objects:
             if ob.type == 'MESH':
-                context.scene.objects.active = ob
+                context.view_layer.objects.active = ob
                 break
         else:
             return "No mesh to export."
diff --git a/mesh_ktools.py b/mesh_ktools.py
index 9867e1bf2f3bab61afd11d730118574d34e2c6bd..9de506b2b932fa06ea0e1667dcece6ba51ccf863 100644
--- a/mesh_ktools.py
+++ b/mesh_ktools.py
@@ -93,13 +93,13 @@ class lattice_to_selection(bpy.types.Operator):
                 interpolation = self.interpolation
 
                 # check if there exists an active object
-                if bpy.context.scene.objects.active:
-                    active_obj = bpy.context.scene.objects.active.name
+                if bpy.context.view_layer.objects.active:
+                    active_obj = bpy.context.view_layer.objects.active.name
                 else:
                     for x in bpy.context.selected_objects:
                         if bpy.data.objects[x.name].type == 'MESH':
-                            bpy.context.scene.objects.active = bpy.data.objects[x.name]
-                            active_obj = bpy.context.scene.objects.active.name
+                            bpy.context.view_layer.objects.active = bpy.data.objects[x.name]
+                            active_obj = bpy.context.view_layer.objects.active.name
                             break
 
 
@@ -159,7 +159,7 @@ class lattice_to_selection(bpy.types.Operator):
                     # select all the original objects and assign the lattice deformer
                     for i in org_objs:
                        if bpy.data.objects[i.name].type == 'MESH' :
-                           bpy.context.scene.objects.active = bpy.data.objects[i.name]
+                           bpy.context.view_layer.objects.active = bpy.data.objects[i.name]
                            bpy.data.objects[i.name].select_set(True)
 
                            bpy.ops.object.modifier_add(type='LATTICE')
@@ -175,14 +175,14 @@ class lattice_to_selection(bpy.types.Operator):
                     if parent_to:
 
                         bpy.data.objects[lattice_obj.name].select_set(True)
-                        bpy.context.scene.objects.active = bpy.data.objects[lattice_obj.name]
+                        bpy.context.view_layer.objects.active = bpy.data.objects[lattice_obj.name]
 
                         bpy.ops.object.parent_set(type='OBJECT', keep_transform=True)
                     else:
 
                         bpy.ops.object.select_all(action='DESELECT')
                         bpy.data.objects[lattice_obj.name].select_set(True)
-                        bpy.context.scene.objects.active = bpy.data.objects[lattice_obj.name]
+                        bpy.context.view_layer.objects.active = bpy.data.objects[lattice_obj.name]
 
 
                     bpy.context.object.data.interpolation_type_u = interpolation
@@ -221,7 +221,7 @@ class lattice_to_selection(bpy.types.Operator):
 
                     bpy.ops.object.select_all(action='DESELECT')
 
-                    bpy.context.scene.objects.active = bpy.data.objects[tmp_obj]
+                    bpy.context.view_layer.objects.active = bpy.data.objects[tmp_obj]
                     bpy.data.objects[tmp_obj].select_set(True)
 
 
@@ -252,7 +252,7 @@ class lattice_to_selection(bpy.types.Operator):
 
                     bpy.ops.object.delete(use_global=False)
 
-                    bpy.context.scene.objects.active = bpy.data.objects[active_obj]
+                    bpy.context.view_layer.objects.active = bpy.data.objects[active_obj]
                     bpy.data.objects[active_obj].select_set(True)
 
                     bpy.ops.object.modifier_add(type='LATTICE')
@@ -268,7 +268,7 @@ class lattice_to_selection(bpy.types.Operator):
                     bpy.ops.object.select_all(action='DESELECT')
 
                     bpy.data.objects[lattice_obj.name].select_set(True)
-                    bpy.context.scene.objects.active = bpy.data.objects[lattice_obj.name]
+                    bpy.context.view_layer.objects.active = bpy.data.objects[lattice_obj.name]
 
                     bpy.context.object.data.interpolation_type_u = interpolation
                     bpy.context.object.data.interpolation_type_v = interpolation
@@ -308,20 +308,20 @@ class calc_normals(bpy.types.Operator):
                 if mode == 'OBJECT':
 
                         sel = bpy.context.selected_objects
-                        active = bpy.context.scene.objects.active.name
+                        active = bpy.context.view_layer.objects.active.name
 
                         bpy.ops.object.shade_smooth()
 
 
                         for ob in sel:
                                 ob = ob.name
-                                bpy.context.scene.objects.active = bpy.data.objects[ob]
+                                bpy.context.view_layer.objects.active = bpy.data.objects[ob]
                                 bpy.ops.object.editmode_toggle()
                                 bpy.ops.mesh.select_all(action='SELECT')
                                 bpy.ops.mesh.normals_make_consistent(inside=invert)
                                 bpy.ops.object.editmode_toggle()
 
-                        bpy.context.scene.objects.active = bpy.data.objects[active]
+                        bpy.context.view_layer.objects.active = bpy.data.objects[active]
 
                 elif mode == 'EDIT':
                         bpy.ops.mesh.normals_make_consistent(inside=invert)
@@ -506,7 +506,7 @@ class quickbool(bpy.types.Operator):
                     bpy.ops.object.select_all(action='DESELECT')
                     bpy.ops.object.select_pattern(pattern=bool)
 
-                    bpy.context.scene.objects.active = bpy.data.objects[bool]
+                    bpy.context.view_layer.objects.active = bpy.data.objects[bool]
 
                     #Delete all geo inside Shrink_Object
                     bpy.ops.object.mode_set(mode = 'EDIT', toggle = False)
@@ -517,7 +517,7 @@ class quickbool(bpy.types.Operator):
                     bpy.ops.object.delete()
 
                     #re-enter edit mode on Original object
-                    bpy.context.scene.objects.active = bpy.data.objects[original]
+                    bpy.context.view_layer.objects.active = bpy.data.objects[original]
                     bpy.ops.object.select_pattern(pattern=original)
                     bpy.ops.object.editmode_toggle()
 
@@ -549,7 +549,7 @@ class quickbool(bpy.types.Operator):
 
                                         bpy.ops.object.select_all(action='DESELECT')
                                         bpy.ops.object.select_pattern(pattern=name)
-                                        bpy.context.scene.objects.active = bpy.data.objects[name]
+                                        bpy.context.view_layer.objects.active = bpy.data.objects[name]
 
                             #Delete all geo inside Shrink_Object
                                         bpy.ops.object.mode_set(mode = 'EDIT', toggle = False)
@@ -558,11 +558,11 @@ class quickbool(bpy.types.Operator):
                                         bpy.ops.object.mode_set(mode = 'OBJECT', toggle = False)
 
                                         bpy.ops.object.delete(use_global=False)
-                                        bpy.context.scene.objects.active = bpy.data.objects[original]
+                                        bpy.context.view_layer.objects.active = bpy.data.objects[original]
                                 else:
                                         bpy.ops.object.select_all(action='DESELECT')
                                         bpy.ops.object.select_pattern(pattern=name)
-                                        bpy.context.scene.objects.active = bpy.data.objects[name]
+                                        bpy.context.view_layer.objects.active = bpy.data.objects[name]
 
                                         bpy.context.object.display_type = 'WIRE'
 
@@ -570,7 +570,7 @@ class quickbool(bpy.types.Operator):
                                         if move_to == True:
                                                 bpy.ops.object.move_to_layer(layers=(False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False))
 
-                                        bpy.context.scene.objects.active = bpy.data.objects[original]
+                                        bpy.context.view_layer.objects.active = bpy.data.objects[original]
 
 
                         bpy.ops.object.mode_set(mode=mode, toggle=False)
@@ -965,7 +965,7 @@ class shrinkwrapSmooth(bpy.types.Operator):
 
                 bpy.ops.object.select_all(action='DESELECT')
                 bpy.ops.object.select_pattern(pattern=tmp_ob)
-                bpy.context.scene.objects.active = bpy.data.objects[tmp_ob]
+                bpy.context.view_layer.objects.active = bpy.data.objects[tmp_ob]
 
                 bpy.ops.object.mode_set(mode = 'EDIT', toggle = False)
                 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
@@ -1029,7 +1029,7 @@ class shrinkwrapSmooth(bpy.types.Operator):
 
                 bpy.ops.object.select_all(action='DESELECT')
                 bpy.ops.object.select_pattern(pattern=shrink_ob)
-                bpy.context.scene.objects.active = bpy.data.objects[shrink_ob]
+                bpy.context.view_layer.objects.active = bpy.data.objects[shrink_ob]
 
                 #Delete all geo inside Shrink_Object
                 bpy.ops.object.mode_set(mode = 'EDIT', toggle = False)
@@ -1040,7 +1040,7 @@ class shrinkwrapSmooth(bpy.types.Operator):
                 bpy.ops.object.delete(use_global=True)
 
                 bpy.ops.object.select_pattern(pattern=tmp_ob)
-                bpy.context.scene.objects.active = bpy.data.objects[tmp_ob]
+                bpy.context.view_layer.objects.active = bpy.data.objects[tmp_ob]
 
 
                 bpy.ops.object.mode_set(mode = 'EDIT', toggle = False)
@@ -1055,7 +1055,7 @@ class shrinkwrapSmooth(bpy.types.Operator):
 
 
                 bpy.ops.object.select_pattern(pattern=org_ob)
-                bpy.context.scene.objects.active = bpy.data.objects[org_ob]
+                bpy.context.view_layer.objects.active = bpy.data.objects[org_ob]
 
                 bpy.ops.object.mode_set(mode = 'EDIT', toggle = False)
 
diff --git a/np_station/np_float_box.py b/np_station/np_float_box.py
index 755517289bdd4a136ba28c3aa13ad995816b0adc..65bd4cd9c35c0f237869267a6d7acfd03cc8cbf0 100644
--- a/np_station/np_float_box.py
+++ b/np_station/np_float_box.py
@@ -219,7 +219,7 @@ class NPFBPrepareContext(bpy.types.Operator):
             helper = NP020FB.helper
             bpy.ops.object.select_all(action = 'DESELECT')
             helper.select_set(True)
-            bpy.context.scene.objects.active = helper
+            bpy.context.view_layer.objects.active = helper
             bpy.context.tool_settings.use_snap = False
             bpy.context.tool_settings.snap_element = 'VERTEX'
             bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -270,7 +270,7 @@ class NPFBPrepareContext(bpy.types.Operator):
             bpy.ops.transform.rotate(value = rot_ang ,axis = rot_axis)
             NP020FB.trans_custom = True
             bpy.ops.transform.create_orientation(use = True)
-            bpy.context.scene.objects.active = helper
+            bpy.context.view_layer.objects.active = helper
             bpy.context.tool_settings.use_snap = False
             bpy.context.tool_settings.snap_element = 'VERTEX'
             bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -278,7 +278,7 @@ class NPFBPrepareContext(bpy.types.Operator):
 
         elif flag in ('RUNTRANS2', 'RUNTRANS3'):
             helper = NP020FB.helper
-            bpy.context.scene.objects.active = helper
+            bpy.context.view_layer.objects.active = helper
             bpy.context.tool_settings.use_snap = False
             bpy.context.tool_settings.snap_element = 'VERTEX'
             bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -731,11 +731,11 @@ class NPFBRestoreContext(bpy.types.Operator):
             for ob in selob:
                 ob.select_set(True)
             if NP020FB.acob is not None:
-                bpy.context.scene.objects.active = NP020FB.acob
+                bpy.context.view_layer.objects.active = NP020FB.acob
                 bpy.ops.object.mode_set(mode = NP020FB.edit_mode)
         else:
             boxob.select_set(True)
-            bpy.context.scene.objects.active = boxob
+            bpy.context.view_layer.objects.active = boxob
             bpy.ops.object.mode_set(mode = NP020FB.edit_mode)
         if NP020FB.trans_custom: bpy.ops.transform.delete_orientation()
         bpy.context.tool_settings.use_snap = NP020FB.use_snap
diff --git a/np_station/np_float_poly.py b/np_station/np_float_poly.py
index f30a1a236f79f62457ed5cf1f041a03446404905..5cc426ef20e78652a4c7430268a3e8554d72392a 100644
--- a/np_station/np_float_poly.py
+++ b/np_station/np_float_poly.py
@@ -690,7 +690,7 @@ class NPFPRunTranslate(bpy.types.Operator):
             bpy.context.tool_settings.snap_target = NP020FP.snap_target
             bpy.context.space_data.pivot_point = NP020FP.pivot_point
             if NP020FP.acob is not None:
-                bpy.context.scene.objects.active = NP020FP.acob
+                bpy.context.view_layer.objects.active = NP020FP.acob
                 bpy.ops.object.mode_set(mode=NP020FP.edit_mode)
             np_print('04_run_TRANS_esc_right_CANCELLED')
 
@@ -722,7 +722,7 @@ class NPFPRunTranslate(bpy.types.Operator):
             bpy.context.space_data.pivot_point = NP020FP.pivot_point
             bpy.context.space_data.transform_orientation = NP020FP.trans_orient
             if NP020FP.acob is not None:
-                bpy.context.scene.objects.active = NP020FP.acob
+                bpy.context.view_layer.objects.active = NP020FP.acob
                 bpy.ops.object.mode_set(mode=NP020FP.edit_mode)
             np_print('04_run_TRANS_esc_right_CANCELLED')
             return{'CANCELLED'}
@@ -1200,7 +1200,7 @@ class NPFPRunNavigate(bpy.types.Operator):
             bpy.context.space_data.transform_orientation = NP020FP.trans_orient
 
             if NP020FP.acob is not None:
-                bpy.context.scene.objects.active = NP020FP.acob
+                bpy.context.view_layer.objects.active = NP020FP.acob
                 bpy.ops.object.mode_set(mode=NP020FP.edit_mode)
             np_print('05_run_NAV_esc_right_any_CANCELLED')
             return{'CANCELLED'}
@@ -1344,12 +1344,12 @@ class NPFPMakeSegment(bpy.types.Operator):
             polyob.select = True
             bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
             NP020FP.polyob = polyob
-        bpy.context.scene.objects.active = polyob
+        bpy.context.view_layer.objects.active = polyob
         bpy.ops.object.mode_set(mode='EDIT')
         bpy.ops.mesh.select_all(action='SELECT')
         bpy.ops.mesh.remove_doubles()
         bpy.ops.object.mode_set(mode='OBJECT')
-        bpy.context.scene.objects.active = end
+        bpy.context.view_layer.objects.active = end
         start.location = endloc3d
         end.location = endloc3d
         bpy.ops.object.select_all(action='DESELECT')
@@ -1413,7 +1413,7 @@ class NPFPDeletePoints(bpy.types.Operator):
         bpy.context.space_data.pivot_point = NP020FP.pivot_point
         bpy.context.space_data.transform_orientation = NP020FP.trans_orient
         if NP020FP.acob is not None:
-            bpy.context.scene.objects.active = NP020FP.acob
+            bpy.context.view_layer.objects.active = NP020FP.acob
             bpy.ops.object.mode_set(mode=NP020FP.edit_mode)
         return {'FINISHED'}
 
@@ -1816,7 +1816,7 @@ class NPFPRunNavEx(bpy.types.Operator):
             bpy.context.space_data.pivot_point = NP020FP.pivot_point
             bpy.context.space_data.transform_orientation = NP020FP.trans_orient
             if NP020FP.acob is not None:
-                bpy.context.scene.objects.active = NP020FP.acob
+                bpy.context.view_layer.objects.active = NP020FP.acob
                 bpy.ops.object.mode_set(mode=NP020FP.edit_mode)
             np_print('05_run_NAVEX_esc_right_any_CANCELLED')
             return{'CANCELLED'}
@@ -2158,7 +2158,7 @@ class NPFPRunExtrude(bpy.types.Operator):
             bpy.context.space_data.pivot_point = NP020FP.pivot_point
             bpy.context.space_data.transform_orientation = NP020FP.trans_orient
             if NP020FP.acob is not None:
-                bpy.context.scene.objects.active = NP020FP.acob
+                bpy.context.view_layer.objects.active = NP020FP.acob
                 bpy.ops.object.mode_set(mode=NP020FP.edit_mode)
             np_print('10_run_EXTRUDE_space_FINISHED_flag_TRANSLATE')
             return{'FINISHED'}
@@ -2192,7 +2192,7 @@ class NPFPRunExtrude(bpy.types.Operator):
             bpy.context.space_data.pivot_point = NP020FP.pivot_point
             bpy.context.space_data.transform_orientation = NP020FP.trans_orient
             if NP020FP.acob is not None:
-                bpy.context.scene.objects.active = NP020FP.acob
+                bpy.context.view_layer.objects.active = NP020FP.acob
                 bpy.ops.object.mode_set(mode=NP020FP.edit_mode)
             np_print('10_run_EXTRUDE_space_CANCELLED_flag_TRANSLATE')
             return{'CANCELLED'}
@@ -2212,7 +2212,7 @@ class NPFPRunExtrude(bpy.types.Operator):
             if context.area.type == 'VIEW_3D':
                 if bpy.context.mode == 'OBJECT':
                     bpy.ops.object.select_all(action='DESELECT')
-                    bpy.context.scene.objects.active = polyob
+                    bpy.context.view_layer.objects.active = polyob
                     polyob.select = True
                     bpy.ops.object.mode_set(mode='EDIT')
                     polyme = polyob.data
@@ -2291,7 +2291,7 @@ class NPFPRunBevel(bpy.types.Operator):
             bpy.context.space_data.pivot_point = NP020FP.pivot_point
             bpy.context.space_data.transform_orientation = NP020FP.trans_orient
             if NP020FP.acob is not None:
-                bpy.context.scene.objects.active = NP020FP.acob
+                bpy.context.view_layer.objects.active = NP020FP.acob
                 bpy.ops.object.mode_set(mode=NP020FP.edit_mode)
             np_print('10_run_EXTRUDE_left_release_FINISHED')
             return{'FINISHED'}
@@ -2322,7 +2322,7 @@ class NPFPRunBevel(bpy.types.Operator):
             bpy.context.space_data.pivot_point = NP020FP.pivot_point
             bpy.context.space_data.transform_orientation = NP020FP.trans_orient
             if NP020FP.acob is not None:
-                bpy.context.scene.objects.active = NP020FP.acob
+                bpy.context.view_layer.objects.active = NP020FP.acob
                 bpy.ops.object.mode_set(mode=NP020FP.edit_mode)
             np_print('11_run_BEVEL_esc_CANCELLED')
             return{'CANCELLED'}
@@ -2341,7 +2341,7 @@ class NPFPRunBevel(bpy.types.Operator):
 
         if flag == 'BEVEL' and bevel:
             if context.area.type == 'VIEW_3D':
-                bpy.context.scene.objects.active = polyob
+                bpy.context.view_layer.objects.active = polyob
                 bpy.ops.mesh.select_all(action='SELECT')
                 args = (self, context)
                 NP020FP.main_BEVEL = 'DESIGNATE BEVEL AMOUNT'
@@ -2378,7 +2378,7 @@ class NPFPRunBevel(bpy.types.Operator):
             bpy.context.space_data.pivot_point = NP020FP.pivot_point
             bpy.context.space_data.transform_orientation = NP020FP.trans_orient
             if NP020FP.acob is not None:
-                bpy.context.scene.objects.active = NP020FP.acob
+                bpy.context.view_layer.objects.active = NP020FP.acob
                 bpy.ops.object.mode_set(mode=NP020FP.edit_mode)
             np_print('11_run_BEVEL_INVOKE_a_FINISHED')
             return {'FINISHED'}
diff --git a/np_station/np_float_rectangle.py b/np_station/np_float_rectangle.py
index fed86fbf67b644ada24ca7e3a255b1e548c625f6..9ac0c6e7d7233f5ae772d4abf0aa01897e2b4e38 100644
--- a/np_station/np_float_rectangle.py
+++ b/np_station/np_float_rectangle.py
@@ -218,7 +218,7 @@ class NPFRPrepareContext(bpy.types.Operator):
             helper = NP020FR.helper
             bpy.ops.object.select_all(action = 'DESELECT')
             helper.select_set(True)
-            bpy.context.scene.objects.active = helper
+            bpy.context.view_layer.objects.active = helper
             bpy.context.tool_settings.use_snap = False
             bpy.context.tool_settings.snap_element = 'VERTEX'
             bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -269,7 +269,7 @@ class NPFRPrepareContext(bpy.types.Operator):
             bpy.ops.transform.rotate(value = rot_ang ,axis = rot_axis)
             NP020FR.trans_custom = True
             bpy.ops.transform.create_orientation(use = True)
-            bpy.context.scene.objects.active = helper
+            bpy.context.view_layer.objects.active = helper
             bpy.context.tool_settings.use_snap = False
             bpy.context.tool_settings.snap_element = 'VERTEX'
             bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -278,7 +278,7 @@ class NPFRPrepareContext(bpy.types.Operator):
         elif flag == 'RUNTRANS2':
             helper = NP020FR.helper
             ndef = NP020FR.ndef
-            bpy.context.scene.objects.active = helper
+            bpy.context.view_layer.objects.active = helper
             bpy.context.tool_settings.use_snap = False
             bpy.context.tool_settings.snap_element = 'VERTEX'
             bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -685,11 +685,11 @@ class NPFRRestoreContext(bpy.types.Operator):
             for ob in selob:
                 ob.select_set(True)
             if NP020FR.acob is not None:
-                bpy.context.scene.objects.active = NP020FR.acob
+                bpy.context.view_layer.objects.active = NP020FR.acob
                 bpy.ops.object.mode_set(mode = NP020FR.edit_mode)
         else:
             recob.select_set(True)
-            bpy.context.scene.objects.active = recob
+            bpy.context.view_layer.objects.active = recob
             bpy.ops.object.mode_set(mode = NP020FR.edit_mode)
         if NP020FR.trans_custom: bpy.ops.transform.delete_orientation()
         bpy.context.tool_settings.use_snap = NP020FR.use_snap
diff --git a/np_station/np_point_align.py b/np_station/np_point_align.py
index 88c5f770e7b72f8f667e71480fbcf93f89fb4313..7744f0820434df6751a37e0a1e2d8c164bb67145 100644
--- a/np_station/np_point_align.py
+++ b/np_station/np_point_align.py
@@ -179,7 +179,7 @@ class NPPLPrepareContext(bpy.types.Operator):
 
         bpy.ops.object.select_all(action = 'DESELECT')
         helper.select_set(True)
-        bpy.context.scene.objects.active = helper
+        bpy.context.view_layer.objects.active = helper
         bpy.context.tool_settings.use_snap = False
         bpy.context.tool_settings.snap_element = 'VERTEX'
         bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -629,7 +629,7 @@ class NPPLRestoreContext(bpy.types.Operator):
         for ob in selob:
             ob.select_set(True)
         if NP020PL.acob is not None:
-            bpy.context.scene.objects.active = NP020PL.acob
+            bpy.context.view_layer.objects.active = NP020PL.acob
             bpy.ops.object.mode_set(mode = NP020PL.edit_mode)
         bpy.context.tool_settings.use_snap = NP020PL.use_snap
         bpy.context.tool_settings.snap_element = NP020PL.snap_element
diff --git a/np_station/np_point_array.py b/np_station/np_point_array.py
index ae05ecf0398423bbdbb377011207320b9b068147..b8b7e633b4dbe2d8092ae21026885b559ab6d7e4 100644
--- a/np_station/np_point_array.py
+++ b/np_station/np_point_array.py
@@ -248,7 +248,7 @@ class NPPAPrepareContext(bpy.types.Operator):
         place = NP020PA.place
         take.select_set(True)
         place.select_set(True)
-        bpy.context.scene.objects.active = place
+        bpy.context.view_layer.objects.active = place
         bpy.context.tool_settings.use_snap = False
         bpy.context.tool_settings.snap_element = 'VERTEX'
         bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -879,7 +879,7 @@ class NPPAArrayTranslate(bpy.types.Operator):
             for i, ob in enumerate(selob):
                 ob.select_set(True)
                 if i == lenselob-1:
-                    bpy.context.scene.objects.active = ob
+                    bpy.context.view_layer.objects.active = ob
             args = (self, context)
             self._handle = bpy.types.SpaceView3D.draw_handler_add(DRAW_ArrayTranslate, args, 'WINDOW', 'POST_PIXEL')
             context.window_manager.modal_handler_add(self)
@@ -1058,7 +1058,7 @@ class NPPARestoreContext(bpy.types.Operator):
         for i, ob in enumerate(selob):
             ob.select_set(True)
             if i == lenselob-1:
-                bpy.context.scene.objects.active = ob
+                bpy.context.view_layer.objects.active = ob
         NP020PA.take = None
         NP020PA.place = None
         NP020PA.takeloc3d = (0.0,0.0,0.0)
@@ -1077,7 +1077,7 @@ class NPPARestoreContext(bpy.types.Operator):
         bpy.context.space_data.pivot_point = NP020PA.pivot_point
         bpy.context.space_data.transform_orientation = NP020PA.trans_orient
         if NP020PA.acob is not None:
-            bpy.context.scene.objects.active = NP020PA.acob
+            bpy.context.view_layer.objects.active = NP020PA.acob
             bpy.ops.object.mode_set(mode = NP020PA.edit_mode)
 
         np_print('07_CleanExit_FINISHED',';','flag = ', NP020PA.flag)
diff --git a/np_station/np_point_copy.py b/np_station/np_point_copy.py
index 5d6a2d989ae50c7fe60190c0ccc9bd255c9508c0..45ee39852b1486e64e45a20b6067677e0e0bc764 100644
--- a/np_station/np_point_copy.py
+++ b/np_station/np_point_copy.py
@@ -248,7 +248,7 @@ class NPPCPrepareContext(bpy.types.Operator):
         place = NP020PC.place
         take.select_set(True)
         place.select_set(True)
-        bpy.context.scene.objects.active = place
+        bpy.context.view_layer.objects.active = place
         bpy.context.tool_settings.use_snap = False
         bpy.context.tool_settings.snap_element = 'VERTEX'
         bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -1144,7 +1144,7 @@ class NPPCRestoreContext(bpy.types.Operator):
         for i, ob in enumerate(selob):
             ob.select_set(True)
             if i == lenselob-1:
-                bpy.context.scene.objects.active = ob
+                bpy.context.view_layer.objects.active = ob
         NP020PC.take = None
         NP020PC.place = None
         NP020PC.takeloc3d = (0.0,0.0,0.0)
diff --git a/np_station/np_point_distance.py b/np_station/np_point_distance.py
index 053c180aa4f78e35cd2cff77dbe63f8a532c81d7..b2bfadc50fffb18650442886258d8a1528dea4f6 100644
--- a/np_station/np_point_distance.py
+++ b/np_station/np_point_distance.py
@@ -958,7 +958,7 @@ class NP020PDRunTranslate(bpy.types.Operator):
             bpy.context.space_data.transform_orientation = NP020PD.trans_orient
             bpy.context.space_data.show_manipulator = NP020PD.show_manipulator
             if NP020PD.acob is not None:
-                bpy.context.scene.objects.active = NP020PD.acob
+                bpy.context.view_layer.objects.active = NP020PD.acob
                 bpy.ops.object.mode_set(mode=NP020PD.edit_mode)
             np_print('04_run_TRANS_esc_right_CANCELLED')
             return{'CANCELLED'}
@@ -1329,7 +1329,7 @@ class NP020PDRunNavigate(bpy.types.Operator):
             bpy.context.space_data.transform_orientation = NP020PD.trans_orient
             bpy.context.space_data.show_manipulator = NP020PD.show_manipulator
             if NP020PD.acob is not None:
-                bpy.context.scene.objects.active = NP020PD.acob
+                bpy.context.view_layer.objects.active = NP020PD.acob
                 bpy.ops.object.mode_set(mode=NP020PD.edit_mode)
             np_print('05_run_NAV_esc_right_any_CANCELLED')
             return{'CANCELLED'}
@@ -1436,7 +1436,7 @@ class NP020PDHoldResult(bpy.types.Operator):
             bpy.context.space_data.transform_orientation = NP020PD.trans_orient
             bpy.context.space_data.show_manipulator = NP020PD.show_manipulator
             if NP020PD.acob is not None:
-                bpy.context.scene.objects.active = NP020PD.acob
+                bpy.context.view_layer.objects.active = NP020PD.acob
                 bpy.ops.object.mode_set(mode=NP020PD.edit_mode)
             np_print('07_HOLD_esc_right_CANCELLED')
             return{'CANCELLED'}
@@ -1522,7 +1522,7 @@ class NP020PDDeletePoints(bpy.types.Operator):
         bpy.context.space_data.transform_orientation = NP020PD.trans_orient
         bpy.context.space_data.show_manipulator = NP020PD.show_manipulator
         if NP020PD.acob is not None:
-            bpy.context.scene.objects.active = NP020PD.acob
+            bpy.context.view_layer.objects.active = NP020PD.acob
             bpy.ops.object.mode_set(mode=NP020PD.edit_mode)
 
         if step == 'simple':
diff --git a/np_station/np_point_instance.py b/np_station/np_point_instance.py
index 36d24f95b39b836c91dcc339c9d56c929588500d..56e2dcff718027369e8ca2dc7c3f4778e33cd313 100644
--- a/np_station/np_point_instance.py
+++ b/np_station/np_point_instance.py
@@ -248,7 +248,7 @@ class NPPIPrepareContext(bpy.types.Operator):
         place = NP020PI.place
         take.select_set(True)
         place.select_set(True)
-        bpy.context.scene.objects.active = place
+        bpy.context.view_layer.objects.active = place
         bpy.context.tool_settings.use_snap = False
         bpy.context.tool_settings.snap_element = 'VERTEX'
         bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -313,7 +313,7 @@ class NPPIRunTranslate(bpy.types.Operator):
                 NP020PI.nextob = bpy.context.selected_objects
                 take.location = copy.deepcopy(place.location)
                 place.select_set(True)
-                bpy.context.scene.objects.active = place
+                bpy.context.view_layer.objects.active = place
                 NP020PI.flag = 'RUNTRANSNEXT_break'
             elif flag == 'RUNTRANSNEXT':
                 NP020PI.deltavec_safe = copy.deepcopy(NP020PI.deltavec)
@@ -1154,7 +1154,7 @@ class NPPIRestoreContext(bpy.types.Operator):
         for i, ob in enumerate(selob):
             ob.select_set(True)
             if i == lenselob-1:
-                bpy.context.scene.objects.active = ob
+                bpy.context.view_layer.objects.active = ob
         NP020PI.take = None
         NP020PI.place = None
         NP020PI.takeloc3d = (0.0,0.0,0.0)
diff --git a/np_station/np_point_move.py b/np_station/np_point_move.py
index 13166e9a6d485eeac8295cf2c43e55b4f0379731..bdf0c1eb053903e0079db7f6fa08ef95c9789299 100644
--- a/np_station/np_point_move.py
+++ b/np_station/np_point_move.py
@@ -214,7 +214,7 @@ class NPPMPrepareContext(bpy.types.Operator):
         for ob in selob:
             ob.select_set(False)
         helper.select_set(True)
-        bpy.context.scene.objects.active = helper
+        bpy.context.view_layer.objects.active = helper
         bpy.context.tool_settings.use_snap = False
         bpy.context.tool_settings.snap_element = 'VERTEX'
         bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -268,7 +268,7 @@ class NPPMRunTranslate(bpy.types.Operator):
             elif flag == 'PLACE':
                 for ob in selob:
                     ob.select_set(True)
-                bpy.context.scene.objects.active = helper
+                bpy.context.view_layer.objects.active = helper
             args = (self, context)
             self._handle = bpy.types.SpaceView3D.draw_handler_add(DRAW_RunTranslate, args, 'WINDOW', 'POST_PIXEL')
             context.window_manager.modal_handler_add(self)
@@ -362,14 +362,14 @@ class NPPMRestoreContext(bpy.types.Operator):
         bpy.ops.object.delete('EXEC_DEFAULT')
         for ob in selob:
             ob.select_set(True)
-            bpy.context.scene.objects.active = ob
+            bpy.context.view_layer.objects.active = ob
         bpy.context.tool_settings.use_snap = NP020PM.use_snap
         bpy.context.tool_settings.snap_element = NP020PM.snap_element
         bpy.context.tool_settings.snap_target = NP020PM.snap_target
         bpy.context.space_data.pivot_point = NP020PM.pivot_point
         bpy.context.space_data.transform_orientation = NP020PM.trans_orient
         if NP020PM.acob is not None:
-            bpy.context.scene.objects.active = NP020PM.acob
+            bpy.context.view_layer.objects.active = NP020PM.acob
             bpy.ops.object.mode_set(mode = NP020PM.edit_mode)
         NP020PM.flag = 'TAKE'
         return {'FINISHED'}
diff --git a/np_station/np_point_scale.py b/np_station/np_point_scale.py
index b6e1c97cc76396da0eeca2c594a3cfc2bfd96700..f6b5d7bc539fa2e939316dbc2ed5b2967bd69896 100644
--- a/np_station/np_point_scale.py
+++ b/np_station/np_point_scale.py
@@ -284,7 +284,7 @@ class NPPSPrepareContext(bpy.types.Operator):
             bpy.context.space_data.transform_orientation = 'GLOBAL'
             for ob in selob:
                 ob.select_set(True)
-                bpy.context.scene.objects.active = ob
+                bpy.context.view_layer.objects.active = ob
             axis = (False, False, False)
             if mode == 0:
                 curloc = cage3d[6]
@@ -863,7 +863,7 @@ class NPPSRestoreContext(bpy.types.Operator):
         bpy.ops.object.select_all(action = 'DESELECT')
         for ob in selob:
             ob.select_set(True)
-            bpy.context.scene.objects.active = ob
+            bpy.context.view_layer.objects.active = ob
         bpy.context.tool_settings.use_snap = NP020PS.use_snap
         bpy.context.tool_settings.snap_element = NP020PS.snap_element
         bpy.context.tool_settings.snap_target = NP020PS.snap_target
@@ -872,7 +872,7 @@ class NPPSRestoreContext(bpy.types.Operator):
         if NP020PS.trans_custom: bpy.ops.transform.delete_orientation()
         bpy.context.scene.cursor_location = NP020PS.curloc
         if NP020PS.acob is not None:
-            bpy.context.scene.objects.active = NP020PS.acob
+            bpy.context.view_layer.objects.active = NP020PS.acob
             bpy.ops.object.mode_set(mode = NP020PS.edit_mode)
         NP020PS.flag = 'DISPLAY'
         return {'FINISHED'}
diff --git a/np_station/np_roto_move.py b/np_station/np_roto_move.py
index 832e5aa6cb5ae30c6ea55144ef71cafaa791008e..dc55a0532fd3abebec4dc3ff0280d14a76ec2336 100644
--- a/np_station/np_roto_move.py
+++ b/np_station/np_roto_move.py
@@ -193,7 +193,7 @@ class NPRMPrepareContext(bpy.types.Operator):
             #bpy.ops.transform.rotate(value = -rot_ang ,axis = rot_axis)
             for ob in selob:
                 ob.select_set(True)
-            bpy.context.scene.objects.active = helper
+            bpy.context.view_layer.objects.active = helper
             bpy.context.tool_settings.use_snap = False
             bpy.context.tool_settings.snap_element = 'VERTEX'
             bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -204,7 +204,7 @@ class NPRMPrepareContext(bpy.types.Operator):
             for ob in selob:
                 ob.select_set(False)
             helper.select_set(True)
-            bpy.context.scene.objects.active = helper
+            bpy.context.view_layer.objects.active = helper
             bpy.context.tool_settings.use_snap = False
             bpy.context.tool_settings.snap_element = 'VERTEX'
             bpy.context.tool_settings.snap_target = 'ACTIVE'
@@ -936,7 +936,7 @@ class NPRMRestoreContext(bpy.types.Operator):
         bpy.context.space_data.transform_orientation = NP020RM.trans_orient
         bpy.context.scene.cursor_location = NP020RM.curloc
         if NP020RM.acob is not None:
-            bpy.context.scene.objects.active = NP020RM.acob
+            bpy.context.view_layer.objects.active = NP020RM.acob
             bpy.ops.object.mode_set(mode = NP020RM.edit_mode)
         NP020RM.flag = 'RUNTRANSCENTER'
         return {'FINISHED'}
diff --git a/np_station/np_shader_brush.py b/np_station/np_shader_brush.py
index ec8321684eb27987f281cda1c320d3f9595e2690..1ea55e02ba9b6fac242b073dc1b02129d76004e5 100644
--- a/np_station/np_shader_brush.py
+++ b/np_station/np_shader_brush.py
@@ -77,8 +77,8 @@ def draw_callback1_px(self, context):
     elif mode == 4:
         instruct = 'paint material on object / objects'
         if hitob is not None:
-            acob = bpy.context.scene.objects.active
-            bpy.context.scene.objects.active = hitob
+            acob = bpy.context.view_layer.objects.active
+            bpy.context.view_layer.objects.active = hitob
             slots = hitob.material_slots
             for i, s in enumerate(slots):
                 hitob.active_material_index = i
@@ -89,14 +89,14 @@ def draw_callback1_px(self, context):
             if hitob.select_get() is True:
                 np_print('true')
                 for ob in self.selob:
-                    bpy.context.scene.objects.active = ob
+                    bpy.context.view_layer.objects.active = ob
                     slots = ob.material_slots
                     for i, s in enumerate(slots):
                         ob.active_material_index = i
                         bpy.ops.object.material_slot_remove()
                     if self.shader is not None:
                         ob.data.materials.append(self.shader)
-            bpy.context.scene.objects.active = acob
+            bpy.context.view_layer.objects.active = acob
             #bpy.context.scene.update()
             np_print('040')
 
@@ -129,7 +129,7 @@ def draw_callback1_px(self, context):
             else:
                 self.shader = None
                 self.shadername = 'None'
-            bpy.context.scene.objects.active = hitob
+            bpy.context.view_layer.objects.active = hitob
             hitob.active_material_index = matindex
             np_print('self.shader', self.shader)
             np_print('050')
@@ -143,8 +143,8 @@ def draw_callback1_px(self, context):
     elif mode == 7:
         instruct = 'paint material on single face'
         if hitob is not None:
-            acob = bpy.context.scene.objects.active
-            bpy.context.scene.objects.active = hitob
+            acob = bpy.context.view_layer.objects.active
+            bpy.context.view_layer.objects.active = hitob
             findex = scenecast[3]
             np_print('findex', findex)
             me = hitob.data
@@ -180,7 +180,7 @@ def draw_callback1_px(self, context):
             bpy.ops.object.material_slot_assign()
             bpy.ops.mesh.select_all(action = 'DESELECT')
             bpy.ops.object.mode_set(mode = 'OBJECT')
-            bpy.context.scene.objects.active = acob
+            bpy.context.view_layer.objects.active = acob
 
 
     # ON-SCREEN INSTRUCTIONS:
diff --git a/object_mesh_versions.py b/object_mesh_versions.py
index ac82ec3dd170d2a41f223c50f85bc93aad3d2f27..89885656ec27e4e69f1a60c53287a7884396f653 100644
--- a/object_mesh_versions.py
+++ b/object_mesh_versions.py
@@ -84,7 +84,7 @@ class KTX_Cleanup(bpy.types.Operator):
     def execute(self, context):
         for o in bpy.data.objects:
             o.select_set(False)
-        context.scene.objects.active = None
+        context.view_layer.objects.active = None
         return {'FINISHED'}
 
 
diff --git a/object_particle_hair_net.py b/object_particle_hair_net.py
index 05bf917173bdc25a9b2c35e78a97105e1ec930bc..3869b92ebf16998c6dd4dbd0c8343dd04730cf37 100644
--- a/object_particle_hair_net.py
+++ b/object_particle_hair_net.py
@@ -292,14 +292,14 @@ def changeSelection(thisObject):
     storedActive, storedSelected = preserveSelection()
 
     bpy.ops.object.select_all(action='DESELECT')
-    bpy.context.scene.objects.active=thisObject
+    bpy.context.view_layer.objects.active=thisObject
     thisObject.select_set(True)
 
     return storedActive, storedSelected
 
 def restoreSelection(storedActive, storedSelected):
     #Restore active object and selection
-    bpy.context.scene.objects.active=storedActive
+    bpy.context.view_layer.objects.active=storedActive
     bpy.ops.object.select_all(action='DESELECT')
     for sel in storedSelected:
         sel.select_set(True)
diff --git a/oscurart_futurism.py b/oscurart_futurism.py
index 9aa9c28f2382f76a2bc09d07de00493a4e6170a4..966bb09c35ee335a9e67e4eac612219d206bf28d 100644
--- a/oscurart_futurism.py
+++ b/oscurart_futurism.py
@@ -52,7 +52,7 @@ def object_osc_futurism (self, context,STEP, HOLD):
     EMPTY["FUTURISM_HOLDIN"] = 0
     EMPTY["FUTURISM_HOLDOUT"] = 0
 
-    bpy.context.scene.objects.active = OBACT  # RECUPERO OBJETO ACTIVO
+    bpy.context.view_layer.objects.active = OBACT  # RECUPERO OBJETO ACTIVO
 
     for OBJETO in range((FE+1)-FS):
         if STEPINC == STEP:
diff --git a/oscurart_mesh_cache_tools.py b/oscurart_mesh_cache_tools.py
index 2e81451bf4645440fba38f05e85cf3a69a84460a..10cd2275ba20f730996c01e9e3ad67f6f0b9b657 100644
--- a/oscurart_mesh_cache_tools.py
+++ b/oscurart_mesh_cache_tools.py
@@ -354,16 +354,16 @@ class OscMeshCacheUp(Operator):
 
     def execute(self, context):
 
-        actob = bpy.context.scene.objects.active
+        actob = bpy.context.view_layer.objects.active
 
         for ob in bpy.context.selected_objects[:]:
-            bpy.context.scene.objects.active = ob
+            bpy.context.view_layer.objects.active = ob
             for mod in ob.modifiers[:]:
                 if mod.type == "MESH_CACHE":
                     for up in range(ob.modifiers.keys().index(mod.name)):
                         bpy.ops.object.modifier_move_up(modifier=mod.name)
 
-        bpy.context.scene.objects.active = actob
+        bpy.context.view_layer.objects.active = actob
 
         return {'FINISHED'}
 
diff --git a/space_view3d_paint_bprojection.py b/space_view3d_paint_bprojection.py
index 174da5ebbfda539ac1e8af307380a459107866db..a4d5b7ec2ca52ac27790ba821a06e0b598af6946 100644
--- a/space_view3d_paint_bprojection.py
+++ b/space_view3d_paint_bprojection.py
@@ -981,7 +981,7 @@ class AddBProjectionPlane(Operator):
             em = context.object
             em.name = BProjection_Empty
 
-            context.scene.objects.active = ob
+            context.view_layer.objects.active = ob
             ob.select_set(True)
 
             bpy.ops.object.editmode_toggle()
@@ -1120,12 +1120,12 @@ class RemoveBProjectionPlane(Operator):
             ob.select_set(False)
 
             em = bpy.data.objects[BProjection_Empty]
-            context.scene.objects.active = em
+            context.view_layer.objects.active = em
             em.hide = False
             em.select_set(True)
             bpy.ops.object.delete()
 
-            context.scene.objects.active = ob
+            context.view_layer.objects.active = ob
             ob.select_set(True)
 
             reinitkey()
@@ -1201,7 +1201,7 @@ class ChangeObject(Operator):
     def execute(self, context):
             new_ob = context.object
             em = bpy.data.objects[BProjection_Empty]
-            context.scene.objects.active = bpy.data.objects[em.custom_active_object]
+            context.view_layer.objects.active = bpy.data.objects[em.custom_active_object]
             ob = context.object
             if ob != new_ob:
                 cm = bpy.context.object.mode
@@ -1242,7 +1242,7 @@ class ChangeObject(Operator):
                 ob.select_set(False)
 
                 bplane.select_set(True)
-                context.scene.objects.active = bplane
+                context.view_layer.objects.active = bplane
                 for ms in (ms for ms in bplane.material_slots if ms.name != BProjection_Material):
                     bplane.active_material = ms.material
                     bpy.ops.object.material_slot_remove()
@@ -1251,7 +1251,7 @@ class ChangeObject(Operator):
                     bplane.vertex_groups.active_index = gs.index
                     bpy.ops.object.vertex_group_remove()
 
-                context.scene.objects.active = new_ob
+                context.view_layer.objects.active = new_ob
                 cm = new_ob.mode
                 bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
                 bpy.ops.object.join()
@@ -1262,7 +1262,7 @@ class ChangeObject(Operator):
                 bpy.ops.object.location_clear()
                 bpy.ops.object.rotation_clear()
                 bpy.ops.object.scale_clear()
-                context.scene.objects.active = new_ob
+                context.view_layer.objects.active = new_ob
                 bpy.ops.object.editmode_toggle()
                 bpy.ops.object.hook_add_selob()
                 bpy.ops.object.editmode_toggle()
diff --git a/space_view3d_quickPrefs.py b/space_view3d_quickPrefs.py
index 1da4bdaaf5e89300e8b07de0478f76883c73d68b..8914e8cfed7850bb84fcca7cbf8144dd63038e7a 100644
--- a/space_view3d_quickPrefs.py
+++ b/space_view3d_quickPrefs.py
@@ -801,8 +801,8 @@ class PANEL(bpy.types.Panel):
                     col.prop(entry, "name", text="")
                 if entry.count> 0:
                     col.prop(entry, "name", text="")
-                if bpy.context.scene.objects.active != None:
-                    name=bpy.context.scene.objects.active.get("gllightpreset", "Default")
+                if bpy.context.view_layer.objects.active != None:
+                    name=bpy.context.view_layer.objects.active.get("gllightpreset", "Default")
 #Draw the import/export part of the box
                 col.prop(scn,'importexport')
                 if scn.importexport: