Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNBurn <7nburn@gmail.com>2019-01-29 17:08:23 +0300
committerNBurn <7nburn@gmail.com>2019-01-29 17:08:23 +0300
commit5c994fde52196dfe8a7e0db03b6935bac001d353 (patch)
treea7836a0741695b78df699e59a30f2a527202a815
parent8b93448f56ecdf9c91ad1b6297580eedf1f6e18f (diff)
addons: more view_layer syntax updates
-rw-r--r--add_advanced_objects_menu/cubester.py8
-rw-r--r--add_mesh_extra_objects/Wallfactory.py4
-rw-r--r--add_mesh_extra_objects/add_mesh_round_brilliant.py5
-rw-r--r--animation_add_corrective_shape_key.py2
-rw-r--r--ant_landscape/ant_functions.py6
-rw-r--r--io_export_unreal_psk_psa.py6
-rw-r--r--io_scene_ms3d/ms3d_export.py3
-rw-r--r--io_scene_ms3d/ms3d_import.py5
-rw-r--r--light_field_tools/light_field_tools.py5
-rw-r--r--object_cloud_gen.py81
-rw-r--r--object_fracture/fracture_ops.py3
-rw-r--r--object_print3d_utils/export.py2
-rw-r--r--uv_texture_atlas.py30
13 files changed, 84 insertions, 76 deletions
diff --git a/add_advanced_objects_menu/cubester.py b/add_advanced_objects_menu/cubester.py
index 6c4f8dfd..20ebb2aa 100644
--- a/add_advanced_objects_menu/cubester.py
+++ b/add_advanced_objects_menu/cubester.py
@@ -172,7 +172,9 @@ def create_material(scene, ob, name):
# generate mesh from audio
-def create_mesh_from_audio(self, scene, verts, faces):
+def create_mesh_from_audio(self, context, verts, faces):
+ scene = context.scene
+ view_layer = context.view_layer
adv_obj = scene.advanced_objects
audio_filepath = adv_obj.cubester_audio_path
width = adv_obj.cubester_audio_width_blocks
@@ -337,7 +339,7 @@ def create_mesh_from_audio(self, scene, verts, faces):
ob.select_set(True)
curve.select_set(False)
- scene.objects.active = ob
+ view_layer.objects.active = ob
# data was collected and then multi-variable regression was done in Excel
# influence of width and length
@@ -912,7 +914,7 @@ class CubeSter(Operator):
path.isfile(adv_obj.cubester_audio_path) and
adv_obj.cubester_check_audio is True):
- create_mesh_from_audio(self, scene, verts, faces)
+ create_mesh_from_audio(self, context, verts, faces)
created = adv_obj.cubester_audio_file_length
else:
self.report({'WARNING'},
diff --git a/add_mesh_extra_objects/Wallfactory.py b/add_mesh_extra_objects/Wallfactory.py
index f7edf659..1f36d884 100644
--- a/add_mesh_extra_objects/Wallfactory.py
+++ b/add_mesh_extra_objects/Wallfactory.py
@@ -865,8 +865,6 @@ class add_mesh_wallb(Operator):
# Make a mesh from a list of verts/edges/faces.
mesh.from_pydata(verts_array, [], faces_array)
- scene = context.scene
-
# Deselect all objects.
bpy.ops.object.select_all(action='DESELECT')
@@ -876,7 +874,7 @@ class add_mesh_wallb(Operator):
scene.objects.link(ob_new)
# leave this out to prevent 'Tab key" going into edit mode :)
# Use rmb click to select and still modify.
- scene.objects.active = ob_new
+ context.view_layer.objects.active = ob_new
ob_new.select_set(True)
ob_new.location = tuple(context.scene.cursor_location)
diff --git a/add_mesh_extra_objects/add_mesh_round_brilliant.py b/add_mesh_extra_objects/add_mesh_round_brilliant.py
index 90673ed4..7794269e 100644
--- a/add_mesh_extra_objects/add_mesh_round_brilliant.py
+++ b/add_mesh_extra_objects/add_mesh_round_brilliant.py
@@ -220,9 +220,6 @@ def addBrilliant(context, s, table_w, crown_h, girdle_t, pavi_d, bezel_f,
cf.append(i)
fa(*cf)
- # bpy variables / shortcuts
- scene = bpy.context.scene
-
# deactivate possible active Objects
bpy.context.view_layer.objects.active = None
@@ -236,7 +233,7 @@ def addBrilliant(context, s, table_w, crown_h, girdle_t, pavi_d, bezel_f,
dobj = object_utils.object_data_add(context, dmesh, operator=None, name="dobj").object
# activate and select object
- scene.objects.active = dobj
+ bpy.context.view_layer.objects.active = dobj
dobj.select_set(True)
obj = bpy.context.active_object
diff --git a/animation_add_corrective_shape_key.py b/animation_add_corrective_shape_key.py
index e7fc75ce..8a9bdb28 100644
--- a/animation_add_corrective_shape_key.py
+++ b/animation_add_corrective_shape_key.py
@@ -228,7 +228,7 @@ class object_duplicate_flatten_modifiers(bpy.types.Operator):
# setup the context
bpy.ops.object.select_all(action='DESELECT')
- scene.objects.active = new_object
+ context.view_layer.objects.active = new_object
new_object.select_set(True)
return {'FINISHED'}
diff --git a/ant_landscape/ant_functions.py b/ant_landscape/ant_functions.py
index a20d2ff1..3f2c6103 100644
--- a/ant_landscape/ant_functions.py
+++ b/ant_landscape/ant_functions.py
@@ -205,7 +205,7 @@ class AntLandscapeRegenerate(bpy.types.Operator):
undo = bpy.context.preferences.edit.use_global_undo
bpy.context.preferences.edit.use_global_undo = False
- scene = bpy.context.scene
+ view_layer = bpy.context.view_layer
# ant object items
obj = bpy.context.active_object
@@ -321,12 +321,12 @@ class AntLandscapeRegenerate(bpy.types.Operator):
new_ob.select_set(False)
obj.select_set(True)
- scene.objects.active = obj
+ view_layer.objects.active = obj
bpy.ops.object.delete(use_global=False)
# Select landscape and make active
new_ob.select_set(True)
- scene.objects.active = new_ob
+ view_layer.objects.active = new_ob
# restore pre operator undo state
context.preferences.edit.use_global_undo = undo
diff --git a/io_export_unreal_psk_psa.py b/io_export_unreal_psk_psa.py
index 7b7272be..8695ee5e 100644
--- a/io_export_unreal_psk_psa.py
+++ b/io_export_unreal_psk_psa.py
@@ -978,6 +978,7 @@ def triangulate_mesh(object):
verbose(header("triangulateNMesh"))
# print(type(object))
scene = bpy.context.scene
+ view_layer = bpy.context.view_layer
me_ob = object.copy()
me_ob.data = object.to_mesh(bpy.context.scene, True, 'PREVIEW') # write data object
@@ -989,7 +990,7 @@ def triangulate_mesh(object):
i.select_set(False) # deselect all objects
me_ob.select_set(True)
- scene.objects.active = me_ob
+ view_layer.objects.active = me_ob
print("Copy and Convert mesh just incase any way...")
@@ -1083,11 +1084,12 @@ def parse_mesh(mesh, psk):
print(header("MESH", 'RIGHT'))
print("Mesh object:", mesh.name)
scene = bpy.context.scene
+ view_layer = bpy.context.view_layer
for i in scene.objects:
i.select_set(False) # deselect all objects
- scene.objects.active = mesh
+ view_layer.objects.active = mesh
setmesh = mesh
mesh = triangulate_mesh(mesh)
diff --git a/io_scene_ms3d/ms3d_export.py b/io_scene_ms3d/ms3d_export.py
index 478ae755..aed7f400 100644
--- a/io_scene_ms3d/ms3d_export.py
+++ b/io_scene_ms3d/ms3d_export.py
@@ -219,6 +219,7 @@ class Ms3dExporter():
###########################################################################
def create_geometry(self, blender_context, ms3d_model, blender_mesh_objects, blender_to_ms3d_bones):
+ blender_view_layer = blender_context.view_layer
blender_scene = blender_context.scene
blender_to_ms3d_vertices = {}
@@ -271,7 +272,7 @@ class Ms3dExporter():
blender_mesh_object_temp = blender_mesh_object.copy()
blender_mesh_object_temp.data = blender_mesh_temp
blender_scene.objects.link(blender_mesh_object_temp)
- blender_scene.objects.active = blender_mesh_object_temp
+ blender_view_layer.objects.active = blender_mesh_object_temp
# apply transform
if self.options_apply_transform:
diff --git a/io_scene_ms3d/ms3d_import.py b/io_scene_ms3d/ms3d_import.py
index dbf6d87e..d4fd6f2c 100644
--- a/io_scene_ms3d/ms3d_import.py
+++ b/io_scene_ms3d/ms3d_import.py
@@ -285,12 +285,13 @@ class Ms3dImporter():
# blender stuff:
# link to blender scene
blender_scene = blender_context.scene
+ blender_view_layer = blender_context.view_layer
blender_scene.objects.link(blender_mesh_object)
#blender_mesh_object.location = blender_scene.cursor_location
enable_edit_mode(False, blender_context)
select_all(False)
blender_mesh_object.select_set(True)
- blender_scene.objects.active = blender_mesh_object
+ blender_view_layer.objects.active = blender_mesh_object
##########################
# take this as active object after import
@@ -827,7 +828,7 @@ class Ms3dImporter():
if joint_length < 0.01:
joint_length = 0.01
- blender_scene.objects.active = blender_armature_object
+ blender_view_layer.objects.active = blender_armature_object
enable_edit_mode(True, blender_context)
for ms3d_joint in ms3d_joints_ordered:
blender_edit_bone = blender_armature.edit_bones.new(ms3d_joint.name)
diff --git a/light_field_tools/light_field_tools.py b/light_field_tools/light_field_tools.py
index f49a54f7..d46dec02 100644
--- a/light_field_tools/light_field_tools.py
+++ b/light_field_tools/light_field_tools.py
@@ -320,6 +320,7 @@ class OBJECT_OT_create_lightfield_basemesh(Operator):
def addMeshObj(self, mesh):
scene = bpy.context.scene
+ view_layer = bpy.context.view_layer
for o in scene.objects:
o.select_set(False)
@@ -329,8 +330,8 @@ class OBJECT_OT_create_lightfield_basemesh(Operator):
scene.objects.link(nobj)
nobj.select_set(True)
- if scene.objects.active is None or scene.objects.active.mode == 'OBJECT':
- scene.objects.active = nobj
+ if view_layer.objects.active is None or view_layer.objects.active.mode == 'OBJECT':
+ view_layer.objects.active = nobj
def execute(self, context):
scene = context.scene
diff --git a/object_cloud_gen.py b/object_cloud_gen.py
index 6255e581..199bc2c2 100644
--- a/object_cloud_gen.py
+++ b/object_cloud_gen.py
@@ -183,7 +183,7 @@ def CreateNodeGroup(Type):
# and adds a bounding box to it.
# It will add or subtract the bound box size by the variable sizeDifference.
-def getMeshandPutinEditMode(scene, object):
+def getMeshandPutinEditMode(view_layer, object):
# Go into Object Mode
bpy.ops.object.mode_set(mode='OBJECT')
@@ -193,7 +193,7 @@ def getMeshandPutinEditMode(scene, object):
# Select the object
object.select_set(True)
- scene.objects.active = object
+ view_layer.objects.active = object
# Go into Edit Mode
bpy.ops.object.mode_set(mode='EDIT')
@@ -201,9 +201,9 @@ def getMeshandPutinEditMode(scene, object):
return object.data
-def maxAndMinVerts(scene, object):
+def maxAndMinVerts(view_layer, object):
- mesh = getMeshandPutinEditMode(scene, object)
+ mesh = getMeshandPutinEditMode(view_layer, object)
verts = mesh.vertices
# Set the max and min verts to the first vertex on the list
@@ -231,13 +231,13 @@ def maxAndMinVerts(scene, object):
return [maxVert, minVert]
-def makeObjectIntoBoundBox(scene, objects, sizeDifference, takeFromObject):
+def makeObjectIntoBoundBox(view_layer, objects, sizeDifference, takeFromObject):
# Let's find the max and min of the reference object,
# it can be the same as the destination object
- [maxVert, minVert] = maxAndMinVerts(scene, takeFromObject)
+ [maxVert, minVert] = maxAndMinVerts(view_layer, takeFromObject)
# get objects mesh
- mesh = getMeshandPutinEditMode(scene, objects)
+ mesh = getMeshandPutinEditMode(view_layer, objects)
# Add the size difference to the max size of the box
maxVert[0] = maxVert[0] + sizeDifference
@@ -292,24 +292,24 @@ def makeObjectIntoBoundBox(scene, objects, sizeDifference, takeFromObject):
mesh.update()
-def applyScaleRotLoc(scene, obj):
+def applyScaleRotLoc(view_layer, obj):
# Deselect All
bpy.ops.object.select_all(action='DESELECT')
# Select the object
obj.select_set(True)
- scene.objects.active = obj
+ view_layer.objects.active = obj
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
-def totallyDeleteObject(scene, obj):
+def totallyDeleteObject(obj):
bpy.data.objects.remove(obj, do_unlink=True)
-def makeParent(parentobj, childobj, scene):
- applyScaleRotLoc(scene, parentobj)
- applyScaleRotLoc(scene, childobj)
+def makeParent(parentobj, childobj, view_layer):
+ applyScaleRotLoc(view_layer, parentobj)
+ applyScaleRotLoc(view_layer, childobj)
childobj.parent = parentobj
@@ -343,13 +343,13 @@ def getpdensitytexture(object):
return tex
-def removeParticleSystemFromObj(scene, obj):
+def removeParticleSystemFromObj(view_layer, obj):
# Deselect All
bpy.ops.object.select_all(action='DESELECT')
# Select the object
obj.select_set(True)
- scene.objects.active = obj
+ view_layer.objects.active = obj
bpy.ops.object.particle_system_remove()
@@ -357,10 +357,10 @@ def removeParticleSystemFromObj(scene, obj):
bpy.ops.object.select_all(action='DESELECT')
-def convertParticlesToMesh(scene, particlesobj, destobj, replacemesh):
+def convertParticlesToMesh(view_layer, particlesobj, destobj, replacemesh):
# Select the Destination object
destobj.select_set(True)
- scene.objects.active = destobj
+ view_layer.objects.active = destobj
# Go to Edit Mode
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
@@ -389,7 +389,7 @@ def convertParticlesToMesh(scene, particlesobj, destobj, replacemesh):
meshPnts.update()
-def combineObjects(scene, combined, listobjs):
+def combineObjects(view_layer, combined, listobjs):
# scene is the current scene
# combined is the object we want to combine everything into
# listobjs is the list of objects to stick into combined
@@ -399,7 +399,7 @@ def combineObjects(scene, combined, listobjs):
# Select the new object.
combined.select_set(True)
- scene.objects.active = combined
+ view_layer.objects.active = combined
# Add data
if len(listobjs) > 0:
@@ -509,6 +509,7 @@ class GenerateCloud(Operator):
# Make variable scene that is current scene
scene = context.scene
+ view_layer = context.view_layer
# Parameters the user may want to change:
# Number of points this number is multiplied by the volume to get
@@ -543,7 +544,7 @@ class GenerateCloud(Operator):
definitionObjects = []
for member in cloudMembers:
- applyScaleRotLoc(scene, member)
+ applyScaleRotLoc(view_layer, member)
if member["CloudMember"] == "CreatedObj":
createdObjects.append(member)
else:
@@ -555,10 +556,10 @@ class GenerateCloud(Operator):
del(defObj["CloudMember"])
for createdObj in createdObjects:
- totallyDeleteObject(scene, createdObj)
+ totallyDeleteObject(createdObj)
# Delete the blend_data object
- totallyDeleteObject(scene, mainObj)
+ totallyDeleteObject(mainObj)
# Select all of the left over boxes so people can immediately
# press generate again if they want
@@ -579,9 +580,9 @@ class GenerateCloud(Operator):
cloudPnts.display_type = 'WIRE'
cloudPnts.hide_render = True
- makeParent(bounds, cloudPnts, scene)
- convertParticlesToMesh(scene, cloudParticles, cloudPnts, True)
- removeParticleSystemFromObj(scene, active_object)
+ makeParent(bounds, cloudPnts, view_layer)
+ convertParticlesToMesh(view_layer, cloudParticles, cloudPnts, True)
+ removeParticleSystemFromObj(view_layer, active_object)
pDensity = getpdensitytexture(bounds)
pDensity.point_density.point_source = 'OBJECT'
@@ -589,7 +590,7 @@ class GenerateCloud(Operator):
# Let's resize the bound box to be more accurate
how_much_bigger = pDensity.point_density.radius
- makeObjectIntoBoundBox(scene, bounds, how_much_bigger, cloudPnts)
+ makeObjectIntoBoundBox(view_layer, bounds, how_much_bigger, cloudPnts)
else:
# Generate Cloud
@@ -619,12 +620,12 @@ class GenerateCloud(Operator):
del selectedObjects[0]
# Apply location Rotation and Scale to all objects involved
- applyScaleRotLoc(scene, bounds)
+ applyScaleRotLoc(view_layer, bounds)
for each in selectedObjects:
- applyScaleRotLoc(scene, each)
+ applyScaleRotLoc(view_layer, each)
# Let's combine all of them together.
- combineObjects(scene, bounds, selectedObjects)
+ combineObjects(view_layer, bounds, selectedObjects)
# Let's add some property info to the objects
for selObj in selectedObjects:
@@ -633,14 +634,14 @@ class GenerateCloud(Operator):
selObj.display_type = 'WIRE'
selObj.hide_render = True
selObj.hide = True
- makeParent(bounds, selObj, scene)
+ makeParent(bounds, selObj, view_layer)
# Do the same to the 1. object since it is no longer in list.
firstObject["CloudMember"] = "DefinitionObj"
firstObject.name = "DefinitionObj"
firstObject.display_type = 'WIRE'
firstObject.hide_render = True
- makeParent(bounds, firstObject, scene)
+ makeParent(bounds, firstObject, view_layer)
# Create Cloud for putting Cloud Mesh #
# Create a new object cloud.
@@ -649,7 +650,7 @@ class GenerateCloud(Operator):
cloud.display_type = 'WIRE'
cloud.hide_render = True
- makeParent(bounds, cloud, scene)
+ makeParent(bounds, cloud, view_layer)
bpy.ops.object.editmode_toggle()
bpy.ops.mesh.select_all(action='SELECT')
@@ -693,10 +694,10 @@ class GenerateCloud(Operator):
# Select the object.
bounds.select_set(True)
- scene.objects.active = bounds
+ view_layer.objects.active = bounds
# Turn bounds object into a box. Use itself as a reference
- makeObjectIntoBoundBox(scene, bounds, 1.0, bounds)
+ makeObjectIntoBoundBox(view_layer, bounds, 1.0, bounds)
# Delete all material slots in bounds object
for i in range(len(bounds.material_slots)):
@@ -839,8 +840,8 @@ class GenerateCloud(Operator):
cloudPnts.display_type = 'WIRE'
cloudPnts.hide_render = True
- makeParent(bounds, cloudPnts, scene)
- convertParticlesToMesh(scene, cloudParticles, cloudPnts, True)
+ makeParent(bounds, cloudPnts, view_layer)
+ convertParticlesToMesh(view_layer, cloudParticles, cloudPnts, True)
# Add a modifier.
bpy.ops.object.modifier_add(type='DISPLACE')
@@ -863,7 +864,7 @@ class GenerateCloud(Operator):
PointDensityNode.point_source = 'OBJECT'
PointDensityNode.object = cloudPnts
- removeParticleSystemFromObj(scene, cloud)
+ removeParticleSystemFromObj(view_layer, cloud)
else:
if bpy.context.scene.render.engine == 'BLENDER_RENDER':
@@ -923,16 +924,16 @@ class GenerateCloud(Operator):
# Select the object.
bounds.select_set(True)
- scene.objects.active = bounds
+ view_layer.objects.active = bounds
# Let's resize the bound box to be more accurate.
how_much_bigger = PDensityRadius + 0.1
# If it's a particle cloud use cloud mesh if otherwise use point mesh
if not scene.cloudparticles:
- makeObjectIntoBoundBox(scene, bounds, how_much_bigger, cloudPnts)
+ makeObjectIntoBoundBox(view_layer, bounds, how_much_bigger, cloudPnts)
else:
- makeObjectIntoBoundBox(scene, bounds, how_much_bigger, cloud)
+ makeObjectIntoBoundBox(view_layer, bounds, how_much_bigger, cloud)
cloud_string = "Cumulous" if scene.cloud_type == '1' else "Cirrus" if \
scene.cloud_type == '2' else "Stratus" if \
diff --git a/object_fracture/fracture_ops.py b/object_fracture/fracture_ops.py
index 73e027a3..7d24116a 100644
--- a/object_fracture/fracture_ops.py
+++ b/object_fracture/fracture_ops.py
@@ -234,6 +234,7 @@ def boolop(ob, cutter, op):
def splitobject(context, ob, crack_type, roughness):
scene = context.scene
+ view_layer = context.view_layer
size = getsizefrommesh(ob)
shards = []
@@ -251,7 +252,7 @@ def splitobject(context, ob, crack_type, roughness):
random.random() * 5000.0,
random.random() * 5000.0]
- scene.objects.active = ob
+ view_layer.objects.active = ob
operations = ['INTERSECT', 'DIFFERENCE']
for op in operations:
diff --git a/object_print3d_utils/export.py b/object_print3d_utils/export.py
index b0e6bc7b..d563b549 100644
--- a/object_print3d_utils/export.py
+++ b/object_print3d_utils/export.py
@@ -194,7 +194,7 @@ def write_mesh(context, info, report_cb):
for base in context_backup["selected_bases"]:
base.select_set(True)
del base
- scene.objects.active = context_backup["active_object"]
+ layer.objects.active = context_backup["active_object"]
if 'FINISHED' in ret:
info.append(("%r ok" % os.path.basename(filepath), None))
diff --git a/uv_texture_atlas.py b/uv_texture_atlas.py
index a8b5befd..f57f3389 100644
--- a/uv_texture_atlas.py
+++ b/uv_texture_atlas.py
@@ -404,6 +404,7 @@ class TexAtl_RemoveFromGroup(Operator):
def execute(self, context):
scene = context.scene
+ view_layer = context.view_layer
# Check if group exists
if check_group_exist(self, context) is False:
@@ -417,7 +418,7 @@ class TexAtl_RemoveFromGroup(Operator):
obj_group = bpy.data.collections[group_name]
for object in context.selected_objects:
- scene.objects.active = object
+ view_layer.objects.active = object
if object.type == 'MESH' and object.name in obj_group.objects:
@@ -440,6 +441,7 @@ class TexAtl_RemoveOtherUVs(Operator):
def execute(self, context):
scene = context.scene
+ view_layer = context.view_layer
group_name = scene.ms_lightmap_groups[
scene.ms_lightmap_groups_index].name
@@ -455,7 +457,7 @@ class TexAtl_RemoveOtherUVs(Operator):
# Remove other UVs of selected objects
for object in context.selected_objects:
- scene.objects.active = object
+ view_layer.objects.active = object
if object.type == 'MESH' and object.name in obj_group.objects:
# remove UVs
@@ -603,13 +605,14 @@ class TexAtl_MergeObjects(Operator):
def execute(self, context):
scene = context.scene
+ view_layer = context.view_layer
# objToDelete = None
bpy.ops.object.select_all(action='DESELECT')
ob_merged_old = bpy.data.objects.get(self.group_name + "_mergedObject")
if ob_merged_old is not None:
ob_merged_old.select_set(True)
- scene.objects.active = ob_merged_old
+ view_layer.objects.active = ob_merged_old
bpy.ops.object.delete(use_global=True)
me = bpy.data.meshes.new(self.group_name + '_mergedObject')
@@ -639,14 +642,14 @@ class TexAtl_MergeObjects(Operator):
for uv in object.data.uv_textures:
if uv.name == self.group_name:
uv.active = True
- scene.objects.active = object
+ view_layer.objects.active = object
# Duplicate Temp Object
bpy.ops.object.select_all(action='DESELECT')
object.select_set(True)
- scene.objects.active = object
+ view_layer.objects.active = object
bpy.ops.object.duplicate(linked=False, mode='TRANSLATION')
- activeNowObject = scene.objects.active
+ activeNowObject = view_layer.objects.active
activeNowObject.select_set(True)
# hide render of original mesh
@@ -669,7 +672,7 @@ class TexAtl_MergeObjects(Operator):
UVLIST.clear() # clear array
# create vertex groups for each selected object
- scene.objects.active = activeNowObject
+ view_layer.objects.active = activeNowObject
vgroup = activeNowObject.vertex_groups.new(name=object.name)
vgroup.add(
list(range(len(activeNowObject.data.vertices))), weight=1.0, type='ADD')
@@ -692,7 +695,7 @@ class TexAtl_MergeObjects(Operator):
bpy.ops.object.select_all(action='DESELECT')
activeNowObject.select_set(True)
ob_merge.select_set(True)
- scene.objects.active = ob_merge
+ view_layer.objects.active = ob_merge
bpy.ops.object.join()
mergeList.clear() # Clear Merge List
@@ -700,7 +703,7 @@ class TexAtl_MergeObjects(Operator):
# make Unwrap
bpy.ops.object.select_all(action='DESELECT')
ob_merge.select_set(True)
- scene.objects.active = ob_merge
+ view_layer.objects.active = ob_merge
# Unfide all faces
bpy.ops.object.mode_set(mode='EDIT')
@@ -737,11 +740,12 @@ class TexAtl_SeparateObjects(Operator):
def execute(self, context):
scene = context.scene
+ view_layer = context.view_layer
ob_merged = bpy.data.objects.get(self.group_name + "_mergedObject")
if ob_merged is not None:
- # if scene.objects.active is not None:
+ # if view_layer.objects.active is not None:
# bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
bpy.ops.object.select_all(action='DESELECT')
ob_merged.hide = False
@@ -756,7 +760,7 @@ class TexAtl_SeparateObjects(Operator):
# object
bpy.ops.object.select_all(action='DESELECT')
ob_merged.select_set(True)
- scene.objects.active = ob_merged
+ view_layer.objects.active = ob_merged
bpy.ops.object.mode_set(mode='EDIT')
if doUnhidePolygons is False:
@@ -770,7 +774,7 @@ class TexAtl_SeparateObjects(Operator):
bpy.ops.object.vertex_group_select()
bpy.ops.mesh.separate(type='SELECTED')
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
- # scene.objects.active.select = False
+ # view_layer.objects.active.select_set(False)
# find separated object
ob_separeted = None
@@ -787,7 +791,7 @@ class TexAtl_SeparateObjects(Operator):
ob_original.hide_select = False
ob_original.hide = False
ob_original.select_set(True)
- scene.objects.active = ob_separeted
+ view_layer.objects.active = ob_separeted
bpy.ops.object.join_uvs()
ob_original.hide_render = False
ob_original.select_set(False)