From 70df942d31aaaa3d25b7c5543f28529cc51170cc Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Thu, 8 Nov 2018 09:06:57 +1100 Subject: [PATCH] Update for changes in Blender's API --- curve_simplify.py | 2 +- io_anim_bvh/import_bvh.py | 8 ++++---- io_coat3D/__init__.py | 28 ++++++++++++++-------------- io_import_images_as_planes.py | 2 +- io_mesh_ply/import_ply.py | 2 +- io_mesh_stl/blender_utils.py | 2 +- io_scene_fbx/import_fbx.py | 6 +++--- io_scene_obj/import_obj.py | 2 +- object_collections.py | 2 +- object_print3d_utils/mesh_helpers.py | 4 ++-- rigify/generate.py | 24 ++++++++++++------------ rigify/legacy/generate.py | 16 ++++++++-------- 12 files changed, 49 insertions(+), 49 deletions(-) diff --git a/curve_simplify.py b/curve_simplify.py index e0d59c60d..4a390feb5 100644 --- a/curve_simplify.py +++ b/curve_simplify.py @@ -309,7 +309,7 @@ def main(context, obj, options, curve_dimension): newCurve = bpy.data.objects.new("Simple_" + obj.name, curve) coll = context.view_layer.active_layer_collection.collection coll.objects.link(newCurve) - newCurve.select_set('SELECT') + newCurve.select_set(True) context.view_layer.objects.active = newCurve newCurve.matrix_world = obj.matrix_world diff --git a/io_anim_bvh/import_bvh.py b/io_anim_bvh/import_bvh.py index 0a9e4b30c..f609ca6ca 100644 --- a/io_anim_bvh/import_bvh.py +++ b/io_anim_bvh/import_bvh.py @@ -348,7 +348,7 @@ def bvh_node_dict2objects(context, bvh_name, bvh_nodes, rotate_mode='NATIVE', fr scene = context.scene for obj in scene.objects: - obj.select_set("DESELECT") + obj.select_set(False) objects = [] @@ -356,7 +356,7 @@ def bvh_node_dict2objects(context, bvh_name, bvh_nodes, rotate_mode='NATIVE', fr obj = bpy.data.objects.new(name, None) context.collection.objects.link(obj) objects.append(obj) - obj.select_set("SELECT") + obj.select_set(True) # nicer drawing. obj.empty_display_type = 'CUBE' @@ -422,14 +422,14 @@ def bvh_node_dict2armature( # Add the new armature, scene = context.scene for obj in scene.objects: - obj.select_set("DESELECT") + obj.select_set(False) arm_data = bpy.data.armatures.new(bvh_name) arm_ob = bpy.data.objects.new(bvh_name, arm_data) context.collection.objects.link(arm_ob) - arm_ob.select_set("SELECT") + arm_ob.select_set(True) context.view_layer.objects.active = arm_ob bpy.ops.object.mode_set(mode='OBJECT', toggle=False) diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py index 751e56f70..88278787e 100644 --- a/io_coat3D/__init__.py +++ b/io_coat3D/__init__.py @@ -194,15 +194,15 @@ def updatemesh(objekti, proxy): if(objekti.vertex_groups.keys() != []): bpy.ops.object.select_all(action='DESELECT') - proxy.select_set('SELECT') - objekti.select_set('SELECT') + proxy.select_set(True) + objekti.select_set(True) bpy.ops.object.vertex_group_copy_to_selected() bpy.ops.object.select_all(action='DESELECT') # UV Set Copy - proxy.select_set('SELECT') - objekti.select_set('SELECT') + proxy.select_set(True) + objekti.select_set(True) if len(objekti.data.uv_layers) > 1: obj_uv_index = objekti.data.uv_layers.active_index @@ -220,7 +220,7 @@ def updatemesh(objekti, proxy): #Mesh Copy - proxy.select_set('SELECT') + proxy.select_set(True) obj_data = objekti.data.id_data objekti.data = proxy.data.id_data objekti.data.id_data.name = obj_data.name @@ -566,7 +566,7 @@ class SCENE_OT_import(bpy.types.Operator): objekti = bpy.data.objects[oname] if(objekti.coat3D.import_mesh and coat3D.importmesh == True): objekti.coat3D.import_mesh = False - objekti.select_set('SELECT') + objekti.select_set(True) new_name = objekti.data.name name_boxs = new_name.split('.') @@ -627,7 +627,7 @@ class SCENE_OT_import(bpy.types.Operator): mat_list.append(obj_mat.material) bpy.ops.object.select_all(action='DESELECT') - obj_proxy.select_set('SELECT') + obj_proxy.select_set(True) bpy.ops.object.select_all(action='TOGGLE') @@ -650,7 +650,7 @@ class SCENE_OT_import(bpy.types.Operator): #tärkee että saadaan oikein käännettyä objekt - objekti.select_set('SELECT') + objekti.select_set(True) bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') objekti.data.materials.pop() @@ -675,14 +675,14 @@ class SCENE_OT_import(bpy.types.Operator): if(coat3D.importmesh and not(os.path.isfile(objekti.coat3D.applink_address))): coat3D.importmesh = False - objekti.select_set('SELECT') + objekti.select_set(True) if(coat3D.importtextures): is_new = False print('matlist: ', mat_list) print('objekti: ', objekti) print('is_new: ', is_new) tex.matlab(objekti,mat_list,texturelist,is_new) - objekti.select_set('DESELECT') + objekti.select_set(False) else: mat_list = [] @@ -696,13 +696,13 @@ class SCENE_OT_import(bpy.types.Operator): print('objekti: ', objekti) print('is_new: ', is_new) tex.matlab(objekti,mat_list,texturelist, is_new) - objekti.select_set('DESELECT') + objekti.select_set(False) bpy.ops.object.select_all(action='DESELECT') if(import_list): for del_obj in diff_objects: - bpy.context.collection.all_objects[del_obj].select_set('SELECT') + bpy.context.collection.all_objects[del_obj].select_set(True) bpy.ops.object.delete() @@ -760,12 +760,12 @@ class SCENE_OT_import(bpy.types.Operator): if(new_obj.coat3D.applink_old == False): nimi += new_obj.data.name + ':::' - new_obj.select_set('SELECT') + new_obj.select_set(True) #bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') new_obj.rotation_euler = (0, 0, 0) new_obj.scale = (1, 1, 1) new_obj.coat3D.applink_firsttime = False - new_obj.select_set('DESELECT') + new_obj.select_set(False) new_obj.coat3D.applink_address = new_applink_address new_obj.coat3D.objecttime = str(os.path.getmtime(new_obj.coat3D.applink_address)) splittext = ntpath.basename(new_applink_address) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index e0c714263..6a0435794 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -908,7 +908,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): # setup new selection for plane in planes: - plane.select_set('SELECT') + plane.select_set(True) # all done! self.report({'INFO'}, "Added {} Image Plane(s)".format(len(planes))) diff --git a/io_mesh_ply/import_ply.py b/io_mesh_ply/import_ply.py index f05e1caac..5ec24f8a9 100644 --- a/io_mesh_ply/import_ply.py +++ b/io_mesh_ply/import_ply.py @@ -398,7 +398,7 @@ def load_ply(filepath): obj = bpy.data.objects.new(ply_name, mesh) bpy.context.collection.objects.link(obj) bpy.context.view_layer.objects.active = obj - obj.select_set("SELECT") + obj.select_set(True) print('\nSuccessfully imported %r in %.3f sec' % (filepath, time.time() - t)) return {'FINISHED'} diff --git a/io_mesh_stl/blender_utils.py b/io_mesh_stl/blender_utils.py index 1dfa76d88..fcc4889a4 100644 --- a/io_mesh_stl/blender_utils.py +++ b/io_mesh_stl/blender_utils.py @@ -60,7 +60,7 @@ def create_and_link_mesh(name, faces, face_nors, points, global_matrix): obj = bpy.data.objects.new(name, mesh) bpy.context.collection.objects.link(obj) bpy.context.view_layer.objects.active = obj - obj.select_set("SELECT") + obj.select_set(True) def faces_from_mesh(ob, global_matrix, use_mesh_modifiers=False): diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index 0a8be6cf8..8e4747b05 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -1971,7 +1971,7 @@ class FbxImportHelperNode: # instance in scene view_layer.active_layer_collection.collection.objects.link(obj) - obj.select_set('SELECT') + obj.select_set(True) return obj @@ -2098,7 +2098,7 @@ class FbxImportHelperNode: # instance in scene view_layer.active_layer_collection.collection.objects.link(arm) - arm.select_set('SELECT') + arm.select_set(True) # Add bones: @@ -2141,7 +2141,7 @@ class FbxImportHelperNode: # instance in scene view_layer.active_layer_collection.collection.objects.link(obj) - obj.select_set('SELECT') + obj.select_set(True) return obj else: diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py index 71810bcc6..5980a0b25 100644 --- a/io_scene_obj/import_obj.py +++ b/io_scene_obj/import_obj.py @@ -1184,7 +1184,7 @@ def load(context, # Create new obj for obj in new_objects: collection.objects.link(obj) - obj.select_set('SELECT') + obj.select_set(True) # we could apply this anywhere before scaling. obj.matrix_world = global_matrix diff --git a/object_collections.py b/object_collections.py index 9c7d6d767..b7ec5c56e 100644 --- a/object_collections.py +++ b/object_collections.py @@ -193,7 +193,7 @@ class OBJECT_OT_collection_unlink(Operator): def select_collection_objects(collection): for ob in collection.objects: - ob.select_set('SELECT') + ob.select_set(True) for collection_nested in collection.collections: select_collection_objects(collection_nested) diff --git a/object_print3d_utils/mesh_helpers.py b/object_print3d_utils/mesh_helpers.py index 44cce337a..6a18e3e29 100644 --- a/object_print3d_utils/mesh_helpers.py +++ b/object_print3d_utils/mesh_helpers.py @@ -242,14 +242,14 @@ def object_merge(context, objects): # deselect all for obj in scene.objects: - obj.select_set('DESELECT') + obj.select_set(False) # add empty object mesh_base = bpy.data.meshes.new(name="~tmp~") obj_base = bpy.data.objects.new(name="~tmp~", object_data=mesh_base) scene_collection.objects.link(obj_base) layer.objects.active = obj_base - obj_base.select_set('SELECT') + obj_base.select_set(True) # loop over all meshes for obj in objects: diff --git a/rigify/generate.py b/rigify/generate.py index b38bfd6d7..c804cb693 100644 --- a/rigify/generate.py +++ b/rigify/generate.py @@ -116,8 +116,8 @@ def generate_rig(context, metarig): obj.animation_data_clear() # Select generated rig object - metarig.select_set('DESELECT') - obj.select_set('SELECT') + metarig.select_set(False) + obj.select_set(True) view_layer.objects.active = obj # Remove wgts if force update is set @@ -125,7 +125,7 @@ def generate_rig(context, metarig): if wgts_group_name in scene.objects and id_store.rigify_force_widget_update: bpy.ops.object.select_all(action='DESELECT') for wgt in bpy.data.objects[wgts_group_name].children: - wgt.select_set('SELECT') + wgt.select_set(True) bpy.ops.object.delete(use_global=False) if rig_old_name: bpy.data.objects[wgts_group_name].name = "WGTS_" + obj.name @@ -154,9 +154,9 @@ def generate_rig(context, metarig): # Select the temp rigs for merging for objt in scene.objects: - objt.select_set('DESELECT') # deselect all objects - temp_rig_1.select_set('SELECT') - temp_rig_2.select_set('SELECT') + objt.select_set(False) # deselect all objects + temp_rig_1.select_set(True) + temp_rig_2.select_set(True) view_layer.objects.active = temp_rig_2 # Merge the temporary rigs @@ -167,8 +167,8 @@ def generate_rig(context, metarig): # Select the generated rig for objt in scene.objects: - objt.select_set('DESELECT') # deselect all objects - obj.select_set('SELECT') + objt.select_set(False) # deselect all objects + obj.select_set(True) view_layer.objects.active = obj # Copy over bone properties @@ -318,7 +318,7 @@ def generate_rig(context, metarig): # if id_store.rigify_generate_mode == 'new': # bpy.ops.object.select_all(action='DESELECT') # for wgt in bpy.data.objects[wgts_group_name].children: - # wgt.select_set('SELECT') + # wgt.select_set(True) # bpy.ops.object.make_single_user(obdata=True) #---------------------------------- @@ -336,7 +336,7 @@ def generate_rig(context, metarig): # Go into editmode in the rig armature bpy.ops.object.mode_set(mode='OBJECT') context.view_layer.objects.active = obj - obj.select_set('SELECT') + obj.select_set(True) bpy.ops.object.mode_set(mode='EDIT') scripts = rig.generate() if scripts is not None: @@ -534,8 +534,8 @@ def create_selection_sets(obj, metarig): bpy.ops.object.mode_set(mode='POSE') bpy.context.view_layer.objects.active = obj - obj.select_set('SELECT') - metarig.select_set('DESELECT') + obj.select_set(True) + metarig.select_set(False) pbones = obj.pose.bones for i, name in enumerate(metarig.data.rigify_layers.keys()): diff --git a/rigify/legacy/generate.py b/rigify/legacy/generate.py index 77c4e28e9..4c571c3fd 100644 --- a/rigify/legacy/generate.py +++ b/rigify/legacy/generate.py @@ -101,8 +101,8 @@ def generate_rig(context, metarig): obj.animation_data_clear() # Select generated rig object - metarig.select_set('DESELECT') - obj.select_set('SELECT') + metarig.select_set(False) + obj.select_set(True) view_layer.objects.active = obj # Remove all bones from the generated rig armature. @@ -122,9 +122,9 @@ def generate_rig(context, metarig): # Select the temp rigs for merging for objt in scene.objects: - objt.select_set('DESELECT') # deselect all objects - temp_rig_1.select_set('SELECT') - temp_rig_2.select_set('SELECT') + objt.select_set(False) # deselect all objects + temp_rig_1.select_set(True) + temp_rig_2.select_set(True) view_layer.objects.active = temp_rig_2 # Merge the temporary rigs @@ -135,8 +135,8 @@ def generate_rig(context, metarig): # Select the generated rig for objt in scene.objects: - objt.select_set('DESELECT') # deselect all objects - obj.select_set('SELECT') + objt.select_set(False) # deselect all objects + obj.select_set(True) view_layer.objects.active = obj # Copy over bone properties @@ -281,7 +281,7 @@ def generate_rig(context, metarig): # Go into editmode in the rig armature bpy.ops.object.mode_set(mode='OBJECT') context.view_layer.objects.active = obj - obj.select_set('SELECT') + obj.select_set(True) bpy.ops.object.mode_set(mode='EDIT') scripts = rig.generate() if scripts is not None: -- GitLab