This commit is contained in:
Andrej730
2024-03-04 15:46:36 +05:00
parent a2fdd93e6b
commit b7e26bacea
3 changed files with 49 additions and 22 deletions
@@ -30,6 +30,7 @@ import functools
import subprocess
import sys
import time
from typing import Union
from . import ifcopenshell_wrapper
from . import settings
@@ -117,6 +118,8 @@ class entity_instance(object):
>>> #423=IfcProductDefinitionShape($,$,(#409,#421))
"""
wrapped_data: ifcopenshell_wrapper.entity_instance
def __init__(self, e, file=None):
if isinstance(e, tuple):
e = ifcopenshell_wrapper.new_IfcBaseClass(*e)
@@ -221,7 +224,7 @@ class entity_instance(object):
return entity_instance.walk(is_instance, unwrap, v)
def attribute_type(self, attr):
def attribute_type(self, attr: int) -> str:
"""Return the data type of a positional attribute of the element
:param attr: The index of the attribute
@@ -231,7 +234,7 @@ class entity_instance(object):
attr_idx = attr if isinstance(attr, numbers.Integral) else self.wrapped_data.get_argument_index(attr)
return self.wrapped_data.get_argument_type(attr_idx)
def attribute_name(self, attr_idx):
def attribute_name(self, attr_idx: int) -> str:
"""Return the name of a positional attribute of the element
:param attr_idx: The index of the attribute
@@ -272,7 +275,7 @@ class entity_instance(object):
def __repr__(self):
return repr(self.wrapped_data)
def to_string(self, valid_spf=True):
def to_string(self, valid_spf=True) -> str:
"""Returns a string representation of the current entity instance.
Equal to str(self) when valid_spf=False. When valid_spf is True
returns a representation of the string that conforms to valid Step
@@ -283,7 +286,7 @@ class entity_instance(object):
return self.wrapped_data.to_string(valid_spf)
def is_a(self, *args):
def is_a(self, *args) -> Union[str, bool]:
"""Return the IFC class name of an instance, or checks if an instance belongs to a class.
The check will also return true if a parent class name is provided.
@@ -306,7 +309,7 @@ class entity_instance(object):
"""
return self.wrapped_data.is_a(*args)
def id(self):
def id(self) -> int:
"""Return the STEP numerical identifier
:rtype: int
@@ -335,7 +338,7 @@ class entity_instance(object):
other.wrapped_data.file_pointer(),
)
def is_entity(self):
def is_entity(self) -> bool:
"""Tests whether the instance is an entity type as opposed to a simple data type.
Returns:
@@ -430,7 +433,9 @@ class entity_instance(object):
)
)
def get_info(self, include_identifier=True, recursive=False, return_type=dict, ignore=(), scalar_only=False):
def get_info(
self, include_identifier=True, recursive=False, return_type=dict, ignore=(), scalar_only=False
) -> dict:
"""Return a dictionary of the entity_instance's properties (Python and IFC) and their values.
:param include_identifier: Whether or not to include the STEP numerical identifier