mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
entity_instance: switch to use of declaration as a property
Fixes most of the bonsai tests.
This commit is contained in:
@@ -187,7 +187,7 @@ def import_attributes(
|
||||
info = {a.name(): None for a in attributes}
|
||||
info["type"] = element
|
||||
else:
|
||||
assert (entity := element.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.declaration()
|
||||
quantity.declaration
|
||||
.as_entity()
|
||||
.attribute_by_index(3)
|
||||
.type_of_attribute()
|
||||
|
||||
@@ -95,7 +95,7 @@ class ColourByPropertyData:
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if not element:
|
||||
return default
|
||||
keys = [a.name() for a in element.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"):
|
||||
@@ -126,7 +126,7 @@ class SelectSimilarData:
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if not element:
|
||||
return []
|
||||
keys = [a.name() for a in element.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"):
|
||||
|
||||
@@ -2166,7 +2166,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.declaration().as_entity().all_attributes()
|
||||
for a in item.declaration().as_entity.all_attributes()
|
||||
if a.type_of_attribute()._is("IfcLengthMeasure")
|
||||
]
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ class ifc5D2json:
|
||||
data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit)
|
||||
if quantity.is_a("IfcPhysicalSimpleQuantity"):
|
||||
measure_class = (
|
||||
quantity.declaration()
|
||||
quantity.declaration
|
||||
.as_entity()
|
||||
.attribute_by_index(3)
|
||||
.type_of_attribute()
|
||||
|
||||
@@ -765,6 +765,7 @@ class entity_instance(entity_instance_mixin):
|
||||
file_: Any
|
||||
id_: Any
|
||||
def data(self, *args): ...
|
||||
@property
|
||||
def declaration(self) -> declaration: ...
|
||||
def file_pointer(self):
|
||||
"""Internal IfcFile pointer address.
|
||||
|
||||
@@ -749,7 +749,7 @@ class Property(Facet):
|
||||
ifcopenshell.util.unit.si_type_names[unit.UnitType],
|
||||
)
|
||||
elif prop_entity.is_a("IfcPhysicalSimpleQuantity"):
|
||||
prop_schema = prop_entity.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():
|
||||
|
||||
@@ -17,7 +17,7 @@ def main() -> int:
|
||||
|
||||
model = ifx.file.with_path(sys.argv[1])
|
||||
for wall in model.instances_by_type("IfcWall"):
|
||||
print(f"#{wall.id()} {wall.declaration().name()}")
|
||||
print(f"#{wall.id()} {wall.declaration.name()}")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user