Blender materials now map 1:1 to IfcMaterial and can store attributes

This commit is contained in:
Dion Moult
2020-11-11 22:13:50 +11:00
parent ecdc05d265
commit d6397baa59
2 changed files with 9 additions and 18 deletions
@@ -1153,9 +1153,7 @@ class IfcParser:
continue
results[slot.material.name] = {
"ifc": None,
"part_ifc": None, # TODO: check if we deprecate this
"raw": slot.material,
"material_type": obj.BIMObjectProperties.material_type,
"attributes": self.get_material_attributes(slot.material),
}
return results
@@ -2035,19 +2033,13 @@ class IfcExporter:
self.ifc_rep_context["Model"]["Body"]["MODEL_VIEW"]["ifc"], None, None, [styled_item]
)
if self.schema_version == "IFC2X3":
material["ifc"] = self.file.createIfcMaterial(material["raw"].name)
material["ifc"] = self.file.createIfcMaterial(material["attributes"]["Name"])
else:
material["ifc"] = self.file.createIfcMaterial(material["raw"].name, None, None)
material["ifc"] = self.file.create_entity("IfcMaterial", **material["attributes"])
self.create_material_psets(material)
self.file.createIfcMaterialDefinitionRepresentation(
material["raw"].name, None, [styled_representation], material["ifc"]
material["attributes"]["Name"], None, [styled_representation], material["ifc"]
)
if material["material_type"] == "IfcMaterial":
continue
material_type = material["material_type"][0:-3]
self.cast_attributes(material_type, material["attributes"])
material["attributes"]["Material"] = material["ifc"]
material["part_ifc"] = self.file.create_entity(material_type, **material["attributes"])
def create_material_profile_def(self, profile):
ifc_class = profile.profile
+6 -7
View File
@@ -469,15 +469,14 @@ def getApplicableAttributes(self, context):
def getApplicableMaterialAttributes(self, context):
global materialattributes_enum
materialattributes_enum.clear()
if "/" in context.active_object.name and context.active_object.name.split("/")[0] in schema.ifc.elements:
material_type = context.active_object.BIMObjectProperties.material_type
if material_type[-3:] == "Set":
material_type = material_type[0:-3]
if "/" in context.active_object.name:
ifc_schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(bpy.context.scene.BIMProperties.export_schema)
entity = ifc_schema.declaration_by_name("IfcMaterial")
materialattributes_enum.extend(
[
(a["name"], a["name"], "")
for a in schema.ifc.IfcMaterialDefinition[material_type]["attributes"]
if self.attributes.find(a["name"]) == -1
(a.name(), a.name(), "")
for a in entity.all_attributes()
if self.attributes.find(a.name()) == -1
]
)
return materialattributes_enum