(self, filepath: str)
| 815 | return [FacetFailure(f) for f in requirement.failures] |
| 816 | |
| 817 | def to_file(self, filepath: str) -> None: |
| 818 | import numpy as np |
| 819 | from bcf.v2.bcfxml import BcfXml |
| 820 | |
| 821 | unit_scale = None |
| 822 | bcfxml = BcfXml.create_new(self.results["title"]) |
| 823 | for specification in self.results["specifications"]: |
| 824 | if specification["status"]: |
| 825 | continue |
| 826 | for requirement in specification["requirements"]: |
| 827 | if requirement["status"]: |
| 828 | continue |
| 829 | for failure in requirement["failed_entities"]: |
| 830 | element = failure["element"] |
| 831 | title_components = [] |
| 832 | for title_component in [ |
| 833 | element.is_a(), |
| 834 | getattr(element, "Name", "") or "Unnamed", |
| 835 | failure.get("reason", "No reason"), |
| 836 | getattr(element, "GlobalId", ""), |
| 837 | getattr(element, "Tag", ""), |
| 838 | ]: |
| 839 | if title_component: |
| 840 | title_components.append(title_component) |
| 841 | title = " - ".join(title_components) |
| 842 | description = f'{specification["name"]} - {requirement["description"]}' |
| 843 | topic = bcfxml.add_topic(title, description, "IfcTester") |
| 844 | if getattr(element, "ObjectPlacement", None): |
| 845 | placement = ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement) |
| 846 | if unit_scale is None: |
| 847 | unit_scale = ifcopenshell.util.unit.calculate_unit_scale(element.wrapped_data.file) |
| 848 | location = [(o * unit_scale) + 5.0 for o in placement[:, 3][:3]] |
| 849 | viewpoint = topic.add_viewpoint_from_point_and_guids(np.array(location), element.GlobalId) |
| 850 | if element.is_a("IfcElement"): |
| 851 | topic.add_viewpoint(element) |
| 852 | bcfxml.save_project(filepath) |
no test coverage detected