Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/modules/bpy_extras/object_utils.py
| Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | def object_data_add(context, obdata, operator=None, name=None): | ||||
| obj_act = layer.objects.active | obj_act = layer.objects.active | ||||
| obj_new = bpy.data.objects.new(name, obdata) | obj_new = bpy.data.objects.new(name, obdata) | ||||
| scene_collection.objects.link(obj_new) | scene_collection.objects.link(obj_new) | ||||
| obj_new.select_set(True) | obj_new.select_set(True) | ||||
| obj_new.matrix_world = add_object_align_init(context, operator) | obj_new.matrix_world = add_object_align_init(context, operator) | ||||
| space_data = context.space_data | space_data = context.space_data | ||||
| if space_data.type == 'VIEW_3D': | if space_data and space_data.type == 'VIEW_3D': | ||||
| if space_data.local_view: | if space_data.local_view: | ||||
| obj_new.local_view_set(space_data, True) | obj_new.local_view_set(space_data, True) | ||||
| if obj_act and obj_act.mode == 'EDIT' and obj_act.type == obj_new.type: | if obj_act and obj_act.mode == 'EDIT' and obj_act.type == obj_new.type: | ||||
| bpy.ops.mesh.select_all(action='DESELECT') | bpy.ops.mesh.select_all(action='DESELECT') | ||||
| obj_act.select_set(True) | obj_act.select_set(True) | ||||
| bpy.ops.object.mode_set(mode='OBJECT') | bpy.ops.object.mode_set(mode='OBJECT') | ||||
| ▲ Show 20 Lines • Show All 128 Lines • Show Last 20 Lines | |||||