mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Run black on IOS-Python
This commit is contained in:
@@ -36,9 +36,7 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
name="Foobar",
|
||||
classification=result,
|
||||
)
|
||||
ifcopenshell.api.classification.remove_reference(
|
||||
self.file, products=[element, element2], reference=reference
|
||||
)
|
||||
ifcopenshell.api.classification.remove_reference(self.file, products=[element, element2], reference=reference)
|
||||
assert len(ifcopenshell.util.classification.get_references(element)) == 0
|
||||
assert len(ifcopenshell.util.classification.get_references(element2)) == 0
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 0
|
||||
@@ -90,9 +88,7 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
classification=result,
|
||||
)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 1
|
||||
ifcopenshell.api.classification.remove_reference(
|
||||
self.file, products=[element, element2], reference=reference
|
||||
)
|
||||
ifcopenshell.api.classification.remove_reference(self.file, products=[element, element2], reference=reference)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 1
|
||||
ifcopenshell.api.classification.remove_reference(self.file, products=[element3], reference=reference)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 0
|
||||
|
||||
@@ -27,9 +27,7 @@ class TestAssignConstraint(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(constraint) == {element, element2}
|
||||
assert len(self.file.by_type("IfcRelAssociatesConstraint")) == 1
|
||||
|
||||
@@ -37,13 +35,9 @@ class TestAssignConstraint(test.bootstrap.IFC4):
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_that_old_relationships_are_updated_if_they_still_contain_elements(self):
|
||||
@@ -54,9 +48,7 @@ class TestAssignConstraint(test.bootstrap.IFC4):
|
||||
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element2, element3], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element2, element3], constraint=constraint)
|
||||
assert len(rel.RelatedObjects) == 3
|
||||
|
||||
|
||||
|
||||
@@ -27,12 +27,8 @@ class TestUnassignConstraint(test.bootstrap.IFC4):
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.unassign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
ifcopenshell.api.constraint.unassign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(element) == set()
|
||||
assert len(self.file.by_type("IfcRelAssociatesConstraint")) == 0
|
||||
|
||||
@@ -40,9 +36,7 @@ class TestUnassignConstraint(test.bootstrap.IFC4):
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.unassign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.unassign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(element) == set()
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(element2) == set()
|
||||
|
||||
@@ -54,12 +48,8 @@ class TestUnassignConstraint(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element1], constraint=constraint)
|
||||
rel = self.file.by_type("IfcRelAssociatesConstraint")[0]
|
||||
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element2, element3], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.unassign_constraint(
|
||||
self.file, products=[element1, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element2, element3], constraint=constraint)
|
||||
ifcopenshell.api.constraint.unassign_constraint(self.file, products=[element1, element2], constraint=constraint)
|
||||
assert rel.RelatedObjects == (element3,)
|
||||
|
||||
|
||||
|
||||
@@ -27,24 +27,18 @@ class TestAssignControl(test.bootstrap.IFC4):
|
||||
control = ifcopenshell.api.cost.add_cost_schedule(self.file)
|
||||
|
||||
# simple assignment
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
relation = ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall)
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
|
||||
assert relation.RelatingControl == control
|
||||
assert relation.RelatedObjects == (wall,)
|
||||
|
||||
# trying to establish existing relationship
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
relation = ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall)
|
||||
assert relation is None
|
||||
|
||||
# assigning same control to another object
|
||||
wall1 = self.file.createIfcWall()
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall1
|
||||
)
|
||||
relation = ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall1)
|
||||
assert relation is not None
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
|
||||
assert relation.RelatingControl == control
|
||||
|
||||
@@ -27,17 +27,13 @@ class TestUnassignControl(test.bootstrap.IFC4):
|
||||
control = ifcopenshell.api.cost.add_cost_schedule(self.file)
|
||||
|
||||
# assign and unassign
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
relation = ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall)
|
||||
ifcopenshell.api.control.unassign_control(self.file, relating_control=control, related_object=wall)
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 0
|
||||
|
||||
# 1 control 2 related objects
|
||||
wall1 = self.file.createIfcWall()
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
relation = ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall)
|
||||
ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall1)
|
||||
ifcopenshell.api.control.unassign_control(self.file, relating_control=control, related_object=wall1)
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
|
||||
|
||||
@@ -33,9 +33,7 @@ class TestAddCostItemQuantity(test.bootstrap.IFC4):
|
||||
|
||||
quantities = []
|
||||
for quantity_type in quantity_types:
|
||||
quantity = ifcopenshell.api.cost.add_cost_item_quantity(
|
||||
self.file, cost_item=item, ifc_class=quantity_type
|
||||
)
|
||||
quantity = ifcopenshell.api.cost.add_cost_item_quantity(self.file, cost_item=item, ifc_class=quantity_type)
|
||||
assert quantity.is_a(quantity_type)
|
||||
assert quantity.Name == "Unnamed"
|
||||
if quantity_type == "IfcQuantityCount":
|
||||
|
||||
@@ -36,9 +36,7 @@ class TestUnassignDocument(test.bootstrap.IFC4):
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
reference = ifcopenshell.api.document.add_reference(self.file, information=None)
|
||||
ifcopenshell.api.document.assign_document(
|
||||
self.file, products=[element, element2, element3], document=reference
|
||||
)
|
||||
ifcopenshell.api.document.assign_document(self.file, products=[element, element2, element3], document=reference)
|
||||
ifcopenshell.api.document.unassign_document(self.file, products=[element, element2], document=reference)
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == {element3}
|
||||
|
||||
|
||||
@@ -30,9 +30,7 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
|
||||
)
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=wall, representation=representation)
|
||||
assert representation not in wall.Representation.Representations
|
||||
ifcopenshell.api.geometry.unassign_representation(
|
||||
self.file, product=wall, representation=representation2
|
||||
)
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=wall, representation=representation2)
|
||||
assert not wall.Representation
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
|
||||
assert len(self.file.by_type("IfcProductDefinitionShape")) == 0
|
||||
@@ -42,9 +40,7 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
|
||||
origin = self.file.createIfcAxis2Placement3D()
|
||||
repmap = self.file.createIfcRepresentationMap(MappedRepresentation=representation, MappingOrigin=origin)
|
||||
walltype = self.file.createIfcWallType(RepresentationMaps=[repmap])
|
||||
ifcopenshell.api.geometry.unassign_representation(
|
||||
self.file, product=walltype, representation=representation
|
||||
)
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=walltype, representation=representation)
|
||||
assert not walltype.RepresentationMaps
|
||||
assert len(self.file.by_type("IfcAxis2Placement3D")) == 0
|
||||
assert len(self.file.by_type("IfcRepresentationMap")) == 0
|
||||
@@ -59,9 +55,7 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
|
||||
rep = self.file.createIfcShapeRepresentation(Items=[mapped_item])
|
||||
prodrep = self.file.createIfcProductDefinitionShape(Representations=[rep])
|
||||
wall = self.file.createIfcWall(Representation=prodrep)
|
||||
ifcopenshell.api.geometry.unassign_representation(
|
||||
self.file, product=walltype, representation=representation
|
||||
)
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=walltype, representation=representation)
|
||||
assert not walltype.RepresentationMaps
|
||||
assert len(self.file.by_type("IfcAxis2Placement3D")) == 0
|
||||
assert len(self.file.by_type("IfcRepresentationMap")) == 0
|
||||
|
||||
@@ -33,5 +33,6 @@ class TestUnassignReference(test.bootstrap.IFC4):
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == set()
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
|
||||
|
||||
class TestUnassignReferenceIFC2X3(test.bootstrap.IFC2X3, TestUnassignReference):
|
||||
pass
|
||||
|
||||
@@ -111,9 +111,7 @@ class TestRemoveMaterialIFC4(test.bootstrap.IFC4, TestRemoveMaterialIFC2X3):
|
||||
def test_removing_material_in_constituent(self):
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, set_type="IfcMaterialConstituentSet"
|
||||
)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialConstituentSet")
|
||||
ifcopenshell.api.material.add_constituent(self.file, constituent_set=material_set, material=material)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material_set)
|
||||
assert len(self.file.by_type("IfcMaterialConstituentSet")[0].MaterialConstituents) == 1
|
||||
|
||||
@@ -79,9 +79,7 @@ class TestAssignObject(test.bootstrap.IFC4):
|
||||
|
||||
# maintain the order in the affected relationships too
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
self.file, related_objects=subelements[2:3], relating_object=element2
|
||||
)
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=subelements[2:3], relating_object=element2)
|
||||
assert rel.RelatedObjects == tuple(subelements[:2] + subelements[3:])
|
||||
|
||||
|
||||
|
||||
@@ -24,9 +24,7 @@ class TestAddPersonAndOrganisation(test.bootstrap.IFC4):
|
||||
def test_adding(self):
|
||||
person = self.file.createIfcPerson()
|
||||
organisation = self.file.createIfcOrganization()
|
||||
ifcopenshell.api.owner.add_person_and_organisation(
|
||||
self.file, person=person, organisation=organisation
|
||||
)
|
||||
ifcopenshell.api.owner.add_person_and_organisation(self.file, person=person, organisation=organisation)
|
||||
|
||||
|
||||
class TestAddPersonAndOrganisationIFC2X3(test.bootstrap.IFC2X3, TestAddPersonAndOrganisation):
|
||||
|
||||
@@ -57,9 +57,7 @@ class TestAssignDeclaration(test.bootstrap.IFC4):
|
||||
def test_that_old_relationships_are_updated_if_they_still_contain_elements(self):
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type], relating_context=library
|
||||
)
|
||||
ifcopenshell.api.project.assign_declaration(self.file, definitions=[element_type], relating_context=library)
|
||||
rel = self.file.by_type("IfcRelDeclares")[0]
|
||||
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
|
||||
@@ -61,9 +61,7 @@ class TestUnassignDeclaration(test.bootstrap.IFC4):
|
||||
element_type1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type1], relating_context=library
|
||||
)
|
||||
ifcopenshell.api.project.assign_declaration(self.file, definitions=[element_type1], relating_context=library)
|
||||
rel = self.file.by_type("IfcRelDeclares")[0]
|
||||
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
|
||||
@@ -183,9 +183,7 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue == 34
|
||||
|
||||
def test_editing_list_valued_properties(self):
|
||||
cable = ifcopenshell.api.root.create_entity(
|
||||
self.file, ifc_class="IfcDistributionPort", predefined_type="CABLE"
|
||||
)
|
||||
cable = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDistributionPort", predefined_type="CABLE")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=cable, name="Pset_DistributionPortTypeCable")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
|
||||
@@ -29,9 +29,7 @@ class TestEditPropTemplate(test.bootstrap.IFC4):
|
||||
prop_template=prop,
|
||||
attributes={"Name": "DemoA", "PrimaryMeasureType": "IfcLabel"},
|
||||
)
|
||||
ifcopenshell.api.pset_template.edit_prop_template(
|
||||
self.file, prop_template=prop, attributes={"Name": "DemoB"}
|
||||
)
|
||||
ifcopenshell.api.pset_template.edit_prop_template(self.file, prop_template=prop, attributes={"Name": "DemoB"})
|
||||
assert prop.Name == "DemoB"
|
||||
|
||||
def test_editing_an_enumeration(self):
|
||||
|
||||
@@ -62,9 +62,7 @@ class TestReassignClass(test.bootstrap.IFC4):
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
|
||||
|
||||
element_type = ifcopenshell.api.root.reassign_class(
|
||||
self.file, product=element_type, ifc_class="IfcSlabType"
|
||||
)
|
||||
element_type = ifcopenshell.api.root.reassign_class(self.file, product=element_type, ifc_class="IfcSlabType")
|
||||
|
||||
# type occurrences have reassigned classes
|
||||
occurrences = ifcopenshell.util.element.get_types(element_type)
|
||||
|
||||
@@ -93,12 +93,8 @@ class TestAssignContainer(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=element1, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=element2, matrix=matrix2.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element1, matrix=matrix1.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element2, matrix=matrix2.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
|
||||
@@ -51,9 +51,7 @@ class TestDereferenceStructure(test.bootstrap.IFC4):
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
subelement3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.spatial.reference_structure(
|
||||
self.file, products=[subelement1], relating_structure=element
|
||||
)
|
||||
ifcopenshell.api.spatial.reference_structure(self.file, products=[subelement1], relating_structure=element)
|
||||
ifcopenshell.api.spatial.reference_structure(
|
||||
self.file, products=[subelement2, subelement3], relating_structure=element
|
||||
)
|
||||
|
||||
@@ -82,9 +82,7 @@ class TestAssignMaterialStyleIFC4(test.bootstrap.IFC4, TestAssignMaterialStyleIF
|
||||
|
||||
style = self.file.createIfcSurfaceStyle()
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, set_type="IfcMaterialConstituentSet"
|
||||
)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialConstituentSet")
|
||||
constituent = ifcopenshell.api.material.add_constituent(
|
||||
self.file, constituent_set=material_set, material=material
|
||||
)
|
||||
|
||||
@@ -61,9 +61,7 @@ class TestAssignPort(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
|
||||
@@ -51,9 +51,7 @@ class TestAssignType(test.bootstrap.IFC4):
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file, related_objects=[element1, element2], relating_type=element_type1
|
||||
)
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type1)
|
||||
rel = element1.IsDefinedBy[0] if self.file.schema == "IFC2X3" else element1.IsTypedBy[0]
|
||||
assert len(rel.RelatedObjects) == 2
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type2)
|
||||
@@ -110,9 +108,7 @@ class TestAssignType(test.bootstrap.IFC4):
|
||||
mapped_rep_id = mapped_rep.id()
|
||||
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
assert (mapped_rep := ifcopenshell.util.representation.get_representation(element1, context=context))
|
||||
assert mapped_rep.id() == mapped_rep_id
|
||||
|
||||
@@ -139,9 +135,7 @@ class TestAssignType(test.bootstrap.IFC4):
|
||||
|
||||
# use 2 elements to trigger material assignment code block
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
assert (material := ifcopenshell.util.element.get_material(element1))
|
||||
assert material.id() == material_id
|
||||
|
||||
|
||||
@@ -29,9 +29,7 @@ class TestUnassignType(test.bootstrap.IFC4):
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
ifcopenshell.api.type.unassign_type(self.file, related_objects=[element1, element2])
|
||||
assert ifcopenshell.util.element.get_type(element1) is None
|
||||
assert ifcopenshell.util.element.get_type(element2) is None
|
||||
|
||||
@@ -61,12 +61,8 @@ class TestAddOpening(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=wall, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=opening, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=wall, matrix=matrix1.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=opening, matrix=matrix1.copy(), is_si=False)
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
|
||||
assert opening.ObjectPlacement.PlacementRelTo.PlacesObject[0] == wall
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(opening.ObjectPlacement), matrix1)
|
||||
|
||||
+25
-15
@@ -1,18 +1,28 @@
|
||||
import time
|
||||
import ifcopenshell
|
||||
|
||||
for i in range(3):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
p = f.createIfcPerson(Id="tfk", GivenName="Thomas")
|
||||
o = f.createIfcOrganization(Name="AECgeeks")
|
||||
pando = f.createIfcPersonAndOrganization(p, o)
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
for j in range(i):
|
||||
f.createIfcProject(ifcopenshell.guid.new(), ownerhist, 'My Project', UnitsInContext=units, RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None, None, 3, None,
|
||||
f.create_entity(f'IfcAxis2Placement3D', f.createIfcCartesianPoint((0., 0., 0.))),
|
||||
)
|
||||
])
|
||||
f.write(f"{'fail' if i == 2 else 'pass'}-{i}-projects-ifc2x3.ifc")
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
p = f.createIfcPerson(Id="tfk", GivenName="Thomas")
|
||||
o = f.createIfcOrganization(Name="AECgeeks")
|
||||
pando = f.createIfcPersonAndOrganization(p, o)
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
for j in range(i):
|
||||
f.createIfcProject(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
"My Project",
|
||||
UnitsInContext=units,
|
||||
RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None,
|
||||
None,
|
||||
3,
|
||||
None,
|
||||
f.create_entity(f"IfcAxis2Placement3D", f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
)
|
||||
],
|
||||
)
|
||||
f.write(f"{'fail' if i == 2 else 'pass'}-{i}-projects-ifc2x3.ifc")
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import ifcopenshell
|
||||
for i, box_alignment in enumerate(['top-left', 'center', 'invalid', 'CENTER']):
|
||||
|
||||
for i, box_alignment in enumerate(["top-left", "center", "invalid", "CENTER"]):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
|
||||
f.createIfcTextLiteralWithExtent(
|
||||
"My presentable text",
|
||||
f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0., 0.))),
|
||||
'RIGHT',
|
||||
f.createIfcPlanarExtent(10., 10.),
|
||||
box_alignment
|
||||
f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))),
|
||||
"RIGHT",
|
||||
f.createIfcPlanarExtent(10.0, 10.0),
|
||||
box_alignment,
|
||||
)
|
||||
|
||||
f.write(f"{'pass' if i in (0,1) else 'fail'}-{i}-box-alignment-{box_alignment}-ifc2x3.ifc")
|
||||
|
||||
+15
-6
@@ -28,11 +28,20 @@ for i, (is_valid, lat) in enumerate(latitudes):
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
site = f.createIfcSite(ifcopenshell.guid.new(), ownerhist, RefLatitude=lat)
|
||||
proj = f.createIfcProject(ifcopenshell.guid.new(), ownerhist, 'My Project', UnitsInContext=units, RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None, None, 3, None,
|
||||
f.create_entity(f'IfcAxis2Placement3D', f.createIfcCartesianPoint((0., 0., 0.))),
|
||||
)
|
||||
])
|
||||
proj = f.createIfcProject(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
"My Project",
|
||||
UnitsInContext=units,
|
||||
RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None,
|
||||
None,
|
||||
3,
|
||||
None,
|
||||
f.create_entity(f"IfcAxis2Placement3D", f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
)
|
||||
],
|
||||
)
|
||||
f.createIfcRelAggregates(ifcopenshell.guid.new(), ownerhist, None, None, proj, [site])
|
||||
f.write(f"{'pass' if is_valid else 'fail'}-site-latitude-{i}-ifc2x3.ifc")
|
||||
|
||||
+5
-10
@@ -1,18 +1,13 @@
|
||||
import ifcopenshell
|
||||
|
||||
for depth in (-1., 0., 1.):
|
||||
for depth in (-1.0, 0.0, 1.0):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcExtrudedAreaSolid(
|
||||
f.createIfcRectangleProfileDef(
|
||||
"AREA", None,
|
||||
f.createIfcAxis2Placement2D(
|
||||
f.createIfcCartesianPoint((0., 0.))
|
||||
), 1., 1.
|
||||
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), 1.0, 1.0
|
||||
),
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.))
|
||||
),
|
||||
f.createIfcDirection((0., 0., 1.)),
|
||||
depth
|
||||
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
depth,
|
||||
)
|
||||
f.write(f"{'pass' if depth > 0. else 'fail'}-extrusion-depth-{depth}-ifc2x3.ifc")
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import ifcopenshell
|
||||
|
||||
for i, (r1, r2) in enumerate([("SUPPLIER", None), ("SUPPLIER", "Valid"), ("USERDEFINED", "Valid"), ("USERDEFINED", None)]):
|
||||
for i, (r1, r2) in enumerate(
|
||||
[("SUPPLIER", None), ("SUPPLIER", "Valid"), ("USERDEFINED", "Valid"), ("USERDEFINED", None)]
|
||||
):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcActorRole(r1, r2)
|
||||
f.write(f"{'fail' if i == 3 else 'pass'}-actor-role-{r1}-{r2}-ifc2x3.ifc")
|
||||
f.write(f"{'fail' if i == 3 else 'pass'}-actor-role-{r1}-{r2}-ifc2x3.ifc")
|
||||
|
||||
+11
-7
@@ -1,18 +1,22 @@
|
||||
import ifcopenshell
|
||||
|
||||
options = {
|
||||
'IfcPostalAddress': ({}, {'Country': 'The Netherlands'}, {'Country': 'The Netherlands', 'Town': 'Eindhoven'}),
|
||||
'IfcTelecomAddress': ({}, {'TelephoneNumbers': ['040-12345678']}, {'TelephoneNumbers': ['040-12345678'], 'PagerNumber': '12345'})
|
||||
"IfcPostalAddress": ({}, {"Country": "The Netherlands"}, {"Country": "The Netherlands", "Town": "Eindhoven"}),
|
||||
"IfcTelecomAddress": (
|
||||
{},
|
||||
{"TelephoneNumbers": ["040-12345678"]},
|
||||
{"TelephoneNumbers": ["040-12345678"], "PagerNumber": "12345"},
|
||||
),
|
||||
}
|
||||
|
||||
for ent in ('IfcPostalAddress', 'IfcTelecomAddress'):
|
||||
for purpose in (None, 'USERDEFINED', 'HOME'):
|
||||
for ud in (None, 'SomethingUserdefined'):
|
||||
for ent in ("IfcPostalAddress", "IfcTelecomAddress"):
|
||||
for purpose in (None, "USERDEFINED", "HOME"):
|
||||
for ud in (None, "SomethingUserdefined"):
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.create_entity(ent, purpose, None, ud, **options[ent][1])
|
||||
|
||||
valid = not (purpose == 'USERDEFINED' and ud is None)
|
||||
valid = not (purpose == "USERDEFINED" and ud is None)
|
||||
|
||||
f.write(f"{'pass' if valid else 'fail'}-{ent}-{purpose}-{ud}-ifc2x3.ifc")
|
||||
|
||||
@@ -21,5 +25,5 @@ for ent in ('IfcPostalAddress', 'IfcTelecomAddress'):
|
||||
f.create_entity(ent, **kwargs)
|
||||
valid = len(kwargs) >= 1
|
||||
if not valid:
|
||||
kwargs = {'all-unset': 1}
|
||||
kwargs = {"all-unset": 1}
|
||||
f.write(f"{'pass' if valid else 'fail'}-{ent}-{'-'.join(kwargs.keys())}-ifc2x3.ifc")
|
||||
|
||||
@@ -2,13 +2,13 @@ import itertools
|
||||
import time
|
||||
import ifcopenshell
|
||||
|
||||
for pty, ety in itertools.product(('GRILLE', 'USERDEFINED'), (None, 'Something')):
|
||||
for pty, ety in itertools.product(("GRILLE", "USERDEFINED"), (None, "Something")):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
p = f.createIfcPerson(Id="tfk", GivenName="Thomas")
|
||||
o = f.createIfcOrganization(Name="AECgeeks")
|
||||
pando = f.createIfcPersonAndOrganization(p, o)
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
f.createIfcAirTerminalType(ifcopenshell.guid.new(), ownerhist, 'My Type', ElementType=ety, PredefinedType=pty)
|
||||
valid = pty != 'USERDEFINED' or ety is not None
|
||||
f.createIfcAirTerminalType(ifcopenshell.guid.new(), ownerhist, "My Type", ElementType=ety, PredefinedType=pty)
|
||||
valid = pty != "USERDEFINED" or ety is not None
|
||||
f.write(f"{'pass' if valid else 'fail'}-air-terminal-type-{pty}-{ety}-ifc2x3.ifc")
|
||||
|
||||
+10
-4
@@ -1,10 +1,16 @@
|
||||
import ifcopenshell
|
||||
|
||||
create_none = lambda f: None
|
||||
create_polyline = lambda f: f.createIfcPolyline((f.createIfcCartesianPoint((0., 0.)), f.createIfcCartesianPoint((1., 0.))))
|
||||
create_point = lambda f: f.createIfcCartesianPoint((0., 0.))
|
||||
create_polyline = lambda f: f.createIfcPolyline(
|
||||
(f.createIfcCartesianPoint((0.0, 0.0)), f.createIfcCartesianPoint((1.0, 0.0)))
|
||||
)
|
||||
create_point = lambda f: f.createIfcCartesianPoint((0.0, 0.0))
|
||||
|
||||
for i, make_item in enumerate((create_none, create_polyline, create_point)):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
inst = f.createIfcAnnotationCurveOccurrence(make_item(f), [f.createIfcPresentationStyleAssignment([f.createIfcCurveStyle()])])
|
||||
f.write(f"{'fail' if i == 2 else 'pass'}-annotation-curve-occurence-{'None' if inst.Item is None else inst.Item.is_a()}-ifc2x3.ifc")
|
||||
inst = f.createIfcAnnotationCurveOccurrence(
|
||||
make_item(f), [f.createIfcPresentationStyleAssignment([f.createIfcCurveStyle()])]
|
||||
)
|
||||
f.write(
|
||||
f"{'fail' if i == 2 else 'pass'}-annotation-curve-occurence-{'None' if inst.Item is None else inst.Item.is_a()}-ifc2x3.ifc"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import ifcopenshell
|
||||
|
||||
create_plane = lambda f: f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0., 0., 0.))))
|
||||
create_polyline = lambda f: f.createIfcPolyline((f.createIfcCartesianPoint((0., 0.)), f.createIfcCartesianPoint((1., 0.))))
|
||||
create_plane = lambda f: f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))))
|
||||
create_polyline = lambda f: f.createIfcPolyline(
|
||||
(f.createIfcCartesianPoint((0.0, 0.0)), f.createIfcCartesianPoint((1.0, 0.0)))
|
||||
)
|
||||
|
||||
for i, make_item in enumerate((create_plane, create_polyline)):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
|
||||
+8
-14
@@ -1,22 +1,16 @@
|
||||
import ifcopenshell
|
||||
|
||||
pts = [(0., 0.), (1., 0.), (1., 1.)]
|
||||
dims = [
|
||||
(2,3,3),
|
||||
(3,3,2),
|
||||
(2,2,2),
|
||||
(3,3,3)
|
||||
]
|
||||
pts = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0)]
|
||||
dims = [(2, 3, 3), (3, 3, 2), (2, 2, 2), (3, 3, 3)]
|
||||
|
||||
|
||||
def make_point(xy, dim):
|
||||
return f.createIfcCartesianPoint((xy + (0.,))[0:dim])
|
||||
return f.createIfcCartesianPoint((xy + (0.0,))[0:dim])
|
||||
|
||||
|
||||
for d in dims:
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
inst = f.createIfcBSplineCurve(1,
|
||||
list(map(lambda t: make_point(*t), zip(pts, d))),
|
||||
"POLYLINE_FORM",
|
||||
False,
|
||||
False
|
||||
inst = f.createIfcBSplineCurve(1, list(map(lambda t: make_point(*t), zip(pts, d))), "POLYLINE_FORM", False, False)
|
||||
f.write(
|
||||
f"{'pass' if len(set(d)) == 1 else 'fail'}-bspline-curve-point-dimensions-{'-'.join(map(str, d))}-ifc2x3.ifc"
|
||||
)
|
||||
f.write(f"{'pass' if len(set(d)) == 1 else 'fail'}-bspline-curve-point-dimensions-{'-'.join(map(str, d))}-ifc2x3.ifc")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import itertools
|
||||
import ifcopenshell
|
||||
|
||||
defaults = {'Girth': 1., 'WallThickness': 0.11}
|
||||
depths = [2., 3.]
|
||||
defaults = {"Girth": 1.0, "WallThickness": 0.11}
|
||||
depths = [2.0, 3.0]
|
||||
widths = [0.2, 0.3]
|
||||
|
||||
for d, w in itertools.product(depths, widths):
|
||||
@@ -12,9 +12,9 @@ for d, w in itertools.product(depths, widths):
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
|
||||
valid = (Girth < (Depth / 2.)) and ((WallThickness < Width/2.) and (WallThickness < Depth/2.))
|
||||
valid = (Girth < (Depth / 2.0)) and ((WallThickness < Width / 2.0) and (WallThickness < Depth / 2.0))
|
||||
|
||||
inst = f.createIfcCShapeProfileDef(
|
||||
'AREA', None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0., 0.))), **D
|
||||
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), **D
|
||||
)
|
||||
f.write(f"{'pass' if valid else 'fail'}-cshape-profile-width-{w}-depth-{d}-ifc2x3.ifc")
|
||||
|
||||
+10
-15
@@ -1,34 +1,29 @@
|
||||
import ifcopenshell
|
||||
|
||||
depth = 1.0
|
||||
for (dir_x, dir_z) in ((0., -1.), (0., 0.), (1., 0.), (1., 0.001), (0., 1.)):
|
||||
for dir_x, dir_z in ((0.0, -1.0), (0.0, 0.0), (1.0, 0.0), (1.0, 0.001), (0.0, 1.0)):
|
||||
|
||||
schemas = ['IFC2X3']
|
||||
if (dir_x, dir_z) == (0., 0.):
|
||||
schemas.append('IFC4')
|
||||
schemas = ["IFC2X3"]
|
||||
if (dir_x, dir_z) == (0.0, 0.0):
|
||||
schemas.append("IFC4")
|
||||
|
||||
for schema in schemas:
|
||||
f = ifcopenshell.file(schema=schema)
|
||||
f.createIfcExtrudedAreaSolid(
|
||||
f.createIfcRectangleProfileDef(
|
||||
"AREA", None,
|
||||
f.createIfcAxis2Placement2D(
|
||||
f.createIfcCartesianPoint((0., 0.))
|
||||
), 1., 1.
|
||||
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), 1.0, 1.0
|
||||
),
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.))
|
||||
),
|
||||
f.createIfcDirection((dir_x, 0., dir_z)),
|
||||
depth
|
||||
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
f.createIfcDirection((dir_x, 0.0, dir_z)),
|
||||
depth,
|
||||
)
|
||||
|
||||
# Due to the way IfcDotProduct and IfcNormalise interact, (0 0 0) actually
|
||||
# results into indeterminate. But in IFC4 onwars there is a rule in IfcDirection
|
||||
# for non-zero magnitude
|
||||
|
||||
valid = dir_z != 0.
|
||||
if f.schema == 'IFC2X3' and (dir_x, dir_z) == (0., 0.):
|
||||
valid = dir_z != 0.0
|
||||
if f.schema == "IFC2X3" and (dir_x, dir_z) == (0.0, 0.0):
|
||||
valid = True
|
||||
|
||||
f.write(f"{'pass' if valid else 'fail'}-extrusion-dir-{dir_x}-{dir_z}-{f.schema.lower()}.ifc")
|
||||
|
||||
+11
-19
@@ -1,9 +1,9 @@
|
||||
import ifcopenshell
|
||||
|
||||
coords = [(0., 0.), (10., 0.), (10., 10.), (0., 10.)]
|
||||
make_3d = lambda cs: [c + (0.,) for c in cs]
|
||||
inner_1 = [(1., 1.), (2., 1.), (2., 2.), (1., 2.)]
|
||||
inner_2 = [(3., 3.), (4., 3.), (4., 4.), (3., 4.)]
|
||||
coords = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]
|
||||
make_3d = lambda cs: [c + (0.0,) for c in cs]
|
||||
inner_1 = [(1.0, 1.0), (2.0, 1.0), (2.0, 2.0), (1.0, 2.0)]
|
||||
inner_2 = [(3.0, 3.0), (4.0, 3.0), (4.0, 4.0), (3.0, 4.0)]
|
||||
|
||||
old_map = map
|
||||
map = lambda fn, *args: list(old_map(fn, *args))
|
||||
@@ -16,7 +16,7 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
[
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_1)),
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
|
||||
]
|
||||
],
|
||||
)
|
||||
f.write(f"pass-arbitrary-profile-with-voids-ifc2x3.ifc")
|
||||
|
||||
@@ -28,7 +28,7 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
[
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_1)),
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
|
||||
]
|
||||
],
|
||||
)
|
||||
f.write(f"fail-arbitrary-profile-with-voids-curve-ifc2x3.ifc")
|
||||
|
||||
@@ -40,7 +40,7 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
[
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_1)),
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
|
||||
]
|
||||
],
|
||||
)
|
||||
f.write(f"fail-arbitrary-profile-with-voids-3d-outer-ifc2x3.ifc")
|
||||
|
||||
@@ -52,7 +52,7 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
[
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(inner_1))),
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
|
||||
]
|
||||
],
|
||||
)
|
||||
f.write(f"fail-arbitrary-profile-with-voids-3d-inner-ifc2x3.ifc")
|
||||
|
||||
@@ -64,7 +64,7 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
[
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(inner_1))),
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(inner_2))),
|
||||
]
|
||||
],
|
||||
)
|
||||
f.write(f"fail-arbitrary-profile-with-voids-3d-inner-2-ifc2x3.ifc")
|
||||
|
||||
@@ -73,14 +73,6 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
"AREA",
|
||||
None,
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, coords)),
|
||||
[
|
||||
f.createIfcLine(
|
||||
f.createIfcCartesianPoint((0., 0.)),
|
||||
f.createIfcVector(
|
||||
f.createIfcDirection((0., 0.)),
|
||||
1.
|
||||
)
|
||||
)
|
||||
]
|
||||
[f.createIfcLine(f.createIfcCartesianPoint((0.0, 0.0)), f.createIfcVector(f.createIfcDirection((0.0, 0.0)), 1.0))],
|
||||
)
|
||||
f.write(f"fail-arbitrary-profile-with-voids-inner-line-ifc2x3.ifc")
|
||||
f.write(f"fail-arbitrary-profile-with-voids-inner-line-ifc2x3.ifc")
|
||||
|
||||
+25
-27
@@ -1,77 +1,75 @@
|
||||
import ifcopenshell
|
||||
|
||||
coords = [(0., 0.), (10., 0.), (10., 10.), (0., 10.)]
|
||||
make_3d = lambda cs: [c + (0.,) for c in cs]
|
||||
inner_1 = [(1., 1.), (2., 1.), (2., 2.), (1., 2.)]
|
||||
inner_2 = [(3., 3.), (4., 3.), (4., 4.), (3., 4.)]
|
||||
coords = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]
|
||||
make_3d = lambda cs: [c + (0.0,) for c in cs]
|
||||
inner_1 = [(1.0, 1.0), (2.0, 1.0), (2.0, 2.0), (1.0, 2.0)]
|
||||
inner_2 = [(3.0, 3.0), (4.0, 3.0), (4.0, 4.0), (3.0, 4.0)]
|
||||
|
||||
old_map = map
|
||||
map = lambda fn, *args: list(old_map(fn, *args))
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.))
|
||||
)
|
||||
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0)))
|
||||
f.write(f"pass-axis2-3d-pos-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
f.createIfcDirection((0., 0., 1.)),
|
||||
f.createIfcDirection((1., 0., 0.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
f.createIfcDirection((1.0, 0.0, 0.0)),
|
||||
)
|
||||
f.write(f"pass-axis2-two-directions-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
Axis=f.createIfcDirection((0., 0., 1.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
Axis=f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
RefDirection=None,
|
||||
)
|
||||
f.write(f"fail-axis2-only-axis-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
Axis=None,
|
||||
RefDirection=f.createIfcDirection((1., 0., 0.)),
|
||||
RefDirection=f.createIfcDirection((1.0, 0.0, 0.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-only-ref-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
f.createIfcDirection((1., 0.)),
|
||||
f.createIfcDirection((0., 1., 0.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
f.createIfcDirection((1.0, 0.0)),
|
||||
f.createIfcDirection((0.0, 1.0, 0.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-2d-axis-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-2d-pos-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
f.createIfcDirection((0., 0., 1.)),
|
||||
f.createIfcDirection((1., 0.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
f.createIfcDirection((1.0, 0.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-2d-ref-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
Axis=f.createIfcDirection((0., 0., 1.)),
|
||||
RefDirection=f.createIfcDirection((0., 0., 1.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
Axis=f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
RefDirection=f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-parallel-axes.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
Axis=f.createIfcDirection((0., 0., 1.)),
|
||||
RefDirection=f.createIfcDirection((0., 0., -1.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
Axis=f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
RefDirection=f.createIfcDirection((0.0, 0.0, -1.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-anti-parallel-axes.ifc")
|
||||
|
||||
+8
-15
@@ -1,26 +1,19 @@
|
||||
import ifcopenshell
|
||||
|
||||
dims = [
|
||||
(1,0,0,0,0,0,0),
|
||||
(1,1,0,0,0,0,0),
|
||||
(0,1,0,0,0,0,0),
|
||||
(-1,0,0,0,0,0,0),
|
||||
(2,0,0,0,0,0,0),
|
||||
(1, 0, 0, 0, 0, 0, 0),
|
||||
(1, 1, 0, 0, 0, 0, 0),
|
||||
(0, 1, 0, 0, 0, 0, 0),
|
||||
(-1, 0, 0, 0, 0, 0, 0),
|
||||
(2, 0, 0, 0, 0, 0, 0),
|
||||
]
|
||||
|
||||
for i, d in enumerate(dims):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcConversionBasedUnit(
|
||||
f.createIfcDimensionalExponents(*d),
|
||||
'LENGTHUNIT',
|
||||
'beard-second',
|
||||
f.createIfcMeasureWithUnit(
|
||||
f.createIfcLengthMeasure(5.0),
|
||||
f.createIfcSIUnit(
|
||||
Prefix='NANO',
|
||||
Name='METRE'
|
||||
)
|
||||
)
|
||||
|
||||
"LENGTHUNIT",
|
||||
"beard-second",
|
||||
f.createIfcMeasureWithUnit(f.createIfcLengthMeasure(5.0), f.createIfcSIUnit(Prefix="NANO", Name="METRE")),
|
||||
)
|
||||
f.write(f"{'pass' if i == 0 else 'fail'}-conv-unit-{i}-ifc2x3.ifc")
|
||||
|
||||
+59
-54
@@ -1,72 +1,77 @@
|
||||
import ifcopenshell
|
||||
|
||||
coords = [(0., 0.), (10., 0.)]
|
||||
coords_2 = [(0., 0.), (10., 0.), (10., 10.), (0., 10.)]
|
||||
make_3d = lambda cs: [c + (0.,) for c in cs]
|
||||
make_nd = lambda d: lambda c: (c + (0.,)) if d == 3 else c
|
||||
coords = [(0.0, 0.0), (10.0, 0.0)]
|
||||
coords_2 = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]
|
||||
make_3d = lambda cs: [c + (0.0,) for c in cs]
|
||||
make_nd = lambda d: lambda c: (c + (0.0,)) if d == 3 else c
|
||||
|
||||
old_map = map
|
||||
map = lambda fn, *args: list(old_map(fn, *args))
|
||||
|
||||
poly_2d = lambda f: [f.createIfcPolyline(map(f.createIfcCartesianPoint, coords))]
|
||||
poly_3d = lambda f: [f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(coords)))]
|
||||
plane = lambda f: [f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0., 0., 0.))))]
|
||||
fbsm = lambda f: [f.createIfcFaceBasedSurfaceModel(
|
||||
FbsmFaces=[f.createIfcOpenShell(
|
||||
CfsFaces=[f.createIfcFace(
|
||||
Bounds=[f.createIfcFaceOuterBound(
|
||||
Bound=f.createIfcPolyLoop(
|
||||
Polygon=map(f.createIfcCartesianPoint, make_3d(coords_2))
|
||||
)
|
||||
)]
|
||||
)]
|
||||
)]
|
||||
)]
|
||||
extrusion = lambda f: [f.createIfcExtrudedAreaSolid(
|
||||
f.createIfcRectangleProfileDef(
|
||||
"AREA", None,
|
||||
f.createIfcAxis2Placement2D(
|
||||
f.createIfcCartesianPoint((0., 0.))
|
||||
), 1., 1.
|
||||
),
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.))
|
||||
),
|
||||
f.createIfcDirection((0., 0., 1.)),
|
||||
1.
|
||||
)]
|
||||
bbox = lambda f: [f.createIfcBoundingBox(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
1., 1., 1.
|
||||
)]
|
||||
plane = lambda f: [f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))))]
|
||||
fbsm = lambda f: [
|
||||
f.createIfcFaceBasedSurfaceModel(
|
||||
FbsmFaces=[
|
||||
f.createIfcOpenShell(
|
||||
CfsFaces=[
|
||||
f.createIfcFace(
|
||||
Bounds=[
|
||||
f.createIfcFaceOuterBound(
|
||||
Bound=f.createIfcPolyLoop(Polygon=map(f.createIfcCartesianPoint, make_3d(coords_2)))
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
extrusion = lambda f: [
|
||||
f.createIfcExtrudedAreaSolid(
|
||||
f.createIfcRectangleProfileDef(
|
||||
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), 1.0, 1.0
|
||||
),
|
||||
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
1.0,
|
||||
)
|
||||
]
|
||||
bbox = lambda f: [f.createIfcBoundingBox(f.createIfcCartesianPoint((0.0, 0.0, 0.0)), 1.0, 1.0, 1.0)]
|
||||
|
||||
gcs = lambda fn: lambda f: [f.createIfcGeometricSet(fn(f))]
|
||||
repeat = lambda n, fn: lambda f: fn(f) * n
|
||||
|
||||
options = [
|
||||
(True, 2, 'Curve2D', '2d-polyline', poly_2d),
|
||||
(False, 3, 'Curve2D', '3d-polyline', poly_3d),
|
||||
(True, 2, 'GeometricCurveSet', 'with-curve', gcs(poly_2d)),
|
||||
(False, 3, 'GeometricCurveSet', 'with-surface', gcs(plane)),
|
||||
(False, 3, 'SurfaceModel', '3d-polyline', poly_3d),
|
||||
(True, 3, 'SurfaceModel', 'surface-model', fbsm),
|
||||
(False, 3, 'SweptSolid', '3d-polyline', poly_3d),
|
||||
(True, 3, 'SweptSolid', 'extrusion', extrusion),
|
||||
(True, 3, 'BoundingBox', 'single-bbox', bbox),
|
||||
(False, 3, 'BoundingBox', 'multiple-bbox', repeat(2, bbox)),
|
||||
(True, 2, "Curve2D", "2d-polyline", poly_2d),
|
||||
(False, 3, "Curve2D", "3d-polyline", poly_3d),
|
||||
(True, 2, "GeometricCurveSet", "with-curve", gcs(poly_2d)),
|
||||
(False, 3, "GeometricCurveSet", "with-surface", gcs(plane)),
|
||||
(False, 3, "SurfaceModel", "3d-polyline", poly_3d),
|
||||
(True, 3, "SurfaceModel", "surface-model", fbsm),
|
||||
(False, 3, "SweptSolid", "3d-polyline", poly_3d),
|
||||
(True, 3, "SweptSolid", "extrusion", extrusion),
|
||||
(True, 3, "BoundingBox", "single-bbox", bbox),
|
||||
(False, 3, "BoundingBox", "multiple-bbox", repeat(2, bbox)),
|
||||
]
|
||||
|
||||
for is_valid, dims, rep_type, name, fn in options:
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcProductDefinitionShape(Representations=[
|
||||
f.createIfcShapeRepresentation(
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None, None, dims, None,
|
||||
f.create_entity(f'IfcAxis2Placement{dims}D', f.createIfcCartesianPoint(make_nd(dims)((0., 0.)))),
|
||||
),
|
||||
'Body',
|
||||
rep_type,
|
||||
fn(f)
|
||||
)
|
||||
])
|
||||
f.createIfcProductDefinitionShape(
|
||||
Representations=[
|
||||
f.createIfcShapeRepresentation(
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None,
|
||||
None,
|
||||
dims,
|
||||
None,
|
||||
f.create_entity(f"IfcAxis2Placement{dims}D", f.createIfcCartesianPoint(make_nd(dims)((0.0, 0.0)))),
|
||||
),
|
||||
"Body",
|
||||
rep_type,
|
||||
fn(f),
|
||||
)
|
||||
]
|
||||
)
|
||||
f.write(f"{'pass' if is_valid else 'fail'}-shaperep-{rep_type.lower()}-{name}-ifc2x3.ifc")
|
||||
|
||||
+3
-11
@@ -1,10 +1,7 @@
|
||||
import time
|
||||
import ifcopenshell
|
||||
|
||||
names = [
|
||||
("Same", "Same"),
|
||||
("Different", "SomethingElse")
|
||||
]
|
||||
names = [("Same", "Same"), ("Different", "SomethingElse")]
|
||||
|
||||
make_prop = lambda f: lambda nm: f.createIfcPropertySingleValue(Name=nm)
|
||||
|
||||
@@ -19,11 +16,6 @@ for nms in names:
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
f.createIfcPropertySet(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
"MyPset",
|
||||
HasProperties=map(make_prop(f), nms)
|
||||
)
|
||||
f.createIfcPropertySet(ifcopenshell.guid.new(), ownerhist, "MyPset", HasProperties=map(make_prop(f), nms))
|
||||
f.write(f"{'pass' if len(set(nms)) == len(nms) else 'fail'}-property-{'-'.join(map(str.lower, nms))}-ifc2x3.ifc")
|
||||
15
|
||||
15
|
||||
|
||||
+4
-10
@@ -9,18 +9,12 @@ for i, nm in enumerate(("no-mls", "mls", "mlsu")):
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
wall = f.createIfcWallStandardCase(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist
|
||||
)
|
||||
if i in (1,2):
|
||||
wall = f.createIfcWallStandardCase(ifcopenshell.guid.new(), ownerhist)
|
||||
if i in (1, 2):
|
||||
mls = f.createIfcMaterialLayerSet([f.createIfcMaterialLayer(None, 0.1)])
|
||||
if i == 2:
|
||||
mls = f.createIfcMaterialLayerSetUsage(mls, 'AXIS2', 'POSITIVE', 0.)
|
||||
mls = f.createIfcMaterialLayerSetUsage(mls, "AXIS2", "POSITIVE", 0.0)
|
||||
f.createIfcRelAssociatesMaterial(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
RelatedObjects=[wall],
|
||||
RelatingMaterial=mls
|
||||
ifcopenshell.guid.new(), ownerhist, RelatedObjects=[wall], RelatingMaterial=mls
|
||||
)
|
||||
f.write(f"{'pass' if i == 2 else 'fail'}-wall-{nm}-ifc2x3.ifc")
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import ifcopenshell
|
||||
|
||||
for i, type_decl in enumerate(('IfcLengthMeasure', 'IfcPlaneAngleMeasure')):
|
||||
for i, type_decl in enumerate(("IfcLengthMeasure", "IfcPlaneAngleMeasure")):
|
||||
f = ifcopenshell.file(schema="IFC4X3_ADD1")
|
||||
f.createIfcRigidOperation(
|
||||
SourceCRS=f.createIfcGeographicCRS('EPSG:4326'),
|
||||
TargetCRS=f.createIfcGeographicCRS('EPSG:3857'),
|
||||
SourceCRS=f.createIfcGeographicCRS("EPSG:4326"),
|
||||
TargetCRS=f.createIfcGeographicCRS("EPSG:3857"),
|
||||
FirstCoordinate=f.create_entity(type_decl, 0.0),
|
||||
SecondCoordinate=f.create_entity('IfcPlaneAngleMeasure', 0.0),
|
||||
Height=0.0
|
||||
SecondCoordinate=f.create_entity("IfcPlaneAngleMeasure", 0.0),
|
||||
Height=0.0,
|
||||
)
|
||||
f.write(f"{'pass' if i else 'fail'}-rigid-op-IfcPlaneAngleMeasure-{type_decl}-ifc4x3_add1.ifc")
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import ifcopenshell
|
||||
|
||||
make_nd = lambda d: lambda *c: (c + (0.,)) if d == 3 else c
|
||||
make_nd = lambda d: lambda *c: (c + (0.0,)) if d == 3 else c
|
||||
|
||||
for d1, d2 in ((2,3), (3,3), (3,2)):
|
||||
for d1, d2 in ((2, 3), (3, 3), (3, 2)):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcLocalPlacement(
|
||||
PlacementRelTo=f.createIfcLocalPlacement(
|
||||
PlacementRelTo=None,
|
||||
RelativePlacement=f.create_entity(f'IfcAxis2Placement{d1}D',
|
||||
f.createIfcCartesianPoint(make_nd(d1)(0., 0.))
|
||||
)
|
||||
RelativePlacement=f.create_entity(
|
||||
f"IfcAxis2Placement{d1}D", f.createIfcCartesianPoint(make_nd(d1)(0.0, 0.0))
|
||||
),
|
||||
),
|
||||
RelativePlacement=f.create_entity(f'IfcAxis2Placement{d2}D',
|
||||
f.createIfcCartesianPoint(make_nd(d2)(0., 0.))
|
||||
)
|
||||
RelativePlacement=f.create_entity(f"IfcAxis2Placement{d2}D", f.createIfcCartesianPoint(make_nd(d2)(0.0, 0.0))),
|
||||
)
|
||||
f.write(f"{'pass' if d1 >= d2 else 'fail'}-placement-{d1}d-{d2}d-ifc2x3.ifc")
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import ifcopenshell
|
||||
|
||||
task = lambda f: f.createIfcTask(ifcopenshell.guid.new(),None,'sleep',IsMilestone=True)
|
||||
task = lambda f: f.createIfcTask(ifcopenshell.guid.new(), None, "sleep", IsMilestone=True)
|
||||
wall = lambda f: f.createIfcWall(ifcopenshell.guid.new())
|
||||
|
||||
for i,fn in enumerate((task, wall)):
|
||||
for i, fn in enumerate((task, wall)):
|
||||
f = ifcopenshell.file(schema="IFC4")
|
||||
elem = fn(f)
|
||||
f.createIfcRelAssociatesMaterial(ifcopenshell.guid.new(), None, None, None, [elem], f.createIfcMaterial('brick'))
|
||||
f.createIfcRelAssociatesMaterial(ifcopenshell.guid.new(), None, None, None, [elem], f.createIfcMaterial("brick"))
|
||||
f.write(f"{'pass' if i else 'fail'}-assoc-material-{elem.is_a()}-{f.schema}.ifc")
|
||||
|
||||
+20
-7
@@ -1,13 +1,26 @@
|
||||
import itertools
|
||||
import ifcopenshell
|
||||
|
||||
def EXISTS(v): return v is not None
|
||||
def NOT(v): return not v
|
||||
|
||||
for LiningDepth, LiningThickness in itertools.product((None, 1.), (None, 1.)):
|
||||
def EXISTS(v):
|
||||
return v is not None
|
||||
|
||||
|
||||
def NOT(v):
|
||||
return not v
|
||||
|
||||
|
||||
for LiningDepth, LiningThickness in itertools.product((None, 1.0), (None, 1.0)):
|
||||
f = ifcopenshell.file(schema="IFC4")
|
||||
valid = NOT(EXISTS(LiningDepth) and NOT(EXISTS(LiningThickness)))
|
||||
f.createIfcWindowType(ifcopenshell.guid.new(), None, 'WindowType', HasPropertySets=[
|
||||
f.createIfcWindowLiningProperties(ifcopenshell.guid.new(), LiningDepth=LiningDepth, LiningThickness=LiningThickness)
|
||||
])
|
||||
f.write(f"{'pass' if valid else 'fail'}-lining-properties-{LiningDepth}-{LiningThickness}.ifc")
|
||||
f.createIfcWindowType(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
"WindowType",
|
||||
HasPropertySets=[
|
||||
f.createIfcWindowLiningProperties(
|
||||
ifcopenshell.guid.new(), LiningDepth=LiningDepth, LiningThickness=LiningThickness
|
||||
)
|
||||
],
|
||||
)
|
||||
f.write(f"{'pass' if valid else 'fail'}-lining-properties-{LiningDepth}-{LiningThickness}.ifc")
|
||||
|
||||
+41
-8
@@ -1,21 +1,54 @@
|
||||
import ifcopenshell
|
||||
|
||||
for cnt in range(0,3):
|
||||
for cnt in range(0, 3):
|
||||
f = ifcopenshell.file(schema="IFC4")
|
||||
elem = f.createIfcWall(ifcopenshell.guid.new())
|
||||
for i in range(cnt):
|
||||
f.createIfcRelDefinesByProperties(ifcopenshell.guid.new(), None, None, None, [elem],
|
||||
f.createIfcPropertySet(ifcopenshell.guid.new(), None, 'Pset_WallCommon', None, [f.createIfcPropertySingleValue('LoadBearing', None, f.createIfcBoolean(True))])
|
||||
f.createIfcRelDefinesByProperties(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
[elem],
|
||||
f.createIfcPropertySet(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
"Pset_WallCommon",
|
||||
None,
|
||||
[f.createIfcPropertySingleValue("LoadBearing", None, f.createIfcBoolean(True))],
|
||||
),
|
||||
)
|
||||
f.write(f"{'pass' if cnt < 2 else 'fail'}-wall-{cnt}-same-psets.ifc")
|
||||
|
||||
|
||||
f = ifcopenshell.file(schema="IFC4")
|
||||
elem = f.createIfcWall(ifcopenshell.guid.new())
|
||||
f.createIfcRelDefinesByProperties(ifcopenshell.guid.new(), None, None, None, [elem],
|
||||
f.createIfcPropertySet(ifcopenshell.guid.new(), None, 'Pset_WallCommon', None, [f.createIfcPropertySingleValue('LoadBearing', None, f.createIfcBoolean(True))])
|
||||
f.createIfcRelDefinesByProperties(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
[elem],
|
||||
f.createIfcPropertySet(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
"Pset_WallCommon",
|
||||
None,
|
||||
[f.createIfcPropertySingleValue("LoadBearing", None, f.createIfcBoolean(True))],
|
||||
),
|
||||
)
|
||||
f.createIfcRelDefinesByProperties(ifcopenshell.guid.new(), None, None, None, [elem],
|
||||
f.createIfcPropertySet(ifcopenshell.guid.new(), None, 'Custom', None, [f.createIfcPropertySingleValue('IsBeautiful', None, f.createIfcBoolean(True))])
|
||||
f.createIfcRelDefinesByProperties(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
[elem],
|
||||
f.createIfcPropertySet(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
"Custom",
|
||||
None,
|
||||
[f.createIfcPropertySingleValue("IsBeautiful", None, f.createIfcBoolean(True))],
|
||||
),
|
||||
)
|
||||
f.write(f"pass-wall-different-psets.ifc")
|
||||
f.write(f"pass-wall-different-psets.ifc")
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import ifcopenshell
|
||||
|
||||
fns = [
|
||||
(False, lambda f: f.createIfcLengthMeasure(-1.)),
|
||||
(True, lambda f: f.createIfcLengthMeasure(1.)),
|
||||
(True, lambda f: f.createIfcPositiveLengthMeasure(1.)),
|
||||
(False, lambda f: f.createIfcDescriptiveMeasure('large'))
|
||||
(False, lambda f: f.createIfcLengthMeasure(-1.0)),
|
||||
(True, lambda f: f.createIfcLengthMeasure(1.0)),
|
||||
(True, lambda f: f.createIfcPositiveLengthMeasure(1.0)),
|
||||
(False, lambda f: f.createIfcDescriptiveMeasure("large")),
|
||||
]
|
||||
|
||||
for valid, fn in fns:
|
||||
f = ifcopenshell.file(schema="IFC4")
|
||||
fs = fn(f)
|
||||
f.createIfcTextStyleFontModel('Comic Sans', ('Comic Sans',), FontSize=fs)
|
||||
f.createIfcTextStyleFontModel("Comic Sans", ("Comic Sans",), FontSize=fs)
|
||||
f.write(f"{'pass' if valid else 'fail'}-font-{fs.is_a()}-{fs[0]}.ifc")
|
||||
|
||||
+43
-18
@@ -1,7 +1,18 @@
|
||||
import time
|
||||
import ifcopenshell
|
||||
|
||||
for ents in [('IfcWall',), ('IfcSpace',), ('IfcZone', 'IfcSpace',), ('IfcWall', 'IfcSpace',)]:
|
||||
for ents in [
|
||||
("IfcWall",),
|
||||
("IfcSpace",),
|
||||
(
|
||||
"IfcZone",
|
||||
"IfcSpace",
|
||||
),
|
||||
(
|
||||
"IfcWall",
|
||||
"IfcSpace",
|
||||
),
|
||||
]:
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
p = f.createIfcPerson(Id="tfk", GivenName="Thomas")
|
||||
o = f.createIfcOrganization(Name="AECgeeks")
|
||||
@@ -9,24 +20,38 @@ for ents in [('IfcWall',), ('IfcSpace',), ('IfcZone', 'IfcSpace',), ('IfcWall',
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
proj = f.createIfcProject(ifcopenshell.guid.new(), ownerhist, 'My Project', UnitsInContext=units, RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None, None, 3, None,
|
||||
f.create_entity(f'IfcAxis2Placement3D', f.createIfcCartesianPoint((0., 0., 0.))),
|
||||
)
|
||||
])
|
||||
proj = f.createIfcProject(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
"My Project",
|
||||
UnitsInContext=units,
|
||||
RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None,
|
||||
None,
|
||||
3,
|
||||
None,
|
||||
f.create_entity(f"IfcAxis2Placement3D", f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
def elems():
|
||||
for ent in ents:
|
||||
el = f.create_entity(ent,
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist
|
||||
)
|
||||
if ent == 'IfcZone':
|
||||
f.createIfcRelAssignsToGroup(ifcopenshell.guid.new(),ownerhist,RelatedObjects=[f.createIfcSpace(ifcopenshell.guid.new(),
|
||||
ownerhist)],RelatingGroup=el)
|
||||
el = f.create_entity(ent, ifcopenshell.guid.new(), ownerhist)
|
||||
if ent == "IfcZone":
|
||||
f.createIfcRelAssignsToGroup(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
RelatedObjects=[f.createIfcSpace(ifcopenshell.guid.new(), ownerhist)],
|
||||
RelatingGroup=el,
|
||||
)
|
||||
yield el
|
||||
zone = f.createIfcZone(ifcopenshell.guid.new(),ownerhist)
|
||||
f.createIfcRelAssignsToGroup(ifcopenshell.guid.new(),ownerhist,RelatedObjects=list(elems()),RelatingGroup=zone)
|
||||
f.createIfcRelAggregates(ifcopenshell.guid.new(),ownerhist,RelatingObject=proj,RelatedObjects=f.by_type('IfcSpace'))
|
||||
valid = not (set(ents) - {'IfcZone', 'IfcSpace'})
|
||||
|
||||
zone = f.createIfcZone(ifcopenshell.guid.new(), ownerhist)
|
||||
f.createIfcRelAssignsToGroup(ifcopenshell.guid.new(), ownerhist, RelatedObjects=list(elems()), RelatingGroup=zone)
|
||||
f.createIfcRelAggregates(
|
||||
ifcopenshell.guid.new(), ownerhist, RelatingObject=proj, RelatedObjects=f.by_type("IfcSpace")
|
||||
)
|
||||
valid = not (set(ents) - {"IfcZone", "IfcSpace"})
|
||||
f.write(f"{'pass' if valid else 'fail'}-zone-with-{'-'.join(ents)}-{f.schema.lower()}.ifc")
|
||||
|
||||
@@ -2,13 +2,15 @@ import ifcopenshell
|
||||
|
||||
segs = [
|
||||
lambda _: None,
|
||||
lambda f: [f.createIfcLineIndex((1,2)),f.createIfcLineIndex((2,3))],
|
||||
lambda f: [f.createIfcLineIndex((1,2)),f.createIfcLineIndex((1,2))]
|
||||
lambda f: [f.createIfcLineIndex((1, 2)), f.createIfcLineIndex((2, 3))],
|
||||
lambda f: [f.createIfcLineIndex((1, 2)), f.createIfcLineIndex((1, 2))],
|
||||
]
|
||||
|
||||
for schema in ('ifc4', 'ifc4x3_add1'):
|
||||
for schema in ("ifc4", "ifc4x3_add1"):
|
||||
for i, seg in enumerate(segs):
|
||||
f = ifcopenshell.file(schema=schema)
|
||||
s = seg(f)
|
||||
f.createIfcIndexedPolyCurve(f.createIfcCartesianPointList2D([(0.0, 0.0),(0.0, 1.0),(1.0, 1.0)]), s)
|
||||
f.write(f'{"fail" if i == 2 else "pass"}-poly-curve-{"no-segments" if s is None else "-".join(["-".join(map(str, x[0])) for x in s])}-{schema}.ifc')
|
||||
f.createIfcIndexedPolyCurve(f.createIfcCartesianPointList2D([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0)]), s)
|
||||
f.write(
|
||||
f'{"fail" if i == 2 else "pass"}-poly-curve-{"no-segments" if s is None else "-".join(["-".join(map(str, x[0])) for x in s])}-{schema}.ifc'
|
||||
)
|
||||
|
||||
@@ -6,21 +6,22 @@ import ifcopenshell.guid
|
||||
def test_global_id_updates():
|
||||
g1, g2, g3 = (ifcopenshell.guid.new() for i in range(3))
|
||||
f = ifcopenshell.file()
|
||||
|
||||
|
||||
f.createIfcWall(g1)
|
||||
f[g1].GlobalId = g2
|
||||
with pytest.raises(RuntimeError):
|
||||
f[g1]
|
||||
assert f[g2]
|
||||
|
||||
|
||||
inst = f.createIfcWall()
|
||||
inst.GlobalId = g3
|
||||
assert f[g3]
|
||||
|
||||
|
||||
# Non-unique guid, succeeds but logs an error
|
||||
ifcopenshell.get_log()
|
||||
inst = f.createIfcWall(g3)
|
||||
assert "Overwriting" in ifcopenshell.get_log()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["-sx", __file__])
|
||||
|
||||
@@ -2,17 +2,19 @@ import pytest
|
||||
import ifcopenshell
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
def test_file_gc():
|
||||
f = ifcopenshell.file()
|
||||
inst = f.createIfcWall(ifcopenshell.guid.new(), Name=chr(0x1F37A))
|
||||
# 0x1F37A should be encoded using X4
|
||||
assert '\\X4\\' in inst.to_string()
|
||||
assert "\\X4\\" in inst.to_string()
|
||||
# to_string() should use upper case entity names
|
||||
assert 'IFCWALL' in inst.to_string()
|
||||
assert "IFCWALL" in inst.to_string()
|
||||
# __str__ uses camel case entity names
|
||||
assert 'IfcWall' in str(inst)
|
||||
assert "IfcWall" in str(inst)
|
||||
# in fact, __str__ is equal to to_string(False)
|
||||
assert str(inst) == inst.to_string(False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["-sx", __file__])
|
||||
|
||||
@@ -9,11 +9,11 @@ import ifcopenshell.api
|
||||
|
||||
|
||||
def test_inverse_indices():
|
||||
f = ifcopenshell.file()
|
||||
f = ifcopenshell.file()
|
||||
|
||||
p0 = f.createIfcCartesianPoint((0.,0.,0.))
|
||||
p1 = f.createIfcCartesianPoint((1.,0.,0.))
|
||||
p2 = f.createIfcCartesianPoint((1.,1.,0.))
|
||||
p0 = f.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
||||
p1 = f.createIfcCartesianPoint((1.0, 0.0, 0.0))
|
||||
p2 = f.createIfcCartesianPoint((1.0, 1.0, 0.0))
|
||||
|
||||
poly = f.createIfcPolyline((p0, p1, p2, p0))
|
||||
place = f.createIfcAxis2Placement3D(p0)
|
||||
@@ -26,7 +26,7 @@ def test_inverse_indices():
|
||||
# @nb this doesn't account for nested lists
|
||||
v = list(v)
|
||||
i = v.index(p0)
|
||||
v[i:i+1] = []
|
||||
v[i : i + 1] = []
|
||||
else:
|
||||
v = p1
|
||||
inst[idx] = v
|
||||
|
||||
@@ -32,24 +32,16 @@ class TestOpen:
|
||||
assert ifcopenshell.open(TEST_FILE_DIR / "wall-with-opening-and-window.ifcxml")
|
||||
|
||||
def test_open_ifc_zip_ifcxml_format(self):
|
||||
assert ifcopenshell.open(
|
||||
TEST_FILE_DIR / "wall-with-opening-and-window_ifcxml_format.ifczip"
|
||||
)
|
||||
assert ifcopenshell.open(TEST_FILE_DIR / "wall-with-opening-and-window_ifcxml_format.ifczip")
|
||||
|
||||
def test_open_ifc_zip_ifcspf_format(self):
|
||||
assert ifcopenshell.open(
|
||||
TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.ifczip"
|
||||
)
|
||||
assert ifcopenshell.open(TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.ifczip")
|
||||
|
||||
def test_open_zip(self):
|
||||
assert ifcopenshell.open(
|
||||
TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.zip"
|
||||
)
|
||||
assert ifcopenshell.open(TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.zip")
|
||||
|
||||
def test_open_anyextension_ifcspf_format(self):
|
||||
assert ifcopenshell.open(
|
||||
TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.anyextension"
|
||||
)
|
||||
assert ifcopenshell.open(TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.anyextension")
|
||||
|
||||
def test_open_anyextension_ifczip_ifcspf_format(self):
|
||||
assert ifcopenshell.open(
|
||||
|
||||
@@ -9,10 +9,13 @@ import ifcopenshell.validate
|
||||
import ifcopenshell.express.rule_executor
|
||||
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"filename",
|
||||
[fn for fn in glob.glob(os.path.join(os.path.dirname(__file__), "fixtures/rules/*.ifc")) if len(sys.argv) < 2 or sys.argv[1] in os.path.basename(fn)],
|
||||
[
|
||||
fn
|
||||
for fn in glob.glob(os.path.join(os.path.dirname(__file__), "fixtures/rules/*.ifc"))
|
||||
if len(sys.argv) < 2 or sys.argv[1] in os.path.basename(fn)
|
||||
],
|
||||
)
|
||||
def test_file(filename):
|
||||
base = os.path.basename(filename)
|
||||
@@ -27,12 +30,14 @@ def test_file(filename):
|
||||
print(f"{len(results)} errors")
|
||||
|
||||
if results:
|
||||
print(tabulate.tabulate(
|
||||
[[c or '' for c in r.values()] for r in results],
|
||||
maxcolwidths=[20,100,20],
|
||||
tablefmt="simple_grid",
|
||||
headers=results[0].keys()
|
||||
))
|
||||
print(
|
||||
tabulate.tabulate(
|
||||
[[c or "" for c in r.values()] for r in results],
|
||||
maxcolwidths=[20, 100, 20],
|
||||
tablefmt="simple_grid",
|
||||
headers=results[0].keys(),
|
||||
)
|
||||
)
|
||||
|
||||
if base.startswith("fail-"):
|
||||
assert len(results) > 0
|
||||
|
||||
@@ -230,7 +230,11 @@ class TestWallOpenings:
|
||||
|
||||
if i == 0 and j == 0:
|
||||
for ln, st in cs:
|
||||
assert len([l for l in log if l.startswith(st)]) == ln, f"\nOn file:\n - {fn}\nMessages:" + "".join(f'\n - "{l}"' for l in log) + f"\nExpected:\n - \"{st}\""
|
||||
assert len([l for l in log if l.startswith(st)]) == ln, (
|
||||
f"\nOn file:\n - {fn}\nMessages:"
|
||||
+ "".join(f'\n - "{l}"' for l in log)
|
||||
+ f'\nExpected:\n - "{st}"'
|
||||
)
|
||||
|
||||
# breakpoint()
|
||||
|
||||
|
||||
@@ -379,23 +379,17 @@ class TestGetMaterial(test.bootstrap.IFC4):
|
||||
|
||||
def test_getting_a_material_layer_set_of_a_product(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element], type="IfcMaterialLayerSet"
|
||||
)
|
||||
rel = ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialLayerSet")
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_profile_set_of_a_product(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element], type="IfcMaterialProfileSet"
|
||||
)
|
||||
rel = ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialProfileSet")
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_layer_set_usage_of_a_product(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
rel = ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialLayerSetUsage")
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_profile_set_usage_of_a_product(self):
|
||||
@@ -407,9 +401,7 @@ class TestGetMaterial(test.bootstrap.IFC4):
|
||||
|
||||
def test_getting_a_material_layer_set_indirectly_from_an_assigned_usage(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
rel = ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialLayerSetUsage")
|
||||
assert subject.get_material(element, should_skip_usage=True) == rel.RelatingMaterial.ForLayerSet
|
||||
|
||||
def test_getting_a_material_profile_set_indirectly_from_an_assigned_usage(self):
|
||||
@@ -501,9 +493,7 @@ class TestGetStyles(test.bootstrap.IFC4):
|
||||
self.file, context=body, length=5, height=3, thickness=0.118
|
||||
)
|
||||
|
||||
ifcopenshell.api.geometry.assign_representation(
|
||||
self.file, product=element, representation=representation
|
||||
)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=element, representation=representation)
|
||||
ifcopenshell.api.style.assign_representation_styles(
|
||||
self.file, shape_representation=representation, styles=[style2]
|
||||
)
|
||||
@@ -540,9 +530,7 @@ class TestGetElementsByMaterial(test.bootstrap.IFC4):
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.material.add_profile(self.file, profile_set=material_set, material=material)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type], material=material_set)
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element], type="IfcMaterialProfileSetUsage"
|
||||
)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialProfileSetUsage")
|
||||
usage = self.file.by_type("IfcMaterialProfileSetUsage")[0]
|
||||
assert subject.get_elements_by_material(self.file, material) == {element, element_type}
|
||||
assert subject.get_elements_by_material(self.file, material_set) == {element, element_type}
|
||||
@@ -551,9 +539,7 @@ class TestGetElementsByMaterial(test.bootstrap.IFC4):
|
||||
def test_getting_elements_of_a_material_constituent_set(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, set_type="IfcMaterialConstituentSet"
|
||||
)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialConstituentSet")
|
||||
ifcopenshell.api.material.add_constituent(self.file, constituent_set=material_set, material=material)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
|
||||
assert subject.get_elements_by_material(self.file, material) == {element}
|
||||
|
||||
@@ -57,7 +57,7 @@ class TestPsetQto:
|
||||
assert "Pset_FurnitureTypeTable" in names
|
||||
names = self.pset_qto.get_applicable_names("IfcFurnitureType", "TABLE")
|
||||
assert "Pset_FurnitureTypeTable" in names
|
||||
names = self.pset_qto.get_applicable_names("IfcFurnitureType" )
|
||||
names = self.pset_qto.get_applicable_names("IfcFurnitureType")
|
||||
names2 = self.pset_qto.get_applicable_names("IfcFurnitureType", "CUSTOM")
|
||||
assert names == names2
|
||||
|
||||
|
||||
@@ -86,9 +86,7 @@ class TestGetElementValue(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
material2 = ifcopenshell.api.material.add_material(self.file, name="CON02")
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, name="FOO", set_type="IfcMaterialLayerSet"
|
||||
)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, name="FOO", set_type="IfcMaterialLayerSet")
|
||||
layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
|
||||
layer.Name = "L1"
|
||||
layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
|
||||
@@ -113,9 +111,7 @@ class TestGetElementValue(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
material2 = ifcopenshell.api.material.add_material(self.file, name="CON02")
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, name="FOO", set_type="IfcMaterialLayerSet"
|
||||
)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, name="FOO", set_type="IfcMaterialLayerSet")
|
||||
layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
|
||||
layer.Name = "L1"
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
|
||||
|
||||
@@ -151,6 +151,7 @@ class TestConvertFileLengthUnits(test.bootstrap.IFC4):
|
||||
unit_assignment = subject.get_unit_assignment(output)
|
||||
assert len(unit_assignment.Units) == 1
|
||||
|
||||
|
||||
class TestConvertFileLengthUnitsIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_converting_map_conversion_if_there_is_no_map_unit(self):
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
@@ -171,7 +172,9 @@ class TestConvertFileLengthUnitsIFC2X3(test.bootstrap.IFC2X3):
|
||||
ifcopenshell.api.context.add_context(self.file, "Model")
|
||||
ifcopenshell.api.georeference.add_georeferencing(self.file)
|
||||
ifcopenshell.api.georeference.edit_georeferencing(
|
||||
self.file, projected_crs={"MapUnit": subject.get_full_unit_name(meter)}, coordinate_operation={"Eastings": 10, "Scale": 0.001}
|
||||
self.file,
|
||||
projected_crs={"MapUnit": subject.get_full_unit_name(meter)},
|
||||
coordinate_operation={"Eastings": 10, "Scale": 0.001},
|
||||
)
|
||||
ifcopenshell.api.unit.assign_unit(self.file, units=[unit])
|
||||
output = subject.convert_file_length_units(self.file, target_units="METER")
|
||||
|
||||
Reference in New Issue
Block a user