mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
This commit is contained in:
@@ -471,14 +471,6 @@ class Usecase:
|
|||||||
The problem with `file.add` it's recursively adding element and all it's attributes
|
The problem with `file.add` it's recursively adding element and all it's attributes
|
||||||
and there is no control to prevent it from adding certain type of elements.
|
and there is no control to prevent it from adding certain type of elements.
|
||||||
"""
|
"""
|
||||||
ifc_file = self.file
|
|
||||||
if not self.assume_asset_uniqueness_by_name:
|
|
||||||
return ifc_file.add(element)
|
|
||||||
|
|
||||||
reuse_identities = self.reuse_identities
|
|
||||||
element_identity = element.wrapped_data.identity()
|
|
||||||
if added_element := reuse_identities.get(element_identity):
|
|
||||||
return added_element
|
|
||||||
|
|
||||||
def get_conversion_factor() -> float:
|
def get_conversion_factor() -> float:
|
||||||
nonlocal conversion_factor
|
nonlocal conversion_factor
|
||||||
@@ -489,6 +481,18 @@ class Usecase:
|
|||||||
conversion_factor = library_scale / current_scale
|
conversion_factor = library_scale / current_scale
|
||||||
return conversion_factor
|
return conversion_factor
|
||||||
|
|
||||||
|
ifc_file = self.file
|
||||||
|
if not self.assume_asset_uniqueness_by_name or element.id() == 0:
|
||||||
|
# file.add doesn't convert units for IfcLengthMeasure entities.
|
||||||
|
if element.is_a("IfcLengthMeasure"):
|
||||||
|
return ifc_file.create_entity(element.is_a(), element.wrappedValue * get_conversion_factor())
|
||||||
|
return ifc_file.add(element)
|
||||||
|
|
||||||
|
reuse_identities = self.reuse_identities
|
||||||
|
element_identity = element.wrapped_data.identity()
|
||||||
|
if added_element := reuse_identities.get(element_identity):
|
||||||
|
return added_element
|
||||||
|
|
||||||
attributes_ = None
|
attributes_ = None
|
||||||
|
|
||||||
def get_attributes() -> tuple[W.attribute, ...]:
|
def get_attributes() -> tuple[W.attribute, ...]:
|
||||||
@@ -541,7 +545,7 @@ class Usecase:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
elif isinstance(attr_value, ifcopenshell.entity_instance):
|
elif isinstance(attr_value, ifcopenshell.entity_instance):
|
||||||
attr_value = self.file_add(attr_value)
|
attr_value = file_add_(attr_value)
|
||||||
|
|
||||||
elif isinstance(attr_value, tuple):
|
elif isinstance(attr_value, tuple):
|
||||||
# Assume type is consistent across the tuple.
|
# Assume type is consistent across the tuple.
|
||||||
|
|||||||
@@ -498,6 +498,17 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
|||||||
updated_points = np.array(arbitrary_profile.OuterCurve.Points) * 0.001
|
updated_points = np.array(arbitrary_profile.OuterCurve.Points) * 0.001
|
||||||
assert np.allclose(updated_points, new_arbitrary_profile.OuterCurve.Points)
|
assert np.allclose(updated_points, new_arbitrary_profile.OuterCurve.Points)
|
||||||
|
|
||||||
|
# Entities without ids.
|
||||||
|
annotation = ifcopenshell.api.root.create_entity(library, "IfcAnnotation")
|
||||||
|
annotation.ObjectType = "LineOfSight"
|
||||||
|
pset = ifcopenshell.api.pset.add_pset(library, annotation, "Pset_AnnotationLineOfSight")
|
||||||
|
ifcopenshell.api.pset.edit_pset(library, pset, properties={"RoadVisibleDistanceLeft": 10})
|
||||||
|
new_annotation = ifcopenshell.api.project.append_asset(ifc_file, library, annotation)
|
||||||
|
assert (
|
||||||
|
ifcopenshell.util.element.get_pset(new_annotation, "Pset_AnnotationLineOfSight", "RoadVisibleDistanceLeft")
|
||||||
|
== 0.01
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestAppendAssetIFC4(test.bootstrap.IFC4, TestAppendAssetIFC2X3):
|
class TestAppendAssetIFC4(test.bootstrap.IFC4, TestAppendAssetIFC2X3):
|
||||||
# NOTE: breaks in IFC2X3 since IfcProfileDef doesn't have "HasProperties" inverse in ifc2x3
|
# NOTE: breaks in IFC2X3 since IfcProfileDef doesn't have "HasProperties" inverse in ifc2x3
|
||||||
|
|||||||
Reference in New Issue
Block a user