mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 16:22:53 +00:00
material.assign_material - support batching #4474
This commit is contained in:
@@ -542,7 +542,7 @@ class MEPGenerator:
|
||||
ifc_representation_class=None,
|
||||
)
|
||||
|
||||
rel = ifcopenshell.api.run("material.assign_material", ifc_file, product=element, type="IfcMaterialProfileSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", ifc_file, products=[element], type="IfcMaterialProfileSet")
|
||||
profile_set = rel.RelatingMaterial
|
||||
material_profile = ifcopenshell.api.run(
|
||||
"material.add_profile", ifc_file, profile_set=profile_set, material=material
|
||||
|
||||
@@ -515,7 +515,7 @@ def ensure_material_assigned(usecase_path, ifc_file, settings):
|
||||
if usecase_path == "material.assign_material":
|
||||
if not settings.get("material", None):
|
||||
return
|
||||
elements = [settings["product"]]
|
||||
elements = settings["products"]
|
||||
else:
|
||||
elements = []
|
||||
for rel in ifc_file.by_type("IfcRelAssociatesMaterial"):
|
||||
|
||||
@@ -283,7 +283,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
else:
|
||||
material = self.add_default_material()
|
||||
rel = ifcopenshell.api.run(
|
||||
"material.assign_material", ifc_file, product=element, type="IfcMaterialLayerSet"
|
||||
"material.assign_material", ifc_file, products=[element], type="IfcMaterialLayerSet"
|
||||
)
|
||||
layer_set = rel.RelatingMaterial
|
||||
layer = ifcopenshell.api.run("material.add_layer", ifc_file, layer_set=layer_set, material=material)
|
||||
@@ -361,7 +361,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
)
|
||||
|
||||
rel = ifcopenshell.api.run(
|
||||
"material.assign_material", ifc_file, product=element, type="IfcMaterialProfileSet"
|
||||
"material.assign_material", ifc_file, products=[element], type="IfcMaterialProfileSet"
|
||||
)
|
||||
profile_set = rel.RelatingMaterial
|
||||
material_profile = ifcopenshell.api.run(
|
||||
|
||||
@@ -102,7 +102,7 @@ def assign_material(ifc, material_tool, material_type, objects):
|
||||
element = ifc.get_entity(obj)
|
||||
if not element:
|
||||
continue
|
||||
ifc.run("material.assign_material", product=element, type=material_type, material=material)
|
||||
ifc.run("material.assign_material", products=[element], type=material_type, material=material)
|
||||
assigned_material = material_tool.get_material(element)
|
||||
if material_tool.is_a_material_set(assigned_material):
|
||||
material_tool.add_material_to_set(material_set=assigned_material, material=material)
|
||||
|
||||
@@ -219,7 +219,7 @@ class Material(blenderbim.core.tool.Material):
|
||||
material = tool.Ifc.get().by_type("IfcMaterial")[0]
|
||||
else:
|
||||
blenderbim.core.material.unassign_material(tool.Ifc, tool.Material, objects=[tool.Ifc.get_object(element)])
|
||||
tool.Ifc.run("material.assign_material", product=element, type="IfcMaterialProfileSet", material=material)
|
||||
tool.Ifc.run("material.assign_material", products=[element], type="IfcMaterialProfileSet", material=material)
|
||||
assinged_material = cls.get_material(element)
|
||||
material_profile = tool.Ifc.run("material.add_profile", profile_set=assinged_material, material=material)
|
||||
return material_profile
|
||||
|
||||
@@ -188,7 +188,7 @@ class LibraryGenerator:
|
||||
def create_layer_set_type(self, name, data):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=data["type"], name=name)
|
||||
element.Description = data["Description"]
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialLayerSet")
|
||||
layer_set = rel.RelatingMaterial
|
||||
for layer_data in data["Layers"]:
|
||||
layer = ifcopenshell.api.run(
|
||||
@@ -201,7 +201,7 @@ class LibraryGenerator:
|
||||
|
||||
def create_layer_type(self, ifc_class, name, thickness):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialLayerSet")
|
||||
layer_set = rel.RelatingMaterial
|
||||
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=layer_set, material=self.materials["TBD"]["ifc"])
|
||||
layer.LayerThickness = thickness
|
||||
@@ -210,7 +210,7 @@ class LibraryGenerator:
|
||||
|
||||
def create_profile_type(self, ifc_class, name, profile):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialProfileSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialProfileSet")
|
||||
profile_set = rel.RelatingMaterial
|
||||
material_profile = ifcopenshell.api.run(
|
||||
"material.add_profile", self.file, profile_set=profile_set, material=self.materials["TBD"]["ifc"]
|
||||
|
||||
@@ -205,7 +205,7 @@ class LibraryGenerator:
|
||||
|
||||
def create_layer_type(self, ifc_class, name, thickness):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialLayerSet")
|
||||
layer_set = rel.RelatingMaterial
|
||||
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=layer_set, material=self.material)
|
||||
layer.LayerThickness = thickness
|
||||
@@ -214,7 +214,7 @@ class LibraryGenerator:
|
||||
|
||||
def create_profile_type(self, ifc_class, name, profile):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialProfileSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialProfileSet")
|
||||
profile_set = rel.RelatingMaterial
|
||||
material_profile = ifcopenshell.api.run(
|
||||
"material.add_profile", self.file, profile_set=profile_set, material=self.material
|
||||
|
||||
@@ -1803,7 +1803,7 @@ class LibraryGenerator:
|
||||
def create_layer_set_type(self, name, data):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=data["type"], name=name)
|
||||
element.Description = data["Description"]
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialLayerSet")
|
||||
layer_set = rel.RelatingMaterial
|
||||
for layer_data in data["Layers"]:
|
||||
layer = ifcopenshell.api.run(
|
||||
@@ -1816,7 +1816,7 @@ class LibraryGenerator:
|
||||
|
||||
def create_layer_type(self, ifc_class, name, thickness):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialLayerSet")
|
||||
layer_set = rel.RelatingMaterial
|
||||
layer = ifcopenshell.api.run(
|
||||
"material.add_layer", self.file, layer_set=layer_set, material=self.materials["TBD"]["ifc"]
|
||||
@@ -1827,7 +1827,7 @@ class LibraryGenerator:
|
||||
|
||||
def create_profile_type(self, ifc_class, name, profile):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialProfileSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialProfileSet")
|
||||
profile_set = rel.RelatingMaterial
|
||||
material_profile = ifcopenshell.api.run(
|
||||
"material.add_profile",
|
||||
|
||||
@@ -175,7 +175,7 @@ class LibraryGenerator:
|
||||
|
||||
def create_profile_type(self, ifc_class, name, profile):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialProfileSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialProfileSet")
|
||||
profile_set = rel.RelatingMaterial
|
||||
material_profile = ifcopenshell.api.run(
|
||||
"material.add_profile", self.file, profile_set=profile_set, material=self.material
|
||||
|
||||
@@ -79,7 +79,7 @@ class TestGetElementsByMaterial(NewFile):
|
||||
tool.Ifc.set(ifc)
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", ifc)
|
||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", ifc, products=[element], material=material)
|
||||
assert subject.get_elements_by_material(material) == {element}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user