mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 08:16:51 +00:00
typing
This commit is contained in:
@@ -42,7 +42,7 @@ from bonsai.bim.module.drawing.helper import format_distance
|
|||||||
from timeit import default_timer as timer
|
from timeit import default_timer as timer
|
||||||
from functools import cache
|
from functools import cache
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
from collections.abc import Iterator
|
from collections.abc import Generator, Iterator
|
||||||
|
|
||||||
UNSPECIAL_ELEMENT_COLOR = (0.2, 0.2, 0.2, 1) # GREY
|
UNSPECIAL_ELEMENT_COLOR = (0.2, 0.2, 0.2, 1) # GREY
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ class BaseDecorator:
|
|||||||
def camera_zoom_to_factor(self, zoom):
|
def camera_zoom_to_factor(self, zoom):
|
||||||
return math.pow(((zoom / 50) + math.sqrt(2)) / 2, 2)
|
return math.pow(((zoom / 50) + math.sqrt(2)) / 2, 2)
|
||||||
|
|
||||||
def get_splines(self, obj):
|
def get_splines(self, obj: bpy.types.Object) -> Generator[list[Vector]]:
|
||||||
"""Iterates through splines
|
"""Iterates through splines
|
||||||
Args:
|
Args:
|
||||||
obj: Blender object with Curve data
|
obj: Blender object with Curve data
|
||||||
@@ -194,13 +194,14 @@ class BaseDecorator:
|
|||||||
Yields:
|
Yields:
|
||||||
verts: points of each spline, world coords
|
verts: points of each spline, world coords
|
||||||
"""
|
"""
|
||||||
|
assert type(obj.data) is bpy.types.Curve
|
||||||
for spline in obj.data.splines:
|
for spline in obj.data.splines:
|
||||||
spline_points = spline.bezier_points if spline.bezier_points else spline.points
|
spline_points = spline.bezier_points if spline.bezier_points else spline.points
|
||||||
if len(spline_points) < 2:
|
if len(spline_points) < 2:
|
||||||
continue
|
continue
|
||||||
yield [obj.matrix_world @ p.co for p in spline_points]
|
yield [obj.matrix_world @ p.co for p in spline_points]
|
||||||
|
|
||||||
def get_path_geom(self, obj, topo=True):
|
def get_path_geom(self, obj: bpy.types.Object, topo: bool = True):
|
||||||
"""Parses path geometry into line segments
|
"""Parses path geometry into line segments
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|||||||
@@ -535,6 +535,7 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
should_setup_workspace: bool
|
should_setup_workspace: bool
|
||||||
activate_workspace: bool
|
activate_workspace: bool
|
||||||
should_setup_toolbar: bool
|
should_setup_toolbar: bool
|
||||||
|
should_use_snap: bool
|
||||||
should_play_chaching_sound: bool
|
should_play_chaching_sound: bool
|
||||||
tmp_dir: str
|
tmp_dir: str
|
||||||
decorations_colour: tuple[float, float, float, float]
|
decorations_colour: tuple[float, float, float, float]
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ import zipfile
|
|||||||
import tempfile
|
import tempfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, Union, TYPE_CHECKING, Any, overload, Literal
|
from typing import Optional, Union, TYPE_CHECKING, Any, overload, Literal
|
||||||
from collections.abc import Sequence
|
from collections.abc import Generator, Sequence
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import ifcopenshell.express.schema_class
|
import ifcopenshell.express.schema_class
|
||||||
@@ -355,7 +355,7 @@ def stream2(path: Union[Path, str], mmap: bool = False, page_size: int = 0):
|
|||||||
yield inst
|
yield inst
|
||||||
|
|
||||||
|
|
||||||
def stream2_from_string(data: str):
|
def stream2_from_string(data: str) -> Generator[dict]:
|
||||||
"""Streams the content of a file path from string, yielding each instance
|
"""Streams the content of a file path from string, yielding each instance
|
||||||
as a dictionary.
|
as a dictionary.
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ def stream2_from_string(data: str):
|
|||||||
yield inst
|
yield inst
|
||||||
|
|
||||||
|
|
||||||
def convert_path_to_rocksdb(ifcspf_path: Union[Path, str], rocksdb_path: Union[Path, str]):
|
def convert_path_to_rocksdb(ifcspf_path: Union[Path, str], rocksdb_path: Union[Path, str]) -> None:
|
||||||
"""Converts an IFC-SPF file on disk to the IfcOpenShell-specific
|
"""Converts an IFC-SPF file on disk to the IfcOpenShell-specific
|
||||||
RocksDB encoding. RocksDB is an embedded key-value store that allows
|
RocksDB encoding. RocksDB is an embedded key-value store that allows
|
||||||
partial reads and is therefore more memory efficient with larger files.
|
partial reads and is therefore more memory efficient with larger files.
|
||||||
|
|||||||
Reference in New Issue
Block a user