mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
declaration as property
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user