mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix errors appending assets when projects are using georeferencing #5110
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.api.georeference
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.type
|
||||
@@ -27,6 +29,8 @@ import ifcopenshell.api.context
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.material
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.placement
|
||||
import numpy as np
|
||||
|
||||
|
||||
class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
@@ -370,6 +374,40 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert self.file.by_type("IfcWall")[0].HasOpenings[0].RelatedOpeningElement.is_a("IfcOpeningElement")
|
||||
|
||||
def test_append_a_product_when_projects_have_georeference(self):
|
||||
ifc_file = ifcopenshell.file()
|
||||
ifcopenshell.api.root.create_entity(ifc_file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.context.add_context(ifc_file, "Model")
|
||||
ifcopenshell.api.georeference.add_georeferencing(ifc_file)
|
||||
ifcopenshell.api.georeference.edit_georeferencing(
|
||||
ifc_file, coordinate_operation={"Eastings": 3.0, "Northings": 23.0}
|
||||
)
|
||||
|
||||
library = ifcopenshell.file.from_string(ifc_file.to_string())
|
||||
ifcopenshell.api.georeference.edit_georeferencing(
|
||||
library, coordinate_operation={"Eastings": 29, "Northings": 42}
|
||||
)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
matrix = np.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
(0.0, 1.0, 0.0, 2.0),
|
||||
(0.0, 0.0, 1.0, 3.0),
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(library, element, matrix)
|
||||
new = ifcopenshell.api.project.append_asset(ifc_file, library=library, element=element)
|
||||
resulting_matrix = np.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 27.0),
|
||||
(0.0, 1.0, 0.0, 21.0),
|
||||
(0.0, 0.0, 1.0, 3.0),
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
assert np.array_equal(ifcopenshell.util.placement.get_local_placement(new.ObjectPlacement), resulting_matrix)
|
||||
|
||||
|
||||
class TestAppendAssetIFC4(test.bootstrap.IFC4, TestAppendAssetIFC2X3):
|
||||
# NOTE: breaks in IFC2X3 since IfcProfileDef doesn't have "HasProperties" inverse in ifc2x3
|
||||
|
||||
Reference in New Issue
Block a user