...
 
Commits (5)
......@@ -52,7 +52,7 @@ def addText(string = '', loc = ((0, 0, 0)), textsize = 1, align = 'CENTER', offs
fnt = bpy.data.fonts.load(font)
tcu.font = fnt
text.location = loc
bpy.context.scene.objects.link(text)
bpy.context.collection.objects.link(text)
return text
......@@ -1462,10 +1462,10 @@ def align_matrix(context, location):
# sets bezierhandles to auto
def setBezierHandles(obj, mode = 'VECTOR'):
scene = bpy.context.scene
view_layer = bpy.context.view_layer
if obj.type != 'CURVE':
return
scene.objects.active = obj
view_layer.objects.active = obj
bpy.ops.object.mode_set(mode = 'EDIT', toggle = True)
bpy.ops.curve.select_all(action = 'SELECT')
bpy.ops.curve.handle_type_set(type = mode)
......@@ -1514,7 +1514,6 @@ def createCurve(vertArray, self, align_matrix):
name = self.Dimension_Type # Type as name
# create curve
scene = bpy.context.scene
newCurve = bpy.data.curves.new(name, type = 'CURVE') # curvedatablock
newSpline = newCurve.splines.new('BEZIER') # spline
......@@ -1528,7 +1527,7 @@ def createCurve(vertArray, self, align_matrix):
# create object with newCurve
DimensionCurve = bpy.data.objects.new(name, newCurve) # object
scene.objects.link(DimensionCurve) # place in active scene
bpy.context.collection.objects.link(DimensionCurve) # place in active scene
DimensionCurve.Dimension = True
DimensionCurve.matrix_world = align_matrix # apply matrix
self.Dimension_Name = DimensionCurve.name
......@@ -1770,7 +1769,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
......
......@@ -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'}
......
......@@ -344,14 +344,14 @@ def DEF_atom_draw_atoms(prop_element,
atom_mesh.from_pydata(atom_vertices, [], [])
atom_mesh.update()
new_atom_mesh = bpy.data.objects.new(name, atom_mesh)
bpy.context.scene.objects.link(new_atom_mesh)
bpy.context.collection.objects.link(new_atom_mesh)
bpy.ops.surface.primitive_nurbs_surface_sphere_add(
view_align=False, enter_editmode=False,
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
......
......@@ -320,7 +320,7 @@ def createObjects(tree, parent=None, objectname=None, probability=0.5, size=0.5,
obj.rotation_euler = rot[:]
obj.scale = [scale, scale, scale]
obj.parent = parent
bpy.context.scene.objects.link(obj)
bpy.context.collection.objects.link(obj)
# this is not the best choice of distribution because we might
# get negative values especially if sigma is large
t += gauss(1.0 / probability, 0.1)
......@@ -565,11 +565,11 @@ def createGeometry(tree, power=0.5, scale=0.01, addleaves=False, pleaf=0.5,
# create the tree object an make it the only selected and active object in the scene
obj_new = bpy.data.objects.new(mesh.name, mesh)
base = bpy.context.scene.objects.link(obj_new)
base = bpy.context.collection.objects.link(obj_new)
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')
......@@ -611,11 +611,11 @@ def createGeometry(tree, power=0.5, scale=0.01, addleaves=False, pleaf=0.5,
bleaf, connectoffset
)
obj_leaves = bpy.data.objects.new(mesh.name, mesh)
base = bpy.context.scene.objects.link(obj_leaves)
base = bpy.context.collection.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')
......@@ -975,7 +975,7 @@ class SCATree(bpy.types.Operator):
if self.showMarkers:
mesh = createMarkers(sca, self.markerScale)
obj_markers = bpy.data.objects.new(mesh.name, mesh)
base = bpy.context.scene.objects.link(obj_markers)
base = bpy.context.collection.objects.link(obj_markers)
timings.add('showmarkers')
sca.iterate2(newendpointsper1000=self.newEndPointsPer1000, maxtime=self.maxTime)
......
......@@ -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"}
......
......@@ -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"}
......
......@@ -36,12 +36,12 @@ def round_sigfigs(num, sig_figs):
class OperatorCallContext():
def __enter__(self):
scene = bpy.context.scene
prefs = bpy.context.preferences
view_layer = bpy.context.view_layer
# store active/selected state to restore it after operator execution
self.curact = scene.objects.active
self.cursel = { ob : ob.select for ob in scene.objects }
self.curact = view_layer.objects.active
self.cursel = { ob : ob.select_get() for ob in scene.objects }
# undo can store files a lot when running operators internally,
# disable since we only need one undo step after main operators anyway
......@@ -53,17 +53,19 @@ class OperatorCallContext():
def __exit__(self, exc_type, exc_value, traceback):
scene = bpy.context.scene
prefs = bpy.context.preferences
view_layer = bpy.context.view_layer
# restore active/selected state
scene.objects.active = self.curact
view_layer.objects.active = self.curact
for ob in scene.objects:
ob.select = self.cursel.get(ob, False)
ob.select_set(self.cursel.get(ob, False))
prefs.edit.use_global_undo = self.use_global_undo
def select_single_object(ob):
scene = bpy.context.scene
view_layer = bpy.context.view_layer
scene.objects.active = ob
view_layer.objects.active = ob
for tob in scene.objects:
tob.select = (tob == ob)
tob.select_set((tob == ob))
......@@ -60,7 +60,7 @@ class CODuplicateCamera(Operator):
cam_obj = active_cam.copy()
cam_obj.data = active_cam.data.copy()
cam_obj.name = "Camera_Overscan"
context.scene.objects.link(cam_obj)
context.collection.objects.link(cam_obj)
except:
self.report({'WARNING'}, "Setting up a new Overscan Camera has failed")
return {'CANCELLED'}
......
......@@ -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 [
......
......@@ -119,7 +119,7 @@ class LoftedSurface:
meshObject = bpy.data.objects.new(self.name, mesh)
bpy.context.scene.objects.link(meshObject)
bpy.context.collection.objects.link(meshObject)
......@@ -267,7 +267,7 @@ class SweptSurface:
meshObject = bpy.data.objects.new(self.name, mesh)
bpy.context.scene.objects.link(meshObject)
bpy.context.collection.objects.link(meshObject)
......@@ -456,4 +456,4 @@ class BirailedSurface:
meshObject = bpy.data.objects.new(self.name, mesh)
bpy.context.scene.objects.link(meshObject)
bpy.context.collection.objects.link(meshObject)
......@@ -19,7 +19,6 @@ class OperatorAutoLoftCurves(Operator):
def execute(self, context):
#print("### TODO: OperatorLoftCurves.execute()")
scene = context.scene
mesh = bpy.data.meshes.new("LoftMesh")
curve0 = context.selected_objects[0]
......@@ -31,7 +30,7 @@ class OperatorAutoLoftCurves(Operator):
loftobj = bpy.data.objects.new(self.name, mesh)
scene.objects.link(loftobj)
context.collection.objects.link(loftobj)
loftobj["autoloft"] = True
if loftobj.get('_RNA_UI') is None:
loftobj['_RNA_UI'] = {}
......
......@@ -80,10 +80,11 @@ class OperatorCallContext():
def __enter__(self):
scene = bpy.context.scene
prefs = bpy.context.preferences
view_layer = bpy.context.view_layer
# store active/selected state to restore it after operator execution
self.curact = scene.objects.active
self.cursel = { ob : ob.select for ob in scene.objects }
self.curact = view_layer.objects.active
self.cursel = { ob : ob.select_get() for ob in scene.objects }
# undo can store files a lot when running operators internally,
# disable since we only need one undo step after main operators anyway
......@@ -95,17 +96,19 @@ class OperatorCallContext():
def __exit__(self, exc_type, exc_value, traceback):
scene = bpy.context.scene
prefs = bpy.context.preferences
view_layer = bpy.context.view_layer
# restore active/selected state
scene.objects.active = self.curact
view_layer.objects.active = self.curact
for ob in scene.objects:
ob.select = self.cursel.get(ob, False)
ob.select_set(self.cursel.get(ob, False))
prefs.edit.use_global_undo = self.use_global_undo
def select_single_object(ob):
scene = bpy.context.scene
view_layer = bpy.context.view_layer
scene.objects.active = ob
view_layer.objects.active = ob
for tob in scene.objects:
tob.select = (tob == ob)
tob.select.set((tob == ob))
......@@ -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)
......@@ -656,7 +656,7 @@ def draw_obj_special(atom_shape, atom):
new_mesh.from_pydata([Vector((0.0,0.0,0.0))], [], [])
new_mesh.update()
new_atom = bpy.data.objects.new(atom.name + "_sep", new_mesh)
bpy.context.scene.objects.link(new_atom)
bpy.context.collection.objects.link(new_atom)
new_atom.location = atom.location
material_new = bpy.data.materials.new(atom.active_material.name + "_sep")
material_new.name = atom.name + "_halo"
......@@ -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)
......@@ -698,7 +698,7 @@ def draw_obj_special(atom_shape, atom):
lamp = bpy.data.objects.new("F2+_lamp", lamp_data)
lamp.location = Vector((0.0, 0.0, 0.0))
lamp.layers = current_layers
bpy.context.scene.objects.link(lamp)
bpy.context.collection.objects.link(lamp)
lamp.parent = cube
# The new 'atom' is the F2+ defect
new_atom = cube
......@@ -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
......@@ -755,7 +755,7 @@ def draw_obj_special(atom_shape, atom):
lamp = bpy.data.objects.new("F+_lamp", lamp_data)
lamp.location = Vector((0.0, 0.0, 0.0))
lamp.layers = current_layers
bpy.context.scene.objects.link(lamp)
bpy.context.collection.objects.link(lamp)
lamp.parent = cube
# The new 'atom' is the F+ defect complex + lamp
new_atom = 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
......@@ -823,7 +823,7 @@ def draw_obj_special(atom_shape, atom):
lamp1 = bpy.data.objects.new("F0_lamp", lamp1_data)
lamp1.location = Vector((scale[0]*1.5, 0.0, 0.0))
lamp1.layers = current_layers
bpy.context.scene.objects.link(lamp1)
bpy.context.collection.objects.link(lamp1)
lamp1.parent = cube
lamp2_data = bpy.data.lamps.new(name="F0_lamp2", type="POINT")
lamp2_data.distance = atom.scale[0] * 2.0
......@@ -833,7 +833,7 @@ def draw_obj_special(atom_shape, atom):
lamp2 = bpy.data.objects.new("F0_lamp", lamp2_data)
lamp2.location = Vector((-scale[0]*1.5, 0.0, 0.0))
lamp2.layers = current_layers
bpy.context.scene.objects.link(lamp2)
bpy.context.collection.objects.link(lamp2)
lamp2.parent = cube
# The new 'atom' is the F0 defect complex + lamps
new_atom = cube
......
......@@ -144,7 +144,7 @@ def write(obname,name,
# scene link check
if obj.name not in bpy.context.scene.objects.keys() :
bpy.context.scene.objects.link(obj)
bpy.context.collection.objects.link(obj)
return obj
......
......@@ -12,14 +12,14 @@ def new(name,datatype,naming_method):
ob = bpy.data.objects.new(name,datatype)
ob.name = name
elif naming_method == 3 :
bpy.context.scene.objects.unlink(ob)
bpy.context.collection.objects.unlink(ob)
ob.user_clear()
bpy.data.objects.remove(ob)
ob = bpy.data.objects.new(name,datatype)
else :
ob = bpy.data.objects.new(name,datatype)
if ob.name not in bpy.context.scene.objects.keys() :
bpy.context.scene.objects.link(ob)
bpy.context.collection.objects.link(ob)
return ob
## returns an object or a list of objects
......
......@@ -591,9 +591,9 @@ BINARY FORMAT
armname = armdata
armdata = bpy.data.armatures.new(name=armname)
arm = bpy.data.objects.new(armname,armdata)
bpy.context.scene.objects.link(arm)
bpy.context.collection.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()
......
......@@ -440,9 +440,8 @@ class Import(bpy.types.Operator):
mesh.update()
ob_new = bpy.data.objects.new(TARGET_NAME, mesh)
ob_new.data = mesh
scene = bpy.context.scene
scene.objects.link(ob_new)
scene.objects.active = ob_new
bpy.context.collection.objects.link(ob_new)
bpy.context.view_layer.objects.active = ob_new
ob_new.select_set(True)
print ('*** End draw ***')
print('*** Start Smooth ***')
......
......@@ -58,6 +58,7 @@ def voodoo_import(infile,ld_cam,ld_points):
file = open(infile,'rU')
scene = bpy.context.scene
collection = bpy.context.collection
initfr = scene.frame_current
b24= True
voodoo_import.frwas= False
......@@ -66,7 +67,7 @@ def voodoo_import(infile,ld_cam,ld_points):
dummy.location = (0.0, 0.0, 0.0)
dummy.rotation_euler = ( -3.141593/2, 0.0, 0.0)
dummy.scale = (0.2, 0.2, 0.2)
scene.objects.link(dummy)
collection.objects.link(dummy)
if ld_cam:
data = bpy.data.cameras.new('voodoo_render_cam')
......@@ -82,7 +83,7 @@ def voodoo_import(infile,ld_cam,ld_points):
data.clip_start = 0.1
data.clip_end = 1000.0
data.display_size = 0.5
scene.objects.link(vcam)
collection.objects.link(vcam)
vcam.parent = dummy
if ld_points:
......@@ -94,7 +95,7 @@ def voodoo_import(infile,ld_cam,ld_points):
# mesh.scale = (5.0, 5.0, 5.0)
mesh.rotation_euler = (0.0, 0.0, 0.0)
mesh.scale = (1.0, 1.0, 1.0)
scene.objects.link(mesh)
collection.objects.link(mesh)
mesh.parent = dummy
verts = []
......
......@@ -205,7 +205,7 @@ def create_mesh(data_list,
surface_mesh.from_pydata(data_mesh, [], data_faces)
surface_mesh.update()
surface = bpy.data.objects.new(image_name, surface_mesh)
bpy.context.scene.objects.link(surface)
bpy.context.collection.objects.link(surface)
bpy.ops.object.select_all(action='DESELECT')
surface.select = True
......@@ -252,7 +252,7 @@ def create_mesh(data_list,
camera = bpy.data.objects.new("A_camera", camera_data)
camera.location = camera_xyz_vec
camera.layers = current_layers
bpy.context.scene.objects.link(camera)
bpy.context.collection.objects.link(camera)
# Here the camera is rotated such it looks towards the center of
# the object. The [0.0, 0.0, 1.0] vector along the z axis
......@@ -303,7 +303,7 @@ def create_mesh(data_list,
lamp = bpy.data.objects.new("A_lamp", lamp_data)
lamp.location = lamp_xyz_vec
lamp.layers = current_layers
bpy.context.scene.objects.link(lamp)
bpy.context.collection.objects.link(lamp)
bpy.context.scene.world.light_settings.use_ambient_occlusion = True
bpy.context.scene.world.light_settings.ao_factor = 0.1
......@@ -528,7 +528,7 @@ def import_xyz(Ball_type,
camera = bpy.data.objects.new("A_camera", camera_data)
camera.location = camera_xyz_vec
camera.layers = current_layers
bpy.context.scene.objects.link(camera)
bpy.context.collection.objects.link(camera)
# Here the camera is rotated such it looks towards the center of
# the object. The [0.0, 0.0, 1.0] vector along the z axis
......@@ -579,7 +579,7 @@ def import_xyz(Ball_type,
lamp = bpy.data.objects.new("A_lamp", lamp_data)
lamp.location = lamp_xyz_vec
lamp.layers = current_layers
bpy.context.scene.objects.link(lamp)
bpy.context.collection.objects.link(lamp)
bpy.context.scene.world.light_settings.use_ambient_occlusion = True
bpy.context.scene.world.light_settings.ao_factor = 0.2
......@@ -607,7 +607,7 @@ def import_xyz(Ball_type,
atom_mesh.from_pydata(atom_vertices, [], [])
atom_mesh.update()
new_atom_mesh = bpy.data.objects.new(atom.name, atom_mesh)
bpy.context.scene.objects.link(new_atom_mesh)
bpy.context.collection.objects.link(new_atom_mesh)
# Now, build a representative sphere (atom)
current_layers=bpy.context.scene.layers
......@@ -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)
......
......@@ -38,10 +38,8 @@ def create_and_link_mesh(name, points):
mesh.validate()
mesh.update()
scene = bpy.context.scene
obj = bpy.data.objects.new(name, mesh)
scene.objects.link(obj)
bpy.context.collection.objects.link(obj)
obj.select_set(True)
......
......@@ -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."
......
......@@ -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."
......
......@@ -268,7 +268,7 @@ def load(self, context, filepath=""):
me.from_pydata(vert_table, [], face_table)
me.update()
ob = bpy.data.objects.new("Py-Mesh", me)
bpy.context.scene.objects.link(ob)
bpy.context.collection.objects.link(ob)
state = 31
......
This diff is collapsed.
......@@ -386,6 +386,7 @@ def write_node_map(fw, ob):
def split_objects(context, objects):
scene = context.scene
view_layer = context.view_layer
final_objects = []
bpy.ops.object.select_all(action='DESELECT')
......@@ -403,7 +404,7 @@ def split_objects(context, objects):
ob.select_set(True)
if ob.type == "MESH":
scene.objects.active = ob
view_layer.objects.active = ob
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.mesh.select_mode(type='EDGE')
......@@ -420,7 +421,7 @@ def split_objects(context, objects):
for split_ob in split_objects:
assert(split_ob.type == "MESH")
scene.objects.active = split_ob
view_layer.objects.active = split_ob
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(type='EDGE')
bpy.ops.mesh.select_all(action="SELECT")
......@@ -476,6 +477,7 @@ def export_map(context, filepath):
print("Map Exporter 0.0")
scene = context.scene
collection = context.collection
objects = context.selected_objects
obs_mesh = []
......@@ -656,7 +658,7 @@ def export_map(context, filepath):
print("\t\tignoring %s" % ob.name)
for ob in obs_mesh:
scene.objects.unlink(ob)
collection.objects.unlink(ob)
bpy.data.objects.remove(ob)
print("Exported Map in %.4fsec" % (time.time() - t))
......
......@@ -238,9 +238,8 @@ def read(context, filepath, scale=100.0, tag=False, utm=False):
me.transform(global_matrix)
# create the object in the scene
scene = context.scene
scene.objects.link(obj)
scene.objects.active = obj
context.collection.objects.link(obj)
context.view_layer.objects.active = obj
obj.select_set(True)
# entry points for other addons
......
......@@ -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)
......
......@@ -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
......
......@@ -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'}
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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':
......
......@@ -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)
......
......@@ -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'}
......
......@@ -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)