diff --git a/src/bcf/src/bcf/xml_parser.py b/src/bcf/src/bcf/xml_parser.py
index bdab51099e..b3b51367e0 100644
--- a/src/bcf/src/bcf/xml_parser.py
+++ b/src/bcf/src/bcf/xml_parser.py
@@ -36,8 +36,9 @@ class AbstractXmlParserSerializer(Protocol):
xml: The XML file as bytes.
clazz: The class to parse to.
"""
+ ...
- def serialize(self, obj: T, ns_map: Optional[dict[str, str]] = None) -> str:
+ def serialize(self, obj: object, ns_map: Optional[dict[str, str]] = None) -> str:
"""
Serialize an object to XML.
@@ -48,6 +49,7 @@ class AbstractXmlParserSerializer(Protocol):
Returns:
The XML as string.
"""
+ ...
class XmlParserSerializer:
@@ -68,7 +70,7 @@ class XmlParserSerializer:
"""
return self.parser.from_bytes(xml, clazz)
- def serialize(self, obj: T, ns_map: Optional[dict[Optional[str], str]] = None) -> str:
+ def serialize(self, obj: object, ns_map: Optional[dict[Optional[str], str]] = None) -> str:
"""
Serialize an object to XML.
diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py
index f2e5532feb..5e427aae3e 100644
--- a/src/blenderbim/blenderbim/bim/import_ifc.py
+++ b/src/blenderbim/blenderbim/bim/import_ifc.py
@@ -756,7 +756,9 @@ class IfcImporter:
return mathutils.Matrix(matrix.tolist())
- def find_decomposed_ifc_class(self, element, ifc_class):
+ def find_decomposed_ifc_class(
+ self, element: ifcopenshell.entity_instance, ifc_class: str
+ ) -> Union[ifcopenshell.entity_instance, None]:
if element.is_a(ifc_class):
return element
rel_aggregates = element.IsDecomposedBy
diff --git a/src/blenderbim/blenderbim/bim/module/pset/prop.py b/src/blenderbim/blenderbim/bim/module/pset/prop.py
index 05b70a79d9..d88884d7df 100644
--- a/src/blenderbim/blenderbim/bim/module/pset/prop.py
+++ b/src/blenderbim/blenderbim/bim/module/pset/prop.py
@@ -19,6 +19,7 @@
import bpy
import blenderbim.bim.schema
import ifcopenshell
+import ifcopenshell.util.attribute
import ifcopenshell.util.element
import blenderbim.tool as tool
from blenderbim.bim.prop import Attribute, StrProperty
diff --git a/src/blenderbim/blenderbim/bim/module/structural/operator.py b/src/blenderbim/blenderbim/bim/module/structural/operator.py
index 8415771d2b..7cf14baa45 100644
--- a/src/blenderbim/blenderbim/bim/module/structural/operator.py
+++ b/src/blenderbim/blenderbim/bim/module/structural/operator.py
@@ -20,6 +20,7 @@ import bpy
import json
import ifcopenshell
import ifcopenshell.api
+import ifcopenshell.util.attribute
import blenderbim.bim.helper
import blenderbim.bim.handler
import blenderbim.core.structural as core
diff --git a/src/blenderbim/blenderbim/tool/geometry.py b/src/blenderbim/blenderbim/tool/geometry.py
index 3133115c62..2d81ba415a 100644
--- a/src/blenderbim/blenderbim/tool/geometry.py
+++ b/src/blenderbim/blenderbim/tool/geometry.py
@@ -24,6 +24,7 @@ import logging
import numpy as np
import ifcopenshell
import ifcopenshell.api
+import ifcopenshell.geom
import ifcopenshell.guid
import ifcopenshell.util.element
import ifcopenshell.util.representation
@@ -570,11 +571,11 @@ class Geometry(blenderbim.core.tool.Geometry):
new.value = element[i]
@classmethod
- def is_body_representation(cls, representation):
+ def is_body_representation(cls, representation: ifcopenshell.entity_instance) -> bool:
return representation.ContextOfItems.ContextIdentifier == "Body"
@classmethod
- def is_box_representation(cls, representation):
+ def is_box_representation(cls, representation: ifcopenshell.entity_instance) -> bool:
return representation.ContextOfItems.ContextIdentifier == "Box"
@classmethod
diff --git a/src/blenderbim/test/tool/test_georeference.py b/src/blenderbim/test/tool/test_georeference.py
index 177d9aeb6b..9ce320e327 100644
--- a/src/blenderbim/test/tool/test_georeference.py
+++ b/src/blenderbim/test/tool/test_georeference.py
@@ -19,6 +19,7 @@
import bpy
import math
import ifcopenshell
+import ifcopenshell.api
import blenderbim.core.tool
import blenderbim.tool as tool
from mathutils import Vector
diff --git a/src/ifcopenshell-python/ifcopenshell/api/context/add_context.py b/src/ifcopenshell-python/ifcopenshell/api/context/add_context.py
index 38c79d20f2..95b38a0f5e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/context/add_context.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/context/add_context.py
@@ -17,12 +17,12 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-from typing import Optional
+from typing import Optional, Literal
def add_context(
file: ifcopenshell.file,
- context_type: str,
+ context_type: Optional[Literal["Model", "Plan"]] = None,
context_identifier: Optional[str] = None,
target_view: Optional[str] = None,
parent: Optional[ifcopenshell.entity_instance] = None,
@@ -96,7 +96,7 @@ def add_context(
:param context_type: The type of the context, must be one of "Model" or
"Plan" only.
- :type context_type: str
+ :type context_type: str, optional
:param context_identifier: The identifier of the context, chosen from
one of the common identifiers above or consult the IFC documentation
(under the IfcShapeRepresentation page) for more details. Optional
diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py
index 9693e46340..149c443881 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py
@@ -21,7 +21,7 @@ import math
import bmesh
import ifcopenshell.util.unit
from mathutils import Vector, Matrix
-from typing import Union, Optional, Literal
+from typing import Union, Optional, Literal, Any
Z_AXIS = Vector((0, 0, 1))
@@ -93,6 +93,9 @@ def add_representation(
class Usecase:
+ file: ifcopenshell.file
+ settings: dict[str, Any]
+
def execute(self):
self.is_manifold = None
if (
diff --git a/src/ifcopenshell-python/ifcopenshell/util/attribute.py b/src/ifcopenshell-python/ifcopenshell/util/attribute.py
index b52fea7e3f..2fa47589c1 100644
--- a/src/ifcopenshell-python/ifcopenshell/util/attribute.py
+++ b/src/ifcopenshell-python/ifcopenshell/util/attribute.py
@@ -16,8 +16,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
+from typing import Union
-def get_primitive_type(attribute_or_data_type):
+
+def get_primitive_type(
+ attribute_or_data_type: Union[ifcopenshell_wrapper.attribute, ifcopenshell_wrapper.parameter_type]
+) -> Union[str, tuple[str, list[str]]]:
if hasattr(attribute_or_data_type, "type_of_attribute"):
data_type = str(attribute_or_data_type.type_of_attribute())
else:
diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py
index 582879f9d3..7f41ce1001 100644
--- a/src/ifcopenshell-python/ifcopenshell/util/selector.py
+++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py
@@ -21,6 +21,7 @@ import lark
import numpy as np
import ifcopenshell.api
import ifcopenshell.util
+import ifcopenshell.util.attribute
import ifcopenshell.util.fm
import ifcopenshell.util.unit
import ifcopenshell.util.element
@@ -30,7 +31,7 @@ import ifcopenshell.util.classification
import ifcopenshell.util.schema
import ifcopenshell.util.shape
from decimal import Decimal
-from typing import Optional, Any, Union
+from typing import Optional, Any, Union, Iterable
filter_elements_grammar = lark.Lark(
@@ -326,10 +327,10 @@ def filter_elements(
def set_element_value(
ifc_file: ifcopenshell.file,
- element: ifcopenshell.entity_instance,
+ element: Union[ifcopenshell.entity_instance, Iterable[ifcopenshell.entity_instance], None],
query: Union[str, list[str]],
- value: Optional[str],
-) -> Union[ifcopenshell.entity_instance, None]:
+ value: Any,
+) -> None:
if isinstance(query, (list, tuple)):
keys = query
else:
diff --git a/src/ifcpatch/ifcpatch/recipes/ResetAbsoluteCoordinates.py b/src/ifcpatch/ifcpatch/recipes/ResetAbsoluteCoordinates.py
index daeff23af8..283c8f71e0 100644
--- a/src/ifcpatch/ifcpatch/recipes/ResetAbsoluteCoordinates.py
+++ b/src/ifcpatch/ifcpatch/recipes/ResetAbsoluteCoordinates.py
@@ -16,9 +16,29 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcPatch. If not, see .
+import logging
+import numpy as np
+import numpy.typing as npt
+import ifcopenshell
+from typing import Literal, Optional, Union
+
class Patcher:
- def __init__(self, src, file, logger, mode="geometry", a=None, b=None, c=None, d=None):
+ def __init__(
+ self,
+ src: str,
+ file: ifcopenshell.file,
+ logger: logging.Logger,
+ mode: Literal[
+ "geometry",
+ "placement",
+ "both",
+ ] = "geometry",
+ a: Optional[float] = None,
+ b: Optional[float] = None,
+ c: Optional[float] = None,
+ d: Optional[float] = None,
+ ):
"""Reset any large coordinates to smaller coordinates based on a threshold
If you find large coordinates in your model, the large coordinates may
@@ -151,7 +171,7 @@ class Patcher:
point.Coordinates[2] + offset_point[2],
)
- def is_point_far_away(self, point):
+ def is_point_far_away(self, point: Union[ifcopenshell.entity_instance, npt.NDArray[np.float64]]) -> bool:
if hasattr(point, "Coordinates"):
return (
abs(point.Coordinates[0]) > self.threshold
diff --git a/src/ifcsverchok/ifcstore.py b/src/ifcsverchok/ifcstore.py
index d812994b04..8e6a5b98ff 100644
--- a/src/ifcsverchok/ifcstore.py
+++ b/src/ifcsverchok/ifcstore.py
@@ -18,6 +18,8 @@
import bpy
import ifcopenshell
+import ifcopenshell.api
+import ifcopenshell.util.representation
from ifcopenshell import template
diff --git a/src/ifcsverchok/nodes/ifc/create_project.py b/src/ifcsverchok/nodes/ifc/create_project.py
index e2b9bf3750..3f8b323e51 100644
--- a/src/ifcsverchok/nodes/ifc/create_project.py
+++ b/src/ifcsverchok/nodes/ifc/create_project.py
@@ -18,6 +18,7 @@
import bpy
import ifcopenshell
+import ifcopenshell.api
import ifcsverchok.helper
from sverchok.node_tree import SverchCustomTreeNode
diff --git a/src/ifcsverchok/nodes/ifc/sverchok_to_ifc.py b/src/ifcsverchok/nodes/ifc/sverchok_to_ifc.py
index bbebc7f51b..3cc528984b 100644
--- a/src/ifcsverchok/nodes/ifc/sverchok_to_ifc.py
+++ b/src/ifcsverchok/nodes/ifc/sverchok_to_ifc.py
@@ -21,6 +21,7 @@ import bpy
import ifcopenshell
import ifcsverchok.helper
import ifcopenshell.api
+import ifcopenshell.util.representation
from ifcsverchok.ifcstore import SvIfcStore
import blenderbim.tool as tool
import blenderbim.core.geometry as core