mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
Fix bug where switching representations would not work or create duplicate meshes.
This commit is contained in:
@@ -147,6 +147,7 @@ class SwitchRepresentation(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.obj = bpy.context.active_object
|
self.obj = bpy.context.active_object
|
||||||
|
self.oprops = self.obj.BIMObjectProperties
|
||||||
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
self.context_of_items = self.file.by_id(self.ifc_definition_id).ContextOfItems
|
self.context_of_items = self.file.by_id(self.ifc_definition_id).ContextOfItems
|
||||||
@@ -162,19 +163,17 @@ class SwitchRepresentation(bpy.types.Operator):
|
|||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
logger = logging.getLogger("ImportIFC")
|
logger = logging.getLogger("ImportIFC")
|
||||||
ifc_import_settings = import_ifc.IfcImportSettings.factory(bpy.context, IfcStore.path, logger)
|
ifc_import_settings = import_ifc.IfcImportSettings.factory(bpy.context, IfcStore.path, logger)
|
||||||
element = self.file.by_id(self.obj.BIMObjectProperties.ifc_definition_id)
|
element = self.file.by_id(self.oprops.ifc_definition_id)
|
||||||
settings = ifcopenshell.geom.settings()
|
settings = ifcopenshell.geom.settings()
|
||||||
|
|
||||||
if self.context_of_items.ContextIdentifier != "Body":
|
if self.context_of_items.ContextIdentifier == "Body":
|
||||||
settings.set(settings.INCLUDE_CURVES, True)
|
if self.disable_opening_subtractions:
|
||||||
|
shape = ifcopenshell.geom.create_shape(settings, self.file.by_id(self.ifc_definition_id))
|
||||||
if self.disable_opening_subtractions and self.context_of_items.ContextIdentifier == "Body":
|
else:
|
||||||
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True)
|
shape = ifcopenshell.geom.create_shape(settings, self.file.by_id(self.oprops.ifc_definition_id))
|
||||||
shape = ifcopenshell.geom.create_shape(settings, self.file.by_id(self.ifc_definition_id))
|
|
||||||
else:
|
else:
|
||||||
shape = ifcopenshell.geom.create_shape(
|
settings.set(settings.INCLUDE_CURVES, True)
|
||||||
settings, self.file.by_id(self.obj.BIMObjectProperties.ifc_definition_id)
|
shape = ifcopenshell.geom.create_shape(settings, self.file.by_id(self.ifc_definition_id))
|
||||||
)
|
|
||||||
|
|
||||||
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
||||||
ifc_importer.file = self.file
|
ifc_importer.file = self.file
|
||||||
@@ -186,9 +185,9 @@ class SwitchRepresentation(bpy.types.Operator):
|
|||||||
material_creator.create(element, self.obj, mesh)
|
material_creator.create(element, self.obj, mesh)
|
||||||
|
|
||||||
if self.disable_opening_subtractions and self.context_of_items.ContextIdentifier == "Body":
|
if self.disable_opening_subtractions and self.context_of_items.ContextIdentifier == "Body":
|
||||||
if self.obj.BIMObjectProperties.ifc_definition_id not in VoidData.products:
|
if self.oprops.ifc_definition_id not in VoidData.products:
|
||||||
VoidData.load(self.obj.BIMObjectProperties.ifc_definition_id)
|
VoidData.load(self.oprops.ifc_definition_id)
|
||||||
for opening_id in VoidData.products[self.obj.BIMObjectProperties.ifc_definition_id]:
|
for opening_id in VoidData.products[self.oprops.ifc_definition_id]:
|
||||||
if opening_id in IfcStore.id_map:
|
if opening_id in IfcStore.id_map:
|
||||||
opening = IfcStore.id_map[opening_id]
|
opening = IfcStore.id_map[opening_id]
|
||||||
modifier = self.obj.modifiers.new("IfcOpeningElement", "BOOLEAN")
|
modifier = self.obj.modifiers.new("IfcOpeningElement", "BOOLEAN")
|
||||||
|
|||||||
Reference in New Issue
Block a user