This commit is contained in:
Andrej730
2024-04-09 16:41:03 +05:00
parent 846ff3b9fd
commit 064fc0e405
6 changed files with 31 additions and 28 deletions
+2 -2
View File
@@ -32,7 +32,7 @@ import blenderbim.bim.import_ifc
from math import radians, pi from math import radians, pi
from mathutils import Vector, Matrix from mathutils import Vector, Matrix
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from typing import List, Union from typing import Union
class Geometry(blenderbim.core.tool.Geometry): class Geometry(blenderbim.core.tool.Geometry):
@@ -889,7 +889,7 @@ class Geometry(blenderbim.core.tool.Geometry):
return inverse return inverse
@classmethod @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` """update `representation_item` style based on styles connected to the `shape_aspect`
through material constituents with the same name through material constituents with the same name
""" """
@@ -17,6 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>. # along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.element import ifcopenshell.util.element
@@ -17,6 +17,8 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>. # along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.element
import ifcopenshell.util.sequence import ifcopenshell.util.sequence
+6 -6
View File
@@ -448,7 +448,7 @@ class file(object):
[self.transaction.store_create(e) for e in reversed(added_elements)] [self.transaction.store_create(e) for e in reversed(added_elements)]
return result 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. """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. 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 :param include_subtypes: Whether or not to return subtypes of the IFC class
:type include_subtypes: bool :type include_subtypes: bool
:returns: A list of ifcopenshell.entity_instance.entity_instance objects :returns: A list of ifcopenshell.entity_instance.entity_instance objects
:rtype: list :rtype: list[ifcopenshell.entity_instance.entity_instance]
""" """
if include_subtypes: if include_subtypes:
return [entity_instance(e, self) for e in self.wrapped_data.by_type(type)] return [entity_instance(e, self) for e in self.wrapped_data.by_type(type)]
@@ -466,7 +466,7 @@ class file(object):
def traverse( def traverse(
self, inst: ifcopenshell.entity_instance, max_levels=None, breadth_first=False 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 """Get a list of all referenced instances for a particular instance including itself
:param inst: The entity instance to get all sub instances :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. :param breadth_first: Whether to use breadth-first search, the default is depth-first.
:type max_levels: bool :type max_levels: bool
:returns: A list of ifcopenshell.entity_instance.entity_instance objects :returns: A list of ifcopenshell.entity_instance.entity_instance objects
:rtype: list :rtype: list[ifcopenshell.entity_instance.entity_instance]
""" """
if max_levels is None: if max_levels is None:
max_levels = -1 max_levels = -1
@@ -490,7 +490,7 @@ class file(object):
def get_inverse( def get_inverse(
self, inst: ifcopenshell.entity_instance, allow_duplicate=False, with_attribute_indices=False 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 """Return a list of entities that reference this entity
:param inst: The entity instance to get inverse relationships :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> :param with_attribute_indices: Returns pairs of <i, idx>
where i[idx] is inst or contains inst. Requires allow_duplicate=True where i[idx] is inst or contains inst. Requires allow_duplicate=True
:returns: A list of ifcopenshell.entity_instance.entity_instance objects :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: if with_attribute_indices and not allow_duplicate:
raise ValueError("with_attribute_indices requires allow_duplicate to be True") raise ValueError("with_attribute_indices requires allow_duplicate to be True")
@@ -19,7 +19,7 @@
from __future__ import annotations from __future__ import annotations
import ifcopenshell import ifcopenshell
import ifcopenshell.util.element import ifcopenshell.util.element
from typing import List, Any, Callable, Optional, Union from typing import Any, Callable, Optional, Union
def get_pset( def get_pset(
@@ -379,7 +379,7 @@ def get_type(element: ifcopenshell.entity_instance) -> ifcopenshell.entity_insta
return relationship.RelatingType 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 """Get all the occurrences of a type element
:param type: The type element :param type: The type element
@@ -401,7 +401,7 @@ def get_types(type: ifcopenshell.entity_instance) -> List[ifcopenshell.entity_in
return [] 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 """Gets element shape aspects
:param element: The element to get the shape aspects of. :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) 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 """Gets individual materials of an element
If the element has a material set, the individual materials of that set are 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) 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. """Retrieves the styles used in an element's representation.
Styles may be retreived from the material or the body 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( def get_elements_by_material(
ifc_file: ifcopenshell.file, material: ifcopenshell.entity_instance ifc_file: ifcopenshell.file, material: ifcopenshell.entity_instance
) -> List[ifcopenshell.entity_instance]: ) -> list[ifcopenshell.entity_instance]:
"""Retrieves the elements related to a material. """Retrieves the elements related to a material.
This includes elements using the material as part of a material set or set 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( def get_elements_by_style(
ifc_file: ifcopenshell.file, style: ifcopenshell.entity_instance 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 """Retrieves the elements whose geometric representation uses a style
:param ifc_file: The IFC file :param ifc_file: The IFC file
@@ -638,7 +638,7 @@ def get_elements_by_style(
def get_elements_by_representation( def get_elements_by_representation(
ifc_file: ifcopenshell.file, representation: ifcopenshell.entity_instance ifc_file: ifcopenshell.file, representation: ifcopenshell.entity_instance
) -> List[ifcopenshell.entity_instance]: ) -> list[ifcopenshell.entity_instance]:
"""Gets all elements using a geometric representation """Gets all elements using a geometric representation
:param ifc_file: The IFC file :param ifc_file: The IFC file
@@ -672,7 +672,7 @@ def get_elements_by_representation(
def get_elements_by_layer( def get_elements_by_layer(
ifc_file: ifcopenshell.file, layer: ifcopenshell.entity_instance 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 """Get all the elements that are used by a presentation layer
:param ifc_file: The IFC file :param ifc_file: The IFC file
@@ -695,7 +695,7 @@ def get_elements_by_layer(
def get_layers( def get_layers(
ifc_file: ifcopenshell.file, element: ifcopenshell.entity_instance 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 """Get the CAD layers that an element is part of
An element may have portions or all of its geometry assigned to a An element may have portions or all of its geometry assigned to a
@@ -784,7 +784,7 @@ def get_container(
container = get_aggregate(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 """Retreives a list of referenced spatial elements
Typically useful for multistorey elements, such as columns or facade 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 [] 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 Retrieves all subelements of an element based on the spatial decomposition
hierarchy. This includes all subspaces and elements contained in subspaces, 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 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. """Retrieves all subelements of an element based on the group.
:param element: The IFC element :param element: The IFC element
@@ -920,7 +920,7 @@ def get_nest(element: ifcopenshell.entity_instance) -> ifcopenshell.entity_insta
return element.Decomposes[0].RelatingObject 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. 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 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. 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( def remove_deep2(
ifc_file: ifcopenshell.file, ifc_file: ifcopenshell.file,
element: ifcopenshell.entity_instance, element: ifcopenshell.entity_instance,
also_consider: List[ifcopenshell.entity_instance] = [], also_consider: list[ifcopenshell.entity_instance] = [],
do_not_delete: List[ifcopenshell.entity_instance] = [], do_not_delete: list[ifcopenshell.entity_instance] = [],
) -> None: ) -> None:
"""Recursively purges a subgraph safely, starting at an element """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( def copy_deep(
ifc_file: ifcopenshell.file, ifc_file: ifcopenshell.file,
element: ifcopenshell.entity_instance, element: ifcopenshell.entity_instance,
exclude: Optional[List[str]] = None, exclude: Optional[list[str]] = None,
exclude_callback: Optional[Callable[[ifcopenshell.entity_instance], bool]] = None, exclude_callback: Optional[Callable[[ifcopenshell.entity_instance], bool]] = None,
copied_entities: Optional[dict[int, ifcopenshell.entity_instance]] = None, copied_entities: Optional[dict[int, ifcopenshell.entity_instance]] = None,
) -> ifcopenshell.entity_instance: ) -> ifcopenshell.entity_instance:
@@ -18,7 +18,7 @@
from fractions import Fraction from fractions import Fraction
from math import pi 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
import ifcopenshell.api import ifcopenshell.api
@@ -696,7 +696,7 @@ def is_attr_type(
def iter_element_and_attributes_per_type( def iter_element_and_attributes_per_type(
ifc_file: ifcopenshell.file, attr_type_name: str 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) schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema)
for element in ifc_file: for element in ifc_file: