mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Remove usage of .wrapped_item and some other fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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"}
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"):
|
||||
|
||||
@@ -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")
|
||||
]
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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<const taxonomy::functor_item>(fn),settings);
|
||||
} else if (kind == taxonomy::PIECEWISE_FUNCTION) {
|
||||
@@ -308,6 +308,9 @@ taxonomy::item::ptr function_item_evaluator::evaluate(const std::vector<double>&
|
||||
}
|
||||
|
||||
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<ifcopenshell::geometry::settings::ComputeCurvature>().get()) {
|
||||
m.row(3) = Eigen::Vector4d(0, 0, 0, 1);
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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]])
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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"):
|
||||
|
||||
@@ -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("=")])
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user