mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 10:23:41 +00:00
Material profile set usages are now supported. Hooray! Thanks Jesusbill!
This commit is contained in:
@@ -318,6 +318,10 @@ class EnableEditingAssignedMaterial(bpy.types.Operator):
|
|||||||
material_set_class = "IfcMaterialLayerSet"
|
material_set_class = "IfcMaterialLayerSet"
|
||||||
elif product_data["type"] == "IfcMaterialProfileSet":
|
elif product_data["type"] == "IfcMaterialProfileSet":
|
||||||
material_set_data = Data.profile_sets[product_data["id"]]
|
material_set_data = Data.profile_sets[product_data["id"]]
|
||||||
|
elif product_data["type"] == "IfcMaterialProfileSetUsage":
|
||||||
|
profile_set_usage = Data.profile_set_usages[product_data["id"]]
|
||||||
|
material_set_data = Data.profile_sets[profile_set_usage["ForProfileSet"]]
|
||||||
|
material_set_class = "IfcMaterialProfileSet"
|
||||||
elif product_data["type"] == "IfcMaterialList":
|
elif product_data["type"] == "IfcMaterialList":
|
||||||
material_set_data = Data.lists[product_data["id"]]
|
material_set_data = Data.lists[product_data["id"]]
|
||||||
else:
|
else:
|
||||||
@@ -409,7 +413,7 @@ class EnableEditingMaterialSetItem(bpy.types.Operator):
|
|||||||
material_set_item_data = Data.constituents[self.material_set_item]
|
material_set_item_data = Data.constituents[self.material_set_item]
|
||||||
elif product_data["type"] == "IfcMaterialLayerSet" or product_data["type"] == "IfcMaterialLayerSetUsage":
|
elif product_data["type"] == "IfcMaterialLayerSet" or product_data["type"] == "IfcMaterialLayerSetUsage":
|
||||||
material_set_item_data = Data.layers[self.material_set_item]
|
material_set_item_data = Data.layers[self.material_set_item]
|
||||||
elif product_data["type"] == "IfcMaterialProfileSet":
|
elif product_data["type"] == "IfcMaterialProfileSet" or product_data["type"] == "IfcMaterialProfileSetUsage":
|
||||||
material_set_item_data = Data.profiles[self.material_set_item]
|
material_set_item_data = Data.profiles[self.material_set_item]
|
||||||
else:
|
else:
|
||||||
material_set_item_data = {}
|
material_set_item_data = {}
|
||||||
@@ -542,7 +546,7 @@ class EditMaterialSetItem(bpy.types.Operator):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
Data.load_layers()
|
Data.load_layers()
|
||||||
elif product_data["type"] == "IfcMaterialProfileSet":
|
elif product_data["type"] == "IfcMaterialProfileSet" or product_data["type"] == "IfcMaterialProfileSetUsage":
|
||||||
profile_attributes = {}
|
profile_attributes = {}
|
||||||
for attribute in props.material_set_item_profile_attributes:
|
for attribute in props.material_set_item_profile_attributes:
|
||||||
if attribute.data_type == "string":
|
if attribute.data_type == "string":
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ def getMaterialTypes(self, context):
|
|||||||
"IfcMaterialLayerSet",
|
"IfcMaterialLayerSet",
|
||||||
"IfcMaterialLayerSetUsage",
|
"IfcMaterialLayerSetUsage",
|
||||||
"IfcMaterialProfileSet",
|
"IfcMaterialProfileSet",
|
||||||
|
"IfcMaterialProfileSetUsage",
|
||||||
"IfcMaterialList",
|
"IfcMaterialList",
|
||||||
]
|
]
|
||||||
if IfcStore.get_file().schema == "IFC2X3":
|
if IfcStore.get_file().schema == "IFC2X3":
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ class BIM_PT_object_material(Panel):
|
|||||||
self.set_items = self.material_set_data["MaterialProfiles"] or []
|
self.set_items = self.material_set_data["MaterialProfiles"] or []
|
||||||
self.set_data = Data.profiles
|
self.set_data = Data.profiles
|
||||||
self.set_item_name = "profile"
|
self.set_item_name = "profile"
|
||||||
|
elif self.product_data["type"] == "IfcMaterialProfileSetUsage":
|
||||||
|
self.material_set_usage = Data.profile_set_usages[self.product_data["id"]]
|
||||||
|
self.material_set_id = self.material_set_usage["ForProfileSet"]
|
||||||
|
self.material_set_data = Data.profile_sets[self.material_set_id]
|
||||||
|
self.set_items = self.material_set_data["MaterialProfiles"] or []
|
||||||
|
self.set_data = Data.profiles
|
||||||
|
self.set_item_name = "profile"
|
||||||
elif self.product_data["type"] == "IfcMaterialList":
|
elif self.product_data["type"] == "IfcMaterialList":
|
||||||
self.material_set_id = self.product_data["id"]
|
self.material_set_id = self.product_data["id"]
|
||||||
self.material_set_data = Data.lists[self.material_set_id]
|
self.material_set_data = Data.lists[self.material_set_id]
|
||||||
|
|||||||
@@ -24,18 +24,28 @@ class Usecase:
|
|||||||
elif self.settings["type"] == "IfcMaterialProfileSet":
|
elif self.settings["type"] == "IfcMaterialProfileSet":
|
||||||
material_set = self.file.create_entity(self.settings["type"])
|
material_set = self.file.create_entity(self.settings["type"])
|
||||||
self.create_material_association(material_set)
|
self.create_material_association(material_set)
|
||||||
|
elif self.settings["type"] == "IfcMaterialProfileSetUsage":
|
||||||
|
material_set = self.file.create_entity("IfcMaterialProfileSet")
|
||||||
|
material_set_usage = self.create_profile_set_usage(material_set)
|
||||||
|
self.create_material_association(material_set_usage)
|
||||||
elif self.settings["type"] == "IfcMaterialList":
|
elif self.settings["type"] == "IfcMaterialList":
|
||||||
material_set = self.file.create_entity(self.settings["type"])
|
material_set = self.file.create_entity(self.settings["type"])
|
||||||
material_set.Materials = [self.settings["material"]]
|
material_set.Materials = [self.settings["material"]]
|
||||||
self.create_material_association(material_set)
|
self.create_material_association(material_set)
|
||||||
|
|
||||||
def create_layer_set_usage(self, material_set):
|
def create_layer_set_usage(self, material_set):
|
||||||
return self.file.create_entity("IfcMaterialLayerSetUsage", **{
|
return self.file.create_entity(
|
||||||
"ForLayerSet": material_set,
|
"IfcMaterialLayerSetUsage",
|
||||||
"LayerSetDirection": "AXIS2" if self.settings["product"].is_a("IfcWall") else "AXIS3",
|
**{
|
||||||
"DirectionSense": "POSITIVE",
|
"ForLayerSet": material_set,
|
||||||
"OffsetFromReferenceLine": 0
|
"LayerSetDirection": "AXIS2" if self.settings["product"].is_a("IfcWall") else "AXIS3",
|
||||||
})
|
"DirectionSense": "POSITIVE",
|
||||||
|
"OffsetFromReferenceLine": 0,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def create_profile_set_usage(self, material_set):
|
||||||
|
return self.file.create_entity("IfcMaterialProfileSetUsage", **{"ForProfileSet": material_set})
|
||||||
|
|
||||||
def assign_ifc_material(self):
|
def assign_ifc_material(self):
|
||||||
rel = self.get_rel_associates_material(self.settings["material"])
|
rel = self.get_rel_associates_material(self.settings["material"])
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ class Data:
|
|||||||
materials = {}
|
materials = {}
|
||||||
constituent_sets = {}
|
constituent_sets = {}
|
||||||
constituents = {}
|
constituents = {}
|
||||||
|
layer_sets_usages = {}
|
||||||
layer_sets = {}
|
layer_sets = {}
|
||||||
layers = {}
|
layers = {}
|
||||||
|
profile_set_usages = {}
|
||||||
profile_sets = {}
|
profile_sets = {}
|
||||||
profiles = {}
|
profiles = {}
|
||||||
lists = {}
|
lists = {}
|
||||||
@@ -23,6 +25,7 @@ class Data:
|
|||||||
cls.layer_set_usages = {}
|
cls.layer_set_usages = {}
|
||||||
cls.layer_sets = {}
|
cls.layer_sets = {}
|
||||||
cls.layers = {}
|
cls.layers = {}
|
||||||
|
cls.profile_set_usages = {}
|
||||||
cls.profile_sets = {}
|
cls.profile_sets = {}
|
||||||
cls.profiles = {}
|
cls.profiles = {}
|
||||||
cls.lists = {}
|
cls.lists = {}
|
||||||
@@ -41,6 +44,7 @@ class Data:
|
|||||||
cls.load_layers()
|
cls.load_layers()
|
||||||
cls.load_layer_usages()
|
cls.load_layer_usages()
|
||||||
cls.load_profiles()
|
cls.load_profiles()
|
||||||
|
cls.load_profile_usages()
|
||||||
cls.load_lists()
|
cls.load_lists()
|
||||||
cls.is_loaded = True
|
cls.is_loaded = True
|
||||||
|
|
||||||
@@ -68,6 +72,11 @@ class Data:
|
|||||||
cls.layer_set_usages = {}
|
cls.layer_set_usages = {}
|
||||||
cls.load_element("IfcMaterialLayerSetUsage", cls.layer_set_usages)
|
cls.load_element("IfcMaterialLayerSetUsage", cls.layer_set_usages)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load_profile_usages(cls):
|
||||||
|
cls.profile_set_usages = {}
|
||||||
|
cls.load_element("IfcMaterialProfileSetUsage", cls.profile_set_usages)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_profiles(cls):
|
def load_profiles(cls):
|
||||||
cls.profile_sets = {}
|
cls.profile_sets = {}
|
||||||
@@ -109,6 +118,4 @@ class Data:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load_association(cls, association, product_id):
|
def load_association(cls, association, product_id):
|
||||||
material_select = association.RelatingMaterial
|
material_select = association.RelatingMaterial
|
||||||
if material_select.is_a("IfcMaterialProfileSetUsage"): # TODO: implement usages
|
|
||||||
material_select = material_select.ForProfileSet
|
|
||||||
cls.products[product_id] = {"type": material_select.is_a(), "id": material_select.id()}
|
cls.products[product_id] = {"type": material_select.is_a(), "id": material_select.id()}
|
||||||
|
|||||||
Reference in New Issue
Block a user