예제 #1
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc.set(ifc)
     representation = ifc.createIfcShapeRepresentation()
     obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
     obj.data.BIMMeshProperties.ifc_definition_id = representation.id()
     assert subject.get_object_representation(obj) == representation
예제 #2
0
 def test_run(self):
     tool.Ifc.set(ifcopenshell.file())
     style_item = tool.Ifc.get().createIfcSurfaceStyleWithTextures()
     style = tool.Ifc.get().createIfcSurfaceStyle(Styles=[style_item])
     obj = bpy.data.materials.new("Material")
     obj.BIMMaterialProperties.ifc_style_id = style.id()
     assert subject.get_surface_texture_style(obj) == style_item
예제 #3
0
 def test_existing_ifc_prefixes_are_not_repeated(self):
     ifc = ifcopenshell.file()
     obj = bpy.data.objects.new("IfcSlab/Object",
                                bpy.data.meshes.new("Mesh"))
     element = ifc.createIfcWall()
     subject.set_object_name(obj, element)
     assert obj.name == "IfcWall/Object"
예제 #4
0
    def test_run(self):
        ifc = ifcopenshell.file()
        tool.Ifc.set(ifc)

        obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
        element = ifc.createIfcOpeningElement()
        tool.Ifc.link(element, obj)

        wall_obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
        wall_element = ifc.createIfcOpeningElement()
        tool.Ifc.link(wall_element, wall_obj)

        ifcopenshell.api.run("void.add_opening",
                             ifc,
                             opening=element,
                             element=wall_element)

        subject.add_dynamic_opening_voids(element, obj)

        modifier = wall_obj.modifiers[0]
        assert modifier.type == "BOOLEAN"
        assert modifier.name == "IfcOpeningElement"
        assert modifier.operation == "DIFFERENCE"
        assert modifier.object == obj
        assert modifier.solver == "EXACT"
        assert modifier.use_self is True
예제 #5
0
 def test_generating_based_on_a_custom_function(self):
     ifc = ifcopenshell.file()
     element_type = ifc.createIfcWallType()
     bpy.context.scene.BIMModelProperties.occurrence_name_style = "CUSTOM"
     bpy.context.scene.BIMModelProperties.occurrence_name_function = '"Foobar"'
     assert subject.generate_occurrence_name(element_type,
                                             "IfcWall") == "Foobar"
예제 #6
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc.set(ifc)
     context = ifc.createIfcGeometricRepresentationContext()
     representation = ifc.createIfcShapeRepresentation(
         ContextOfItems=context)
     assert subject.get_representation_context(representation) == context
예제 #7
0
 def create_ifc_file(self):
     self.file = ifcopenshell.file()
     units = self.file.createIfcUnitAssignment(
         [self.file.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
     self.origin = self.file.createIfcAxis2Placement3D(
         self.file.createIfcCartesianPoint((0.0, 0.0, 0.0)),
         self.file.createIfcDirection((0.0, 0.0, 1.0)),
         self.file.createIfcDirection((1.0, 0.0, 0.0)),
     )
     self.placement = self.file.createIfcLocalPlacement(None, self.origin)
     self.context = self.file.createIfcGeometricRepresentationContext(
         None, "Model", 3, 1.0e-05, self.origin)
     self.subcontext = self.file.createIfcGeometricRepresentationSubcontext(
         "Body", "Model", None, None, None, None, self.context, None,
         "MODEL_VIEW", None)
     self.project = self.file.create_entity(
         "IfcProject", **{
             "GlobalId": ifcopenshell.guid.new(),
             "Name": "DXF Conversion",
             "RepresentationContexts": [self.context],
             "UnitsInContext": units,
         })
     self.site = self.file.create_entity(
         "IfcSite", **{
             "GlobalId": ifcopenshell.guid.new(),
             "Name": "DXF Conversion Site",
             "ObjectPlacement": self.placement
         })
     self.file.createIfcRelAggregates(ifcopenshell.guid.new(), None, None,
                                      None, self.project, [self.site])
예제 #8
0
 def __init__(self, schema: str = "IFC4"):
     self.file = ifcopenshell.file(schema=schema)
     self.application = self.create_application()
     self.project_library = None
     self.lang = config.get_lang()
     self.country = config.get_country()
     self.owner_history = None
예제 #9
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc.set(ifc)
     reference = ifc.createIfcLibraryReference()
     subject.set_active_reference(reference)
     assert bpy.context.scene.BIMLibraryProperties.active_reference_id == reference.id(
     )
예제 #10
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc.set(ifc)
     library = ifc.createIfcLibraryInformation()
     subject.set_active_library(library)
     assert bpy.context.scene.BIMLibraryProperties.active_library_id == library.id(
     )
예제 #11
0
 def patch(self):
     ifc_file = self.file
     new_file = ifcopenshell.file(schema=ifc_file.schema)
     self.new_file = new_file
     for space_id in self.space_ids:
         self.write_space(space_id)
     new_file.write(self.output_path())
예제 #12
0
 def test_run(self):
     ifc = ifcopenshell.file()
     style = ifc.createIfcSurfaceStyle("Name", "BOTH")
     obj = bpy.data.materials.new("Material")
     subject.import_surface_attributes(style, obj)
     assert obj.BIMStyleProperties.attributes.get("Name").string_value == "Name"
     assert obj.BIMStyleProperties.attributes.get("Side").enum_value == "BOTH"
예제 #13
0
 def test_link_a_style(self):
     ifc = ifcopenshell.file()
     subject.set(ifc)
     element = ifc.createIfcSurfaceStyle()
     obj = bpy.data.materials.new("Material")
     subject.link(element, obj)
     assert subject.get_object(element) == obj
예제 #14
0
 def test_importing_monetary_units_ifc2x3(self):
     ifc = ifcopenshell.file(schema="IFC2X3")
     unit = ifc.createIfcMonetaryUnit()
     unit.Currency = "USD"
     subject.import_unit_attributes(unit)
     props = bpy.context.scene.BIMUnitProperties
     assert props.unit_attributes.get("Currency").enum_value == "USD"
예제 #15
0
 def test_run_ifc2x3(self):
     tool.Ifc.set(ifcopenshell.file(schema="IFC2X3"))
     assert subject.export_brick_attributes(
         "http://example.org/digitaltwin#floor") == {
             "ItemReference": "http://example.org/digitaltwin#floor",
             "Name": "floor",
         }
예제 #16
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc().set(ifc)
     element = ifc.createIfcDuctSegment()
     port = ifc.createIfcDistributionPort()
     ifcopenshell.api.run("system.assign_port", ifc, element=element, port=port)
     subject.get_ports(element) == [port]
예제 #17
0
 def test_importing_monetary_units(self):
     ifc = ifcopenshell.file()
     unit = ifc.createIfcMonetaryUnit()
     unit.Currency = "Currency"
     subject.import_unit_attributes(unit)
     props = bpy.context.scene.BIMUnitProperties
     assert props.unit_attributes.get("Currency").string_value == "Currency"
예제 #18
0
 def patch(self):
     import ifcopenshell
     from shutil import copyfile
     storeys = self.file.by_type('IfcBuildingStorey')
     for i, storey in enumerate(storeys):
         dest = '{}-{}.ifc'.format(i, storey.Name)
         copyfile(self.src, dest)
         old_ifc = ifcopenshell.open(dest)
         new_ifc = ifcopenshell.file(schema=self.file.schema)
         if self.file.schema == 'IFC2X3':
             elements = old_ifc.by_type('IfcProject') + old_ifc.by_type(
                 'IfcProduct')
         else:
             elements = old_ifc.by_type('IfcContext') + old_ifc.by_type(
                 'IfcProduct')
         inverse_elements = []
         for element in elements:
             if element.is_a('IfcElement') \
                     and not self.is_in_storey(element, storey):
                 element.Representation = None
                 continue
             if element.is_a('IfcElement'):
                 styled_rep_items = [
                     i for i in old_ifc.traverse(element)
                     if i.is_a('IfcRepresentationItem') and i.StyledByItem
                 ]
                 [new_ifc.add(i.StyledByItem[0]) for i in styled_rep_items]
             new_ifc.add(element)
             inverse_elements.extend(old_ifc.get_inverse(element))
         for inverse_element in inverse_elements:
             new_ifc.add(inverse_element)
         for element in new_ifc.by_type('IfcElement'):
             if not self.is_in_storey(element, storey):
                 new_ifc.remove(element)
         new_ifc.write(dest)
예제 #19
0
 def test_run(self):
     ifc = ifcopenshell.file()
     port1 = ifcopenshell.api.run("system.add_port", ifc)
     port2 = ifcopenshell.api.run("system.add_port", ifc)
     ifcopenshell.api.run("system.connect_port", ifc, port1=port1, port2=port2)
     assert subject.get_connected_port(port1) == port2
     assert subject.get_connected_port(port2) == port1
예제 #20
0
 def test_importing_a_telecom_address(self):
     ifc = ifcopenshell.file()
     tool.Ifc().set(ifc)
     address = ifc.createIfcTelecomAddress()
     address.Purpose = "USERDEFINED"
     address.Description = "Description"
     address.UserDefinedPurpose = "UserDefinedPurpose"
     address.TelephoneNumbers = ["Telephone", "Numbers"]
     address.FacsimileNumbers = ["Facsimile", "Numbers"]
     address.PagerNumber = "PagerNumber"
     address.ElectronicMailAddresses = ["Electronic", "Mail", "Addresses"]
     address.WWWHomePageURL = "WWWHomePageURL"
     address.MessagingIDs = ["Messaging", "IDs"]
     subject().set_address(address)
     subject().import_address_attributes()
     props = bpy.context.scene.BIMOwnerProperties
     assert props.address_attributes.get(
         "Purpose").enum_value == "USERDEFINED"
     assert props.address_attributes.get(
         "Description").string_value == "Description"
     assert props.address_attributes.get(
         "UserDefinedPurpose").string_value == "UserDefinedPurpose"
     assert [a.name
             for a in props.telephone_numbers] == ["Telephone", "Numbers"]
     assert [a.name
             for a in props.facsimile_numbers] == ["Facsimile", "Numbers"]
     assert [a.name for a in props.electronic_mail_addresses
             ] == ["Electronic", "Mail", "Addresses"]
     assert [a.name for a in props.messaging_ids] == ["Messaging", "IDs"]
예제 #21
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc().set(ifc)
     person = ifc.createIfcPerson()
     person.Identification = "identification"
     person.GivenName = "given_name"
     person.FamilyName = "family_name"
     person.MiddleNames = ("middle", "names")
     person.PrefixTitles = ("prefix", "titles")
     person.SuffixTitles = ("suffix", "titles")
     subject().set_person(person)
     subject().import_person_attributes()
     props = bpy.context.scene.BIMOwnerProperties
     assert props.person_attributes.get(
         "Identification").string_value == "identification"
     assert props.person_attributes.get(
         "GivenName").string_value == "given_name"
     assert props.person_attributes.get(
         "FamilyName").string_value == "family_name"
     assert len(props.middle_names) == 2
     assert props.middle_names[0].name == "middle"
     assert props.middle_names[1].name == "names"
     assert len(props.prefix_titles) == 2
     assert props.prefix_titles[0].name == "prefix"
     assert props.prefix_titles[1].name == "titles"
     assert len(props.suffix_titles) == 2
     assert props.suffix_titles[0].name == "suffix"
     assert props.suffix_titles[1].name == "titles"
예제 #22
0
 def test_returning_nothing_if_uncontained(self):
     ifc = ifcopenshell.file()
     tool.Ifc.set(ifc)
     obj = bpy.data.objects.new("Object", None)
     wall = ifc.createIfcWall()
     tool.Ifc.link(wall, obj)
     assert subject.get_object_storey(obj) is None
예제 #23
0
 def test_getting_empty_list_attributes_as_none(self):
     ifc = ifcopenshell.file()
     tool.Ifc().set(ifc)
     result = subject().export_person_attributes()
     assert result["MiddleNames"] is None
     assert result["PrefixTitles"] is None
     assert result["SuffixTitles"] is None
예제 #24
0
 def test_returning_none_if_the_storey_height_is_undefined(self):
     ifc = ifcopenshell.file()
     tool.Ifc.set(ifc)
     building = ifc.createIfcBuilding()
     storey = ifc.createIfcBuildingStorey()
     ifcopenshell.api.run("aggregate.assign_object", ifc, product=storey, relating_object=building)
     assert subject.get_storey_height_in_si(storey, 1) is None
예제 #25
0
 def test_run(self):
     ifc = ifcopenshell.file()
     subject.set(ifc)
     element = ifc.createIfcWall()
     obj = bpy.data.objects.new("Object", None)
     subject.link(element, obj)
     assert subject.get_object(element) == obj
예제 #26
0
 def test_run(self):
     ifc = ifcopenshell.file()
     subject.set(ifc)
     obj = bpy.data.objects.new("Object", None)
     element = ifc.createIfcWall()
     obj.BIMObjectProperties.ifc_definition_id = element.id()
     assert subject.get_entity(obj) == element
예제 #27
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc.set(ifc)
     project = ifc.createIfcProject(ifcopenshell.guid.new())
     project.Name = "My Project"
     BrickStore.graph = brickschema.Graph()
     result = subject.add_brickifc_project(
         "http://example.org/digitaltwin#")
     assert result == f"http://example.org/digitaltwin#{project.GlobalId}"
     brick = URIRef(result)
     assert list(
         BrickStore.graph.triples(
             (brick, RDF.type,
              URIRef("https://brickschema.org/extension/ifc#Project"))))
     assert list(
         BrickStore.graph.triples(
             (brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"),
              Literal("My Project"))))
     assert list(
         BrickStore.graph.triples(
             (brick,
              URIRef("https://brickschema.org/extension/ifc#projectID"),
              Literal(project.GlobalId))))
     assert list(
         BrickStore.graph.triples((
             brick,
             URIRef("https://brickschema.org/extension/ifc#fileLocation"),
             Literal(bpy.context.scene.BIMProperties.ifc_file),
         )))
예제 #28
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc().set(ifc)
     obj = bpy.data.objects.new("Object", None)
     element = ifc.createIfcWall()
     tool.Ifc.link(element, obj)
     subject.delete_element_objects([element])
     assert not bpy.data.objects.get("Object")
예제 #29
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc().set(ifc)
     obj = bpy.data.objects.new("Object", None)
     element = ifc.createIfcWall()
     tool.Ifc.link(element, obj)
     obj = subject.create_empty_at_cursor_with_element_orientation(element)
     assert obj.matrix_world == bpy.context.scene.cursor.matrix
예제 #30
0
 def test_link_a_material(self):
     ifc = ifcopenshell.file()
     subject.set(ifc)
     element = ifc.createIfcMaterial()
     obj = bpy.data.materials.new("Material")
     subject.link(element, obj)
     assert subject.get_entity(obj) == element
     assert subject.get_object(element) == obj