mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 13:28:19 +00:00
typing
This commit is contained in:
@@ -20,26 +20,32 @@ import bpy
|
|||||||
import blf
|
import blf
|
||||||
import gpu
|
import gpu
|
||||||
import bmesh
|
import bmesh
|
||||||
|
import ifcopenshell
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
from bpy.types import SpaceView3D
|
from bpy.types import SpaceView3D
|
||||||
from mathutils import Vector
|
from mathutils import Vector
|
||||||
from gpu_extras.batch import batch_for_shader
|
from gpu_extras.batch import batch_for_shader
|
||||||
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
||||||
|
from typing import Sequence
|
||||||
|
|
||||||
|
|
||||||
class ItemDecorator:
|
class ItemDecorator:
|
||||||
is_installed = False
|
is_installed = False
|
||||||
handlers = []
|
handlers = []
|
||||||
|
objs: dict[str, dict[str, list]]
|
||||||
|
obj_is_selected: dict[str, bool]
|
||||||
|
obj_is_boolean: dict[str, list[ifcopenshell.entity_instance]]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def install(cls, context):
|
def install(cls, context):
|
||||||
if cls.is_installed:
|
if cls.is_installed:
|
||||||
cls.uninstall()
|
cls.uninstall()
|
||||||
obj_is_selected = {}
|
obj_is_selected: dict[str, bool] = {}
|
||||||
obj_is_boolean = {}
|
obj_is_boolean: dict[str, list[ifcopenshell.entity_instance]] = {}
|
||||||
objs = {}
|
objs: dict[str, dict[str, list]] = {}
|
||||||
for item_obj in context.scene.BIMGeometryProperties.item_objs:
|
for item_obj in context.scene.BIMGeometryProperties.item_objs:
|
||||||
if obj := item_obj.obj:
|
if obj := item_obj.obj:
|
||||||
|
obj: bpy.types.Object
|
||||||
objs[obj.name] = cls.get_obj_data(obj)
|
objs[obj.name] = cls.get_obj_data(obj)
|
||||||
obj_is_selected[obj.name] = obj.select_get()
|
obj_is_selected[obj.name] = obj.select_get()
|
||||||
item = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
item = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
||||||
@@ -54,7 +60,7 @@ class ItemDecorator:
|
|||||||
cls.is_installed = True
|
cls.is_installed = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_obj_data(cls, obj):
|
def get_obj_data(cls, obj: bpy.types.Object) -> dict[str, list]:
|
||||||
verts = []
|
verts = []
|
||||||
edges = []
|
edges = []
|
||||||
tris = []
|
tris = []
|
||||||
@@ -145,8 +151,8 @@ class ItemDecorator:
|
|||||||
blf.draw(font_id, tag)
|
blf.draw(font_id, tag)
|
||||||
blf.disable(font_id, blf.SHADOW)
|
blf.disable(font_id, blf.SHADOW)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context: bpy.types.Context) -> None:
|
||||||
def transparent_color(color, alpha=0.05):
|
def transparent_color(color: Sequence[float], alpha: float = 0.05) -> list[float]:
|
||||||
color = [i for i in color]
|
color = [i for i in color]
|
||||||
color[3] = alpha
|
color[3] = alpha
|
||||||
return color
|
return color
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import ifcopenshell.api.grid
|
|||||||
import bonsai.core.geometry
|
import bonsai.core.geometry
|
||||||
import bonsai.core.geometry as core
|
import bonsai.core.geometry as core
|
||||||
import bonsai.core.aggregate
|
import bonsai.core.aggregate
|
||||||
|
import bonsai.core.nest
|
||||||
import bonsai.core.style
|
import bonsai.core.style
|
||||||
import bonsai.core.root
|
import bonsai.core.root
|
||||||
import bonsai.core.drawing
|
import bonsai.core.drawing
|
||||||
|
|||||||
Reference in New Issue
Block a user