diff --git a/src/bcf/bcf/v2/visinfo.py b/src/bcf/bcf/v2/visinfo.py index 46d274ea1d..fc6d9b6822 100644 --- a/src/bcf/bcf/v2/visinfo.py +++ b/src/bcf/bcf/v2/visinfo.py @@ -316,7 +316,7 @@ def build_viewpoint(element: entity_instance) -> mdl.VisualizationInfo: Returns: The BCF viewpoint definition. """ - ifc_file = element.wrapped_data.file + ifc_file = element.file unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file) elem_placement = ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement) elem_placement[:3, 3] *= unit_scale diff --git a/src/bcf/bcf/v3/visinfo.py b/src/bcf/bcf/v3/visinfo.py index 7880ddb10f..14e21468f5 100644 --- a/src/bcf/bcf/v3/visinfo.py +++ b/src/bcf/bcf/v3/visinfo.py @@ -316,7 +316,7 @@ def build_viewpoint(element: entity_instance) -> mdl.VisualizationInfo: Returns: The BCF viewpoint definition. """ - ifc_file = element.wrapped_data.file + ifc_file = element.file unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file) elem_placement = ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement) elem_placement[:3, 3] *= unit_scale diff --git a/src/bonsai/bonsai/bim/helper.py b/src/bonsai/bonsai/bim/helper.py index 49f49582b4..1bf710b69e 100644 --- a/src/bonsai/bonsai/bim/helper.py +++ b/src/bonsai/bonsai/bim/helper.py @@ -181,7 +181,7 @@ def import_attributes( info = {a.name(): None for a in attributes} info["type"] = element else: - assert (entity := element.wrapped_data.declaration().as_entity()) + assert (entity := element.declaration().as_entity()) attributes = entity.all_attributes() info = element.get_info() for attribute in attributes: diff --git a/src/bonsai/bonsai/bim/module/cost/data.py b/src/bonsai/bonsai/bim/module/cost/data.py index 4b5198bb03..ceeaf16815 100644 --- a/src/bonsai/bonsai/bim/module/cost/data.py +++ b/src/bonsai/bonsai/bim/module/cost/data.py @@ -206,7 +206,7 @@ class CostSchedulesData: data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit) if quantity.is_a("IfcPhysicalSimpleQuantity"): measure_class = ( - quantity.wrapped_data.declaration() + quantity.declaration() .as_entity() .attribute_by_index(3) .type_of_attribute() diff --git a/src/bonsai/bonsai/bim/module/debug/operator.py b/src/bonsai/bonsai/bim/module/debug/operator.py index 0820d5e3d6..054c81f0b7 100644 --- a/src/bonsai/bonsai/bim/module/debug/operator.py +++ b/src/bonsai/bonsai/bim/module/debug/operator.py @@ -89,7 +89,7 @@ class PrintIfcFile(bpy.types.Operator): return tool.Ifc.get() def execute(self, context): - print(tool.Ifc.get().wrapped_data.to_string()) + print(tool.Ifc.get().to_string()) return {"FINISHED"} diff --git a/src/bonsai/bonsai/bim/module/geometry/operator.py b/src/bonsai/bonsai/bim/module/geometry/operator.py index e6d8383322..e5a82901cc 100644 --- a/src/bonsai/bonsai/bim/module/geometry/operator.py +++ b/src/bonsai/bonsai/bim/module/geometry/operator.py @@ -785,7 +785,7 @@ def lock_error_message(name: str) -> str: def calc_delete_is_batch(ifc_file: ifcopenshell.file, context: bpy.types.Context) -> bool: - total_elements = len(tool.Ifc.get().wrapped_data.entity_names()) + total_elements = len(tool.Ifc.get().entity_names()) total_polygons = sum([len(o.data.polygons) for o in context.selected_objects if o.type == "MESH"]) # These numbers are a bit arbitrary, but basically batching is only # really necessary on large models and large geometry removals. diff --git a/src/bonsai/bonsai/bim/module/search/data.py b/src/bonsai/bonsai/bim/module/search/data.py index 4bde0aa359..67435d9c33 100644 --- a/src/bonsai/bonsai/bim/module/search/data.py +++ b/src/bonsai/bonsai/bim/module/search/data.py @@ -93,7 +93,7 @@ class ColourByPropertyData: element = tool.Ifc.get_entity(obj) if not element: return default - keys = [a.name() for a in element.wrapped_data.declaration().as_entity().all_attributes()] + keys = [a.name() for a in element.declaration().as_entity().all_attributes()] psets = ifcopenshell.util.element.get_psets(element) for pset, properties in psets.items(): if pset.endswith("Common"): @@ -124,7 +124,7 @@ class SelectSimilarData: element = tool.Ifc.get_entity(obj) if not element: return [] - keys = [a.name() for a in element.wrapped_data.declaration().as_entity().all_attributes()] + keys = [a.name() for a in element.declaration().as_entity().all_attributes()] psets = ifcopenshell.util.element.get_psets(element, psets_only=True) for pset, properties in psets.items(): if pset.endswith("Common"): diff --git a/src/bonsai/bonsai/tool/geometry.py b/src/bonsai/bonsai/tool/geometry.py index e2955d3d28..793d3e77d8 100644 --- a/src/bonsai/bonsai/tool/geometry.py +++ b/src/bonsai/bonsai/tool/geometry.py @@ -1800,7 +1800,7 @@ class Geometry(bonsai.core.tool.Geometry): item = tool.Ifc.get().by_id(props.ifc_definition_id) allowed_attributes = [ a.name() - for a in item.wrapped_data.declaration().as_entity().all_attributes() + for a in item.declaration().as_entity().all_attributes() if a.type_of_attribute()._is("IfcLengthMeasure") ] diff --git a/src/exterior-shell-extractor/main.py b/src/exterior-shell-extractor/main.py index 831c2e10fb..b9a914887e 100644 --- a/src/exterior-shell-extractor/main.py +++ b/src/exterior-shell-extractor/main.py @@ -457,7 +457,7 @@ class context: for f in self.fs: if kwargs.keys() == {'include'}: - kwargs2 = {'include': [e for e in kwargs['include'] if e.wrapped_data.file == f]} + kwargs2 = {'include': [e for e in kwargs['include'] if e.file == f]} else: kwargs2 = kwargs it = ifcopenshell.geom.iterator(s, f, geometry_library="cgal", **kwargs2) diff --git a/src/ifc5d/ifc5d/ifc2json.py b/src/ifc5d/ifc5d/ifc2json.py index fae04126af..39cff58653 100644 --- a/src/ifc5d/ifc5d/ifc2json.py +++ b/src/ifc5d/ifc5d/ifc2json.py @@ -168,7 +168,7 @@ class ifc5D2json: data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit) if quantity.is_a("IfcPhysicalSimpleQuantity"): measure_class = ( - quantity.wrapped_data.declaration() + quantity.declaration() .as_entity() .attribute_by_index(3) .type_of_attribute() diff --git a/src/ifcgeom/function_item_evaluator.cpp b/src/ifcgeom/function_item_evaluator.cpp index 9bacf94ac0..300736800a 100644 --- a/src/ifcgeom/function_item_evaluator.cpp +++ b/src/ifcgeom/function_item_evaluator.cpp @@ -223,7 +223,7 @@ struct offset_fn_evaluator : public fn_evaluator { function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::Settings& settings,taxonomy::function_item::const_ptr fn) { - auto kind = fn->kind(); + auto kind = fn ? fn->kind() : taxonomy::kinds::NODE; if (kind == taxonomy::FUNCTOR_ITEM) { fn_evaluator_ = new functor_fn_evaluator(std::dynamic_pointer_cast(fn),settings); } else if (kind == taxonomy::PIECEWISE_FUNCTION) { @@ -308,6 +308,9 @@ taxonomy::item::ptr function_item_evaluator::evaluate(const std::vector& } Eigen::Matrix4d function_item_evaluator::evaluate(double u) const { + if (fn_evaluator_ == nullptr) { + throw std::runtime_error("Function item not initialized"); + } Eigen::Matrix4d m = fn_evaluator_->evaluate(u); if (!fn_evaluator_->settings_.get().get()) { m.row(3) = Eigen::Vector4d(0, 0, 0, 1); diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index c350d08fbd..6759fb6f3c 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -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 diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_curve.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_curve.py index 4fcadc176e..55c0cc52e2 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_curve.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_curve.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py index bb31342efb..32b3dce5bd 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_stationing_referent.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_stationing_referent.py index 2ac08a2fbf..b22b884661 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_stationing_referent.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_stationing_referent.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py index 5b36cddd75..346ca8904c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/create_layout_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/create_layout_segment.py index 3f6789fd98..40d97d5df4 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/create_layout_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/create_layout_segment.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/get_curve_segment_transition_code.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/get_curve_segment_transition_code.py index 577b14d709..4cbcf39297 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/get_curve_segment_transition_code.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/get_curve_segment_transition_code.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/util.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/util.py index 389f94576a..b61a4273f8 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/util.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/util.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py index 22eb022e99..0951aba498 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py @@ -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_ diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py index 7f7f05948d..7438230ee0 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py +++ b/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py @@ -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() diff --git a/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py b/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py index 545d68c50a..ae4af9e604 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC2X3.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC2X3.py index 345620bdae..0a13b357ee 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC2X3.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC2X3.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4.py index b973c2e484..aea4ab615b 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X1.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X1.py index ca0e5ef130..10f1435d08 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X1.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X1.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X2.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X2.py index 4c0a82ba74..c08d0ca3d3 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X2.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X2.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3.py index 6271263953..249fe6771e 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_ADD1.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_ADD1.py index 53ca078c98..cda94c67d7 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_ADD1.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_ADD1.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_ADD2.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_ADD2.py index 2b09aad1cf..946dfe3b0f 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_ADD2.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_ADD2.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC1.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC1.py index e4488d8c2e..364f475658 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC1.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC1.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC2.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC2.py index 7b8fa6f30b..58f822f610 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC2.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC2.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC3.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC3.py index 787b376787..4def6a3c26 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC3.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC3.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC4.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC4.py index ac69924453..734d59d4ef 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC4.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_RC4.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_TC1.py b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_TC1.py index b607cf8b3a..b835bfefff 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_TC1.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rules/IFC4X3_TC1.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/file.py b/src/ifcopenshell-python/ifcopenshell/file.py index 02ca4b9d64..82e17c217b 100644 --- a/src/ifcopenshell-python/ifcopenshell/file.py +++ b/src/ifcopenshell-python/ifcopenshell/file.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/sql.py b/src/ifcopenshell-python/ifcopenshell/sql.py index 18665f0d72..579231240e 100644 --- a/src/ifcopenshell-python/ifcopenshell/sql.py +++ b/src/ifcopenshell-python/ifcopenshell/sql.py @@ -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): diff --git a/src/ifcopenshell-python/ifcopenshell/stream.py b/src/ifcopenshell-python/ifcopenshell/stream.py index f5fc60d04b..6f4309f1b8 100644 --- a/src/ifcopenshell-python/ifcopenshell/stream.py +++ b/src/ifcopenshell-python/ifcopenshell/stream.py @@ -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: diff --git a/src/ifcopenshell-python/ifcopenshell/util/alignment.py b/src/ifcopenshell-python/ifcopenshell/util/alignment.py index ad6c6dd65d..a2e9c08455 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/alignment.py +++ b/src/ifcopenshell-python/ifcopenshell/util/alignment.py @@ -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: diff --git a/src/ifcopenshell-python/ifcopenshell/util/schema.py b/src/ifcopenshell-python/ifcopenshell/util/schema.py index d3d7b65c6a..02ee72bd72 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/schema.py +++ b/src/ifcopenshell-python/ifcopenshell/util/schema.py @@ -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()) # [, , ..., ] """ 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) diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index a2ce6fb467..743d8d15c8 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/util/unit.py b/src/ifcopenshell-python/ifcopenshell/util/unit.py index cc767fe3a7..850b609846 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/unit.py +++ b/src/ifcopenshell-python/ifcopenshell/util/unit.py @@ -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: diff --git a/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py b/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py index 14f8173a3a..23b95f8771 100644 --- a/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py +++ b/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py @@ -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 diff --git a/src/ifcopenshell-python/test/test_file.py b/src/ifcopenshell-python/test/test_file.py index 31c77cd6e6..0c9bd4eda9 100644 --- a/src/ifcopenshell-python/test/test_file.py +++ b/src/ifcopenshell-python/test/test_file.py @@ -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): diff --git a/src/ifcopenshell-python/test/test_streaming_rocksdb_and_simpletyperefs.py b/src/ifcopenshell-python/test/test_streaming_rocksdb_and_simpletyperefs.py index b0bfb2925a..5673678ba5 100644 --- a/src/ifcopenshell-python/test/test_streaming_rocksdb_and_simpletyperefs.py +++ b/src/ifcopenshell-python/test/test_streaming_rocksdb_and_simpletyperefs.py @@ -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 diff --git a/src/ifcopenshell-python/test/util/test_unit.py b/src/ifcopenshell-python/test/util/test_unit.py index 6e28a28e70..8b25e6bc7d 100644 --- a/src/ifcopenshell-python/test/util/test_unit.py +++ b/src/ifcopenshell-python/test/util/test_unit.py @@ -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): diff --git a/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py b/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py index 1e8ac55b7c..35c4aaffcb 100644 --- a/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py +++ b/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py @@ -204,7 +204,7 @@ class Patcher(ifcpatch.BasePatcher): d.name() for d in self.schema.declarations() if isinstance(d, ifcopenshell.ifcopenshell_wrapper.entity) ] else: - ifc_classes = self.file.wrapped_data.types() + ifc_classes = self.file.types() for ifc_class in ifc_classes: declaration = self.schema.declaration_by_name(ifc_class) diff --git a/src/ifcpatch/ifcpatch/recipes/PatchStationReferentPosition.py b/src/ifcpatch/ifcpatch/recipes/PatchStationReferentPosition.py index 556c43a094..b304249ad4 100644 --- a/src/ifcpatch/ifcpatch/recipes/PatchStationReferentPosition.py +++ b/src/ifcpatch/ifcpatch/recipes/PatchStationReferentPosition.py @@ -22,7 +22,7 @@ class Patcher(ifcpatch.BasePatcher): self.file_patched: ifcopenshell.file def patch(self): - patched_file = ifcopenshell.file.from_string(self.file.wrapped_data.to_string()) + patched_file = ifcopenshell.file.from_string(self.file.to_string()) alignments = patched_file.by_type("IfcAlignment") for alignment in alignments: @@ -31,12 +31,12 @@ class Patcher(ifcpatch.BasePatcher): nests = alignment.IsNestedBy first_referent = nests[1].RelatedObjects[0] start_station = ifcopenshell.util.element.get_pset(first_referent, "Pset_Stationing", "Station") - # start_station = first_referent.IsDefinedBy[0].RelatingPropertyDefinition.HasProperties[0].NominalValue.wrapped_data # get station from first_referent + # start_station = first_referent.IsDefinedBy[0].RelatingPropertyDefinition.HasProperties[0].NominalValue # get station from first_referent for referent in nests[1].RelatedObjects: if referent.ObjectPlacement == None: # Need to get Station property from Pset_Stationing + Station property from the first referent... the DistanceAlong is the different in these values station = ifcopenshell.util.element.get_pset(referent, "Pset_Stationing", "Station") - # station = referent.IsDefinedBy[0].RelatingPropertyDefinition.HasProperties[0].NominalValue.wrapped_data # get station from current referent + # station = referent.IsDefinedBy[0].RelatingPropertyDefinition.HasProperties[0].NominalValue # get station from current referent object_placement = patched_file.createIfcLinearPlacement( RelativePlacement=patched_file.createIfcAxis2PlacementLinear( Location=patched_file.createIfcPointByDistanceExpression( diff --git a/src/ifcpatch/ifcpatch/recipes/RecycleNonRootedElements.py b/src/ifcpatch/ifcpatch/recipes/RecycleNonRootedElements.py index 93ab762778..b1ab03fd75 100644 --- a/src/ifcpatch/ifcpatch/recipes/RecycleNonRootedElements.py +++ b/src/ifcpatch/ifcpatch/recipes/RecycleNonRootedElements.py @@ -65,7 +65,7 @@ class Patcher: deleted.sort() deleted_q = deque(deleted) new = "" - for line in self.file.wrapped_data.to_string().split("\n"): + for line in self.file.to_string().split("\n"): try: if int(line.split("=")[0][1:]) != deleted_q[0]: new += line + "\n" diff --git a/src/ifcsverchok/nodes/ifc/create_project.py b/src/ifcsverchok/nodes/ifc/create_project.py index cc782de19d..c9c54b77f8 100644 --- a/src/ifcsverchok/nodes/ifc/create_project.py +++ b/src/ifcsverchok/nodes/ifc/create_project.py @@ -52,7 +52,7 @@ class SvIfcCreateProject(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helpe # file file = self.inputs["file"].sv_get()[0][0] if file: - schema_name = file.wrapped_data.schema + schema_name = file.schema else: schema_name = "IFC4" diff --git a/src/ifcsverchok/nodes/ifc/remove.py b/src/ifcsverchok/nodes/ifc/remove.py index 2e76d28896..a5558e3bc4 100644 --- a/src/ifcsverchok/nodes/ifc/remove.py +++ b/src/ifcsverchok/nodes/ifc/remove.py @@ -57,7 +57,7 @@ class SvIfcRemove(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfc def process(self): file: ifcopenshell.file file = self.inputs["file"].sv_get()[0][0] - self.new_file = ifcopenshell.file.from_string(file.wrapped_data.to_string()) + self.new_file = ifcopenshell.file.from_string(file.to_string()) self.remove_entity(self.inputs["entity"].sv_get()) self.outputs["file"].sv_set([[self.new_file]]) diff --git a/src/ifctester/ifctester/facet.py b/src/ifctester/ifctester/facet.py index 6b5536299d..321632dfcb 100644 --- a/src/ifctester/ifctester/facet.py +++ b/src/ifctester/ifctester/facet.py @@ -214,7 +214,7 @@ class Entity(Facet): pass else: results = [] - ifc_classes = [t for t in ifc_file.wrapped_data.types() if t.upper() == self.name] + ifc_classes = [t for t in ifc_file.types() if t.upper() == self.name] for ifc_class in ifc_classes: try: results.extend(ifc_file.by_type(ifc_class, include_subtypes=False)) @@ -303,7 +303,7 @@ class Attribute(Facet): def __call__(self, inst: ifcopenshell.entity_instance, logger: Optional[Logger] = None) -> AttributeResult: if isinstance(self.name, str): names = [self.name] - attribute_type = inst.wrapped_data.get_attribute_category(self.name) + attribute_type = inst.get_attribute_category(self.name) if attribute_type == 1: # Forward attribute values = [getattr(inst, self.name, None)] else: @@ -314,7 +314,7 @@ class Attribute(Facet): values = [] for k, v in info.items(): if k == self.name: - attribute_type = inst.wrapped_data.get_attribute_category(k) + attribute_type = inst.get_attribute_category(k) if attribute_type == 1: # Forward attribute names.append(k) values.append(v) @@ -338,13 +338,13 @@ class Attribute(Facet): elif value == tuple(): is_empty = True else: - argument_index = inst.wrapped_data.get_argument_index(names[i]) + argument_index = inst.get_argument_index(names[i]) try: attribute_type = inst.attribute_type(argument_index) if attribute_type == "LOGICAL" and value == "UNKNOWN": is_empty = True except: - if names[i] in inst.wrapped_data.get_inverse_attribute_names(): + if names[i] in inst.get_inverse_attribute_names(): is_empty = True if not is_empty: non_empty_values.append(value) @@ -700,7 +700,7 @@ class Property(Facet): prop = pset_props.get(self.baseName) if prop == "UNKNOWN" and next( p - for p in self.get_properties(inst.wrapped_data.file.by_id(pset_props["id"])) + for p in self.get_properties(inst.file.by_id(pset_props["id"])) if p.Name == self.baseName ).NominalValue.is_a("IfcLogical"): pass @@ -718,7 +718,7 @@ class Property(Facet): reason = {"type": "NOVALUE"} break - pset_entity = inst.wrapped_data.file.by_id(pset_props["id"]) + pset_entity = inst.file.by_id(pset_props["id"]) is_property_supported_class = True for prop_entity in self.get_properties(pset_entity): @@ -735,7 +735,7 @@ class Property(Facet): reason = {"type": "DATATYPE", "actual": data_type, "dataType": self.dataType} break - unit = ifcopenshell.util.unit.get_property_unit(prop_entity, inst.wrapped_data.file) + unit = ifcopenshell.util.unit.get_property_unit(prop_entity, inst.file) if unit and getattr(unit, "Name", None): # TODO support unnamed derived units output_prefix = "KILO" if unit.UnitType == "MASSUNIT" else None @@ -747,7 +747,7 @@ class Property(Facet): ifcopenshell.util.unit.si_type_names[unit.UnitType], ) elif prop_entity.is_a("IfcPhysicalSimpleQuantity"): - prop_schema = prop_entity.wrapped_data.declaration().as_entity() + prop_schema = prop_entity.declaration().as_entity() data_type = prop_schema.attribute_by_index(3).type_of_attribute().declared_type().name() if self.dataType and data_type.lower() != self.dataType.lower(): @@ -755,7 +755,7 @@ class Property(Facet): reason = {"type": "DATATYPE", "actual": data_type, "dataType": self.dataType} break - unit = ifcopenshell.util.unit.get_property_unit(prop_entity, inst.wrapped_data.file) + unit = ifcopenshell.util.unit.get_property_unit(prop_entity, inst.file) if unit: props[pset_name][prop_entity.Name] = ifcopenshell.util.unit.convert( prop_entity[3], @@ -784,7 +784,7 @@ class Property(Facet): is_pass = False reason = {"type": "DATATYPE", "actual": data_type, "dataType": self.dataType} break - unit = ifcopenshell.util.unit.get_property_unit(prop_entity, inst.wrapped_data.file) + unit = ifcopenshell.util.unit.get_property_unit(prop_entity, inst.file) if unit: props[pset_name][prop_entity.Name] = [ ifcopenshell.util.unit.convert( @@ -807,7 +807,7 @@ class Property(Facet): is_pass = False reason = {"type": "DATATYPE", "actual": data_type, "dataType": self.dataType} break - unit = ifcopenshell.util.unit.get_property_unit(prop_entity, inst.wrapped_data.file) + unit = ifcopenshell.util.unit.get_property_unit(prop_entity, inst.file) if unit: values = [ ifcopenshell.util.unit.convert( @@ -822,7 +822,7 @@ class Property(Facet): props[pset_name][prop_entity.Name] = values elif prop_entity.is_a("IfcPropertyTableValue"): values = [] - units = ifcopenshell.util.unit.get_property_table_unit(prop_entity, inst.wrapped_data.file) + units = ifcopenshell.util.unit.get_property_table_unit(prop_entity, inst.file) for attribute in ["Defining", "Defined"]: column_values = props[pset_name][prop_entity.Name][f"{attribute}Values"] if not column_values: diff --git a/src/ifctester/ifctester/reporter.py b/src/ifctester/ifctester/reporter.py index 2ce8a8c45f..b7344b0111 100644 --- a/src/ifctester/ifctester/reporter.py +++ b/src/ifctester/ifctester/reporter.py @@ -811,7 +811,7 @@ class Bcf(Json): if getattr(element, "ObjectPlacement", None): placement = ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement) if unit_scale is None: - unit_scale = ifcopenshell.util.unit.calculate_unit_scale(element.wrapped_data.file) + unit_scale = ifcopenshell.util.unit.calculate_unit_scale(element.file) location = [(o * unit_scale) + 5.0 for o in placement[:, 3][:3]] viewpoint = topic.add_viewpoint_from_point_and_guids(np.array(location), element.GlobalId) if element.is_a("IfcElement"): diff --git a/src/ifctester/test/ids_doc_generator.py b/src/ifctester/test/ids_doc_generator.py index fa95854d35..b02d6908cb 100644 --- a/src/ifctester/test/ids_doc_generator.py +++ b/src/ifctester/test/ids_doc_generator.py @@ -62,7 +62,7 @@ class FacetDocGenerator: result = "pass" if expected is True else "fail" - ifc = inst.wrapped_data.file + ifc = inst.file if "GlobalId" not in name: regenerate_guids(ifc) @@ -81,7 +81,7 @@ class FacetDocGenerator: raise Exception("About to emit invalid example data:", issue) # ifc_text = "\n".join([f"{e} /* Testcase */" if e == inst else str(e) for e in f]) - lines = ifc.wrapped_data.to_string().split("\n")[7:-3] + lines = ifc.to_string().split("\n")[7:-3] ifc_text = "\n".join([f"{l} /* Testcase */" if f"#{inst.id()}=" in l else l for l in lines]) basename = f"{result}-" + re.sub("[^0-9a-zA-Z]", "_", name.lower()) @@ -152,7 +152,7 @@ class IdsDocGenerator: for issue in l.statements: raise Exception("About to emit invalid example data:", issue) - lines = ifc.wrapped_data.to_string().split("\n")[7:-3] + lines = ifc.to_string().split("\n")[7:-3] ifc_text = "" for i, line in enumerate(lines): step_id = int(line[1 : line.index("=")]) diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index 6cae0fc2ca..d2b27bec31 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -78,6 +78,8 @@ // _add() because mixin defined add which adds transaction logic %rename("_add") addEntity; %rename("remove") removeEntity; +%rename("_traverse") traverse; +%rename("_traverse_breadth_first") traverse_breadth_first; class attribute_value_derived {}; %{ @@ -533,10 +535,14 @@ private: } } - const char* const get_argument_type(unsigned int i) const { + const char* const attribute_type(unsigned int i) const { return IfcUtil::ArgumentTypeToString(helper_fn_attribute_type($self, i)); } + const char* const attribute_type(const std::string& name) const { + return IfcUtil::ArgumentTypeToString(helper_fn_attribute_type($self, express_Base_get_argument_index($self, name))); + } + const std::string& attribute_name(unsigned int i) const { if ($self->declaration().as_entity()) { return $self->declaration().as_entity()->attribute_by_index(i)->name(); diff --git a/src/opencdeserver/api/app/ifcgraph/ifcgraph.py b/src/opencdeserver/api/app/ifcgraph/ifcgraph.py index afe1c36749..7a0843f457 100644 --- a/src/opencdeserver/api/app/ifcgraph/ifcgraph.py +++ b/src/opencdeserver/api/app/ifcgraph/ifcgraph.py @@ -42,9 +42,9 @@ def create_pure_node_from_ifc_entity(ifc_entity, ifc_file, hierarchy=True): node.add_label(ifc_entity.is_a()) attributes_type = ["ENTITY INSTANCE", "AGGREGATE OF ENTITY INSTANCE", "DERIVED"] for i in range(ifc_entity.__len__()): - if not ifc_entity.wrapped_data.get_argument_type(i) in attributes_type: - name = ifc_entity.wrapped_data.get_argument_name(i) - name_value = ifc_entity.wrapped_data.get_argument(i) + if not ifc_entity.get_argument_type(i) in attributes_type: + name = ifc_entity.get_argument_name(i) + name_value = ifc_entity.get_argument(i) node[name] = name_value node.__primarylabel__ = "Root" node.__primarykey__ = "id" @@ -57,21 +57,21 @@ def create_graph_from_ifc_entity_all(graph, ifc_entity, ifc_file): graph.merge(node) for i in range(ifc_entity.__len__()): if ifc_entity[i]: - if ifc_entity.wrapped_data.get_argument_type(i) == "ENTITY INSTANCE": + if ifc_entity.get_argument_type(i) == "ENTITY INSTANCE": if ifc_entity[i].is_a() in ["IfcOwnerHistory"] and ifc_entity.is_a() != "IfcProject": continue else: sub_node = create_pure_node_from_ifc_entity(ifc_entity[i], ifc_file) - REL = Relationship(node, ifc_entity.wrapped_data.get_argument_name(i), sub_node) + REL = Relationship(node, ifc_entity.get_argument_name(i), sub_node) graph.merge(REL) - elif ifc_entity.wrapped_data.get_argument_type(i) == "AGGREGATE OF ENTITY INSTANCE": + elif ifc_entity.get_argument_type(i) == "AGGREGATE OF ENTITY INSTANCE": for sub_entity in ifc_entity[i]: sub_node = create_pure_node_from_ifc_entity(sub_entity, ifc_file) - REL = Relationship(node, ifc_entity.wrapped_data.get_argument_name(i), sub_node) + REL = Relationship(node, ifc_entity.get_argument_name(i), sub_node) graph.merge(REL) - for rel_name in ifc_entity.wrapped_data.get_inverse_attribute_names(): - if ifc_entity.wrapped_data.get_inverse(rel_name): - inverse_relations = ifc_entity.wrapped_data.get_inverse(rel_name) + for rel_name in ifc_entity.get_inverse_attribute_names(): + if ifc_entity.get_inverse(rel_name): + inverse_relations = ifc_entity.get_inverse(rel_name) for wrapped_rel_entity in inverse_relations: rel_entity = ifc_file.by_id(wrapped_rel_entity.id()) sub_node = create_pure_node_from_ifc_entity(rel_entity, ifc_file) @@ -82,8 +82,8 @@ def create_graph_from_ifc_entity_all(graph, ifc_entity, ifc_file): def create_full_graph(graph, ifc_file): idx = 1 - length = len(ifc_file.wrapped_data.entity_names()) - for entity_id in ifc_file.wrapped_data.entity_names(): + length = len(ifc_file.entity_names()) + for entity_id in ifc_file.entity_names(): entity = ifc_file.by_id(entity_id) print(idx, "/", length, entity) create_graph_from_ifc_entity_all(graph, entity, ifc_file)