mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +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 = {a.name(): None for a in attributes}
|
||||||
info["type"] = element
|
info["type"] = element
|
||||||
else:
|
else:
|
||||||
assert (entity := element.declaration().as_entity())
|
assert (entity := element.declaration.as_entity())
|
||||||
attributes = entity.all_attributes()
|
attributes = entity.all_attributes()
|
||||||
info = element.get_info()
|
info = element.get_info()
|
||||||
for attribute in attributes:
|
for attribute in attributes:
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class CostSchedulesData:
|
|||||||
data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit)
|
data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit)
|
||||||
if quantity.is_a("IfcPhysicalSimpleQuantity"):
|
if quantity.is_a("IfcPhysicalSimpleQuantity"):
|
||||||
measure_class = (
|
measure_class = (
|
||||||
quantity.declaration()
|
quantity.declaration
|
||||||
.as_entity()
|
.as_entity()
|
||||||
.attribute_by_index(3)
|
.attribute_by_index(3)
|
||||||
.type_of_attribute()
|
.type_of_attribute()
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class ColourByPropertyData:
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
if not element:
|
if not element:
|
||||||
return default
|
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)
|
psets = ifcopenshell.util.element.get_psets(element)
|
||||||
for pset, properties in psets.items():
|
for pset, properties in psets.items():
|
||||||
if pset.endswith("Common"):
|
if pset.endswith("Common"):
|
||||||
@@ -126,7 +126,7 @@ class SelectSimilarData:
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
if not element:
|
if not element:
|
||||||
return []
|
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)
|
psets = ifcopenshell.util.element.get_psets(element, psets_only=True)
|
||||||
for pset, properties in psets.items():
|
for pset, properties in psets.items():
|
||||||
if pset.endswith("Common"):
|
if pset.endswith("Common"):
|
||||||
|
|||||||
@@ -2166,7 +2166,7 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
item = tool.Ifc.get().by_id(props.ifc_definition_id)
|
item = tool.Ifc.get().by_id(props.ifc_definition_id)
|
||||||
allowed_attributes = [
|
allowed_attributes = [
|
||||||
a.name()
|
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")
|
if a.type_of_attribute()._is("IfcLengthMeasure")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ class ifc5D2json:
|
|||||||
data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit)
|
data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit)
|
||||||
if quantity.is_a("IfcPhysicalSimpleQuantity"):
|
if quantity.is_a("IfcPhysicalSimpleQuantity"):
|
||||||
measure_class = (
|
measure_class = (
|
||||||
quantity.declaration()
|
quantity.declaration
|
||||||
.as_entity()
|
.as_entity()
|
||||||
.attribute_by_index(3)
|
.attribute_by_index(3)
|
||||||
.type_of_attribute()
|
.type_of_attribute()
|
||||||
|
|||||||
@@ -765,6 +765,7 @@ class entity_instance(entity_instance_mixin):
|
|||||||
file_: Any
|
file_: Any
|
||||||
id_: Any
|
id_: Any
|
||||||
def data(self, *args): ...
|
def data(self, *args): ...
|
||||||
|
@property
|
||||||
def declaration(self) -> declaration: ...
|
def declaration(self) -> declaration: ...
|
||||||
def file_pointer(self):
|
def file_pointer(self):
|
||||||
"""Internal IfcFile pointer address.
|
"""Internal IfcFile pointer address.
|
||||||
|
|||||||
@@ -749,7 +749,7 @@ class Property(Facet):
|
|||||||
ifcopenshell.util.unit.si_type_names[unit.UnitType],
|
ifcopenshell.util.unit.si_type_names[unit.UnitType],
|
||||||
)
|
)
|
||||||
elif prop_entity.is_a("IfcPhysicalSimpleQuantity"):
|
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()
|
data_type = prop_schema.attribute_by_index(3).type_of_attribute().declared_type().name()
|
||||||
|
|
||||||
if self.dataType and data_type.lower() != self.dataType.lower():
|
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])
|
model = ifx.file.with_path(sys.argv[1])
|
||||||
for wall in model.instances_by_type("IfcWall"):
|
for wall in model.instances_by_type("IfcWall"):
|
||||||
print(f"#{wall.id()} {wall.declaration().name()}")
|
print(f"#{wall.id()} {wall.declaration.name()}")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user