mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 19:07:57 +00:00
typing
This commit is contained in:
@@ -1077,7 +1077,7 @@ class ProductDecorator:
|
||||
data["verts"] = []
|
||||
|
||||
# Verts
|
||||
polyline_vertices = []
|
||||
polyline_vertices: list[Vector] = []
|
||||
polyline_props = tool.Model.get_polyline_props()
|
||||
polyline_data = polyline_props.insertion_polyline
|
||||
polyline_points = polyline_data[0].polyline_points if polyline_data else []
|
||||
@@ -1197,7 +1197,7 @@ class ProductDecorator:
|
||||
data = {}
|
||||
data["verts"] = []
|
||||
# Verts
|
||||
polyline_vertices = []
|
||||
polyline_vertices: list[Vector] = []
|
||||
polyline_props = tool.Model.get_polyline_props()
|
||||
polyline_data = polyline_props.insertion_polyline
|
||||
polyline_points = polyline_data[0].polyline_points if polyline_data else []
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import bisect
|
||||
import json
|
||||
import traceback
|
||||
from typing import TYPE_CHECKING, Literal, assert_never, get_args
|
||||
from typing import TYPE_CHECKING, Any, Literal, assert_never, get_args
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
@@ -695,9 +695,9 @@ class EditFilterQuery(Operator, tool.Ifc.Operator):
|
||||
filter_groups = tool.Search.get_filter_groups(module)
|
||||
|
||||
if tool.Blender.get_addon_preferences().chain_filter_with_set_operations:
|
||||
filter_structure = []
|
||||
filter_structure: list[list[dict[str, Any]]] = []
|
||||
for filter_group in filter_groups:
|
||||
group_data = []
|
||||
group_data: list[dict[str, Any]] = []
|
||||
for ifc_filter in filter_group.filters:
|
||||
filter_data = {
|
||||
"type": ifc_filter.type,
|
||||
@@ -852,9 +852,9 @@ class SaveSearch(Operator, tool.Ifc.Operator):
|
||||
query = tool.Search.export_filter_query(filter_groups)
|
||||
results = tool.Search.execute_filter_groups(filter_groups)
|
||||
|
||||
filter_structure = []
|
||||
filter_structure: list[list[dict[str, Any]]] = []
|
||||
for filter_group in filter_groups:
|
||||
group_data = []
|
||||
group_data: list[dict[str, Any]] = []
|
||||
for ifc_filter in filter_group.filters:
|
||||
filter_data = {
|
||||
"type": ifc_filter.type,
|
||||
|
||||
@@ -2626,7 +2626,7 @@ class Model(bonsai.core.tool.Model):
|
||||
reference_obj: bpy.types.Object,
|
||||
objs: Iterable[bpy.types.Object],
|
||||
align_type: Literal["CENTER", "POSITIVE", "NEGATIVE"],
|
||||
):
|
||||
) -> None:
|
||||
if align_type == "CENTER":
|
||||
point = reference_obj.matrix_world @ (Vector(reference_obj.bound_box[0]) + (reference_obj.dimensions / 2))
|
||||
elif align_type == "POSITIVE":
|
||||
@@ -2771,7 +2771,7 @@ class Model(bonsai.core.tool.Model):
|
||||
SvIfcStore.use_bonsai_file = False
|
||||
|
||||
@classmethod
|
||||
def create_bmesh_from_vertices(cls, vertices, is_closed=False):
|
||||
def create_bmesh_from_vertices(cls, vertices: list[Vector], is_closed: bool = False) -> bmesh.types.BMesh:
|
||||
bm = bmesh.new()
|
||||
|
||||
new_verts = [bm.verts.new(v) for v in vertices]
|
||||
|
||||
@@ -20,7 +20,7 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
from itertools import cycle
|
||||
from typing import TYPE_CHECKING, Literal, Union
|
||||
from typing import TYPE_CHECKING, Any, Literal, Union
|
||||
|
||||
import bpy
|
||||
import ifcopenshell.guid
|
||||
@@ -51,7 +51,9 @@ class Search(bonsai.core.tool.Search):
|
||||
|
||||
@classmethod
|
||||
def import_filter_structure(
|
||||
cls, filter_structure: list, filter_groups: bpy.types.bpy_prop_collection_idprop[BIMFilterGroup]
|
||||
cls,
|
||||
filter_structure: list[list[dict[str, Any]]],
|
||||
filter_groups: bpy.types.bpy_prop_collection_idprop[BIMFilterGroup],
|
||||
) -> None:
|
||||
filter_groups.clear()
|
||||
|
||||
@@ -188,7 +190,9 @@ class Search(bonsai.core.tool.Search):
|
||||
return ""
|
||||
|
||||
@classmethod
|
||||
def execute_filter_groups(cls, filter_groups: bpy.types.bpy_prop_collection_idprop[BIMFilterGroup]) -> set:
|
||||
def execute_filter_groups(
|
||||
cls, filter_groups: bpy.types.bpy_prop_collection_idprop[BIMFilterGroup]
|
||||
) -> set[ifcopenshell.entity_instance]:
|
||||
"""
|
||||
Execute filter groups with simplified chaining support.
|
||||
Within a single group chain, all filters chain sequentially with ADD/SUBTRACT/FILTER modes.
|
||||
@@ -196,10 +200,10 @@ class Search(bonsai.core.tool.Search):
|
||||
"""
|
||||
preferences = tool.Blender.get_addon_preferences()
|
||||
|
||||
all_group_results = []
|
||||
all_group_results: list[set[ifcopenshell.entity_instance]] = []
|
||||
|
||||
for group_idx, filter_group in enumerate(filter_groups):
|
||||
group_results = set()
|
||||
for filter_group in filter_groups:
|
||||
group_results: set[ifcopenshell.entity_instance] = set()
|
||||
|
||||
for filter_index, ifc_filter in enumerate(filter_group.filters):
|
||||
if not ifc_filter.value:
|
||||
@@ -245,7 +249,7 @@ class Search(bonsai.core.tool.Search):
|
||||
if group_results:
|
||||
all_group_results.append(group_results)
|
||||
|
||||
final_results = set()
|
||||
final_results: set[ifcopenshell.entity_instance] = set()
|
||||
for group_results in all_group_results:
|
||||
final_results.update(group_results)
|
||||
|
||||
@@ -262,9 +266,9 @@ class Search(bonsai.core.tool.Search):
|
||||
"""
|
||||
filter_structure = data.get("filter_structure", [])
|
||||
|
||||
all_group_results = []
|
||||
all_group_results: list[set[ifcopenshell.entity_instance]] = []
|
||||
for group_data in filter_structure:
|
||||
group_results = set()
|
||||
group_results: set[ifcopenshell.entity_instance] = set()
|
||||
|
||||
for filter_data in group_data:
|
||||
filter_mode = filter_data.get("filter_mode", "ADD")
|
||||
@@ -332,7 +336,7 @@ class Search(bonsai.core.tool.Search):
|
||||
if group_results:
|
||||
all_group_results.append(group_results)
|
||||
|
||||
final_results = set()
|
||||
final_results: set[ifcopenshell.entity_instance] = set()
|
||||
for group_results in all_group_results:
|
||||
final_results.update(group_results)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user