addons-contrib: view_layer.objects.active syntax update
authorNBurn <7nburn@gmail.com>
Tue, 29 Jan 2019 01:12:14 +0000 (20:12 -0500)
committerNBurn <7nburn@gmail.com>
Tue, 29 Jan 2019 01:12:14 +0000 (20:12 -0500)
31 files changed:
add_dimension.py
add_mesh_castle/Castle.py
add_mesh_clusters/__init__.py
add_mesh_space_tree/__init__.py
amaranth/render/meshlight_select.py
amaranth/scene/debug.py
cmu_mocap_browser/makehuman.py
io_atomblend_utilities/io_atomblend_utilities.py
io_directx_bel/import_x.py
io_mesh_xyz/import_xyz.py
io_scene_cod/export_xanim.py
io_scene_cod/export_xmodel.py
mesh_ktools.py
np_station/np_float_box.py
np_station/np_float_poly.py
np_station/np_float_rectangle.py
np_station/np_point_align.py
np_station/np_point_array.py
np_station/np_point_copy.py
np_station/np_point_distance.py
np_station/np_point_instance.py
np_station/np_point_move.py
np_station/np_point_scale.py
np_station/np_roto_move.py
np_station/np_shader_brush.py
object_mesh_versions.py
object_particle_hair_net.py
oscurart_futurism.py
oscurart_mesh_cache_tools.py
space_view3d_paint_bprojection.py
space_view3d_quickPrefs.py

index 090f16f..08b6e09 100644 (file)
@@ -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
index 465e9c2..343e218 100644 (file)
@@ -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'}
 
index 971171e..ef2a29a 100644 (file)
@@ -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
 
index cf77a43..6938100 100644 (file)
@@ -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')
 
index 00c3071..b7c7c88 100644 (file)
@@ -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"}
index 4226e9a..50461fe 100755 (executable)
@@ -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"}
 
index 7c8d843..381d598 100644 (file)
@@ -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 [
index 71f6c5c..0d9fd12 100644 (file)
@@ -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
index 6d3cecf..7c7bb64 100644 (file)
@@ -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()
 
index 07640a0..d6804f8 100644 (file)
@@ -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)
 
index 39fdef2..0e11ce0 100644 (file)
@@ -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."
 
index 5ad05ad..47c8ca9 100644 (file)
@@ -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."
index 9867e1b..9de506b 100644 (file)
@@ -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)
 
index 7555172..65bd4cd 100644 (file)
@@ -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
index f30a1a2..5cc426e 100644 (file)
@@ -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'}
index fed86fb..9ac0c6e 100644 (file)
@@ -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
index 88c5f77..7744f08 100644 (file)
@@ -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
index ae05ecf..b8b7e63 100644 (file)
@@ -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)
index 5d6a2d9..45ee398 100644 (file)
@@ -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)
index 053c180..b2bfadc 100644 (file)
@@ -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':
index 36d24f9..56e2dcf 100644 (file)
@@ -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)
index 13166e9..bdf0c1e 100644 (file)
@@ -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'}
index b6e1c97..f6b5d7b 100644 (file)
@@ -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'}
index 832e5aa..dc55a05 100644 (file)
@@ -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'}
index ec83216..1ea55e0 100644 (file)
@@ -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:
index ac82ec3..8988565 100644 (file)
@@ -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'}
 
 
index 05bf917..3869b92 100644 (file)
@@ -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)
index 9aa9c28..966bb09 100644 (file)
@@ -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:
index 2e81451..10cd227 100644 (file)
@@ -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'}
 
index 174da5e..a4d5b7e 100644 (file)
@@ -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()
index 1da4bda..8914e8c 100644 (file)
@@ -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: