diff --git a/src/blenderbim/blenderbim/bim/module/geometry/operator.py b/src/blenderbim/blenderbim/bim/module/geometry/operator.py index 8f4f0a3927..b659ea2a69 100644 --- a/src/blenderbim/blenderbim/bim/module/geometry/operator.py +++ b/src/blenderbim/blenderbim/bim/module/geometry/operator.py @@ -211,18 +211,22 @@ class SwitchRepresentation(bpy.types.Operator, Operator): should_switch_all_meshes: bpy.props.BoolProperty() def _execute(self, context): - target = tool.Ifc.get().by_id(self.ifc_definition_id).ContextOfItems + target_representation = tool.Ifc.get().by_id(self.ifc_definition_id) + target = target_representation.ContextOfItems is_subcontext = target.is_a("IfcGeometricRepresentationSubContext") for obj in set(context.selected_objects + [context.active_object]): element = tool.Ifc.get_entity(obj) if not element: continue - if is_subcontext: - representation = ifcopenshell.util.representation.get_representation( - element, target.ContextType, target.ContextIdentifier, target.TargetView - ) + if obj == context.active_object: + representation = target_representation else: - representation = ifcopenshell.util.representation.get_representation(element, target.ContextType) + if is_subcontext: + representation = ifcopenshell.util.representation.get_representation( + element, target.ContextType, target.ContextIdentifier, target.TargetView + ) + else: + representation = ifcopenshell.util.representation.get_representation(element, target.ContextType) if not representation: continue core.switch_representation( diff --git a/src/blenderbim/blenderbim/tool/geometry.py b/src/blenderbim/blenderbim/tool/geometry.py index 5e480ade96..fe55d3c590 100644 --- a/src/blenderbim/blenderbim/tool/geometry.py +++ b/src/blenderbim/blenderbim/tool/geometry.py @@ -479,23 +479,19 @@ class Geometry(blenderbim.core.tool.Geometry): element = tool.Ifc.get_entity(obj) settings = ifcopenshell.geom.settings() settings.set(settings.WELD_VERTICES, True) - context = representation.ContextOfItems + if element.is_a("IfcTypeProduct") or not apply_openings: + settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True) + if context.ContextIdentifier == "Body" and context.TargetView == "MODEL_VIEW": try: - if element.is_a("IfcTypeProduct") or not apply_openings: - shape = ifcopenshell.geom.create_shape(settings, representation) - else: - shape = ifcopenshell.geom.create_shape(settings, element) + shape = ifcopenshell.geom.create_shape(settings, element, representation) except: settings.set(settings.INCLUDE_CURVES, True) - if element.is_a("IfcTypeProduct") or not apply_openings: - shape = ifcopenshell.geom.create_shape(settings, representation) - else: - shape = ifcopenshell.geom.create_shape(settings, element) + shape = ifcopenshell.geom.create_shape(settings, element, representation) else: settings.set(settings.INCLUDE_CURVES, True) - shape = ifcopenshell.geom.create_shape(settings, representation) + shape = ifcopenshell.geom.create_shape(settings, element, representation) ifc_importer = blenderbim.bim.import_ifc.IfcImporter(ifc_import_settings) ifc_importer.file = tool.Ifc.get()