mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
Blender materials now map 1:1 to IfcMaterial and can store attributes
This commit is contained in:
@@ -1153,9 +1153,7 @@ class IfcParser:
|
|||||||
continue
|
continue
|
||||||
results[slot.material.name] = {
|
results[slot.material.name] = {
|
||||||
"ifc": None,
|
"ifc": None,
|
||||||
"part_ifc": None, # TODO: check if we deprecate this
|
|
||||||
"raw": slot.material,
|
"raw": slot.material,
|
||||||
"material_type": obj.BIMObjectProperties.material_type,
|
|
||||||
"attributes": self.get_material_attributes(slot.material),
|
"attributes": self.get_material_attributes(slot.material),
|
||||||
}
|
}
|
||||||
return results
|
return results
|
||||||
@@ -2035,19 +2033,13 @@ class IfcExporter:
|
|||||||
self.ifc_rep_context["Model"]["Body"]["MODEL_VIEW"]["ifc"], None, None, [styled_item]
|
self.ifc_rep_context["Model"]["Body"]["MODEL_VIEW"]["ifc"], None, None, [styled_item]
|
||||||
)
|
)
|
||||||
if self.schema_version == "IFC2X3":
|
if self.schema_version == "IFC2X3":
|
||||||
material["ifc"] = self.file.createIfcMaterial(material["raw"].name)
|
material["ifc"] = self.file.createIfcMaterial(material["attributes"]["Name"])
|
||||||
else:
|
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.create_material_psets(material)
|
||||||
self.file.createIfcMaterialDefinitionRepresentation(
|
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):
|
def create_material_profile_def(self, profile):
|
||||||
ifc_class = profile.profile
|
ifc_class = profile.profile
|
||||||
|
|||||||
@@ -469,15 +469,14 @@ def getApplicableAttributes(self, context):
|
|||||||
def getApplicableMaterialAttributes(self, context):
|
def getApplicableMaterialAttributes(self, context):
|
||||||
global materialattributes_enum
|
global materialattributes_enum
|
||||||
materialattributes_enum.clear()
|
materialattributes_enum.clear()
|
||||||
if "/" in context.active_object.name and context.active_object.name.split("/")[0] in schema.ifc.elements:
|
if "/" in context.active_object.name:
|
||||||
material_type = context.active_object.BIMObjectProperties.material_type
|
ifc_schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(bpy.context.scene.BIMProperties.export_schema)
|
||||||
if material_type[-3:] == "Set":
|
entity = ifc_schema.declaration_by_name("IfcMaterial")
|
||||||
material_type = material_type[0:-3]
|
|
||||||
materialattributes_enum.extend(
|
materialattributes_enum.extend(
|
||||||
[
|
[
|
||||||
(a["name"], a["name"], "")
|
(a.name(), a.name(), "")
|
||||||
for a in schema.ifc.IfcMaterialDefinition[material_type]["attributes"]
|
for a in entity.all_attributes()
|
||||||
if self.attributes.find(a["name"]) == -1
|
if self.attributes.find(a.name()) == -1
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return materialattributes_enum
|
return materialattributes_enum
|
||||||
|
|||||||
Reference in New Issue
Block a user