mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 20:00:02 +00:00
Fix bug where 2D types were not loaded as a fallback from the body representation.
This commit is contained in:
@@ -625,37 +625,33 @@ class IfcImporter:
|
|||||||
|
|
||||||
def create_element_type(self, element):
|
def create_element_type(self, element):
|
||||||
self.ifc_import_settings.logger.info("Creating object %s", element)
|
self.ifc_import_settings.logger.info("Creating object %s", element)
|
||||||
representation_map = self.get_type_product_body_representation_map(element)
|
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
|
if not representation:
|
||||||
|
representation = ifcopenshell.util.representation.get_representation(element, "Plan", "Annotation")
|
||||||
|
if not representation:
|
||||||
|
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Annotation")
|
||||||
mesh = None
|
mesh = None
|
||||||
if representation_map:
|
if representation:
|
||||||
representation = representation_map.MappedRepresentation
|
|
||||||
mesh_name = "{}/{}".format(representation.ContextOfItems.id(), representation.id())
|
mesh_name = "{}/{}".format(representation.ContextOfItems.id(), representation.id())
|
||||||
mesh = self.meshes.get(mesh_name)
|
mesh = self.meshes.get(mesh_name)
|
||||||
if mesh is None:
|
if mesh is None:
|
||||||
|
shape = None
|
||||||
try:
|
try:
|
||||||
shape = ifcopenshell.geom.create_shape(self.settings, representation_map.MappedRepresentation)
|
shape = ifcopenshell.geom.create_shape(self.settings, representation)
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
shape = ifcopenshell.geom.create_shape(self.settings_2d, representation)
|
||||||
|
except:
|
||||||
|
self.ifc_import_settings.logger.error("Failed to generate shape for %s", element)
|
||||||
|
if shape:
|
||||||
mesh = self.create_mesh(element, shape)
|
mesh = self.create_mesh(element, shape)
|
||||||
tool.Loader.link_mesh(shape, mesh)
|
tool.Loader.link_mesh(shape, mesh)
|
||||||
self.meshes[mesh_name] = mesh
|
self.meshes[mesh_name] = mesh
|
||||||
except:
|
|
||||||
self.ifc_import_settings.logger.error("Failed to generate shape for %s", element)
|
|
||||||
obj = bpy.data.objects.new(tool.Loader.get_name(element), mesh)
|
obj = bpy.data.objects.new(tool.Loader.get_name(element), mesh)
|
||||||
self.link_element(element, obj)
|
self.link_element(element, obj)
|
||||||
self.material_creator.create(element, obj, mesh)
|
self.material_creator.create(element, obj, mesh)
|
||||||
self.type_products[element.GlobalId] = obj
|
self.type_products[element.GlobalId] = obj
|
||||||
|
|
||||||
def get_type_product_body_representation_map(self, element):
|
|
||||||
if not element.RepresentationMaps:
|
|
||||||
return
|
|
||||||
for representation_map in element.RepresentationMaps:
|
|
||||||
context = representation_map.MappedRepresentation.ContextOfItems
|
|
||||||
if (
|
|
||||||
context.ContextType == "Model"
|
|
||||||
and context.ContextIdentifier == "Body"
|
|
||||||
and context.TargetView == "MODEL_VIEW"
|
|
||||||
):
|
|
||||||
return representation_map
|
|
||||||
|
|
||||||
def create_native_elements(self):
|
def create_native_elements(self):
|
||||||
progress = 0
|
progress = 0
|
||||||
checkpoint = time.time()
|
checkpoint = time.time()
|
||||||
|
|||||||
Reference in New Issue
Block a user