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