addons: view_layer.objects.active syntax update

This commit is contained in:
nBurn 2019-01-28 20:04:35 -05:00
parent bdc109a530
commit edd2de62eb
44 changed files with 201 additions and 201 deletions

View File

@ -90,7 +90,7 @@ class Circle_Array(Operator):
check_mod.use_relative_offset = False
else:
# fallback
bpy.context.scene.objects.active = active
bpy.context.view_layer.objects.active = active
bpy.ops.object.modifier_add(type='ARRAY')
active.modifiers[0].use_object_offset = True
active.modifiers[0].use_relative_offset = False
@ -98,7 +98,7 @@ class Circle_Array(Operator):
active.modifiers[0].use_object_offset = True
active.modifiers[0].use_relative_offset = False
active.select_set(False)
bpy.context.scene.objects.active = context.active_object
bpy.context.view_layer.objects.active = context.active_object
bpy.ops.view3d.snap_cursor_to_selected()
if active.modifiers[0].offset_object is None:
@ -109,7 +109,7 @@ class Circle_Array(Operator):
else:
empty_name = active.modifiers[0].offset_object
bpy.context.scene.objects.active = active
bpy.context.view_layer.objects.active = active
num = active.modifiers["Array"].count
rotate_num = 360 / num
active.select_set(True)
@ -134,7 +134,7 @@ class Circle_Array(Operator):
else:
empty_name = active.modifiers[0].offset_object
bpy.context.scene.objects.active = active
bpy.context.view_layer.objects.active = active
num = active.modifiers["Array"].count
rotate_num = 360 / num
active.select_set(True)

View File

@ -198,7 +198,7 @@ def create_mesh_from_audio(self, scene, verts, faces):
mesh.from_pydata(verts, [], faces)
ob = bpy.data.objects.new("cubed", mesh)
bpy.context.scene.objects.link(ob)
bpy.context.scene.objects.active = ob
bpy.context.view_layer.objects.active = ob
ob.select_set(True)
# initial vertex colors
@ -413,7 +413,7 @@ def create_mesh_from_image(self, scene, verts, faces):
mesh.from_pydata(verts, [], faces)
ob = bpy.data.objects.new("cubed", mesh)
context.scene.objects.link(ob)
context.scene.objects.active = ob
context.view_layer.objects.active = ob
ob.select_set(True)
# uv unwrap

View File

@ -420,7 +420,7 @@ def build_edge_frames(edges):
def make_manifold_struts(truss_obj, od, segments):
bpy.context.scene.objects.active = truss_obj
bpy.context.view_layer.objects.active = truss_obj
bpy.ops.object.editmode_toggle()
truss_mesh = bmesh.from_edit_mesh(truss_obj.data).copy()
bpy.ops.object.editmode_toggle()
@ -494,7 +494,7 @@ def create_struts(self, context, ind, od, segments, solid, loops, manifold):
bpy.context.scene.objects.link(obj)
obj.select_set(True)
obj.location = truss_obj.location
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
mesh.update()

View File

@ -255,7 +255,7 @@ def main(context, lat_props):
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.object.select_pattern(pattern=lat.name, extend=False)
context.scene.objects.active = lat
context.view_layer.objects.active = lat
context.scene.update()

View File

@ -207,7 +207,7 @@ def makeChain(self, context, mult, curverig):
# select the curve
bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects['Cable'].select = 1
bpy.context.scene.objects.active = bpy.data.objects['Cable']
bpy.context.view_layer.objects.active = bpy.data.objects['Cable']
# switch to Edit mode
bpy.ops.object.mode_set(mode='EDIT')
@ -223,7 +223,7 @@ def makeChain(self, context, mult, curverig):
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
ACTARM.select = 1
bpy.context.scene.objects.active = bpy.data.objects['Armature']
bpy.context.view_layer.objects.active = bpy.data.objects['Armature']
bpy.ops.object.mode_set(mode='POSE')
bpy.ops.pose.select_all(action='DESELECT')
ACTARM.data.bones[-1].select = 1

View File

@ -60,7 +60,7 @@ def pix(self, obj):
sca = self.size * (100 - self.gap) * .005
bpy.ops.mesh.primitive_cube_add(layers=[True] + [False] * 19)
bpy.ops.transform.resize(value=[sca] * 3)
bpy.context.scene.objects.active = dup
bpy.context.view_layer.objects.active = dup
bpy.ops.object.parent_set(type='OBJECT')

View File

@ -102,7 +102,7 @@ class makestructure(Operator):
for obj in oblst:
bpy.ops.object.select_pattern(pattern=obj.name) # Select base mesh
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
if obj.data.uv_layers[:] != []:
uvyes = 1
else:
@ -173,7 +173,7 @@ class makestructure(Operator):
constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED',
proportional_edit_falloff='SMOOTH', proportional_size=1, release_confirm=True
)
bpy.context.scene.objects.active = obj # Again needed to avoid poll() taking me down
bpy.context.view_layer.objects.active = obj # Again needed to avoid poll() taking me down
bpy.ops.object.make_links_data(type='MODIFIERS')
bpy.ops.object.make_links_data(type='MATERIAL')
@ -181,7 +181,7 @@ class makestructure(Operator):
bpy.ops.object.join_uvs()
bpy.ops.collection.objects_remove()
bpy.context.scene.objects.active = select
bpy.context.view_layer.objects.active = select
if self.dc is True:
bpy.context.scene.objects.unlink(obj)

View File

@ -129,7 +129,7 @@ class TriLighting(Operator):
camera = cam_obj
bpy.ops.view3d.viewnumpad(type='TOP')
obj = bpy.context.scene.objects.active
obj = bpy.context.view_layer.objects.active
# Calculate Energy for each Lamp
if(self.contrast > 0):

View File

@ -152,7 +152,7 @@ class OBJECT_OT_TriangulateButton(Operator):
my.matrix_world = obj.matrix_world.copy()
obj.select_set(False)
my.select_set(True)
context.scene.objects.active = my
context.view_layer.objects.active = my
self.report({'INFO'}, "Mesh created (" + str(len(faces)) + " triangles)")
print("Total :%s faces %s verts" % (len(faces), len(points_3D)))
return {'FINISHED'}
@ -211,7 +211,7 @@ class OBJECT_OT_TriangulateButton(Operator):
# Update scene
bpy.context.scene.objects.link(tinObj) # Link object to scene
bpy.context.scene.objects.active = tinObj
bpy.context.view_layer.objects.active = tinObj
tinObj.select_set(True)
obj.select_set(False)
@ -314,7 +314,7 @@ class OBJECT_OT_VoronoiButton(Operator):
# update scene
bpy.context.scene.objects.link(voronoiObj) # Link object to scene
bpy.context.scene.objects.active = voronoiObj
bpy.context.view_layer.objects.active = voronoiObj
voronoiObj.select_set(True)
obj.select_set(False)

View File

@ -345,7 +345,7 @@ def writeArrayToCubes(arr, gridBU, orig, cBOOL=False, jBOOL=True):
q.select_set(False)
if q.name[0:5] == 'xCUBE':
q.select_set(True)
bpy.context.scene.objects.active = q
bpy.context.view_layer.objects.active = q
def addVert(ob, pt, conni=-1):

View File

@ -193,14 +193,14 @@ def add_type1(self, context):
def make_path(self, context, verts):
target = bpy.context.scene.objects.active
target = bpy.context.view_layer.objects.active
bpy.ops.curve.primitive_nurbs_path_add(
view_align=False, enter_editmode=False, location=(0, 0, 0)
)
target.data.taper_object = bpy.context.scene.objects.active
taper = bpy.context.scene.objects.active
target.data.taper_object = bpy.context.view_layer.objects.active
taper = bpy.context.view_layer.objects.active
taper.name = target.name + '_Taper'
bpy.context.scene.objects.active = target
bpy.context.view_layer.objects.active = target
points = taper.data.splines[0].points
for i in range(len(verts)):
@ -208,7 +208,7 @@ def make_path(self, context, verts):
def make_curve(self, context, verts, lh, rh):
target = bpy.context.scene.objects.active
target = bpy.context.view_layer.objects.active
curve_data = bpy.data.curves.new(
name=target.name + '_Bevel', type='CURVE'
)
@ -229,8 +229,8 @@ def make_curve(self, context, verts, lh, rh):
c += 1
object_data_add(context, curve_data, operator=self)
target.data.bevel_object = bpy.context.scene.objects.active
bpy.context.scene.objects.active = target
target.data.bevel_object = bpy.context.view_layer.objects.active
bpy.context.view_layer.objects.active = target
class add_tapercurve(Operator):
@ -404,7 +404,7 @@ class Bevel_Taper_Curve_Menu(Menu):
def menu_funcs(self, context):
if bpy.context.scene.objects.active.type == "CURVE":
if bpy.context.view_layer.objects.active.type == "CURVE":
self.layout.menu("VIEW3D_MT_bevel_taper_curve_menu")

View File

@ -664,7 +664,7 @@ def addBeamObj(sRef, context):
beamMesh = bpy.data.meshes.new("Beam")
beamObj = bpy.data.objects.new("Beam", beamMesh)
context.scene.objects.link(beamObj)
context.scene.objects.active = beamObj
context.view_layer.objects.active = beamObj
beamObj.select_set(True)
beamMesh.from_pydata(verts, [], faces)

View File

@ -224,7 +224,7 @@ def addBrilliant(context, s, table_w, crown_h, girdle_t, pavi_d, bezel_f,
scene = bpy.context.scene
# deactivate possible active Objects
bpy.context.scene.objects.active = None
bpy.context.view_layer.objects.active = None
# create actual mesh and object based on Verts and Faces given
dmesh = bpy.data.meshes.new("dmesh")

View File

@ -283,7 +283,7 @@ class MakeTriangle(Operator):
exitEditMode()
bpy.ops.object.select_all(action="DESELECT")
NewObj.select_set(True)
context.scene.objects.active = NewObj
context.view_layer.objects.active = NewObj
if self.at_3Dcursor is True:
# we'll need to be sure there is actually an object selected

View File

@ -1121,7 +1121,7 @@ class GenerateGeodesicDome(Operator):
vefm_271.vefm_add_object(mesh)
last_generated_object = context.active_object
last_generated_object.location = (0, 0, 0)
context.scene.objects.active = last_generated_object
context.view_layer.objects.active = last_generated_object
elif self.geodesic_types == 'Grid':
basegeodesic = forms_271.grid(self.grxres, self.gryres,
self.grxsz, self.grysz, 1.0, 1.0, 0, 0, 0,

View File

@ -833,7 +833,7 @@ class importmesh(mesh):
mesh.__init__(self)
obj = bpy.data.objects[meshname]
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
impmesh = None
if not breakquadflag:

View File

@ -338,7 +338,7 @@ def doodads(object1, mesh1, dmin, dmax):
# First we have to apply scaling and rotation to the mesh
bpy.ops.object.select_pattern(pattern=bpy.context.scene.discomb.DISC_doodads[type_dood], extend=False)
bpy.context.scene.objects.active = bpy.data.objects[bpy.context.scene.discomb.DISC_doodads[type_dood]]
bpy.context.view_layer.objects.active = bpy.data.objects[bpy.context.scene.discomb.DISC_doodads[type_dood]]
bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)
for polygon in bpy.data.objects[bpy.context.scene.discomb.DISC_doodads[type_dood]].data.polygons:
@ -382,7 +382,7 @@ def protusions_repeat(object1, mesh1, r_prot):
def setMatProt(discObj, origObj, sideProtMat, topProtMat):
# First we put the materials in their slots
bpy.ops.object.select_pattern(pattern=discObj.name, extend=False)
bpy.context.scene.objects.active = bpy.data.objects[discObj.name]
bpy.context.view_layer.objects.active = bpy.data.objects[discObj.name]
try:
origObj.material_slots[topProtMat]
origObj.material_slots[sideProtMat]
@ -405,7 +405,7 @@ def setMatProt(discObj, origObj, sideProtMat, topProtMat):
def setMatDood(doodObj):
# First we add the materials slots
bpy.ops.object.select_pattern(pattern=doodObj.name, extend=False)
bpy.context.scene.objects.active = doodObj
bpy.context.view_layer.objects.active = doodObj
for name in bpy.context.scene.discomb.DISC_doodads:
try:
bpy.ops.object.material_slot_add()
@ -477,7 +477,7 @@ def discombobulate(minHeight, maxHeight, minTaper, maxTaper, sf1, sf2, sf3, sf4,
# Reload the datas
bpy.ops.object.select_all(action="DESELECT")
bpy.ops.object.select_pattern(pattern=object.name, extend=False)
bpy.context.scene.objects.active = bpy.data.objects[object.name]
bpy.context.view_layer.objects.active = bpy.data.objects[object.name]
obverts = bpy.context.active_object.data.vertices
obpolygons = bpy.context.active_object.data.polygons
@ -494,7 +494,7 @@ def discombobulate(minHeight, maxHeight, minTaper, maxTaper, sf1, sf2, sf3, sf4,
setMatProt(object1, origObj, sideProtMat, topProtMat)
bpy.ops.object.select_pattern(pattern=object1.name, extend=False)
bpy.context.scene.objects.active = bpy.data.objects[object1.name]
bpy.context.view_layer.objects.active = bpy.data.objects[object1.name]
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.normals_make_consistent(inside=False)
bpy.ops.mesh.select_all(action='DESELECT')
@ -516,11 +516,11 @@ def discombobulate(minHeight, maxHeight, minTaper, maxTaper, sf1, sf2, sf3, sf4,
object2.scale = to_scale
bpy.ops.object.select_pattern(pattern=object.name, extend=False)
bpy.context.scene.objects.active = bpy.data.objects[object.name]
bpy.context.view_layer.objects.active = bpy.data.objects[object.name]
bpy.ops.object.delete()
bpy.ops.object.select_pattern(pattern=object1.name, extend=False)
bpy.context.scene.objects.active = bpy.data.objects[object1.name]
bpy.context.view_layer.objects.active = bpy.data.objects[object1.name]
bpy.context.scene.update()
# translate, scale and rotate discombobulated results

View File

@ -70,7 +70,7 @@ class OBJECT_OT_objecttrace(Operator):
brushObj = context.selected_objects
for i in brushObj:
context.scene.objects.active = i
context.view_layer.objects.active = i
if i and i.type != 'CURVE':
bpy.ops.object.btconvertcurve()
# Materials
@ -157,7 +157,7 @@ class OBJECT_OT_objectconnect(Operator):
p.handle_right_type = curve_handle
p.handle_left_type = curve_handle
bpy.context.scene.objects.active = curve
bpy.context.view_layer.objects.active = curve
bpy.ops.object.mode_set(mode='OBJECT')
# place hooks
@ -270,7 +270,7 @@ class OBJECT_OT_particletrace(Operator):
bpy.ops.object.select_all(action='DESELECT')
for curveobject in curvelist:
curveobject.select_set(True)
bpy.context.scene.objects.active = curveobject
bpy.context.view_layer.objects.active = curveobject
bpy.ops.object.collection_link(group="Btrace")
# Materials
trace_mats = addtracemat(curveobject.data)
@ -373,7 +373,7 @@ class OBJECT_OT_traceallparticles(Operator):
# Select new curve
bpy.ops.object.select_all(action='DESELECT')
curve.select_set(True)
bpy.context.scene.objects.active = curve
bpy.context.view_layer.objects.active = curve
# Materials
trace_mats = addtracemat(curve.data)
@ -451,7 +451,7 @@ class OBJECT_OT_writing(Operator):
writeObj = context.selected_objects
if Btrace.animate:
for i in writeObj:
context.scene.objects.active = i
context.view_layer.objects.active = i
bpy.ops.curve.btgrow()
# Materials
trace_mats = addtracemat(bpy.context.object.data)
@ -459,16 +459,16 @@ class OBJECT_OT_writing(Operator):
check_materials = False
else:
for i in writeObj:
context.scene.objects.active = i
context.view_layer.objects.active = i
# Materials
trace_mats = addtracemat(bpy.context.object.data)
if not trace_mats and check_materials is True:
check_materials = False
# Delete grease pencil strokes
context.scene.objects.active = gactive
context.view_layer.objects.active = gactive
bpy.ops.gpencil.data_unlink()
context.scene.objects.active = gactiveCurve
context.view_layer.objects.active = gactiveCurve
# Smooth object
bpy.ops.object.shade_smooth()
# Return to first frame
@ -742,7 +742,7 @@ class OBJECT_OT_meshfollow(Operator):
for curveobject in curvelist:
if curveobject.type == 'CURVE':
curveobject.select_set(True)
context.scene.objects.active = curveobject
context.view_layer.objects.active = curveobject
bpy.ops.object.collection_link(group="Btrace")
# Materials
trace_mats = addtracemat(curveobject.data)
@ -1167,7 +1167,7 @@ class OBJECT_OT_curvegrow(Operator):
objs = context.selected_objects
# Execute on multiple selected objects
for i in objs:
context.scene.objects.active = i
context.view_layer.objects.active = i
obj = context.active_object
try:
obj.data.fill_mode = 'FULL'
@ -1242,7 +1242,7 @@ class OBJECT_OT_reset(Operator):
try:
objs = context.selected_objects
for i in objs: # Execute on multiple selected objects
context.scene.objects.active = i
context.view_layer.objects.active = i
obj = context.active_object
obj.animation_data_clear()
if obj.type == 'CURVE':

View File

@ -89,7 +89,7 @@ class RunAction(Operator):
# -------------------------
bpy.ops.object.select_all(False)
myempty.select_set(True)
context.scene.objects.active = myempty
context.view_layer.objects.active = myempty
# save current configuration
savedinterpolation = context.preferences.edit.keyframe_new_interpolation_type
# change interpolation mode
@ -158,7 +158,7 @@ class RunAction(Operator):
# Track constraint
if turn_camera.track is True:
bpy.context.scene.objects.active = camera
bpy.context.view_layer.objects.active = camera
bpy.ops.object.constraint_add(type='TRACK_TO')
bpy.context.object.constraints[-1].track_axis = 'TRACK_NEGATIVE_Z'
bpy.context.object.constraints[-1].up_axis = 'UP_Y'
@ -173,7 +173,7 @@ class RunAction(Operator):
# -------------------------
bpy.ops.object.select_all(False)
selectobject.select_set(True)
bpy.context.scene.objects.active = selectobject
bpy.context.view_layer.objects.active = selectobject
bpy.context.scene.frame_set(savedframe)
return {'FINISHED'}

View File

@ -183,9 +183,9 @@ class StructureBuilder(DataStructure):
"""
Create the armature and leave it in edit mode
"""
bpy.context.scene.objects.active = None
bpy.context.view_layer.objects.active = None
bpy.ops.object.add(type='ARMATURE', enter_editmode=True)
self.object = bpy.context.scene.objects.active
self.object = bpy.context.view_layer.objects.active
self.armature = self.object.data
self.object.name = self.name
self.armature.name = self.name

View File

@ -221,7 +221,7 @@ class BTerrain:
@staticmethod
def _center(obj):
"""Move object geometry to object origin"""
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
bpy.ops.object.origin_set(center='BOUNDS')
@staticmethod

View File

@ -1036,7 +1036,7 @@ def meshmerge(selectedobjects):
# begin merging the mesh together as one
for count in range(len(cloneobjects)):
if count == 0:
bpy.context.scene.objects.active = cloneobjects[count]
bpy.context.view_layer.objects.active = cloneobjects[count]
print("Set Active Object:", cloneobjects[count].name)
cloneobjects[count].select_set(True)
bpy.ops.object.join() # join object together
@ -2030,7 +2030,7 @@ class OBJECT_OT_UTSelectedFaceSmooth(Operator):
i.select_set(False) # deselect all objects
obj.select_set(True) # set current object select
bpy.context.scene.objects.active = obj # set active object
bpy.context.view_layer.objects.active = obj # set active object
mesh = bmesh.new()
mesh.from_mesh(obj.data)
@ -2089,7 +2089,7 @@ def rebuildmesh(obj):
for i in bpy.context.scene.objects:
i.select_set(False) # deselect all objects
obj.select_set(True)
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
me_ob = bpy.data.meshes.new(("Re_" + obj.name))
mesh = obj.data
@ -2223,7 +2223,7 @@ def rebuildarmature(obj):
i.select_set(False) # deselect all objects
ob_new.select_set(True)
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
bpy.ops.object.mode_set(mode='EDIT')
for bone in obj.data.edit_bones:
@ -2236,7 +2236,7 @@ def rebuildarmature(obj):
for i in bpy.context.scene.objects:
i.select_set(False) # deselect all objects
bpy.context.scene.objects.active = ob_new
bpy.context.view_layer.objects.active = ob_new
bpy.ops.object.mode_set(mode='EDIT')
for bone in obj.data.bones:
@ -2567,7 +2567,7 @@ def udkcheckmeshline():
i.select_set(False) # deselect all objects
objmesh.select_set(True)
bpy.context.scene.objects.active = objmesh # set active mesh
bpy.context.view_layer.objects.active = objmesh # set active mesh
wedges = ObjMap()
points = ObjMap()
bpy.ops.object.mode_set(mode='EDIT') # set in edit mode

View File

@ -428,7 +428,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
i.select_set(False) #deselect all objects
ob_new.select_set(True)
#set current armature to edit the bone
bpy.context.scene.objects.active = ob_new
bpy.context.view_layer.objects.active = ob_new
#set mode to able to edit the bone
if bpy.ops.object.mode_set.poll():
bpy.ops.object.mode_set(mode='EDIT')

View File

@ -676,7 +676,7 @@ def draw_atoms_one_type(draw_all_atoms_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[3]*Ball_radius_factor,) * 3
if atom[0] == "Vacancy":
@ -977,7 +977,7 @@ def draw_sticks_skin(all_atoms,
# This is for putting the radiu of the sticks onto
# the desired value 'Stick_diameter'
bpy.context.scene.objects.active = new_stick_mesh
bpy.context.view_layer.objects.active = new_stick_mesh
# EDIT mode
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bm = bmesh.from_edit_mesh(new_stick_mesh.data)
@ -1062,7 +1062,7 @@ def draw_sticks_normal(all_atoms,
rotation=(0, 0, 0),
layers=current_layers)
# Put the stick into the scene ...
stick = bpy.context.scene.objects.active
stick = bpy.context.view_layer.objects.active
# ... and rotate the stick.
stick.rotation_euler = euler
# ... and name
@ -1083,7 +1083,7 @@ def draw_sticks_normal(all_atoms,
for stick in list_group_sub:
stick.select_set(True)
bpy.ops.object.join()
list_group.append(bpy.context.scene.objects.active)
list_group.append(bpy.context.view_layer.objects.active)
bpy.ops.object.select_all(action='DESELECT')
list_group_sub = []
counter = 0
@ -1096,7 +1096,7 @@ def draw_sticks_normal(all_atoms,
for stick in list_group_sub:
stick.select_set(True)
bpy.ops.object.join()
list_group.append(bpy.context.scene.objects.active)
list_group.append(bpy.context.view_layer.objects.active)
bpy.ops.object.select_all(action='DESELECT')
for group in list_group:
@ -1104,7 +1104,7 @@ def draw_sticks_normal(all_atoms,
bpy.ops.object.join()
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',
center='MEDIAN')
sticks = bpy.context.scene.objects.active
sticks = bpy.context.view_layer.objects.active
sticks.active_material = stick_material
else:
bpy.ops.object.empty_add(type='ARROWS',
@ -1112,7 +1112,7 @@ def draw_sticks_normal(all_atoms,
location=(0, 0, 0),
rotation=(0, 0, 0),
layers=current_layers)
sticks = bpy.context.scene.objects.active
sticks = bpy.context.view_layer.objects.active
for stick in list_group_sub:
stick.parent = sticks
@ -1389,4 +1389,4 @@ def import_pdb(Ball_type,
# activate the last selected object
if obj:
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj

View File

@ -157,11 +157,11 @@ class Ms3dExporter():
post_setup_environment(self, blender_context)
# restore active object
blender_context.scene.objects.active = self.active_object
blender_context.view_layer.objects.active = self.active_object
if ((not blender_context.scene.objects.active)
if ((not blender_context.view_layer.objects.active)
and (blender_context.selected_objects)):
blender_context.scene.objects.active \
blender_context.view_layer.objects.active \
= blender_context.selected_objects[0]
# restore pre operator undo state

View File

@ -103,7 +103,7 @@ def pre_setup_environment(porter, blender_context):
blender_context.preferences.edit.use_global_undo = False
# inject active_object to self
porter.active_object = blender_context.scene.objects.active
porter.active_object = blender_context.view_layer.objects.active
# change to a well defined mode
enable_edit_mode(True, blender_context)
@ -118,11 +118,11 @@ def pre_setup_environment(porter, blender_context):
###############################################################################
def post_setup_environment(porter, blender_context):
# restore active object
blender_context.scene.objects.active = porter.active_object
blender_context.view_layer.objects.active = porter.active_object
if not blender_context.scene.objects.active \
if not blender_context.view_layer.objects.active \
and blender_context.selected_objects:
blender_context.scene.objects.active \
blender_context.view_layer.objects.active \
= blender_context.selected_objects[0]
# restore pre operator undo state

View File

@ -102,7 +102,7 @@ def get_object_select(obj):
def set_active_object(obj):
if check_version(2, 80, 0) < 0:
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
else:
bpy.context.view_layer.objects.active = obj

View File

@ -514,7 +514,7 @@ if mat:
return "WARNING", "Can't preview on EDIT MODE"
if dummy!= active:
self.last_selected = context.object.name
context.scene.objects.active = dummy
context.view_layer.objects.active = dummy
objects.append(dummy)
#apply
else:
@ -529,11 +529,11 @@ if mat:
try:
last = context.scene.objects[self.last_selected]
if last in context.selected_objects:
context.scene.objects.active = last
context.view_layer.objects.active = last
else:
self.last_selected = ""
except:
context.scene.objects.active = None
context.view_layer.objects.active = None
dummy.select_set(False)
#objects = context.selected_objects
@ -893,7 +893,7 @@ class MATLIB_OT_flush(Operator):
dummy = matlib.get_dummy(context)
if dummy == context.object:
try:
context.scene.objects.active = context.scene.objects[matlib.last_selected]
context.view_layer.objects.active = context.scene.objects[matlib.last_selected]
except:
pass
@ -1023,7 +1023,7 @@ class MATLIB_OT_operator(Operator):
dummy = matlib.get_dummy(context)
if dummy == context.object:
try:
context.scene.objects.active = context.scene.objects[matlib.last_selected]
context.view_layer.objects.active = context.scene.objects[matlib.last_selected]
except:
pass

View File

@ -592,7 +592,7 @@ def assign_mat(matname="Default", operator=None):
me.update()
# restore the active object
bpy.context.scene.objects.active = actob
bpy.context.view_layer.objects.active = actob
# restore selection state
actob.select = selected

View File

@ -126,7 +126,7 @@ def get_strokes_type(main_object):
if strokes_type == "":
if len(bpy.context.selected_objects) == 2:
for ob in bpy.context.selected_objects:
if ob != bpy.context.scene.objects.active and ob.type == "CURVE":
if ob != bpy.context.view_layer.objects.active and ob.type == "CURVE":
strokes_type = "EXTERNAL_CURVE"
strokes_num = len(ob.data.splines)
@ -136,7 +136,7 @@ def get_strokes_type(main_object):
strokes_type = "CURVE_WITH_NON_BEZIER_SPLINES"
break
elif ob != bpy.context.scene.objects.active and ob.type != "CURVE":
elif ob != bpy.context.view_layer.objects.active and ob.type != "CURVE":
strokes_type = "EXTERNAL_NO_CURVE"
elif len(bpy.context.selected_objects) > 2:
strokes_type = "MORE_THAN_ONE_EXTERNAL"
@ -401,7 +401,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
try:
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.original_curve.select_set(True)
bpy.context.scene.objects.active = self.original_curve
bpy.context.view_layer.objects.active = self.original_curve
bpy.ops.object.delete()
except:
@ -409,12 +409,12 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_object.select_set(True)
bpy.context.scene.objects.active = self.main_object
bpy.context.view_layer.objects.active = self.main_object
else:
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.original_curve.select_set(True)
self.main_object.select_set(True)
bpy.context.scene.objects.active = self.main_object
bpy.context.view_layer.objects.active = self.main_object
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -997,7 +997,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob_original_splines.select = True
bpy.context.scene.objects.active = ob_original_splines
bpy.context.view_layer.objects.active = ob_original_splines
if len(ob_original_splines.data.splines) >= 2:
bpy.ops.object.duplicate('INVOKE_REGION_WIN')
@ -1123,7 +1123,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob_splines.select = True
bpy.context.scene.objects.active = ob_splines
bpy.context.view_layer.objects.active = ob_splines
# Deselect all points
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -1311,7 +1311,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
for o in objects_to_delete:
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
o.select_set(True)
bpy.context.scene.objects.active = o
bpy.context.view_layer.objects.active = o
bpy.ops.object.delete()
# If the main object has modifiers, turn their "viewport view status" to
@ -1359,7 +1359,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob.select_set(True)
bpy.context.scene.objects.active = ob
bpy.context.view_layer.objects.active = ob
# Get together each vert and its nearest, to the middle position
verts = ob.data.vertices
@ -1407,7 +1407,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
threshold=average_edge_length / 15.0)
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
final_points_ob = bpy.context.scene.objects.active
final_points_ob = bpy.context.view_layer.objects.active
# Make a dictionary with the verts related to each vert
related_key_verts = {}
@ -1538,14 +1538,14 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
# Delete final points temporal object
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
final_points_ob.select = True
bpy.context.scene.objects.active = final_points_ob
bpy.context.view_layer.objects.active = final_points_ob
bpy.ops.object.delete()
# Delete isolated verts if there are any
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob_surface.select = True
bpy.context.scene.objects.active = ob_surface
bpy.context.view_layer.objects.active = ob_surface
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.mesh.select_all(action='DESELECT')
@ -1589,7 +1589,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.duplicate('INVOKE_REGION_WIN')
final_ob_duplicate = bpy.context.scene.objects.active
final_ob_duplicate = bpy.context.view_layer.objects.active
bpy.ops.object.modifier_add('INVOKE_REGION_WIN', type='SHRINKWRAP')
shrinkwrap_modifier = final_ob_duplicate.modifiers[-1]
@ -1683,14 +1683,14 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
# Delete duplicated object
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
final_ob_duplicate.select_set(True)
bpy.context.scene.objects.active = final_ob_duplicate
bpy.context.view_layer.objects.active = final_ob_duplicate
bpy.ops.object.delete()
# Join crosshatched surface and main object
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob_surface.select = True
self.main_object.select_set(True)
bpy.context.scene.objects.active = self.main_object
bpy.context.view_layer.objects.active = self.main_object
bpy.ops.object.join('INVOKE_REGION_WIN')
@ -1894,7 +1894,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_splines.select = True
bpy.context.scene.objects.active = self.main_splines
bpy.context.view_layer.objects.active = self.main_splines
# Enter editmode for the new curve (converted from grease pencil strokes), to smooth it out
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -2446,7 +2446,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob_simplified_curve[i].select_set(True)
bpy.context.scene.objects.active = ob_simplified_curve[i]
bpy.context.view_layer.objects.active = ob_simplified_curve[i]
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.curve.select_all('INVOKE_REGION_WIN', action='SELECT')
@ -2491,7 +2491,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
# Delete the temporal curve
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob_simplified_curve[i].select_set(True)
bpy.context.scene.objects.active = ob_simplified_curve[i]
bpy.context.view_layer.objects.active = ob_simplified_curve[i]
bpy.ops.object.delete()
@ -2630,7 +2630,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob_ctrl_pts.select_set(True)
bpy.context.scene.objects.active = ob_ctrl_pts
bpy.context.view_layer.objects.active = ob_ctrl_pts
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.mesh.select_all(action='DESELECT')
@ -2697,7 +2697,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
# Create curves from control points.
bpy.ops.object.convert('INVOKE_REGION_WIN', target='CURVE', keep_original=False)
ob_curves_surf = bpy.context.scene.objects.active
ob_curves_surf = bpy.context.view_layer.objects.active
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.curve.spline_type_set('INVOKE_REGION_WIN', type='BEZIER')
bpy.ops.curve.handle_type_set('INVOKE_REGION_WIN', type='AUTOMATIC')
@ -2772,7 +2772,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
splines_U_objects.append(ob_spline_U)
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob_spline_U.select = True
bpy.context.scene.objects.active = ob_spline_U
bpy.context.view_layer.objects.active = ob_spline_U
# When option "Loops on strokes" is active each "Cross" loop will have
# its own proportions according to where the original strokes "touch" them
@ -2976,14 +2976,14 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
# Delete object with control points and object from grease pencil conversion
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob_ctrl_pts.select_set(True)
bpy.context.scene.objects.active = ob_ctrl_pts
bpy.context.view_layer.objects.active = ob_ctrl_pts
bpy.ops.object.delete()
for sp_ob in splines_U_objects:
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
sp_ob.select_set(True)
bpy.context.scene.objects.active = sp_ob
bpy.context.view_layer.objects.active = sp_ob
bpy.ops.object.delete()
@ -3023,7 +3023,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
# Join the new mesh to the main object
ob_surface.select = True
self.main_object.select_set(True)
bpy.context.scene.objects.active = self.main_object
bpy.context.view_layer.objects.active = self.main_object
bpy.ops.object.join('INVOKE_REGION_WIN')
@ -3061,7 +3061,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_splines.select = True
bpy.context.scene.objects.active = self.main_splines
bpy.context.view_layer.objects.active = self.main_splines
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -3084,7 +3084,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_object.select_set(True)
bpy.context.scene.objects.active = self.main_object
bpy.context.view_layer.objects.active = self.main_object
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -3098,13 +3098,13 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_splines.select = True
bpy.context.scene.objects.active = self.main_splines
bpy.context.view_layer.objects.active = self.main_splines
bpy.ops.object.delete()
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_object.select_set(True)
bpy.context.scene.objects.active = self.main_object
bpy.context.view_layer.objects.active = self.main_object
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -3115,7 +3115,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
def invoke(self, context, event):
self.initial_global_undo_state = bpy.context.preferences.edit.use_global_undo
self.main_object = bpy.context.scene.objects.active
self.main_object = bpy.context.view_layer.objects.active
self.main_object_selected_verts_count = int(self.main_object.data.total_vert_sel)
bpy.context.preferences.edit.use_global_undo = False
@ -3159,13 +3159,13 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
# self.original_curve = bpy.context.object
gplayer_prefix_translated = bpy.app.translations.pgettext_data('GP_Layer')
for ob in bpy.context.selected_objects:
if ob != bpy.context.scene.objects.active and \
if ob != bpy.context.view_layer.objects.active and \
ob.name.startswith((gplayer_prefix_translated, 'GP_Layer')):
self.original_curve = ob
self.using_external_curves = False
elif self.strokes_type == "EXTERNAL_CURVE":
for ob in bpy.context.selected_objects:
if ob != bpy.context.scene.objects.active:
if ob != bpy.context.view_layer.objects.active:
self.original_curve = ob
self.using_external_curves = True
@ -3177,17 +3177,17 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
if o.name.find("SURFSKIO_") != -1:
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
o.select_set(True)
bpy.context.scene.objects.active = o
bpy.context.view_layer.objects.active = o
bpy.ops.object.delete()
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.original_curve.select_set(True)
bpy.context.scene.objects.active = self.original_curve
bpy.context.view_layer.objects.active = self.original_curve
bpy.ops.object.duplicate('INVOKE_REGION_WIN')
self.temporary_curve = bpy.context.scene.objects.active
self.temporary_curve = bpy.context.view_layer.objects.active
# Deselect all points of the curve
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -3207,7 +3207,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.temporary_curve.select_set(True)
bpy.context.scene.objects.active = self.temporary_curve
bpy.context.view_layer.objects.active = self.temporary_curve
# Set a minimum number of points for crosshatch
minimum_points_num = 15
@ -3245,7 +3245,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
if not self.is_crosshatch:
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.temporary_curve.select_set(True)
bpy.context.scene.objects.active = self.temporary_curve
bpy.context.view_layer.objects.active = self.temporary_curve
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -3321,13 +3321,13 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
# Delete temporary strokes curve object
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.temporary_curve.select_set(True)
bpy.context.scene.objects.active = self.temporary_curve
bpy.context.view_layer.objects.active = self.temporary_curve
bpy.ops.object.delete()
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_object.select_set(True)
bpy.context.scene.objects.active = self.main_object
bpy.context.view_layer.objects.active = self.main_object
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -3340,13 +3340,13 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.original_curve.select_set(True)
bpy.context.scene.objects.active = self.original_curve
bpy.context.view_layer.objects.active = self.original_curve
bpy.ops.object.delete()
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_object.select_set(True)
bpy.context.scene.objects.active = self.main_object
bpy.context.view_layer.objects.active = self.main_object
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -3415,14 +3415,14 @@ class GPENCIL_OT_SURFSK_edit_strokes(Operator):
selected_objs = bpy.context.selected_objects
if self.strokes_type == "EXTERNAL_CURVE" or self.strokes_type == "SINGLE_CURVE_STROKE_NO_SELECTION":
for ob in selected_objs:
if ob != bpy.context.scene.objects.active:
if ob != bpy.context.view_layer.objects.active:
curve_ob = ob
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
curve_ob.select_set(True)
bpy.context.scene.objects.active = curve_ob
bpy.context.view_layer.objects.active = curve_ob
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
elif self.strokes_type == "GP_STROKES" or self.strokes_type == "SINGLE_GP_STROKE_NO_SELECTION":
@ -3430,7 +3430,7 @@ class GPENCIL_OT_SURFSK_edit_strokes(Operator):
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.gpencil.convert('INVOKE_REGION_WIN', type='CURVE', use_link_strokes=False)
for ob in bpy.context.selected_objects:
if ob != bpy.context.scene.objects.active and ob.name.startswith("GP_Layer"):
if ob != bpy.context.view_layer.objects.active and ob.name.startswith("GP_Layer"):
ob_gp_strokes = ob
# ob_gp_strokes = bpy.context.object
@ -3438,14 +3438,14 @@ class GPENCIL_OT_SURFSK_edit_strokes(Operator):
# Delete grease pencil strokes
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_object.select_set(True)
bpy.context.scene.objects.active = self.main_object
bpy.context.view_layer.objects.active = self.main_object
bpy.ops.gpencil.active_frame_delete('INVOKE_REGION_WIN')
# Clean up curves
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
ob_gp_strokes.select_set(True)
bpy.context.scene.objects.active = ob_gp_strokes
bpy.context.view_layer.objects.active = ob_gp_strokes
curve_crv = ob_gp_strokes.data
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@ -3488,7 +3488,7 @@ class CURVE_OT_SURFSK_reorder_splines(Operator):
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.gpencil.convert('INVOKE_REGION_WIN', type='CURVE', use_link_strokes=False)
for ob in bpy.context.selected_objects:
if ob != bpy.context.scene.objects.active and ob.name.startswith("GP_Layer"):
if ob != bpy.context.view_layer.objects.active and ob.name.startswith("GP_Layer"):
GP_strokes_curve = ob
# GP_strokes_curve = bpy.context.object
@ -3496,7 +3496,7 @@ class CURVE_OT_SURFSK_reorder_splines(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
GP_strokes_curve.select_set(True)
bpy.context.scene.objects.active = GP_strokes_curve
bpy.context.view_layer.objects.active = GP_strokes_curve
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.curve.select_all('INVOKE_REGION_WIN', action='SELECT')
@ -3512,7 +3512,7 @@ class CURVE_OT_SURFSK_reorder_splines(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_curve.select_set(True)
bpy.context.scene.objects.active = self.main_curve
bpy.context.view_layer.objects.active = self.main_curve
bpy.ops.object.duplicate('INVOKE_REGION_WIN')
curves_duplicate_1 = bpy.context.object
@ -3555,7 +3555,7 @@ class CURVE_OT_SURFSK_reorder_splines(Operator):
# Duplicate the duplicate and add Shrinkwrap to it, with the grease pencil strokes curve as target
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
curves_duplicate_2.select_set(True)
bpy.context.scene.objects.active = curves_duplicate_2
bpy.context.view_layer.objects.active = curves_duplicate_2
bpy.ops.object.modifier_add('INVOKE_REGION_WIN', type='SHRINKWRAP')
curves_duplicate_2.modifiers["Shrinkwrap"].wrap_method = "NEAREST_VERTEX"
@ -3627,7 +3627,7 @@ class CURVE_OT_SURFSK_reorder_splines(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_curve.select_set(True)
bpy.context.scene.objects.active = self.main_curve
bpy.context.view_layer.objects.active = self.main_curve
self.main_curve.name = "SURFSKIO_CRV_ORD"
@ -3657,7 +3657,7 @@ class CURVE_OT_SURFSK_reorder_splines(Operator):
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
bpy.data.objects[splines_unordered[order_idx]].select = True
bpy.data.objects["SURFSKIO_CRV_ORD"].select_set(True)
bpy.context.scene.objects.active = bpy.data.objects["SURFSKIO_CRV_ORD"]
bpy.context.view_layer.objects.active = bpy.data.objects["SURFSKIO_CRV_ORD"]
bpy.ops.object.join('INVOKE_REGION_WIN')
@ -3668,13 +3668,13 @@ class CURVE_OT_SURFSK_reorder_splines(Operator):
for o in objects_to_delete:
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
o.select_set(True)
bpy.context.scene.objects.active = o
bpy.context.view_layer.objects.active = o
bpy.ops.object.delete()
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
bpy.data.objects[curve_original_name].select_set(True)
bpy.context.scene.objects.active = bpy.data.objects[curve_original_name]
bpy.context.view_layer.objects.active = bpy.data.objects[curve_original_name]
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.curve.select_all('INVOKE_REGION_WIN', action='DESELECT')

View File

@ -1561,7 +1561,7 @@ def update_bevel(context):
for obj in selection:
bpy.ops.object.select_all(action='DESELECT')
obj.select_set(True)
context.scene.objects.active = obj
context.view_layer.objects.active = obj
# Test object name
if obj.data.name.startswith("S_") or obj.data.name.startswith("S "):
@ -1575,7 +1575,7 @@ def update_bevel(context):
if mod.type == 'BEVEL':
act_bevel = True
if act_bevel:
context.scene.objects.active = bpy.data.objects[obj.name]
context.view_layer.objects.active = bpy.data.objects[obj.name]
active = obj
bpy.ops.object.mode_set(mode='EDIT')
@ -1631,7 +1631,7 @@ def update_bevel(context):
for obj in selection:
obj.select_set(True)
context.scene.objects.active = active
context.view_layer.objects.active = active
# Create bevel
@ -1639,7 +1639,7 @@ def CreateBevel(context, CurrentObject):
# Save active object
SavActive = context.active_object
# Active "CurrentObject"
context.scene.objects.active = CurrentObject
context.view_layer.objects.active = CurrentObject
bpy.ops.object.mode_set(mode='EDIT')
@ -1686,7 +1686,7 @@ def CreateBevel(context, CurrentObject):
context.object.data.auto_smooth_angle = 1.0471975
# Restore the active object
context.scene.objects.active = SavActive
context.view_layer.objects.active = SavActive
# Picking (template)
@ -1853,7 +1853,7 @@ def SelectObject(self, copyobj):
SelectObject(self, child)
if copyobj.parent is None:
bpy.context.scene.objects.active = copyobj
bpy.context.view_layer.objects.active = copyobj
# Undo
@ -1908,7 +1908,7 @@ def Undo(self):
for so in SelectObjList:
bpy.data.objects[so.name].select_set(True)
bpy.context.scene.objects.active = Active_Obj
bpy.context.view_layer.objects.active = Active_Obj
self.UList_Index -= 1
self.UList[self.UList_Index + 1:] = []
@ -1979,7 +1979,7 @@ def duplicateObject(self):
for o in self.SavSel:
o.select_set(True)
bpy.context.scene.objects.active = self.OpsObj
bpy.context.view_layer.objects.active = self.OpsObj
def update_grid(self, context):
@ -2056,7 +2056,7 @@ def update_grid(self, context):
# Update data
obj.data = mymesh
# Make the object active to remove doubles
context.scene.objects.active = obj
context.view_layer.objects.active = obj
def boolean_operation(bool_type="DIFFERENCE"):
@ -2082,7 +2082,7 @@ def Rebool(context, self):
bpy.ops.object.select_all(action='TOGGLE')
context.scene.objects.active = obj
context.view_layer.objects.active = obj
obj.display_type = "SOLID"
obj.select_set(True)
bpy.ops.object.duplicate_move(
@ -2144,7 +2144,7 @@ def Rebool(context, self):
if mb.type == 'BEVEL':
mb.show_viewport = True
context.scene.objects.active = obj
context.view_layer.objects.active = obj
obj.select_set(True)
if self.DontApply is False:
try:
@ -2189,7 +2189,7 @@ def Selection_Save_Restore(self):
Selection_Save(self)
bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects["CT_Profil"].select_set(True)
bpy.context.scene.objects.active = bpy.data.objects["CT_Profil"]
bpy.context.view_layer.objects.active = bpy.data.objects["CT_Profil"]
if bpy.data.objects["CT_Profil"] in self.SavSel:
self.SavSel.remove(bpy.data.objects["CT_Profil"])
bpy.ops.object.delete(use_global=False)
@ -2206,7 +2206,7 @@ def Selection_Restore(self):
for o in self.SavSel:
o.select_set(True)
if self.Sav_ac:
bpy.context.scene.objects.active = bpy.data.objects.get(self.Sav_ac, None)
bpy.context.view_layer.objects.active = bpy.data.objects.get(self.Sav_ac, None)
# Modal Operator
@ -2388,7 +2388,7 @@ class Carver(bpy.types.Operator):
bpy.ops.object.select_all(action='TOGGLE')
self.ProfileBrush.select_set(True)
context.scene.objects.active = self.ProfileBrush
context.view_layer.objects.active = self.ProfileBrush
# Set xRay
self.ProfileBrush.show_in_front = True
@ -2416,7 +2416,7 @@ class Carver(bpy.types.Operator):
bpy.ops.object.select_all(action='TOGGLE')
self.ObjectBrush.select_set(True)
context.scene.objects.active = self.ObjectBrush
context.view_layer.objects.active = self.ObjectBrush
bpy.ops.object.modifier_remove(modifier="CT_SOLIDIFY")
@ -2428,7 +2428,7 @@ class Carver(bpy.types.Operator):
self.SolidifyPossible = True
bpy.ops.object.select_all(action='TOGGLE')
self.ObjectBrush.select_set(True)
context.scene.objects.active = self.ObjectBrush
context.view_layer.objects.active = self.ObjectBrush
# Set xRay
self.ObjectBrush.show_in_front = True
bpy.ops.object.modifier_add(type='SOLIDIFY')
@ -2527,12 +2527,12 @@ class Carver(bpy.types.Operator):
bpy.ops.object.select_all(action='TOGGLE')
if self.ObjectMode:
self.ObjectBrush.select_set(True)
context.scene.objects.active = self.ObjectBrush
context.view_layer.objects.active = self.ObjectBrush
# Active le xray
self.ObjectBrush.show_in_front = True
else:
self.ProfileBrush.select_set(True)
context.scene.objects.active = self.ProfileBrush
context.view_layer.objects.active = self.ProfileBrush
# Active le xray
self.ProfileBrush.show_in_front = True
@ -2782,7 +2782,7 @@ class Carver(bpy.types.Operator):
bpy.ops.object.select_all(action='TOGGLE')
self.ObjectBrush.select_set(True)
context.scene.objects.active = self.ObjectBrush
context.view_layer.objects.active = self.ObjectBrush
bpy.ops.object.modifier_remove(modifier="CT_SOLIDIFY")
@ -2853,7 +2853,7 @@ class Carver(bpy.types.Operator):
bpy.ops.object.select_all(action='TOGGLE')
self.ObjectBrush.select_set(True)
context.scene.objects.active = self.ObjectBrush
context.view_layer.objects.active = self.ObjectBrush
bpy.ops.object.modifier_remove(modifier="CT_SOLIDIFY")
bpy.ops.object.select_all(action='TOGGLE')
@ -2861,7 +2861,7 @@ class Carver(bpy.types.Operator):
Selection_Restore(self)
Selection_Save_Restore(self)
context.scene.objects.active = self.CurrentActive
context.view_layer.objects.active = self.CurrentActive
context.scene.mesh_carver.nProfile = self.nProfil
bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
@ -3152,7 +3152,7 @@ class Carver(bpy.types.Operator):
if len(context.selected_objects) > 0:
bpy.ops.object.select_all(action='TOGGLE')
context.scene.objects.active = self.CurrentObj
context.view_layer.objects.active = self.CurrentObj
bpy.data.objects[self.CurrentObj.name].select_set(True)
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
@ -3218,7 +3218,7 @@ class Carver(bpy.types.Operator):
bpy.ops.object.select_all(action='TOGGLE')
context.scene.objects.active = self.CurrentObj
context.view_layer.objects.active = self.CurrentObj
bpy.data.objects[self.CurrentObj.name].select_set(True)
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
@ -3265,7 +3265,7 @@ class Carver(bpy.types.Operator):
# Select cut object
bpy.data.objects[self.CurrentObj.name].select_set(True)
context.scene.objects.active = self.CurrentObj
context.view_layer.objects.active = self.CurrentObj
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
@ -3273,7 +3273,7 @@ class Carver(bpy.types.Operator):
# Select object to cut
bpy.data.objects[ActiveObj.name].select_set(True)
context.scene.objects.active = ActiveObj
context.view_layer.objects.active = ActiveObj
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
@ -3331,9 +3331,9 @@ class Carver(bpy.types.Operator):
context.scene.cursor_location = CursorLocation
if self.ObjectMode:
context.scene.objects.active = self.ObjectBrush
context.view_layer.objects.active = self.ObjectBrush
if self.ProfileMode:
context.scene.objects.active = self.ProfileBrush
context.view_layer.objects.active = self.ProfileBrush
if self.DontApply is False:
# Apply booleans
@ -3374,7 +3374,7 @@ class Carver(bpy.types.Operator):
for ActiveObj in ActiveObjList:
bpy.data.objects[ActiveObj.name].select_set(True)
context.scene.objects.active = ActiveObj
context.view_layer.objects.active = ActiveObj
# Update bevel
list_act_obj = context.selected_objects.copy()
if self.Auto_BevelUpdate:
@ -3387,7 +3387,7 @@ class Carver(bpy.types.Operator):
self.ObjectBrush.select_set(True)
for ActiveObj in ActiveObjList:
bpy.data.objects[ActiveObj.name].select_set(True)
context.scene.objects.active = ActiveObj
context.view_layer.objects.active = ActiveObj
# If object has children, set "Wire" draw type
if self.ObjectBrush is not None:

View File

@ -487,7 +487,7 @@ class EdgeRoundifier(Operator):
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.mode_set(mode='EDIT')
mesh = context.scene.objects.active.data
mesh = context.view_layer.objects.active.data
bm = bmesh.new()
bm.from_mesh(mesh)
@ -619,7 +619,7 @@ class EdgeRoundifier(Operator):
self.resetValues(parameters["workMode"])
self.obj = context.scene.objects.active
self.obj = context.view_layer.objects.active
scaledEdges = self.scaleDuplicatedEdges(bm, edges, parameters)
if len(scaledEdges) > 0:
@ -1335,7 +1335,7 @@ class EdgeRoundifier(Operator):
def selectEdgesAfterRoundifier(self, context, edges):
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.mode_set(mode='EDIT')
mesh = context.scene.objects.active.data
mesh = context.view_layer.objects.active.data
bmnew = bmesh.new()
bmnew.from_mesh(mesh)

View File

@ -309,7 +309,7 @@ class MESH_OT_add_faces_to_object(Operator):
# PKHG>INFO now the extruded facec have to move in normal direction
bpy.ops.object.mode_set(mode='EDIT')
obj = bpy.context.scene.objects.active
obj = bpy.context.view_layer.objects.active
bm = bmesh.from_edit_mesh(obj.data)
todo_faces = [face for face in bm.faces if face.select]
for face in todo_faces:
@ -680,7 +680,7 @@ def prepare(self, context, remove_start_faces=True):
Start for a face selected change of faces
select an object of type mesh, with activated several (all) faces
"""
obj = bpy.context.scene.objects.active
obj = bpy.context.view_layer.objects.active
bpy.ops.object.mode_set(mode='OBJECT')
selectedpolygons = [el for el in obj.data.polygons if el.select]

View File

@ -139,7 +139,7 @@ class dual_mesh(Operator):
ob.data = ob.data.copy()
bpy.ops.object.select_all(action='DESELECT')
ob.select_set(True)
bpy.context.scene.objects.active = ob0
bpy.context.view_layer.objects.active = ob0
bpy.ops.object.mode_set(mode='EDIT')
# prevent borders erosion
@ -276,7 +276,7 @@ class dual_mesh(Operator):
for o in sel:
o.select_set(True)
bpy.context.scene.objects.active = act
bpy.context.view_layer.objects.active = act
bpy.ops.object.mode_set(mode=mode)
return {'FINISHED'}

View File

@ -338,7 +338,7 @@ class lattice_along_surface(Operator):
if len(grid_mesh.polygons) > 64 * 64:
bpy.ops.object.delete(use_global=False)
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
self.report({'ERROR'}, "Maximum resolution allowed for Lattice is 64")
return {'CANCELLED'}
@ -379,7 +379,7 @@ class lattice_along_surface(Operator):
if bb.z == 0:
lattice.scale.z = 1
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
bpy.ops.object.modifier_add(type='LATTICE')
obj.modifiers[-1].object = lattice
@ -387,7 +387,7 @@ class lattice_along_surface(Operator):
if self.set_parent:
obj.select_set(True)
lattice.select_set(True)
bpy.context.scene.objects.active = lattice
bpy.context.view_layer.objects.active = lattice
bpy.ops.object.parent_set(type='LATTICE')
# reading grid structure
@ -436,7 +436,7 @@ class lattice_along_surface(Operator):
lattice.select_set(True)
obj.select_set(False)
bpy.ops.object.delete(use_global=False)
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
bpy.ops.object.modifier_remove(modifier=obj.modifiers[-1].name)
if nu > 64 or nv > 64:
@ -455,7 +455,7 @@ class lattice_along_surface(Operator):
lattice.select_set(False)
obj.select_set(False)
bpy.ops.object.delete(use_global=False)
bpy.context.scene.objects.active = lattice
bpy.context.view_layer.objects.active = lattice
lattice.select_set(True)
if self.high_quality_lattice:
@ -466,7 +466,7 @@ class lattice_along_surface(Operator):
if self.hide_lattice:
bpy.ops.object.hide_view_set(unselected=False)
bpy.context.scene.objects.active = obj
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
lattice.select_set(False)

View File

@ -889,7 +889,7 @@ class tessellate(Operator):
scene = bpy.context.scene
scene.objects.link(new_ob)
new_ob.select_set(True)
bpy.context.scene.objects.active = new_ob
bpy.context.view_layer.objects.active = new_ob
if self.merge:
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(
@ -1432,7 +1432,7 @@ class settings_tessellate(Operator):
scene = bpy.context.scene
scene.objects.link(temp_ob)
temp_ob.select_set(True)
bpy.context.scene.objects.active = temp_ob
bpy.context.view_layer.objects.active = temp_ob
try:
bpy.ops.object.vertex_group_copy_to_linked()
@ -1441,7 +1441,7 @@ class settings_tessellate(Operator):
scene.objects.unlink(temp_ob)
bpy.data.objects.remove(temp_ob)
bpy.context.scene.objects.active = self.ob
bpy.context.view_layer.objects.active = self.ob
if self.merge:
bpy.ops.object.mode_set(mode='EDIT')
@ -1544,9 +1544,9 @@ class rotate_face(Operator):
bpy.ops.object.mode_set(mode='OBJECT')
for o in [obj for obj in bpy.data.objects if
obj.tissue_tessellate.generator == ob.name]:
bpy.context.scene.objects.active = o
bpy.context.view_layer.objects.active = o
bpy.ops.object.update_tessellate()
bpy.context.scene.objects.active = ob
bpy.context.view_layer.objects.active = ob
bpy.ops.object.mode_set(mode='EDIT')
return {'FINISHED'}

View File

@ -177,7 +177,7 @@ class uv_to_mesh(Operator):
ob0.select_set(True)
bpy.ops.object.delete(use_global=False)
ob.select_set(True)
bpy.context.scene.objects.active = ob
bpy.context.view_layer.objects.active = ob
return {'FINISHED'}

View File

@ -122,7 +122,7 @@ def createIntermediate(performer_obj, enduser_obj, root, s_frame, e_frame, scene
inter_obj.data = inter_obj.data.copy() # duplicate data
bpy.context.scene.objects.link(inter_obj)
inter_obj.name = "intermediate"
bpy.context.scene.objects.active = inter_obj
bpy.context.view_layer.objects.active = inter_obj
bpy.ops.object.mode_set(mode='EDIT')
#add some temporary connecting bones in case end user bones are not connected to their parents
rollDict = {}
@ -538,7 +538,7 @@ def totalRetarget(performer_obj, enduser_obj, scene, s_frame, e_frame):
if not advanced:
print("hry")
bpy.ops.object.select_all(action='DESELECT')
bpy.context.scene.objects.active = enduser_obj
bpy.context.view_layer.objects.active = enduser_obj
bpy.ops.object.select_pattern(pattern=enduser_obj.name, extend=False)
IKRetarget(performer_obj, enduser_obj, s_frame, e_frame, scene, step)
bpy.ops.object.select_pattern(pattern=stride_bone.name, extend=False)

View File

@ -70,7 +70,7 @@ def create_cutter(context, crack_type, scale, roughness):
v.co *= scale
if crack_type == 'SPHERE_ROUGH':
for v in context.scene.objects.active.data.vertices:
for v in context.view_layer.objects.active.data.vertices:
v.co[0] += roughness * scale * 0.2 * (random.random() - 0.5)
v.co[1] += roughness * scale * 0.1 * (random.random() - 0.5)
v.co[2] += roughness * scale * 0.1 * (random.random() - 0.5)
@ -142,10 +142,10 @@ def getIslands(shard):
shards = []
for gi in range(0, gindex):
bpy.ops.object.select_all(action='DESELECT')
bpy.context.scene.objects.active = shard
bpy.context.view_layer.objects.active = shard
shard.select_set(True)
bpy.ops.object.duplicate(linked=False, mode='DUMMY')
a = bpy.context.scene.objects.active
a = bpy.context.view_layer.objects.active
sm = a.data
print (a.name)
@ -159,7 +159,7 @@ def getIslands(shard):
#print('getIslands: ' + str(x))
a.data.vertices[x].select = True
print(bpy.context.scene.objects.active.name)
print(bpy.context.view_layer.objects.active.name)
bpy.ops.object.editmode_toggle()
bpy.ops.mesh.delete()

View File

@ -48,7 +48,7 @@ def makeFracture(child_verts=False, division=100, noise=0.00,
scaleX=1.00, scaleY=1.00, scaleZ=1.00, recursion=0, margin=0.001):
# Get active object name and active layer
active_name = bpy.context.scene.objects.active.name
active_name = bpy.context.view_layer.objects.active.name
active_layer = bpy.context.scene.active_layer
# source method of whether use child verts
@ -81,7 +81,7 @@ def _makeJoin(active_name, active_layer):
if fractures:
# Execute join
bpy.context.scene.objects.active = fractures[0]
bpy.context.view_layer.objects.active = fractures[0]
fractures[0].select_set(True)
bpy.ops.object.join()
else:
@ -91,7 +91,7 @@ def _makeJoin(active_name, active_layer):
)
# Change name
bpy.context.scene.objects.active.name = active_name + '_crack'
bpy.context.view_layer.objects.active.name = active_name + '_crack'
# Change origin
bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN')

View File

@ -181,7 +181,7 @@ def init_props():
# selects vertices
def select_vertices(mesh_obj, idx):
bpy.context.scene.objects.active = mesh_obj
bpy.context.view_layer.objects.active = mesh_obj
mode = mesh_obj.mode
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

View File

@ -73,7 +73,7 @@ class POVRAY_OT_lathe_add(bpy.types.Operator):
rotation=(0, 0, 0),
layers=layers,
)
ob = context.scene.objects.active
ob = context.view_layer.objects.active
ob_data = ob.data
ob.name = ob_data.name = "PovLathe"
ob_data.dimensions = '2D'
@ -1073,7 +1073,7 @@ class POVRAY_OT_rainbow_add(bpy.types.Operator):
ob.location = -cam.location
#refocus on the actual rainbow
bpy.context.scene.objects.active = ob
bpy.context.view_layer.objects.active = ob
ob.select_set(True)
return {'FINISHED'}

View File

@ -215,7 +215,7 @@ class ModifiersSubsurfLevel_Set(Operator, BasePollCheck):
try:
if not selection:
for obj in bpy.data.objects:
context.scene.objects.active = obj
context.view_layer.objects.active = obj
bpy.ops.object.modifier_add(type='SUBSURF')
value = 0
for mod in obj.modifiers:

View File

@ -357,7 +357,7 @@ class SCENE_OT_namedlayer_select_objects_by_layer(Operator):
objects.append(obj)
not_all_selected -= 1
if self.active:
context.scene.objects.active = obj
context.view_layer.objects.active = obj
if obj.select_get():
not_all_selected += 1
if not not_all_selected: