Allow graceful migration of IFC entities when exporting so the user doesn't need to fix every invalid schema attribute themselves3RlG$Bayj3kPlwh4EEvXJP

This commit is contained in:
Dion Moult
2020-12-06 11:37:48 +11:00
parent 981f0c23c7
commit 0d03b4e008
2 changed files with 15 additions and 11 deletions
@@ -1885,11 +1885,7 @@ class IfcExporter:
try:
product["ifc"] = self.file.create_entity(product["class"], **product["attributes"])
except RuntimeError as e:
self.ifc_export_settings.logger.error(
'The type product "{}/{}" could not be created: {}'.format(
product["class"], product["attributes"]["Name"], e.args
)
)
product["ifc"] = self.create_ifc_entity(product)
def add_predefined_attributes_to_type_product(self, product, attributes):
self.create_predefined_attributes(attributes)
@@ -2073,7 +2069,7 @@ class IfcExporter:
return results
def create_styled_item(self, styled_item, representation_item=None):
surface_style = self.ifc_parser.surface_styles[styled_item["attributes"]["Name"]]
surface_style = self.ifc_parser.surface_styles[styled_item["raw"].name]
if not surface_style["ifc"]:
styles = []
styles.append(self.create_surface_style_rendering(styled_item))
@@ -2302,11 +2298,20 @@ class IfcExporter:
try:
product["ifc"] = self.file.create_entity(product["class"], **product["attributes"])
except RuntimeError as e:
self.ifc_export_settings.logger.error(
'The product "{}/{}" could not be created: {}'.format(
product["class"], product["attributes"]["Name"], e.args
product["ifc"] = self.create_ifc_entity(product)
def create_ifc_entity(self, data):
result = self.file.create_entity(data["class"])
for key, value in data["attributes"].items():
try:
setattr(result, key, value)
except RuntimeError as e:
self.ifc_export_settings.logger.error(
'The entity "{}/{}" attribute {} with value {} could not be created: {}'.format(
data["class"], data["attributes"]["Name"], key, value, e.args
)
)
)
return result
def get_product_attribute_type(self, product_class, attribute_name):
element_schema = schema.ifc.elements[product_class]
@@ -4118,7 +4118,6 @@ class ActivateDrawingStyle(bpy.types.Operator):
space.overlay.show_axis_z = style["space.overlay.show_axis_z"]
space.overlay.show_object_origins = style["space.overlay.show_object_origins"]
space.overlay.show_relationship_lines = style["space.overlay.show_relationship_lines"]
space.shading.type = "RENDERED"
def set_query(self):
self.selector = ifcopenshell.util.selector.Selector()