From 0f03e412c3352a3fa4064d7a00f162c7965fd562 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 9 Aug 2024 19:00:01 +0500 Subject: [PATCH] bcf - port 3c17718 to v3 According to docs bcf is using meters as their length unit - https://github.com/BuildingSMART/BCF-XML/tree/release_3_0/Documentation We should create some kind of common code folder to keep this sane... --- src/bcf/bcf/v3/visinfo.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bcf/bcf/v3/visinfo.py b/src/bcf/bcf/v3/visinfo.py index d1e438fada..66430da972 100644 --- a/src/bcf/bcf/v3/visinfo.py +++ b/src/bcf/bcf/v3/visinfo.py @@ -5,7 +5,8 @@ from typing import Any, Iterable, Optional import numpy as np from ifcopenshell import entity_instance -from ifcopenshell.util import placement +import ifcopenshell.util.unit +import ifcopenshell.util.placement from numpy.typing import NDArray import bcf.v3.model as mdl @@ -218,7 +219,12 @@ def build_viewpoint(element: entity_instance) -> mdl.VisualizationInfo: Returns: The BCF viewpoint definition. """ - elem_placement = placement.get_local_placement(element.ObjectPlacement) + ifc_file = element.wrapped_data.file + unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file) + elem_placement = ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement) + elem_placement[0][3] *= unit_scale + elem_placement[1][3] *= unit_scale + elem_placement[2][3] *= unit_scale return mdl.VisualizationInfo( guid=str(uuid.uuid4()),