declaration as property

This commit is contained in:
Thomas Krijnen
2026-01-15 16:11:58 +01:00
parent d82e1da907
commit 5c4046e054
5 changed files with 8 additions and 8 deletions
@@ -615,7 +615,7 @@ class Usecase:
nonlocal attributes_
if attributes_ is not None:
return attributes_
attributes_ = element.declaration().as_entity().all_attributes()
attributes_ = element.declaration.all_attributes()
return attributes_
def get_existing_element_(
@@ -81,7 +81,7 @@ class Usecase:
self.style = style
attribute_types: dict[str, str] = {}
for attribute in style.declaration().as_entity().all_attributes():
for attribute in style.declaration.all_attributes():
attribute_type = attribute.type_of_attribute()
if attribute_type.as_aggregation_type() is None:
attribute_type = attribute_type.declared_type().name()
@@ -70,7 +70,7 @@ def get_declaration(element: ifcopenshell.entity_instance):
print(declaration.is_abstract()) # False
print(declaration.supertype().name()) # IfcBuildingElement
"""
return element.declaration().as_entity()
return element.declaration
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.declaration().as_entity())
results = ifcopenshell.util.schema.get_supertypes(wall.declaration.as_entity())
# [<entity IfcBuildingElement>, <entity IfcElement>, ..., <entity IfcRoot>]
"""
results = []
@@ -569,8 +569,8 @@ def set_element_value(
element: ifcopenshell.entity_instance, value: Union[str, None], *, is_type: bool
) -> None:
predefined_type = element.PredefinedType
declaration = element.declaration()
entity = declaration.as_entity()
declaration = element.declaration
entity = declaration
enum_attr = next(attr for attr in entity.attributes() if attr.name() == "PredefinedType")
enum_items = ifcopenshell.util.attribute.get_enum_items(enum_attr)
@@ -639,7 +639,7 @@ def set_element_value(
except:
# Try to cast
data_type = ifcopenshell.util.attribute.get_primitive_type(
element.declaration().as_entity().attribute_by_index(element.get_argument_index(key))
element.declaration.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.declaration().as_entity()
entity = prop.declaration
measure_class = entity.attribute_by_index(3).type_of_attribute().declared_type().name()
elif prop.is_a("IfcPropertySingleValue"):
measure_class = prop.NominalValue.is_a()