diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py index 1d6e021c21..c9087bc1bf 100644 --- a/src/blenderbim/blenderbim/bim/import_ifc.py +++ b/src/blenderbim/blenderbim/bim/import_ifc.py @@ -60,7 +60,6 @@ class MaterialCreator: def create(self, element, obj, mesh): self.mesh = mesh - self.obj = obj if (hasattr(element, "Representation") and not element.Representation) or ( hasattr(element, "RepresentationMaps") and not element.RepresentationMaps ): @@ -140,11 +139,11 @@ class MaterialCreator: def assign_material_slots_to_faces(self): if "ios_materials" not in self.mesh or not self.mesh["ios_materials"]: return - if len(self.obj.material_slots) == 1: + if len(self.mesh.materials) == 1: return material_to_slot = {} for i, material in enumerate(self.mesh["ios_materials"]): - slot_index = self.obj.material_slots.find(self.styles[material].name) + slot_index = self.mesh.materials.find(self.styles[material].name) material_to_slot[i] = slot_index if len(self.mesh.polygons) == len(self.mesh["ios_material_ids"]): diff --git a/src/blenderbim/blenderbim/bim/module/model/slab.py b/src/blenderbim/blenderbim/bim/module/model/slab.py index f04102bdaa..f33d6f0709 100644 --- a/src/blenderbim/blenderbim/bim/module/model/slab.py +++ b/src/blenderbim/blenderbim/bim/module/model/slab.py @@ -681,32 +681,33 @@ class EditExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator): # Only certain classes should have a footprint if element.is_a() not in ("IfcSlab", "IfcRamp"): - return {"FINISHED"} + return footprint_context = ifcopenshell.util.representation.get_context( tool.Ifc.get(), "Plan", "FootPrint", "SKETCH_VIEW" ) - if footprint_context: - curves = [profile.OuterCurve] - if profile.is_a("IfcArbitraryProfileDefWithVoids"): - curves.extend(profile.InnerCurves) - new_footprint = ifcopenshell.api.run( - "geometry.add_footprint_representation", tool.Ifc.get(), context=footprint_context, curves=curves + if not footprint_context: + return + + curves = [profile.OuterCurve] + if profile.is_a("IfcArbitraryProfileDefWithVoids"): + curves.extend(profile.InnerCurves) + new_footprint = ifcopenshell.api.run( + "geometry.add_footprint_representation", tool.Ifc.get(), context=footprint_context, curves=curves + ) + old_footprint = ifcopenshell.util.representation.get_representation( + element, "Plan", "FootPrint", "SKETCH_VIEW" + ) + if old_footprint: + for inverse in tool.Ifc.get().get_inverse(old_footprint): + ifcopenshell.util.element.replace_attribute(inverse, old_footprint, new_footprint) + blenderbim.core.geometry.remove_representation( + tool.Ifc, tool.Geometry, obj=obj, representation=old_footprint ) - old_footprint = ifcopenshell.util.representation.get_representation( - element, "Plan", "FootPrint", "SKETCH_VIEW" + else: + ifcopenshell.api.run( + "geometry.assign_representation", tool.Ifc.get(), product=element, representation=new_footprint ) - if old_footprint: - for inverse in tool.Ifc.get().get_inverse(old_footprint): - ifcopenshell.util.element.replace_attribute(inverse, old_footprint, new_footprint) - blenderbim.core.geometry.remove_representation( - tool.Ifc, tool.Geometry, obj=obj, representation=old_footprint - ) - else: - ifcopenshell.api.run( - "geometry.assign_representation", tool.Ifc.get(), product=element, representation=new_footprint - ) - return {"FINISHED"} class ResetVertex(bpy.types.Operator):