mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
typing
This commit is contained in:
@@ -32,7 +32,7 @@ import blenderbim.bim.import_ifc
|
||||
from math import radians, pi
|
||||
from mathutils import Vector, Matrix
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from typing import List, Union
|
||||
from typing import Union
|
||||
|
||||
|
||||
class Geometry(blenderbim.core.tool.Geometry):
|
||||
@@ -889,7 +889,7 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
return inverse
|
||||
|
||||
@classmethod
|
||||
def get_shape_aspect_styles(cls, element, shape_aspect, representation_item) -> List[ifcopenshell.entity_instance]:
|
||||
def get_shape_aspect_styles(cls, element, shape_aspect, representation_item) -> list[ifcopenshell.entity_instance]:
|
||||
"""update `representation_item` style based on styles connected to the `shape_aspect`
|
||||
through material constituents with the same name
|
||||
"""
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.sequence
|
||||
|
||||
|
||||
|
||||
@@ -448,7 +448,7 @@ class file(object):
|
||||
[self.transaction.store_create(e) for e in reversed(added_elements)]
|
||||
return result
|
||||
|
||||
def by_type(self, type: str, include_subtypes=True) -> List[ifcopenshell.entity_instance]:
|
||||
def by_type(self, type: str, include_subtypes=True) -> list[ifcopenshell.entity_instance]:
|
||||
"""Return IFC objects filtered by IFC Type and wrapped with the entity_instance class.
|
||||
|
||||
If an IFC type class has subclasses, all entities of those subclasses are also returned.
|
||||
@@ -458,7 +458,7 @@ class file(object):
|
||||
:param include_subtypes: Whether or not to return subtypes of the IFC class
|
||||
:type include_subtypes: bool
|
||||
:returns: A list of ifcopenshell.entity_instance.entity_instance objects
|
||||
:rtype: list
|
||||
:rtype: list[ifcopenshell.entity_instance.entity_instance]
|
||||
"""
|
||||
if include_subtypes:
|
||||
return [entity_instance(e, self) for e in self.wrapped_data.by_type(type)]
|
||||
@@ -466,7 +466,7 @@ class file(object):
|
||||
|
||||
def traverse(
|
||||
self, inst: ifcopenshell.entity_instance, max_levels=None, breadth_first=False
|
||||
) -> List[ifcopenshell.entity_instance]:
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
"""Get a list of all referenced instances for a particular instance including itself
|
||||
|
||||
:param inst: The entity instance to get all sub instances
|
||||
@@ -476,7 +476,7 @@ class file(object):
|
||||
:param breadth_first: Whether to use breadth-first search, the default is depth-first.
|
||||
:type max_levels: bool
|
||||
:returns: A list of ifcopenshell.entity_instance.entity_instance objects
|
||||
:rtype: list
|
||||
:rtype: list[ifcopenshell.entity_instance.entity_instance]
|
||||
"""
|
||||
if max_levels is None:
|
||||
max_levels = -1
|
||||
@@ -490,7 +490,7 @@ class file(object):
|
||||
|
||||
def get_inverse(
|
||||
self, inst: ifcopenshell.entity_instance, allow_duplicate=False, with_attribute_indices=False
|
||||
) -> List[ifcopenshell.entity_instance]:
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
"""Return a list of entities that reference this entity
|
||||
|
||||
:param inst: The entity instance to get inverse relationships
|
||||
@@ -499,7 +499,7 @@ class file(object):
|
||||
:param with_attribute_indices: Returns pairs of <i, idx>
|
||||
where i[idx] is inst or contains inst. Requires allow_duplicate=True
|
||||
:returns: A list of ifcopenshell.entity_instance.entity_instance objects
|
||||
:rtype: list
|
||||
:rtype: list[ifcopenshell.entity_instance.entity_instance]
|
||||
"""
|
||||
if with_attribute_indices and not allow_duplicate:
|
||||
raise ValueError("with_attribute_indices requires allow_duplicate to be True")
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
from __future__ import annotations
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
from typing import List, Any, Callable, Optional, Union
|
||||
from typing import Any, Callable, Optional, Union
|
||||
|
||||
|
||||
def get_pset(
|
||||
@@ -379,7 +379,7 @@ def get_type(element: ifcopenshell.entity_instance) -> ifcopenshell.entity_insta
|
||||
return relationship.RelatingType
|
||||
|
||||
|
||||
def get_types(type: ifcopenshell.entity_instance) -> List[ifcopenshell.entity_instance]:
|
||||
def get_types(type: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
"""Get all the occurrences of a type element
|
||||
|
||||
:param type: The type element
|
||||
@@ -401,7 +401,7 @@ def get_types(type: ifcopenshell.entity_instance) -> List[ifcopenshell.entity_in
|
||||
return []
|
||||
|
||||
|
||||
def get_shape_aspects(element: ifcopenshell.entity_instance) -> List[ifcopenshell.entity_instance]:
|
||||
def get_shape_aspects(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
"""Gets element shape aspects
|
||||
|
||||
:param element: The element to get the shape aspects of.
|
||||
@@ -471,7 +471,7 @@ def get_material(
|
||||
return get_material(relating_type, should_skip_usage)
|
||||
|
||||
|
||||
def get_materials(element: ifcopenshell.entity_instance, should_inherit=True) -> List[ifcopenshell.entity_instance]:
|
||||
def get_materials(element: ifcopenshell.entity_instance, should_inherit=True) -> list[ifcopenshell.entity_instance]:
|
||||
"""Gets individual materials of an element
|
||||
|
||||
If the element has a material set, the individual materials of that set are
|
||||
@@ -506,7 +506,7 @@ def get_materials(element: ifcopenshell.entity_instance, should_inherit=True) ->
|
||||
return list(material.Materials)
|
||||
|
||||
|
||||
def get_styles(element: ifcopenshell.entity_instance) -> List[ifcopenshell.entity_instance]:
|
||||
def get_styles(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
"""Retrieves the styles used in an element's representation.
|
||||
|
||||
Styles may be retreived from the material or the body representation.
|
||||
@@ -552,7 +552,7 @@ def get_styles(element: ifcopenshell.entity_instance) -> List[ifcopenshell.entit
|
||||
|
||||
def get_elements_by_material(
|
||||
ifc_file: ifcopenshell.file, material: ifcopenshell.entity_instance
|
||||
) -> List[ifcopenshell.entity_instance]:
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
"""Retrieves the elements related to a material.
|
||||
|
||||
This includes elements using the material as part of a material set or set
|
||||
@@ -596,7 +596,7 @@ def get_elements_by_material(
|
||||
|
||||
def get_elements_by_style(
|
||||
ifc_file: ifcopenshell.file, style: ifcopenshell.entity_instance
|
||||
) -> List[ifcopenshell.entity_instance]:
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
"""Retrieves the elements whose geometric representation uses a style
|
||||
|
||||
:param ifc_file: The IFC file
|
||||
@@ -638,7 +638,7 @@ def get_elements_by_style(
|
||||
|
||||
def get_elements_by_representation(
|
||||
ifc_file: ifcopenshell.file, representation: ifcopenshell.entity_instance
|
||||
) -> List[ifcopenshell.entity_instance]:
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
"""Gets all elements using a geometric representation
|
||||
|
||||
:param ifc_file: The IFC file
|
||||
@@ -672,7 +672,7 @@ def get_elements_by_representation(
|
||||
|
||||
def get_elements_by_layer(
|
||||
ifc_file: ifcopenshell.file, layer: ifcopenshell.entity_instance
|
||||
) -> List[ifcopenshell.entity_instance]:
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
"""Get all the elements that are used by a presentation layer
|
||||
|
||||
:param ifc_file: The IFC file
|
||||
@@ -695,7 +695,7 @@ def get_elements_by_layer(
|
||||
|
||||
def get_layers(
|
||||
ifc_file: ifcopenshell.file, element: ifcopenshell.entity_instance
|
||||
) -> List[ifcopenshell.entity_instance]:
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
"""Get the CAD layers that an element is part of
|
||||
|
||||
An element may have portions or all of its geometry assigned to a
|
||||
@@ -784,7 +784,7 @@ def get_container(
|
||||
container = get_aggregate(container)
|
||||
|
||||
|
||||
def get_referenced_structures(element: ifcopenshell.entity_instance) -> List[ifcopenshell.entity_instance]:
|
||||
def get_referenced_structures(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
"""Retreives a list of referenced spatial elements
|
||||
|
||||
Typically useful for multistorey elements, such as columns or facade
|
||||
@@ -808,7 +808,7 @@ def get_referenced_structures(element: ifcopenshell.entity_instance) -> List[ifc
|
||||
return []
|
||||
|
||||
|
||||
def get_decomposition(element: ifcopenshell.entity_instance, is_recursive=True) -> List[ifcopenshell.entity_instance]:
|
||||
def get_decomposition(element: ifcopenshell.entity_instance, is_recursive=True) -> list[ifcopenshell.entity_instance]:
|
||||
"""
|
||||
Retrieves all subelements of an element based on the spatial decomposition
|
||||
hierarchy. This includes all subspaces and elements contained in subspaces,
|
||||
@@ -850,7 +850,7 @@ def get_decomposition(element: ifcopenshell.entity_instance, is_recursive=True)
|
||||
return results
|
||||
|
||||
|
||||
def get_grouped_by(element: ifcopenshell.entity_instance) -> List[ifcopenshell.entity_instance]:
|
||||
def get_grouped_by(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
"""Retrieves all subelements of an element based on the group.
|
||||
|
||||
:param element: The IFC element
|
||||
@@ -920,7 +920,7 @@ def get_nest(element: ifcopenshell.entity_instance) -> ifcopenshell.entity_insta
|
||||
return element.Decomposes[0].RelatingObject
|
||||
|
||||
|
||||
def get_parts(element: ifcopenshell.entity_instance) -> List[ifcopenshell.entity_instance]:
|
||||
def get_parts(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
"""
|
||||
Retrieves the parts of an element that have an aggregation relationship.
|
||||
|
||||
@@ -941,7 +941,7 @@ def get_parts(element: ifcopenshell.entity_instance) -> List[ifcopenshell.entity
|
||||
return element.IsDecomposedBy[0].RelatedObjects
|
||||
|
||||
|
||||
def get_components(element: ifcopenshell.entity_instance, include_ports=False) -> List[ifcopenshell.entity_instance]:
|
||||
def get_components(element: ifcopenshell.entity_instance, include_ports=False) -> list[ifcopenshell.entity_instance]:
|
||||
"""
|
||||
Retrieves the components of an element that have an nest relationship.
|
||||
|
||||
@@ -1069,8 +1069,8 @@ def unbatch_remove_deep2(ifc_file: ifcopenshell.file) -> ifcopenshell.file:
|
||||
def remove_deep2(
|
||||
ifc_file: ifcopenshell.file,
|
||||
element: ifcopenshell.entity_instance,
|
||||
also_consider: List[ifcopenshell.entity_instance] = [],
|
||||
do_not_delete: List[ifcopenshell.entity_instance] = [],
|
||||
also_consider: list[ifcopenshell.entity_instance] = [],
|
||||
do_not_delete: list[ifcopenshell.entity_instance] = [],
|
||||
) -> None:
|
||||
"""Recursively purges a subgraph safely, starting at an element
|
||||
|
||||
@@ -1170,7 +1170,7 @@ def copy(ifc_file: ifcopenshell.file, element: ifcopenshell.entity_instance) ->
|
||||
def copy_deep(
|
||||
ifc_file: ifcopenshell.file,
|
||||
element: ifcopenshell.entity_instance,
|
||||
exclude: Optional[List[str]] = None,
|
||||
exclude: Optional[list[str]] = None,
|
||||
exclude_callback: Optional[Callable[[ifcopenshell.entity_instance], bool]] = None,
|
||||
copied_entities: Optional[dict[int, ifcopenshell.entity_instance]] = None,
|
||||
) -> ifcopenshell.entity_instance:
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
from fractions import Fraction
|
||||
from math import pi
|
||||
from typing import Tuple, Iterable, Any, Union, Literal, Optional
|
||||
from typing import Iterable, Any, Union, Literal, Optional
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
@@ -696,7 +696,7 @@ def is_attr_type(
|
||||
|
||||
def iter_element_and_attributes_per_type(
|
||||
ifc_file: ifcopenshell.file, attr_type_name: str
|
||||
) -> Iterable[Tuple[ifcopenshell.entity_instance, ifcopenshell.ifcopenshell_wrapper.attribute, Any, str]]:
|
||||
) -> Iterable[tuple[ifcopenshell.entity_instance, ifcopenshell.ifcopenshell_wrapper.attribute, Any, str]]:
|
||||
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema)
|
||||
|
||||
for element in ifc_file:
|
||||
|
||||
Reference in New Issue
Block a user