This commit is contained in:
Andrej730
2026-03-13 18:28:51 +05:00
parent 1576302caf
commit eba798c544
30 changed files with 142 additions and 75 deletions
+2 -2
View File
@@ -215,11 +215,11 @@ def _extract_docs(cls: type, method_name: str, boilerplate_args: Union[Sequence[
input_data = inputs[input_name]
# E.g. list[str].
if isinstance(type_hint, typing.GenericAlias):
if isinstance(type_hint, typing.GenericAlias): # pyright: ignore[reportAttributeAccessIssue]
input_data["generic_type"] = type_hint.__name__
type_hint = typing.get_args(type_hint)[0]
if isinstance(type_hint, typing._UnionGenericAlias):
if isinstance(type_hint, typing._UnionGenericAlias): # pyright: ignore[reportAttributeAccessIssue]
inputs[input_name]["type"] = [t.__name__ for t in typing.get_args(type_hint)]
elif type_hint.__name__ == "Literal":
inputs[input_name]["type"] = "Literal"
@@ -67,9 +67,9 @@ class Patcher:
def patch(self) -> None:
import bonsai.tool as tool
import bpy
import bpy # pyright: ignore[reportMissingImports]
import ifcopenshell.util.element
from mathutils import Matrix, Vector
from mathutils import Matrix, Vector # pyright: ignore[reportMissingImports]
if len(bpy.data.objects) > 0:
bpy.data.batch_remove(bpy.data.objects)
@@ -18,11 +18,15 @@
import logging
from typing import Optional
from typing import Optional, TYPE_CHECKING
import ifcopenshell
import ifcopenshell.util.shape_builder
if TYPE_CHECKING:
import bpy # pyright: ignore[reportMissingImports]
class Patcher:
def __init__(
@@ -109,12 +113,14 @@ class Patcher:
self.should_create_edges = should_create_edges
def patch(self) -> None:
import bmesh
import bmesh # pyright: ignore[reportMissingImports]
import bonsai.tool as tool
import bpy
import ifcopenshell.util.shape_builder
import bpy # pyright: ignore[reportMissingImports]
import ifcopenshell.util.schema
import ifcopenshell.util.unit
bpy.context.scene.BIMProjectProperties.should_use_native_meshes = True
props = tool.Project.get_project_props()
props.should_use_native_meshes = True
bpy.ops.bim.load_project(filepath=self.filepath)
old_history_size = tool.Ifc.get().history_size
@@ -125,7 +131,7 @@ class Patcher:
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
for obj in bpy.data.objects:
if not obj.BIMObjectProperties.ifc_definition_id or not obj.data:
if not tool.Blender.get_ifc_definition_id(obj) or not obj.data:
continue
if not obj.data.polygons:
continue
@@ -159,14 +165,14 @@ class Patcher:
self.file = tool.Ifc.get()
def create_edges(self, obj):
import bmesh
def create_edges(self, obj: bpy.types.Object) -> None:
import bmesh # pyright: ignore[reportMissingImports]
import bonsai.tool as tool
import bpy
import bpy # pyright: ignore[reportMissingImports]
import ifcopenshell.api.geometry
import ifcopenshell.api.root
import ifcopenshell.util.element
import ifcopenshell.util.representation
import ifcopenshell.util.schema
element = tool.Ifc.get_entity(obj)
data = obj.data
@@ -224,16 +230,16 @@ class Patcher:
ifcopenshell.util.schema.reassign_class(tool.Ifc.get(), element2, "IfcVirtualElement")
bm.free()
def create_face_sampleable_object(self, obj):
def create_face_sampleable_object(self, obj: bpy.types.Object) -> None:
# No sharp faces
from math import degrees
import bmesh
import bmesh # pyright: ignore[reportMissingImports]
import bonsai.tool as tool
import ifcopenshell.api.geometry
import ifcopenshell.api.root
import ifcopenshell.util.element
import ifcopenshell.util.representation
import ifcopenshell.util.shape_builder
print("working on ", obj.name)
element = tool.Ifc.get_entity(obj)
@@ -271,17 +277,17 @@ class Patcher:
bm.free()
def create_edge_sampleable_object(self, obj):
def create_edge_sampleable_object(self, obj: bpy.types.Object) -> None:
# This is crazy but we need a sharp face per island
from math import degrees, radians, sin
import bmesh
import bmesh # pyright: ignore[reportMissingImports]
import bonsai.tool as tool
import ifcopenshell.api.geometry
import ifcopenshell.api.root
import ifcopenshell.util.element
import ifcopenshell.util.representation
from mathutils import Matrix
import ifcopenshell.util.shape_builder
from mathutils import Matrix # pyright: ignore[reportMissingImports]
# Get the active object (assumed to have a mesh)
mesh = obj.data
@@ -430,7 +436,6 @@ class Patcher:
bm.free()
print("Added a triangle to", islands_count, "mesh island(s).")
return
def create_curves_from_curve_ifc2x3(
self, is_2d: bool = False, curve_object_data=None
@@ -80,9 +80,9 @@ class Patcher:
def patch(self) -> None:
from math import degrees
import bmesh
import bmesh # pyright: ignore[reportMissingImports]
import bonsai.tool as tool
import bpy
import bpy # pyright: ignore[reportMissingImports]
props = tool.Project.get_project_props()
props.should_use_native_meshes = True