mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
typing
This commit is contained in:
@@ -29,6 +29,7 @@ import subprocess
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
import ifcopenshell.ifcopenshell_wrapper
|
import ifcopenshell.ifcopenshell_wrapper
|
||||||
import ifcopenshell.geom
|
import ifcopenshell.geom
|
||||||
import ifcopenshell.util.selector
|
import ifcopenshell.util.selector
|
||||||
|
|||||||
@@ -725,11 +725,11 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def should_use_presentation_style_assignment(cls):
|
def should_use_presentation_style_assignment(cls) -> bool:
|
||||||
return bpy.context.scene.BIMGeometryProperties.should_use_presentation_style_assignment
|
return bpy.context.scene.BIMGeometryProperties.should_use_presentation_style_assignment
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_model_representations(cls):
|
def get_model_representations(cls) -> list[ifcopenshell.entity_instance]:
|
||||||
return tool.Ifc.get().by_type("IfcShapeRepresentation")
|
return tool.Ifc.get().by_type("IfcShapeRepresentation")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -648,6 +648,8 @@ def get_styles(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entit
|
|||||||
return styles
|
return styles
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: ifc_file argument is unnecessary for some methods now
|
||||||
|
# since we have entity_instance.file, so we can deprecate it.
|
||||||
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]:
|
||||||
@@ -1041,7 +1043,9 @@ def get_parent(element: ifcopenshell.entity_instance) -> Union[ifcopenshell.enti
|
|||||||
- Voiding: the opening voids another physical element, such as a hole in a wall
|
- Voiding: the opening voids another physical element, such as a hole in a wall
|
||||||
|
|
||||||
:param element: Any physical or spatial element in the tree
|
:param element: Any physical or spatial element in the tree
|
||||||
|
:type element: ifcopenshell.entity_instance
|
||||||
:return: Its parent. This must exist for any valid file, or None if we've reached the IfcProject.
|
:return: Its parent. This must exist for any valid file, or None if we've reached the IfcProject.
|
||||||
|
:rtype: Union[ifcopenshell.entity_instance, None]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -1065,7 +1069,9 @@ def get_filled_void(element: ifcopenshell.entity_instance) -> Union[ifcopenshell
|
|||||||
Examples include windows and doors which fill a opening inside a wall.
|
Examples include windows and doors which fill a opening inside a wall.
|
||||||
|
|
||||||
:param element: The building element, typically a window or door
|
:param element: The building element, typically a window or door
|
||||||
|
:type element: ifcopenshell.entity_instance
|
||||||
:return: The IfcOpeningElement that it is filling
|
:return: The IfcOpeningElement that it is filling
|
||||||
|
:rtype: Union[ifcopenshell.entity_instance, None]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -1084,7 +1090,9 @@ def get_voided_element(element: ifcopenshell.entity_instance) -> Union[ifcopensh
|
|||||||
For all valid models, this should never return None.
|
For all valid models, this should never return None.
|
||||||
|
|
||||||
:param element: The IfcOpeningElement
|
:param element: The IfcOpeningElement
|
||||||
|
:type element: ifcopenshell.entity_instance
|
||||||
:return: The building element, such as a wall or slab
|
:return: The building element, such as a wall or slab
|
||||||
|
:rtype: Union[ifcopenshell.entity_instance, None]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -1102,7 +1110,9 @@ def get_aggregate(element: ifcopenshell.entity_instance) -> Union[ifcopenshell.e
|
|||||||
Retrieves the aggregate parent of an element.
|
Retrieves the aggregate parent of an element.
|
||||||
|
|
||||||
:param element: The IFC element
|
:param element: The IFC element
|
||||||
|
:type element: ifcopenshell.entity_instance
|
||||||
:return: The aggregate of the element
|
:return: The aggregate of the element
|
||||||
|
:rtype: Union[ifcopenshell.entity_instance, None]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -1116,14 +1126,14 @@ def get_aggregate(element: ifcopenshell.entity_instance) -> Union[ifcopenshell.e
|
|||||||
return decomposes[0].RelatingObject
|
return decomposes[0].RelatingObject
|
||||||
|
|
||||||
|
|
||||||
def get_nest(element: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance]:
|
def get_nest(element: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
||||||
"""
|
"""
|
||||||
Retrieves the nest parent of an element.
|
Retrieves the nest parent of an element.
|
||||||
|
|
||||||
:param element: The IFC element
|
:param element: The IFC element
|
||||||
:type element: ifcopenshell.entity_instance
|
:type element: ifcopenshell.entity_instance
|
||||||
:return: The nested whole of the element
|
:return: The nested whole of the element
|
||||||
:rtype: ifcopenshell.entity_instance
|
:rtype: Union[ifcopenshell.entity_instance, None]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -1159,6 +1169,7 @@ def get_parts(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity
|
|||||||
if (is_decomposed_by := getattr(element, "IsDecomposedBy", None)) is not None and is_decomposed_by:
|
if (is_decomposed_by := getattr(element, "IsDecomposedBy", None)) is not None and is_decomposed_by:
|
||||||
if is_decomposed_by[0].is_a("IfcRelAggregates"):
|
if is_decomposed_by[0].is_a("IfcRelAggregates"):
|
||||||
return is_decomposed_by[0].RelatedObjects
|
return is_decomposed_by[0].RelatedObjects
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
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]:
|
||||||
@@ -1188,6 +1199,7 @@ def get_components(element: ifcopenshell.entity_instance, include_ports=False) -
|
|||||||
elif (is_decomposed_by := getattr(element, "IsDecomposedBy", None)) is not None and is_decomposed_by:
|
elif (is_decomposed_by := getattr(element, "IsDecomposedBy", None)) is not None and is_decomposed_by:
|
||||||
if is_decomposed_by[0].is_a("IfcRelNests"):
|
if is_decomposed_by[0].is_a("IfcRelNests"):
|
||||||
return is_decomposed_by[0].RelatedObjects
|
return is_decomposed_by[0].RelatedObjects
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
ReferenceData = namedtuple("ReferenceData", "inverse_attribute, rel_class, relating_element_attribute")
|
ReferenceData = namedtuple("ReferenceData", "inverse_attribute, rel_class, relating_element_attribute")
|
||||||
|
|||||||
@@ -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 numpy as np
|
import numpy as np
|
||||||
|
import numpy.typing as npt
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.placement
|
import ifcopenshell.util.placement
|
||||||
from typing import Optional, Union, TypedDict
|
from typing import Optional, Union, TypedDict
|
||||||
@@ -98,12 +99,12 @@ def resolve_representation(representation: ifcopenshell.entity_instance) -> ifco
|
|||||||
|
|
||||||
|
|
||||||
class ResolvedItemDict(TypedDict):
|
class ResolvedItemDict(TypedDict):
|
||||||
matrix: np.array
|
matrix: npt.NDArray[np.float64]
|
||||||
item: ifcopenshell.entity_instance
|
item: ifcopenshell.entity_instance
|
||||||
|
|
||||||
|
|
||||||
def resolve_items(
|
def resolve_items(
|
||||||
representation: ifcopenshell.entity_instance, matrix: Optional[np.array] = None
|
representation: ifcopenshell.entity_instance, matrix: Optional[npt.NDArray[np.float64]] = None
|
||||||
) -> list[ResolvedItemDict]:
|
) -> list[ResolvedItemDict]:
|
||||||
if matrix is None:
|
if matrix is None:
|
||||||
matrix = np.eye(4)
|
matrix = np.eye(4)
|
||||||
|
|||||||
Reference in New Issue
Block a user