addons: more view_layer syntax updates
This commit is contained in:
parent
8b93448f56
commit
5c994fde52
|
@ -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'},
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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'}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue