mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
project.assign_declaration - support batching #4474
This commit is contained in:
@@ -40,7 +40,7 @@ class LibraryGenerator:
|
||||
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name="Australian Library"
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definition=self.library, relating_context=self.project
|
||||
"project.assign_declaration", self.file, definitions=[self.library], relating_context=self.project
|
||||
)
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit])
|
||||
@@ -196,7 +196,7 @@ class LibraryGenerator:
|
||||
)
|
||||
layer.Name = layer_data[0]
|
||||
layer.LayerThickness = layer_data[2]
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
return element
|
||||
|
||||
def create_layer_type(self, ifc_class, name, thickness):
|
||||
@@ -205,7 +205,7 @@ class LibraryGenerator:
|
||||
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
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
return element
|
||||
|
||||
def create_profile_type(self, ifc_class, name, profile):
|
||||
@@ -216,7 +216,7 @@ class LibraryGenerator:
|
||||
"material.add_profile", self.file, profile_set=profile_set, material=self.materials["TBD"]["ifc"]
|
||||
)
|
||||
ifcopenshell.api.run("material.assign_profile", self.file, material_profile=material_profile, profile=profile)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
|
||||
def create_type(self, ifc_class, name, representations):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
@@ -248,7 +248,7 @@ class LibraryGenerator:
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", self.file, product=element, representation=representation
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
|
||||
|
||||
LibraryGenerator().generate()
|
||||
|
||||
@@ -35,7 +35,7 @@ class LibraryGenerator:
|
||||
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name="BlenderBIM Demo Library"
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definition=self.library, relating_context=self.project
|
||||
"project.assign_declaration", self.file, definitions=[self.library], relating_context=self.project
|
||||
)
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file, length={"is_metric": True, "raw": "METERS"})
|
||||
model = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
@@ -209,7 +209,7 @@ class LibraryGenerator:
|
||||
layer_set = rel.RelatingMaterial
|
||||
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=layer_set, material=self.material)
|
||||
layer.LayerThickness = thickness
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
return element
|
||||
|
||||
def create_profile_type(self, ifc_class, name, profile):
|
||||
@@ -220,7 +220,7 @@ class LibraryGenerator:
|
||||
"material.add_profile", self.file, profile_set=profile_set, material=self.material
|
||||
)
|
||||
ifcopenshell.api.run("material.assign_profile", self.file, material_profile=material_profile, profile=profile)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
|
||||
def create_type(self, ifc_class, name, representations):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
@@ -252,7 +252,7 @@ class LibraryGenerator:
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", self.file, product=element, representation=representation
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
|
||||
|
||||
LibraryGenerator().generate()
|
||||
|
||||
@@ -42,7 +42,7 @@ class LibraryGenerator:
|
||||
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name=library_name
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definition=self.library, relating_context=self.project
|
||||
"project.assign_declaration", self.file, definitions=[self.library], relating_context=self.project
|
||||
)
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit])
|
||||
@@ -131,7 +131,7 @@ class LibraryGenerator:
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", self.file, product=element, representation=representation
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -37,7 +37,7 @@ class LibraryGenerator:
|
||||
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name=library_name
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definition=self.library, relating_context=self.project
|
||||
"project.assign_declaration", self.file, definitions=[self.library], relating_context=self.project
|
||||
)
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit])
|
||||
@@ -1797,7 +1797,7 @@ class LibraryGenerator:
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", self.file, product=element, representation=representation_2d
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
return element
|
||||
|
||||
def create_layer_set_type(self, name, data):
|
||||
@@ -1811,7 +1811,7 @@ class LibraryGenerator:
|
||||
)
|
||||
layer.Name = layer_data[0]
|
||||
layer.LayerThickness = layer_data[2]
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
return element
|
||||
|
||||
def create_layer_type(self, ifc_class, name, thickness):
|
||||
@@ -1822,7 +1822,7 @@ class LibraryGenerator:
|
||||
"material.add_layer", self.file, layer_set=layer_set, material=self.materials["TBD"]["ifc"]
|
||||
)
|
||||
layer.LayerThickness = thickness
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
return element
|
||||
|
||||
def create_profile_type(self, ifc_class, name, profile):
|
||||
@@ -1837,7 +1837,7 @@ class LibraryGenerator:
|
||||
# material=self.materials["TBD"]["ifc"]
|
||||
)
|
||||
ifcopenshell.api.run("material.assign_profile", self.file, material_profile=material_profile, profile=profile)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
|
||||
def create_type(self, ifc_class, name, representations):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
@@ -1869,7 +1869,7 @@ class LibraryGenerator:
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", self.file, product=element, representation=representation
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -319,7 +319,7 @@ class LibraryGenerator:
|
||||
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name=library_name
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definition=self.library, relating_context=self.project
|
||||
"project.assign_declaration", self.file, definitions=[self.library], relating_context=self.project
|
||||
)
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit])
|
||||
@@ -447,7 +447,7 @@ class LibraryGenerator:
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", self.file, product=element, representation=representation_2d
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
return element
|
||||
|
||||
def create_type(self, ifc_class, name, representations):
|
||||
@@ -480,7 +480,7 @@ class LibraryGenerator:
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", self.file, product=element, representation=representation
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class LibraryGenerator:
|
||||
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name="BlenderBIM Demo Library"
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definition=self.library, relating_context=self.library
|
||||
"project.assign_declaration", self.file, definitions=[self.library], relating_context=self.library
|
||||
)
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file, length={"is_metric": True, "raw": "METERS"})
|
||||
model = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
@@ -98,7 +98,7 @@ class LibraryGenerator:
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", self.file, product=element, representation=representation
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
|
||||
|
||||
LibraryGenerator().generate()
|
||||
|
||||
@@ -43,7 +43,7 @@ class LibraryGenerator:
|
||||
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name=f"{parse_profiles_type} Steel Profiles Library"
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definition=self.library, relating_context=self.project
|
||||
"project.assign_declaration", self.file, definitions=[self.library], relating_context=self.project
|
||||
)
|
||||
dim_exponents = self.file.createIfcDimensionalExponents(0, 0, 0, 0, 0, 0, 0)
|
||||
length_unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
@@ -182,7 +182,7 @@ class LibraryGenerator:
|
||||
# material=self.materials["TBD"]["ifc"]
|
||||
)
|
||||
ifcopenshell.api.run("material.assign_profile", self.file, material_profile=material_profile, profile=profile)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definitions=[element], relating_context=self.library)
|
||||
|
||||
def create_double_l_profile(self, profile, resulting_profile_name=None, profiles_gap=0, mode = "LLBB"):
|
||||
def create_derived_profile(profile, mirrored=False):
|
||||
|
||||
@@ -91,7 +91,7 @@ def mirror_placement_test():
|
||||
library = ifcopenshell.api.run(
|
||||
"root.create_entity", ifc_file, ifc_class="IfcProjectLibrary", name=f"Non-structural assets library"
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", ifc_file, definition=library, relating_context=project)
|
||||
ifcopenshell.api.run("project.assign_declaration", ifc_file, definitions=[library], relating_context=project)
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc_file, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc_file, units=[unit])
|
||||
model = ifcopenshell.api.run("context.add_context", ifc_file, context_type="Model")
|
||||
@@ -152,7 +152,7 @@ def mirror_placement_test():
|
||||
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc_file, ifc_class="IfcFurnitureType", name="test")
|
||||
ifcopenshell.api.run("geometry.assign_representation", ifc_file, product=element, representation=representation_3d)
|
||||
ifcopenshell.api.run("project.assign_declaration", ifc_file, definition=element, relating_context=library)
|
||||
ifcopenshell.api.run("project.assign_declaration", ifc_file, definitions=[element], relating_context=library)
|
||||
|
||||
ifc_file.write("tmp.ifc")
|
||||
|
||||
@@ -165,7 +165,7 @@ def curve_between_two_points_test():
|
||||
library = ifcopenshell.api.run(
|
||||
"root.create_entity", ifc_file, ifc_class="IfcProjectLibrary", name=f"Non-structural assets library"
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", ifc_file, definition=library, relating_context=project)
|
||||
ifcopenshell.api.run("project.assign_declaration", ifc_file, definitions=[library], relating_context=project)
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc_file, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc_file, units=[unit])
|
||||
model = ifcopenshell.api.run("context.add_context", ifc_file, context_type="Model")
|
||||
@@ -217,7 +217,7 @@ def curve_between_two_points_test():
|
||||
print(representation_2d)
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc_file, ifc_class="IfcFurnitureType", name="test")
|
||||
ifcopenshell.api.run("geometry.assign_representation", ifc_file, product=element, representation=representation_2d)
|
||||
ifcopenshell.api.run("project.assign_declaration", ifc_file, definition=element, relating_context=library)
|
||||
ifcopenshell.api.run("project.assign_declaration", ifc_file, definitions=[element], relating_context=library)
|
||||
|
||||
ifc_file.write("tmp.ifc")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user