mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
typing
This commit is contained in:
@@ -20,6 +20,7 @@ import bpy
|
||||
import bmesh
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.util.schema
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.type
|
||||
|
||||
@@ -48,7 +48,7 @@ from collections import defaultdict
|
||||
from math import radians, pi
|
||||
from mathutils import Vector, Matrix
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from typing import Union, Iterable, Optional, Literal, Iterator, List, TYPE_CHECKING
|
||||
from typing import Union, Iterable, Optional, Literal, Iterator, List, TYPE_CHECKING, get_args
|
||||
from typing_extensions import TypeIs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -815,13 +815,9 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def has_mesh_properties(cls, data: Union[bpy.types.ID, None]) -> TypeIs[TYPES_WITH_MESH_PROPERTIES]:
|
||||
supported_types = (
|
||||
bpy.types.Mesh,
|
||||
bpy.types.Curve,
|
||||
bpy.types.Camera,
|
||||
bpy.types.PointLight,
|
||||
)
|
||||
def has_mesh_properties(
|
||||
cls, data: Union[bpy.types.ID, None], supported_types=get_args(TYPES_WITH_MESH_PROPERTIES)
|
||||
) -> TypeIs[TYPES_WITH_MESH_PROPERTIES]:
|
||||
if not data:
|
||||
return False
|
||||
return isinstance(data, supported_types)
|
||||
@@ -888,10 +884,10 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
|
||||
@classmethod
|
||||
def is_representation_item(cls, obj: bpy.types.Object) -> bool:
|
||||
return (
|
||||
obj.data
|
||||
and hasattr(obj.data, "BIMMeshProperties")
|
||||
and (ifc_id := obj.data.BIMMeshProperties.ifc_definition_id)
|
||||
return bool(
|
||||
(data := obj.data)
|
||||
and isinstance(data, Geometry.TYPES_WITH_MESH_PROPERTIES)
|
||||
and (ifc_id := data.BIMMeshProperties.ifc_definition_id)
|
||||
and tool.Ifc.get().by_id(ifc_id).is_a("IfcRepresentationItem")
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user