This commit is contained in:
Andrej
2025-06-11 11:40:25 +05:00
parent 2741acf4fe
commit cd952d7e54
2 changed files with 82 additions and 36 deletions
@@ -204,6 +204,7 @@ class entity_instance:
vs = entity_instance.wrap_value(self.wrapped_data.get_inverse(name), self.wrapped_data.file)
if settings.unpack_non_aggregate_inverses:
schema_name = self.wrapped_data.is_a(True).split(".")[0]
ent: ifcopenshell_wrapper.entity
ent = ifcopenshell_wrapper.schema_by_name(schema_name).declaration_by_name(self.is_a())
inv = [i for i in ent.all_inverse_attributes() if i.name() == name][0]
if (inv.bound1(), inv.bound2()) == (-1, -1):
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
from typing import Any, Union
from typing import Any, Union, Literal
# `std::vector<xxx>` usually translated to `tuple[xxx, ...]`.
@@ -569,7 +569,7 @@ class aggregation_type(parameter_type):
def bound2(self): ...
def type_of_aggregation(self): ...
def type_of_aggregation_string(self): ...
def type_of_element(self): ...
def type_of_element(self) -> parameter_type: ...
class attribute:
def name(self) -> str: ...
@@ -708,13 +708,16 @@ class cylinder(surface):
class declaration:
def _is(self, *args: str) -> bool: ...
def as_entity(self): ...
def as_enumeration_type(self): ...
def as_select_type(self): ...
def as_type_declaration(self): ...
def index_in_schema(self): ...
def as_entity(self) -> Union[entity, None]: ...
def as_enumeration_type(self) -> Union[enumeration_type, None]: ...
def as_select_type(self) -> Union[select_type, None]: ...
def as_type_declaration(self) -> Union[type_declaration, None]: ...
def index_in_schema(self) -> int: ...
def name(self) -> str: ...
def name_uc(self): ...
def name_uc(self) -> str:
"""Get name in upper case."""
...
def schema(self) -> schema_definition: ...
def type(self): ...
@@ -745,40 +748,63 @@ class ellipse(curve):
class entity(declaration):
def all_attributes(self) -> tuple[attribute, ...]: ...
def all_inverse_attributes(self): ...
def argument_types(self): ...
def as_entity(self): ...
def all_inverse_attributes(self) -> tuple[inverse_attribute, ...]: ...
def argument_types(self) -> tuple[str, ...]:
"""Get a tuple of types for each attribute in ``all_attributes()``."""
...
def as_entity(self) -> entity: ...
def attribute_by_index(self, index: int) -> attribute: ...
def attribute_count(self) -> int: ...
def attribute_index(self, *args): ...
def attributes(self): ...
def attribute_index(self, *args: Union[str, attribute]) -> int:
"""
:param args: A single attribute name / attribute.
"""
...
def attributes(self) -> tuple[attribute, ...]: ...
def derived(self) -> tuple[bool, ...]:
"""Return a tuple of booleans indicating whether each direct attribute is derived."""
...
def is_abstract(self): ...
def is_abstract(self) -> bool: ...
def set_attributes(self, attributes, derived): ...
def set_inverse_attributes(self, inverse_attributes): ...
def set_subtypes(self, subtypes): ...
def subtypes(self): ...
def supertype(self): ...
def subtypes(self) -> tuple[entity, ...]: ...
def supertype(self) -> Union[entity, None]: ...
class entity_instance:
file_: Any
id_: Any
def data(self, *args): ...
def declaration(self): ...
def file_pointer(self): ...
def declaration(self) -> declaration: ...
def file_pointer(self):
"""Internal IfcFile pointer address."""
...
def get_argument(self, *args): ...
def get_argument_index(self, a): ...
def get_argument_name(self, i): ...
def get_argument_type(self, i): ...
def get_attribute_category(self, name): ...
def get_attribute_category(self, name: str) -> Literal[0, 1, 2]:
"""Get attribute category id.
Available categories:
- `0` - invalid attribute
- `1` - forward attribute
- `2` - inverse attributes
"""
...
def get_attribute_names(self): ...
def get_inverse(self, a): ...
def get_inverse_attribute_names(self): ...
def id(self): ...
def identity(self): ...
def id(self) -> int: ...
def identity(self) -> int:
"""Entity instance identity, unique across all opened IFC files during current session."""
...
def is_a(self, *args): ...
def setArgumentAsAggregateOfAggregateOfDouble(self, i, v): ...
def setArgumentAsAggregateOfAggregateOfEntityInstance(self, i, v): ...
@@ -799,11 +825,16 @@ class entity_instance:
def unset_attribute_value(self, i): ...
class enumeration_type(declaration):
def argument_types(self): ...
def as_enumeration_type(self): ...
def enumeration_items(self): ...
def lookup_enum_offset(self, string): ...
def lookup_enum_value(self, i): ...
def argument_types(self) -> tuple[str, ...]: ...
def as_enumeration_type(self) -> enumeration_type: ...
def enumeration_items(self) -> tuple[str, ...]: ...
def lookup_enum_offset(self, string: str) -> int:
"""Get index of the string in enum."""
...
def lookup_enum_value(self, i: int) -> str:
"""Get a string for the index in enum."""
...
class extrusion(sweep):
depth: Any
@@ -843,7 +874,10 @@ class file:
@staticmethod
def createTimestamp(): ...
def entity_names(self): ...
def file_pointer(self): ...
def file_pointer(self) -> int:
"""Internal IfcFile pointer address."""
...
def getInverse(self, instance_id, type, attribute_index): ...
def getMaxId(self): ...
def getTotalInverses(self, instance_id): ...
@@ -861,7 +895,7 @@ class file:
@staticmethod
def guid_map(*args): ...
@property
def header(self): ...
def header(self) -> IfcSpfHeader: ...
def ifcroot_type(self): ...
def instance_by_guid(self, guid): ...
def instances_by_reference(self, id): ...
@@ -1131,18 +1165,29 @@ class revolve(sweep):
def matrix(self): ...
class schema_definition:
def declaration_by_name(self, *args: str) -> declaration: ...
def declarations(self) -> tuple[declaration, ...]: ...
def declaration_by_name(self, *args: str) -> declaration:
"""
:return: ``declaration`` but upcasted to the most advanced available type
(e.g. ``entity``, ``type_declaration``, etc).
"""
...
def declarations(self) -> tuple[declaration, ...]:
"""
:return: returned declarations are also upcasted, see ``declaration_by_name``.
"""
...
def entities(self) -> tuple[entity, ...]: ...
def enumeration_types(self): ...
def enumeration_types(self) -> tuple[enumeration_type, ...]: ...
def select_types(self) -> tuple[select_type, ...]: ...
def type_declarations(self) -> tuple[type_declaration, ...]: ...
def instantiate(self, decl, data): ...
def name(self) -> str: ...
def select_types(self): ...
def type_declarations(self): ...
class select_type(declaration):
def as_select_type(self): ...
def select_list(self): ...
def as_select_type(self) -> select_type: ...
def select_list(self) -> tuple[declaration, ...]: ...
class shell:
closed: Any
@@ -1424,7 +1469,7 @@ class type_by_kind:
class type_declaration(declaration):
def argument_types(self): ...
def as_type_declaration(self): ...
def as_type_declaration(self) -> type_declaration: ...
def declared_type(self): ...
def arrange_polygons(polygons): ...