mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 11:46:33 +00:00
black
This commit is contained in:
@@ -61,19 +61,13 @@ def copy_representation(
|
|||||||
ifcopenshell.api.geometry.copy_representation(model,
|
ifcopenshell.api.geometry.copy_representation(model,
|
||||||
source=wall_a, target=wall_b)
|
source=wall_a, target=wall_b)
|
||||||
"""
|
"""
|
||||||
source_rep = ifcopenshell.util.representation.get_representation(
|
source_rep = ifcopenshell.util.representation.get_representation(source, "Model", context_identifier)
|
||||||
source, "Model", context_identifier
|
|
||||||
)
|
|
||||||
if source_rep is None:
|
if source_rep is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
new_rep = ifcopenshell.util.element.copy_deep(
|
new_rep = ifcopenshell.util.element.copy_deep(file, source_rep, exclude=["IfcGeometricRepresentationContext"])
|
||||||
file, source_rep, exclude=["IfcGeometricRepresentationContext"]
|
|
||||||
)
|
|
||||||
|
|
||||||
existing_rep = ifcopenshell.util.representation.get_representation(
|
existing_rep = ifcopenshell.util.representation.get_representation(target, "Model", context_identifier)
|
||||||
target, "Model", context_identifier
|
|
||||||
)
|
|
||||||
if existing_rep:
|
if existing_rep:
|
||||||
ifcopenshell.api.geometry.unassign_representation(file, product=target, representation=existing_rep)
|
ifcopenshell.api.geometry.unassign_representation(file, product=target, representation=existing_rep)
|
||||||
ifcopenshell.api.geometry.remove_representation(file, representation=existing_rep)
|
ifcopenshell.api.geometry.remove_representation(file, representation=existing_rep)
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ class TestClipSolid(test.bootstrap.IFC4):
|
|||||||
assert result.is_a("IfcBooleanClippingResult")
|
assert result.is_a("IfcBooleanClippingResult")
|
||||||
assert result.SecondOperand.is_a("IfcHalfSpaceSolid")
|
assert result.SecondOperand.is_a("IfcHalfSpaceSolid")
|
||||||
|
|
||||||
|
|
||||||
def test_element_registers_result_in_bbim_boolean(self):
|
def test_element_registers_result_in_bbim_boolean(self):
|
||||||
extrusion = self.make_extrusion()
|
extrusion = self.make_extrusion()
|
||||||
wall = self.file.createIfcWall()
|
wall = self.file.createIfcWall()
|
||||||
|
|||||||
@@ -147,7 +147,6 @@ class TestClipSolidBounded(test.bootstrap.IFC4):
|
|||||||
assert result.FirstOperand == first_clip
|
assert result.FirstOperand == first_clip
|
||||||
assert first_clip.FirstOperand == extrusion
|
assert first_clip.FirstOperand == extrusion
|
||||||
|
|
||||||
|
|
||||||
def test_element_registers_result_in_bbim_boolean(self):
|
def test_element_registers_result_in_bbim_boolean(self):
|
||||||
extrusion = self.make_extrusion()
|
extrusion = self.make_extrusion()
|
||||||
wall = self.file.createIfcWall()
|
wall = self.file.createIfcWall()
|
||||||
|
|||||||
@@ -28,14 +28,18 @@ class TestCopyRepresentation(test.bootstrap.IFC4):
|
|||||||
body = ifcopenshell.util.representation.get_context(self.file, "Model", "Body", "MODEL_VIEW")
|
body = ifcopenshell.util.representation.get_context(self.file, "Model", "Body", "MODEL_VIEW")
|
||||||
if body is None:
|
if body is None:
|
||||||
model = self.file.createIfcGeometricRepresentationContext(
|
model = self.file.createIfcGeometricRepresentationContext(
|
||||||
ContextType="Model", CoordinateSpaceDimension=3, Precision=1e-5,
|
ContextType="Model",
|
||||||
|
CoordinateSpaceDimension=3,
|
||||||
|
Precision=1e-5,
|
||||||
WorldCoordinateSystem=self.file.createIfcAxis2Placement3D(
|
WorldCoordinateSystem=self.file.createIfcAxis2Placement3D(
|
||||||
self.file.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
self.file.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
body = self.file.createIfcGeometricRepresentationSubContext(
|
body = self.file.createIfcGeometricRepresentationSubContext(
|
||||||
ContextIdentifier="Body", ContextType="Model",
|
ContextIdentifier="Body",
|
||||||
TargetView="MODEL_VIEW", ParentContext=model,
|
ContextType="Model",
|
||||||
|
TargetView="MODEL_VIEW",
|
||||||
|
ParentContext=model,
|
||||||
)
|
)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
@@ -52,9 +56,7 @@ class TestCopyRepresentation(test.bootstrap.IFC4):
|
|||||||
wall_b = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
wall_b = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||||
self._add_body_rep(wall_a)
|
self._add_body_rep(wall_a)
|
||||||
|
|
||||||
result = ifcopenshell.api.geometry.copy_representation(
|
result = ifcopenshell.api.geometry.copy_representation(self.file, source=wall_a, target=wall_b)
|
||||||
self.file, source=wall_a, target=wall_b
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result is not None
|
assert result is not None
|
||||||
assert result.is_a("IfcShapeRepresentation")
|
assert result.is_a("IfcShapeRepresentation")
|
||||||
@@ -67,9 +69,7 @@ class TestCopyRepresentation(test.bootstrap.IFC4):
|
|||||||
wall_b = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
wall_b = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||||
source_rep = self._add_body_rep(wall_a)
|
source_rep = self._add_body_rep(wall_a)
|
||||||
|
|
||||||
new_rep = ifcopenshell.api.geometry.copy_representation(
|
new_rep = ifcopenshell.api.geometry.copy_representation(self.file, source=wall_a, target=wall_b)
|
||||||
self.file, source=wall_a, target=wall_b
|
|
||||||
)
|
|
||||||
|
|
||||||
assert new_rep.id() != source_rep.id()
|
assert new_rep.id() != source_rep.id()
|
||||||
assert new_rep.Items[0].id() != source_rep.Items[0].id()
|
assert new_rep.Items[0].id() != source_rep.Items[0].id()
|
||||||
@@ -79,9 +79,7 @@ class TestCopyRepresentation(test.bootstrap.IFC4):
|
|||||||
wall_b = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
wall_b = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||||
source_rep = self._add_body_rep(wall_a)
|
source_rep = self._add_body_rep(wall_a)
|
||||||
|
|
||||||
new_rep = ifcopenshell.api.geometry.copy_representation(
|
new_rep = ifcopenshell.api.geometry.copy_representation(self.file, source=wall_a, target=wall_b)
|
||||||
self.file, source=wall_a, target=wall_b
|
|
||||||
)
|
|
||||||
|
|
||||||
assert new_rep.ContextOfItems.id() == source_rep.ContextOfItems.id()
|
assert new_rep.ContextOfItems.id() == source_rep.ContextOfItems.id()
|
||||||
|
|
||||||
@@ -92,9 +90,7 @@ class TestCopyRepresentation(test.bootstrap.IFC4):
|
|||||||
old_rep = self._add_body_rep(wall_b)
|
old_rep = self._add_body_rep(wall_b)
|
||||||
old_rep_id = old_rep.id()
|
old_rep_id = old_rep.id()
|
||||||
|
|
||||||
ifcopenshell.api.geometry.copy_representation(
|
ifcopenshell.api.geometry.copy_representation(self.file, source=wall_a, target=wall_b)
|
||||||
self.file, source=wall_a, target=wall_b
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.file.by_id(old_rep_id)
|
self.file.by_id(old_rep_id)
|
||||||
@@ -108,9 +104,7 @@ class TestCopyRepresentation(test.bootstrap.IFC4):
|
|||||||
source_rep = self._add_body_rep(wall_a)
|
source_rep = self._add_body_rep(wall_a)
|
||||||
source_rep_id = source_rep.id()
|
source_rep_id = source_rep.id()
|
||||||
|
|
||||||
ifcopenshell.api.geometry.copy_representation(
|
ifcopenshell.api.geometry.copy_representation(self.file, source=wall_a, target=wall_b)
|
||||||
self.file, source=wall_a, target=wall_b
|
|
||||||
)
|
|
||||||
|
|
||||||
assert self.file.by_id(source_rep_id) is not None # source must still exist
|
assert self.file.by_id(source_rep_id) is not None # source must still exist
|
||||||
assert ifcopenshell.util.representation.get_representation(wall_a, "Model", "Body") is not None
|
assert ifcopenshell.util.representation.get_representation(wall_a, "Model", "Body") is not None
|
||||||
@@ -119,9 +113,7 @@ class TestCopyRepresentation(test.bootstrap.IFC4):
|
|||||||
wall_a = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
wall_a = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||||
wall_b = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
wall_b = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||||
|
|
||||||
result = ifcopenshell.api.geometry.copy_representation(
|
result = ifcopenshell.api.geometry.copy_representation(self.file, source=wall_a, target=wall_b)
|
||||||
self.file, source=wall_a, target=wall_b
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result is None
|
assert result is None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user