diff --git a/src/blenderbim/blenderbim/bim/module/drawing/decoration.py b/src/blenderbim/blenderbim/bim/module/drawing/decoration.py index f5ce7c2840..4f3764df3c 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/decoration.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/decoration.py @@ -748,7 +748,7 @@ class AngleDecorator(BaseDecorator): arcs_color = None edges_color = UNSPECIAL_ELEMENT_COLOR - if context.object == obj and obj.data.is_editmode: + if context.active_object == obj and obj.data.is_editmode: arcs_color = context.preferences.addons["blenderbim"].preferences.decorator_color_special edges_color = None diff --git a/src/blenderbim/blenderbim/bim/module/drawing/svgwriter.py b/src/blenderbim/blenderbim/bim/module/drawing/svgwriter.py index 6024aee181..625bb8af47 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/svgwriter.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/svgwriter.py @@ -961,7 +961,7 @@ class SvgWriter: p0 = points_2d[1] + dir0 * angle_radius p2 = points_2d[1] + dir1 * angle_radius points_chunk = [view3d_utils.region_2d_to_origin_3d(region, region_3d, p) for p in [p0, p3, p2]] - # points = [p.co.xyz for p in bpy.context.object.data.splines[0].points[:3]] + # points = [p.co.xyz for p in bpy.context.active_object.data.splines[0].points[:3]] bm = bmesh.new() bm.verts.index_update() diff --git a/src/blenderbim/blenderbim/bim/module/drawing/workspace.py b/src/blenderbim/blenderbim/bim/module/drawing/workspace.py index 2e42fabada..73704e32e7 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/workspace.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/workspace.py @@ -229,7 +229,7 @@ class AnnotationToolUI: @classmethod def draw_edit_object_interface(cls, context): - if DecoratorData.get_ifc_text_data(bpy.context.object): + if DecoratorData.get_ifc_text_data(bpy.context.active_object): add_layout_hotkey_operator(cls.layout, "Edit Text", "S_E", "") @classmethod @@ -306,10 +306,10 @@ class Hotkey(bpy.types.Operator, Operator): create_annotation() def hotkey_S_E(self): - if not bpy.context.object: + if not bpy.context.active_object: return - if DecoratorData.get_ifc_text_data(bpy.context.object): + if DecoratorData.get_ifc_text_data(bpy.context.active_object): bpy.ops.bim.edit_text_popup() def hotkey_S_G(self): diff --git a/src/blenderbim/blenderbim/bim/module/model/door.py b/src/blenderbim/blenderbim/bim/module/model/door.py index 838e42bf9a..6150f472c6 100644 --- a/src/blenderbim/blenderbim/bim/module/model/door.py +++ b/src/blenderbim/blenderbim/bim/module/model/door.py @@ -276,7 +276,7 @@ def create_bm_door_lining(bm, size: Vector, thickness: list, position: Vector = def update_door_modifier_bmesh(context): - obj = context.object + obj = context.active_object props = obj.BIMDoorProperties overall_width = props.overall_width @@ -456,7 +456,7 @@ def update_door_modifier_bmesh(context): bmesh.ops.translate(bm, vec=V(0, lining_offset, 0), verts=lining_offset_verts) bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001) - if bpy.context.object.mode == "EDIT": + if bpy.context.active_object.mode == "EDIT": bmesh.update_edit_mesh(obj.data) else: bm.to_mesh(obj.data) @@ -475,9 +475,9 @@ class BIM_OT_add_door(bpy.types.Operator, tool.Ifc.Operator): self.report({"ERROR"}, "You need to start IFC project first to create a door.") return {"CANCELLED"} - if context.object is not None: - spawn_location = context.object.location.copy() - context.object.select_set(False) + if context.active_object is not None: + spawn_location = context.active_object.location.copy() + context.active_object.select_set(False) else: spawn_location = bpy.context.scene.cursor.location.copy() diff --git a/src/blenderbim/blenderbim/bim/module/model/railing.py b/src/blenderbim/blenderbim/bim/module/model/railing.py index 71c07a986b..7382d68977 100644 --- a/src/blenderbim/blenderbim/bim/module/model/railing.py +++ b/src/blenderbim/blenderbim/bim/module/model/railing.py @@ -120,7 +120,7 @@ def update_railing_modifier_bmesh(context): """before using should make sure that Data contains up-to-date information. If BBIM Pset just changed should call refresh() before updating bmesh """ - obj = context.object + obj = context.active_object props = obj.BIMRailingProperties # NOTE: using Data since bmesh update will hapen very often @@ -274,9 +274,9 @@ class BIM_OT_add_railing(bpy.types.Operator, tool.Ifc.Operator): self.report({"ERROR"}, "You need to start IFC project first to create a railing.") return {"CANCELLED"} - if context.object is not None: - spawn_location = context.object.location.copy() - context.object.select_set(False) + if context.active_object is not None: + spawn_location = context.active_object.location.copy() + context.active_object.select_set(False) else: spawn_location = bpy.context.scene.cursor.location.copy() @@ -442,7 +442,7 @@ class EnableEditingRailingPath(bpy.types.Operator, tool.Ifc.Operator): props.is_editing_path = True update_railing_modifier_bmesh(context) - if bpy.context.object.mode != "EDIT": + if bpy.context.active_object.mode != "EDIT": bpy.ops.object.mode_set(mode="EDIT") bpy.ops.wm.tool_set_by_id(tool.Blender.get_viewport_context(), name="bim.cad_tool") ProfileDecorator.install(context, exit_edit_mode_callback=lambda: cancel_editing_railing_path(context)) @@ -457,7 +457,7 @@ def cancel_editing_railing_path(context): props.is_editing_path = False update_railing_modifier_bmesh(context) - if bpy.context.object.mode == "EDIT": + if bpy.context.active_object.mode == "EDIT": bpy.ops.object.mode_set(mode="OBJECT") return {"FINISHED"} @@ -492,7 +492,7 @@ class FinishEditingRailingPath(bpy.types.Operator, tool.Ifc.Operator): # since we know that BBIM_Railing could have changed refresh() update_railing_modifier_bmesh(context) - if bpy.context.object.mode == "EDIT": + if bpy.context.active_object.mode == "EDIT": bpy.ops.object.mode_set(mode="OBJECT") update_railing_modifier_ifc_data(context) return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/model/roof.py b/src/blenderbim/blenderbim/bim/module/model/roof.py index f3d90c0c73..8f1f3c753a 100644 --- a/src/blenderbim/blenderbim/bim/module/model/roof.py +++ b/src/blenderbim/blenderbim/bim/module/model/roof.py @@ -424,7 +424,7 @@ def update_roof_modifier_bmesh(context): """before using should make sure that Data contains up-to-date information. If BBIM Pset just changed should call refresh() before updating bmesh """ - obj = context.object + obj = context.active_object props = obj.BIMRoofProperties # NOTE: using Data since bmesh update will hapen very often @@ -506,9 +506,9 @@ class BIM_OT_add_roof(bpy.types.Operator, tool.Ifc.Operator): self.report({"ERROR"}, "You need to start IFC project first to create a roof.") return {"CANCELLED"} - if context.object is not None: - spawn_location = context.object.location.copy() - context.object.select_set(False) + if context.active_object is not None: + spawn_location = context.active_object.location.copy() + context.active_object.select_set(False) else: spawn_location = bpy.context.scene.cursor.location.copy() @@ -654,7 +654,7 @@ class EnableEditingRoofPath(bpy.types.Operator, tool.Ifc.Operator): props.is_editing_path = True update_roof_modifier_bmesh(context) - if bpy.context.object.mode != "EDIT": + if bpy.context.active_object.mode != "EDIT": bpy.ops.object.mode_set(mode="EDIT") bpy.ops.wm.tool_set_by_id(tool.Blender.get_viewport_context(), name="bim.cad_tool") @@ -706,7 +706,7 @@ def cancel_editing_roof_path(context): props.is_editing_path = False update_roof_modifier_bmesh(context) - if bpy.context.object.mode == "EDIT": + if bpy.context.active_object.mode == "EDIT": bpy.ops.object.mode_set(mode="OBJECT") return {"FINISHED"} @@ -747,7 +747,7 @@ class FinishEditingRoofPath(bpy.types.Operator, tool.Ifc.Operator): update_roof_modifier_bmesh(context) update_roof_modifier_ifc_data(context) - if bpy.context.object.mode == "EDIT": + if bpy.context.active_object.mode == "EDIT": bpy.ops.object.mode_set(mode="OBJECT") update_roof_modifier_ifc_data(context) return {"FINISHED"} @@ -789,7 +789,7 @@ class SetGableRoofEdgeAngle(bpy.types.Operator): # tried to avoid bmesh with foreach_get and foreach_set # but in EDIT mode it's only possible to change attributes by working with bmesh - me = context.object.data + me = context.active_object.data bm = tool.Blender.get_bmesh_for_mesh(me) # check if attribute exists or create one diff --git a/src/blenderbim/blenderbim/bim/module/model/stair.py b/src/blenderbim/blenderbim/bim/module/model/stair.py index 331173f381..dbf24d3ae7 100644 --- a/src/blenderbim/blenderbim/bim/module/model/stair.py +++ b/src/blenderbim/blenderbim/bim/module/model/stair.py @@ -215,7 +215,7 @@ def update_stair_modifier(context): props_kwargs = obj.BIMStairProperties.get_props_kwargs() vertices, edges, faces = generate_stair_2d_profile(**props_kwargs) - obj = context.object + obj = context.active_object bm = bmesh.new() bm.verts.index_update() bm.edges.index_update() @@ -234,7 +234,7 @@ def update_stair_modifier(context): translate_verts = [v for v in extruded["geom"] if isinstance(v, BMVert)] bmesh.ops.translate(bm, vec=extrusion_vector, verts=translate_verts) - if context.object.mode == "EDIT": + if context.active_object.mode == "EDIT": bmesh.update_edit_mesh(obj.data) else: bm.to_mesh(obj.data) @@ -316,9 +316,9 @@ class BIM_OT_add_clever_stair(bpy.types.Operator, tool.Ifc.Operator): self.report({"ERROR"}, "You need to start IFC project first to create a stair.") return {"CANCELLED"} - if context.object is not None: - spawn_location = context.object.location.copy() - context.object.select_set(False) + if context.active_object is not None: + spawn_location = context.active_object.location.copy() + context.active_object.select_set(False) else: spawn_location = bpy.context.scene.cursor.location.copy() diff --git a/src/blenderbim/blenderbim/bim/module/model/sverchok_modifier.py b/src/blenderbim/blenderbim/bim/module/model/sverchok_modifier.py index 4444870fe9..7c6428a4eb 100644 --- a/src/blenderbim/blenderbim/bim/module/model/sverchok_modifier.py +++ b/src/blenderbim/blenderbim/bim/module/model/sverchok_modifier.py @@ -51,7 +51,7 @@ def update_sverchok_modifier(context): bm.edges.index_update() bm.faces.index_update() - if context.object.mode == "EDIT": + if context.active_object.mode == "EDIT": bmesh.update_edit_mesh(obj.data) else: bm.to_mesh(obj.data) diff --git a/src/blenderbim/blenderbim/bim/module/model/window.py b/src/blenderbim/blenderbim/bim/module/model/window.py index d19763b445..ea5458da4d 100644 --- a/src/blenderbim/blenderbim/bim/module/model/window.py +++ b/src/blenderbim/blenderbim/bim/module/model/window.py @@ -292,7 +292,7 @@ def create_bm_window( def update_window_modifier_bmesh(context): - obj = context.object + obj = context.active_object props = obj.BIMWindowProperties panel_schema = DEFAULT_PANEL_SCHEMAS[props.window_type] accumulated_height = [0] * len(panel_schema[0]) @@ -425,7 +425,7 @@ def update_window_modifier_bmesh(context): bmesh.ops.translate(bm, vec=V(0, lining_offset, 0), verts=bm.verts) bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001) - if bpy.context.object.mode == "EDIT": + if bpy.context.active_object.mode == "EDIT": bmesh.update_edit_mesh(obj.data) else: bm.to_mesh(obj.data) @@ -444,9 +444,9 @@ class BIM_OT_add_window(bpy.types.Operator, tool.Ifc.Operator): self.report({"ERROR"}, "You need to start IFC project first to create a window.") return {"CANCELLED"} - if context.object is not None: - spawn_location = context.object.location.copy() - context.object.select_set(False) + if context.active_object is not None: + spawn_location = context.active_object.location.copy() + context.active_object.select_set(False) else: spawn_location = bpy.context.scene.cursor.location.copy() diff --git a/src/blenderbim/blenderbim/tool/blender.py b/src/blenderbim/blenderbim/tool/blender.py index e315341eaa..b829b9f16e 100644 --- a/src/blenderbim/blenderbim/tool/blender.py +++ b/src/blenderbim/blenderbim/tool/blender.py @@ -398,12 +398,12 @@ class Blender: ) bmesh.update_edit_mesh(mesh) if not obj: - if not bpy.context.object or bpy.context.object.data != mesh: + if not bpy.context.active_object or bpy.context.active_object.data != mesh: raise Exception( "Error applying bmesh in EDIT object - object is " "not provided and can't be acquired from the context. " ) - obj = bpy.context.object + obj = bpy.context.active_object obj.update_from_editmode() else: bm.to_mesh(mesh) diff --git a/src/blenderbim/scripts/geonodes_modifier_prototype.py b/src/blenderbim/scripts/geonodes_modifier_prototype.py index f536b046f1..77b7b660a6 100644 --- a/src/blenderbim/scripts/geonodes_modifier_prototype.py +++ b/src/blenderbim/scripts/geonodes_modifier_prototype.py @@ -106,7 +106,7 @@ def update_geonodes_modifier(): bm.edges.index_update() bm.faces.index_update() - if bpy.context.object.mode == "EDIT": + if bpy.context.active_object.mode == "EDIT": bmesh.update_edit_mesh(obj.data) else: bm.to_mesh(obj.data) diff --git a/src/blenderbim/test/bim/feature/pset.feature b/src/blenderbim/test/bim/feature/pset.feature index c7ad1db8c9..b4c87ffb1f 100644 --- a/src/blenderbim/test/bim/feature/pset.feature +++ b/src/blenderbim/test/bim/feature/pset.feature @@ -347,7 +347,7 @@ Scenario: Remove pset - multiple objects Scenario: Edit pset length property Given an empty IFC project And I press "mesh.add_clever_stair" - And the variable "pset" is "tool.Pset.get_element_pset(tool.Ifc.get_entity(bpy.context.object), 'Pset_StairFlightCommon').id()" + And the variable "pset" is "tool.Pset.get_element_pset(tool.Ifc.get_entity(bpy.context.active_object), 'Pset_StairFlightCommon').id()" And the variable "si_conversion" is "ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())" And I press "bim.enable_pset_editing(pset_id={pset}, obj='IfcStairFlight/StairFlight', obj_type='Object')" @@ -380,7 +380,7 @@ Scenario: Edit qset length property Given an empty IFC project And I press "mesh.add_clever_stair" And I press "bim.calculate_all_quantities" - And the variable "pset" is "tool.Pset.get_element_pset(tool.Ifc.get_entity(bpy.context.object), 'Qto_StairFlightBaseQuantities').id()" + And the variable "pset" is "tool.Pset.get_element_pset(tool.Ifc.get_entity(bpy.context.active_object), 'Qto_StairFlightBaseQuantities').id()" And the variable "si_conversion" is "ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())" And I press "bim.enable_pset_editing(pset_id={pset}, obj='IfcStairFlight/StairFlight', obj_type='Object')"