mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Remove usage of .wrapped_item and some other fixes
This commit is contained in:
@@ -256,7 +256,7 @@ def create_entity(type: str, schema: str = "IFC4", *args: Any, **kwargs: Any) ->
|
||||
model.add(person) # #1=IfcPerson($,$,$,$,$,$,$,$)
|
||||
"""
|
||||
e = entity_instance((schema, type))
|
||||
attrs = list(enumerate(args)) + [(e.wrapped_data.get_argument_index(name), arg) for name, arg in kwargs.items()]
|
||||
attrs = list(enumerate(args)) + [(e.get_argument_index(name), arg) for name, arg in kwargs.items()]
|
||||
for idx, arg in attrs:
|
||||
e[idx] = arg
|
||||
return e
|
||||
|
||||
@@ -79,7 +79,7 @@ def _add_curve_segment_to_composite_curve(
|
||||
|
||||
if zero_length_segment:
|
||||
settings = ifcopenshell.geom.settings()
|
||||
segment_fn = ifcopenshell_wrapper.map_shape(settings, curve_segment.wrapped_data)
|
||||
segment_fn = ifcopenshell_wrapper.map_shape(settings, curve_segment)
|
||||
segment_evaluator = ifcopenshell_wrapper.function_item_evaluator(settings, segment_fn)
|
||||
e = segment_evaluator.evaluate(segment_fn.end())
|
||||
end = np.array(e)
|
||||
|
||||
@@ -97,7 +97,7 @@ def _add_segment_to_layout(file: ifcopenshell.file, layout: entity_instance, seg
|
||||
|
||||
# compute the end point matrix
|
||||
settings = ifcopenshell.geom.settings()
|
||||
segment_fn = ifcopenshell_wrapper.map_shape(settings, mapped_segment.wrapped_data)
|
||||
segment_fn = ifcopenshell_wrapper.map_shape(settings, mapped_segment)
|
||||
segment_evaluator = ifcopenshell_wrapper.function_item_evaluator(settings, segment_fn)
|
||||
e = segment_evaluator.evaluate(segment_fn.end())
|
||||
end = np.array(e)
|
||||
@@ -144,7 +144,7 @@ def _add_segment_to_layout(file: ifcopenshell.file, layout: entity_instance, seg
|
||||
end_referent.ObjectPlacement.RelativePlacement.Location.DistanceAlong.wrappedValue = start_dist_along
|
||||
settings = ifcopenshell.geom.settings()
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment)
|
||||
curve_fn = ifcopenshell_wrapper.map_shape(settings, basis_curve.wrapped_data)
|
||||
curve_fn = ifcopenshell_wrapper.map_shape(settings, basis_curve)
|
||||
curve_evaluator = ifcopenshell_wrapper.function_item_evaluator(settings, curve_fn)
|
||||
p = curve_evaluator.evaluate(start_dist_along * unit_scale)
|
||||
p = np.array(p)
|
||||
|
||||
@@ -84,7 +84,7 @@ def add_stationing_referent(
|
||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(file)
|
||||
|
||||
settings = ifcopenshell.geom.settings()
|
||||
fn = ifcopenshell_wrapper.map_shape(settings, basis_curve.wrapped_data)
|
||||
fn = ifcopenshell_wrapper.map_shape(settings, basis_curve)
|
||||
|
||||
if basis_curve.is_a("IfcPolyline") or basis_curve.is_a("IfcIndexedPolyCurve"):
|
||||
fn = ifcopenshell_wrapper.convert_loop_to_function_item(fn)
|
||||
|
||||
@@ -77,7 +77,7 @@ def add_zero_length_segment(file: ifcopenshell.file, layout: entity_instance, in
|
||||
# because this becomes of placement of the zero length segment
|
||||
last_segment = layout.Segments[-1]
|
||||
settings = ifcopenshell.geom.settings()
|
||||
fn = wrapper.map_shape(settings, last_segment.wrapped_data)
|
||||
fn = wrapper.map_shape(settings, last_segment)
|
||||
eval = wrapper.function_item_evaluator(settings, fn)
|
||||
e = np.array(eval.evaluate(fn.end()))
|
||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(file)
|
||||
@@ -135,7 +135,7 @@ def add_zero_length_segment(file: ifcopenshell.file, layout: entity_instance, in
|
||||
settings = ifcopenshell.geom.settings()
|
||||
mapped_segments = _map_alignment_horizontal_segment(file, last_segment)
|
||||
geometry_segment = mapped_segments[0] if mapped_segments[1] == None else mapped_segments[1]
|
||||
fn = wrapper.map_shape(settings, geometry_segment.wrapped_data)
|
||||
fn = wrapper.map_shape(settings, geometry_segment)
|
||||
eval = wrapper.function_item_evaluator(settings, fn)
|
||||
e = np.array(eval.evaluate(fn.end()))
|
||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(file)
|
||||
@@ -177,7 +177,7 @@ def add_zero_length_segment(file: ifcopenshell.file, layout: entity_instance, in
|
||||
settings = ifcopenshell.geom.settings()
|
||||
mapped_segments = _map_alignment_vertical_segment(file, last_segment)
|
||||
geometry_segment = mapped_segments[0] if mapped_segments[1] == None else mapped_segments[1]
|
||||
fn = wrapper.map_shape(settings, geometry_segment.wrapped_data)
|
||||
fn = wrapper.map_shape(settings, geometry_segment)
|
||||
eval = wrapper.function_item_evaluator(settings, fn)
|
||||
e = np.array(eval.evaluate(fn.end()))
|
||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(file)
|
||||
|
||||
@@ -78,7 +78,7 @@ def create_layout_segment(
|
||||
|
||||
settings = ifcopenshell.geom.settings()
|
||||
|
||||
segment_fn = ifcopenshell_wrapper.map_shape(settings, curve_segment.wrapped_data)
|
||||
segment_fn = ifcopenshell_wrapper.map_shape(settings, curve_segment)
|
||||
segment_evaluator = ifcopenshell_wrapper.function_item_evaluator(settings, segment_fn)
|
||||
e = segment_evaluator.evaluate(segment_fn.end())
|
||||
end = np.array(e)
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ def get_curve_segment_transition_code(
|
||||
settings = ifcopenshell.geom.settings()
|
||||
settings.set("COMPUTE_CURVATURE", True)
|
||||
|
||||
segment_fn = ifcopenshell_wrapper.map_shape(settings, segment.wrapped_data)
|
||||
segment_fn = ifcopenshell_wrapper.map_shape(settings, segment)
|
||||
segment_evaluator = ifcopenshell_wrapper.function_item_evaluator(settings, segment_fn)
|
||||
e = segment_evaluator.evaluate(segment_fn.end())
|
||||
end = np.array(e)
|
||||
@@ -64,7 +64,7 @@ def get_curve_segment_transition_code(
|
||||
# must add the new segment to the container before mapping it, otherwise the segment doesn't
|
||||
# have enough context to know if it is for horizontal, vertical, cant
|
||||
|
||||
next_segment_fn = ifcopenshell_wrapper.map_shape(settings, next_segment.wrapped_data)
|
||||
next_segment_fn = ifcopenshell_wrapper.map_shape(settings, next_segment)
|
||||
next_segment_evaluator = ifcopenshell_wrapper.function_item_evaluator(settings, next_segment_fn)
|
||||
s = next_segment_evaluator.evaluate(next_segment_fn.start())
|
||||
start = np.array(s)
|
||||
|
||||
@@ -49,7 +49,7 @@ def evaluate_representation(shape_rep: entity_instance, dist_along: float) -> np
|
||||
# TODO: confirm point is not beyond limits of alignment
|
||||
|
||||
s = ifcopenshell.geom.settings()
|
||||
function_item = ifcopenshell_wrapper.map_shape(s, shape_rep.wrapped_data)
|
||||
function_item = ifcopenshell_wrapper.map_shape(s, shape_rep)
|
||||
evaluator = ifcopenshell_wrapper.function_item_evaluator(s, function_item)
|
||||
|
||||
trans_matrix = evaluator.evaluate(dist_along)
|
||||
@@ -72,7 +72,7 @@ def evaluate_segment(segment: entity_instance, dist_along: float) -> np.ndarray:
|
||||
raise ValueError(f"Provided value {dist_along=} is beyond the end of the segment ({segment.SegmentLength}).")
|
||||
|
||||
s = ifcopenshell.geom.settings()
|
||||
function_item = ifcopenshell_wrapper.map_shape(s, segment.wrapped_data)
|
||||
function_item = ifcopenshell_wrapper.map_shape(s, segment)
|
||||
evaluator = ifcopenshell_wrapper.function_item_evaluator(s, function_item)
|
||||
|
||||
trans_matrix = evaluator.evaluate(dist_along)
|
||||
|
||||
@@ -453,7 +453,7 @@ class Usecase:
|
||||
# 3 IfcPresentationLayerAssignment.AssignedItems
|
||||
skip_not_reused_entities_attr_i = 2
|
||||
|
||||
element_identity = element.wrapped_data.identity()
|
||||
element_identity = element.identity()
|
||||
|
||||
# Check if inverse element was created before.
|
||||
# Still need to recreate it again - e.g. it could be some rel
|
||||
@@ -489,7 +489,7 @@ class Usecase:
|
||||
if self.is_another_asset(item):
|
||||
continue
|
||||
if skip_not_reused_entities_attr_i is not None and i == skip_not_reused_entities_attr_i:
|
||||
identity = item.wrapped_data.identity()
|
||||
identity = item.identity()
|
||||
if (item := self.reuse_identities.get(identity)) is None:
|
||||
continue
|
||||
else:
|
||||
@@ -603,7 +603,7 @@ class Usecase:
|
||||
return ifc_file.add(element)
|
||||
|
||||
reuse_identities = self.reuse_identities
|
||||
element_identity = element.wrapped_data.identity()
|
||||
element_identity = element.identity()
|
||||
if added_element := reuse_identities.get(element_identity):
|
||||
return added_element
|
||||
|
||||
@@ -614,7 +614,7 @@ class Usecase:
|
||||
nonlocal attributes_
|
||||
if attributes_ is not None:
|
||||
return attributes_
|
||||
attributes_ = element.wrapped_data.declaration().as_entity().all_attributes()
|
||||
attributes_ = element.declaration().as_entity().all_attributes()
|
||||
return attributes_
|
||||
|
||||
def get_existing_element_(
|
||||
@@ -622,7 +622,7 @@ class Usecase:
|
||||
) -> Union[ifcopenshell.entity_instance, None]:
|
||||
# Check identity because `subelement` might not be the current `element`,
|
||||
# e.g. for IfcPersonAndOrganization.
|
||||
element_identity = subelement.wrapped_data.identity()
|
||||
element_identity = subelement.identity()
|
||||
if subelement_ := reuse_identities.get(element_identity):
|
||||
return subelement_
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class Usecase:
|
||||
self.style = style
|
||||
|
||||
attribute_types: dict[str, str] = {}
|
||||
for attribute in style.wrapped_data.declaration().as_entity().all_attributes():
|
||||
for attribute in style.declaration().as_entity().all_attributes():
|
||||
attribute_type = attribute.type_of_attribute()
|
||||
if attribute_type.as_aggregation_type() is None:
|
||||
attribute_type = attribute_type.declared_type().name()
|
||||
|
||||
@@ -903,8 +903,8 @@ def usedin(inst, ref_name):
|
||||
return []
|
||||
_, __, attr = ref_name.split('.')
|
||||
def filter():
|
||||
for ref, attr_idx in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for ref, attr_idx in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ def usedin(inst, ref_name):
|
||||
(_, __, attr) = ref_name.split('.')
|
||||
|
||||
def filter():
|
||||
for (ref, attr_idx) in inst.wrapped_data.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.wrapped_data.get_attribute_names()[attr_idx].lower() == attr:
|
||||
for (ref, attr_idx) in inst.file.get_inverse(inst, allow_duplicate=True, with_attribute_indices=True):
|
||||
if ref.get_attribute_names()[attr_idx].lower() == attr:
|
||||
yield ref
|
||||
return list(filter())
|
||||
|
||||
|
||||
@@ -506,7 +506,9 @@ class file_mixin:
|
||||
|
||||
registry = {}
|
||||
|
||||
def post_init(self, iden):
|
||||
def post_init(self, iden = None):
|
||||
if iden is None:
|
||||
iden = int(self.this)
|
||||
if state := self.registry.get(iden):
|
||||
self.state = state
|
||||
else:
|
||||
@@ -746,9 +748,9 @@ class file_mixin:
|
||||
max_levels = -1
|
||||
|
||||
if breadth_first:
|
||||
fn = self.traverse_breadth_first
|
||||
fn = self._traverse_breadth_first
|
||||
else:
|
||||
fn = self.traverse
|
||||
fn = self._traverse
|
||||
|
||||
return fn(inst, max_levels)
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ class sqlite_entity(entity_instance):
|
||||
# print("GETATTR", self.sqlite_wrapper.id, self.sqlite_wrapper.ifc_class, name)
|
||||
|
||||
INVALID, FORWARD, INVERSE = range(3)
|
||||
attr_cat = self.wrapped_data.get_attribute_category(name)
|
||||
attr_cat = self.get_attribute_category(name)
|
||||
if attr_cat == FORWARD:
|
||||
if self.sqlite_wrapper.attribute_cache:
|
||||
# print(self.sqlite_wrapper.ifc_class)
|
||||
@@ -431,7 +431,7 @@ class sqlite_entity(entity_instance):
|
||||
return self.sqlite_wrapper.inverse_attribute_cache[name]
|
||||
|
||||
raise AttributeError(
|
||||
"entity instance of type '%s' has no attribute '%s'" % (self.wrapped_data.is_a(True), name)
|
||||
"entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name)
|
||||
)
|
||||
|
||||
def unserialise_value(self, value):
|
||||
|
||||
@@ -339,7 +339,7 @@ try:
|
||||
|
||||
def __getattr__(self, name: str) -> Any:
|
||||
INVALID, FORWARD, INVERSE = range(3)
|
||||
attr_cat = self.wrapped_data.get_attribute_category(name)
|
||||
attr_cat = self.get_attribute_category(name)
|
||||
if attr_cat == FORWARD:
|
||||
if self.stream_wrapper.attribute_cache:
|
||||
return self.stream_wrapper.attribute_cache[name]
|
||||
@@ -388,7 +388,7 @@ try:
|
||||
return self.stream_wrapper.inverse_attribute_cache[name]
|
||||
|
||||
raise AttributeError(
|
||||
"entity instance of type '%s' has no attribute '%s'" % (self.wrapped_data.is_a(True), name)
|
||||
"entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name)
|
||||
)
|
||||
|
||||
def __eq__(self, other: stream_entity) -> bool:
|
||||
|
||||
@@ -24,7 +24,7 @@ import ifcopenshell.util.unit
|
||||
def add_linear_placement_fallback_position(file: ifcopenshell.file) -> ifcopenshell.file:
|
||||
import ifcopenshell.api.alignment
|
||||
|
||||
patched_file = ifcopenshell.file.from_string(file.wrapped_data.to_string())
|
||||
patched_file = ifcopenshell.file.from_string(file.to_string())
|
||||
|
||||
linear_placements = patched_file.by_type("IfcLinearPlacement")
|
||||
for lp in linear_placements:
|
||||
@@ -36,7 +36,7 @@ def add_linear_placement_fallback_position(file: ifcopenshell.file) -> ifcopensh
|
||||
def create_alignment_geometry(file: ifcopenshell.file) -> ifcopenshell.file:
|
||||
import ifcopenshell.api.alignment
|
||||
|
||||
patched_file = ifcopenshell.file.from_string(file.wrapped_data.to_string())
|
||||
patched_file = ifcopenshell.file.from_string(file.to_string())
|
||||
|
||||
alignments = patched_file.by_type("IfcAlignment")
|
||||
for alignment in alignments:
|
||||
@@ -49,7 +49,7 @@ def append_zero_length_segments(file: ifcopenshell.file) -> ifcopenshell.file:
|
||||
"""Appends zero length segments to all alignment layouts and layout geometry, if missing."""
|
||||
import ifcopenshell.api.alignment
|
||||
|
||||
patched_file = ifcopenshell.file.from_string(file.wrapped_data.to_string())
|
||||
patched_file = ifcopenshell.file.from_string(file.to_string())
|
||||
|
||||
alignments = patched_file.by_type("IfcAlignment")
|
||||
for alignment in alignments:
|
||||
|
||||
@@ -70,7 +70,7 @@ def get_declaration(element: ifcopenshell.entity_instance):
|
||||
print(declaration.is_abstract()) # False
|
||||
print(declaration.supertype().name()) # IfcBuildingElement
|
||||
"""
|
||||
return element.wrapped_data.declaration().as_entity()
|
||||
return element.declaration().as_entity()
|
||||
|
||||
|
||||
def is_a(declaration: ifcopenshell.ifcopenshell_wrapper.declaration, ifc_class: str) -> bool:
|
||||
@@ -104,7 +104,7 @@ def get_supertypes(
|
||||
.. code:: python
|
||||
|
||||
wall = model.createIfcWall()
|
||||
results = ifcopenshell.util.schema.get_supertypes(wall.wrapped_data.declaration().as_entity())
|
||||
results = ifcopenshell.util.schema.get_supertypes(wall.declaration().as_entity())
|
||||
# [<entity IfcBuildingElement>, <entity IfcElement>, ..., <entity IfcRoot>]
|
||||
"""
|
||||
results = []
|
||||
@@ -462,7 +462,7 @@ class Migrator:
|
||||
) -> None:
|
||||
# NOTE: `attribute` is an attribute in new file schema
|
||||
# print("Migrating attribute", element, new_element, attribute.name())
|
||||
old_file = element.wrapped_data.file
|
||||
old_file = element.file
|
||||
if hasattr(element, attribute.name()):
|
||||
value = getattr(element, attribute.name())
|
||||
# print("Attribute names matched", value)
|
||||
|
||||
@@ -386,7 +386,7 @@ def _get_element_value(element: ifcopenshell.entity_instance, keys: list[str]) -
|
||||
if key in ("x", "y", "z"):
|
||||
value = xyz["xyz".index(key)]
|
||||
else:
|
||||
enh = ifcopenshell.util.geolocation.auto_xyz2enh(element.wrapped_data.file, *xyz)
|
||||
enh = ifcopenshell.util.geolocation.auto_xyz2enh(element.file, *xyz)
|
||||
value = enh[("easting", "northing", "elevation").index(key)]
|
||||
else:
|
||||
value = None
|
||||
@@ -569,7 +569,7 @@ def set_element_value(
|
||||
element: ifcopenshell.entity_instance, value: Union[str, None], *, is_type: bool
|
||||
) -> None:
|
||||
predefined_type = element.PredefinedType
|
||||
declaration = element.wrapped_data.declaration()
|
||||
declaration = element.declaration()
|
||||
entity = declaration.as_entity()
|
||||
enum_attr = next(attr for attr in entity.attributes() if attr.name() == "PredefinedType")
|
||||
enum_items = ifcopenshell.util.attribute.get_enum_items(enum_attr)
|
||||
@@ -639,9 +639,9 @@ def set_element_value(
|
||||
except:
|
||||
# Try to cast
|
||||
data_type = ifcopenshell.util.attribute.get_primitive_type(
|
||||
element.wrapped_data.declaration()
|
||||
element.declaration()
|
||||
.as_entity()
|
||||
.attribute_by_index(element.wrapped_data.get_argument_index(key))
|
||||
.attribute_by_index(element.get_argument_index(key))
|
||||
)
|
||||
if data_type == "string":
|
||||
value = str(value)
|
||||
|
||||
@@ -475,7 +475,7 @@ def get_property_unit(
|
||||
measure_class = None
|
||||
|
||||
if prop.is_a("IfcPhysicalSimpleQuantity"):
|
||||
entity = prop.wrapped_data.declaration().as_entity()
|
||||
entity = prop.declaration().as_entity()
|
||||
measure_class = entity.attribute_by_index(3).type_of_attribute().declared_type().name()
|
||||
elif prop.is_a("IfcPropertySingleValue"):
|
||||
measure_class = prop.NominalValue.is_a()
|
||||
@@ -875,7 +875,7 @@ def convert_file_length_units(ifc_file: ifcopenshell.file, target_units: str = "
|
||||
si_unit = get_unit_name(target_units)
|
||||
|
||||
# Copy all elements from the original file to the patched file
|
||||
file_patched = ifcopenshell.file.from_string(ifc_file.wrapped_data.to_string())
|
||||
file_patched = ifcopenshell.file.from_string(ifc_file.to_string())
|
||||
|
||||
old_length = get_project_unit(file_patched, "LENGTHUNIT")
|
||||
if si_unit:
|
||||
|
||||
@@ -45,7 +45,7 @@ class TestRemoveSurfaceStyleIFC2X3(test.bootstrap.IFC2X3):
|
||||
# See issue #2046, IfcOpenShell exhibits different behaviour - we can
|
||||
# remove entity_instances() without an ID if we create them afresh, but
|
||||
# will segfault if we load them stale.
|
||||
g = ifcopenshell.file.from_string(self.file.wrapped_data.to_string())
|
||||
g = ifcopenshell.file.from_string(self.file.to_string())
|
||||
ifcopenshell.api.style.remove_surface_style(g, style=g.by_type("IfcSurfaceStyleRendering")[0])
|
||||
assert len(list(g)) == 0
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ class TestFile(test.bootstrap.IFC4):
|
||||
|
||||
def test_creating_ifc_data_from_a_string(self):
|
||||
element = self.file.createIfcWall()
|
||||
g = ifcopenshell.file.from_string(self.file.wrapped_data.to_string())
|
||||
g = ifcopenshell.file.from_string(self.file.to_string())
|
||||
assert g.by_id(1).is_a("IfcWall")
|
||||
|
||||
def test_assigning_header(self):
|
||||
|
||||
@@ -93,9 +93,9 @@ def test_rocks():
|
||||
assert f[139].RelatingPropertyDefinition.is_a("IfcPropertySetDefinitionSet")
|
||||
assert {x.id() for x in f[139].RelatingPropertyDefinition[0]} == {136, 138}
|
||||
|
||||
b = f.wrapped_data.key_value_store_query("i|139|5")[2:]
|
||||
b = f.key_value_store_query("i|139|5")[2:]
|
||||
iden = struct.unpack("Q", b)[0]
|
||||
b = f.wrapped_data.key_value_store_query(f"t|{iden}|0")[1:]
|
||||
b = f.key_value_store_query(f"t|{iden}|0")[1:]
|
||||
assert set(struct.unpack("Q", b[i : i + 8])[0] for i in range(1, len(b), 9)) == {136, 138}
|
||||
|
||||
del f
|
||||
|
||||
@@ -242,7 +242,7 @@ class TestConvertFileLengthUnits(test.bootstrap.IFC2X3):
|
||||
ifcopenshell.api.unit.assign_unit(self.file, units=[unit])
|
||||
output = subject.convert_file_length_units(self.file, target_units="METER")
|
||||
# there was some renumbering bug in the rocksdb rewrite this statement is to test for that
|
||||
assert max(i.id() for i in output) == len(output.wrapped_data.entity_names()) + 1
|
||||
assert max(i.id() for i in output) == len(output.entity_names()) + 1
|
||||
assert subject.get_full_unit_name(subject.get_project_unit(output, "LENGTHUNIT")) == "METRE"
|
||||
|
||||
def test_attribute_conversion(self):
|
||||
|
||||
Reference in New Issue
Block a user