Remove usage of .wrapped_item and some other fixes

This commit is contained in:
Thomas Krijnen
2026-01-10 11:01:18 +01:00
parent 5c9213426f
commit b66b04b001
55 changed files with 129 additions and 118 deletions
+13 -13
View 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:
+1 -1
View File
@@ -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"):
+3 -3
View File
@@ -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("=")])