mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
typing
This commit is contained in:
@@ -20,6 +20,7 @@ import bpy
|
||||
import math
|
||||
import mathutils.geometry
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.unit
|
||||
import bonsai.tool as tool
|
||||
from mathutils import Vector
|
||||
from typing import Union
|
||||
|
||||
@@ -157,15 +157,17 @@ class RepresentationsData:
|
||||
if not cls.data["representations"]:
|
||||
return []
|
||||
obj = tool.Geometry.get_active_or_representation_obj()
|
||||
assert obj
|
||||
if not obj.data:
|
||||
return []
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
assert element
|
||||
base_representation = tool.Geometry.get_active_representation(obj)
|
||||
if not base_representation:
|
||||
return [] # Maybe in profile editing mode
|
||||
|
||||
# shape aspects matching context of the active representation
|
||||
matching_shape_aspects = []
|
||||
matching_shape_aspects: list[ifcopenshell.entity_instance] = []
|
||||
for shape_aspect in ifcopenshell.util.element.get_shape_aspects(element):
|
||||
matching_representation = tool.Geometry.get_shape_aspect_representation(shape_aspect, base_representation)
|
||||
if matching_representation:
|
||||
|
||||
@@ -121,7 +121,7 @@ def get_layers_no_active(self, context):
|
||||
return LayersData.data["layers_enum_no_active"]
|
||||
|
||||
|
||||
def update_shape_aspect(self, context):
|
||||
def update_shape_aspect(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> None:
|
||||
shape_aspect_id = self.representation_item_shape_aspect
|
||||
attrs = self.shape_aspect_attrs
|
||||
|
||||
@@ -250,9 +250,8 @@ class BIMObjectGeometryProperties(PropertyGroup):
|
||||
representation_item_layer: EnumProperty(items=get_layers, name="Representation Item's Layer")
|
||||
|
||||
@property
|
||||
def active_item(self):
|
||||
if 0 <= self.active_item_index < len(self.items):
|
||||
return self.items[self.active_item_index]
|
||||
def active_item(self) -> Union[RepresentationItem, None]:
|
||||
return tool.Blender.get_active_uilist_element(self.items, self.active_item_index)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
contexts: str
|
||||
|
||||
@@ -24,7 +24,7 @@ from bpy.types import Panel, UIList
|
||||
from bonsai.bim.helper import draw_attributes
|
||||
from bonsai.bim.helper import prop_with_search
|
||||
from bonsai.bim.module.material.data import MaterialsData, ObjectMaterialData
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bonsai.bim.module.material.prop import Material, BIMMaterialProperties
|
||||
@@ -289,7 +289,7 @@ class BIM_PT_object_material(Panel):
|
||||
row = box.row()
|
||||
prop_with_search(row, self.mprops, "profiles", icon="ITALIC", text="Profile")
|
||||
|
||||
def draw_read_only_set_item_ui(self, box, set_item):
|
||||
def draw_read_only_set_item_ui(self, box: bpy.types.UILayout, set_item: dict[str, Any]) -> None:
|
||||
if ObjectMaterialData.data["material_class"] == "IfcMaterialList":
|
||||
row = box.row(align=True)
|
||||
row.label(text="IfcMaterial", icon="LAYER_ACTIVE")
|
||||
|
||||
@@ -237,7 +237,8 @@ class BIM_PT_object_psets(Panel):
|
||||
def draw_header(self, context):
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="") # empty text occupies the left of the row
|
||||
row.prop(context.scene.GlobalPsetProperties, "pset_filter", text="", icon="VIEWZOOM")
|
||||
global_props = tool.Pset.get_global_pset_props()
|
||||
row.prop(global_props, "pset_filter", text="", icon="VIEWZOOM")
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
@@ -261,6 +262,7 @@ class BIM_PT_object_psets(Panel):
|
||||
op.obj = context.active_object.name
|
||||
op.obj_type = "Object"
|
||||
|
||||
global_props = tool.Pset.get_global_pset_props()
|
||||
if not props.active_pset_id and props.active_pset_name and props.active_pset_type == "PSET":
|
||||
draw_psetqto_ui(
|
||||
context,
|
||||
@@ -269,7 +271,7 @@ class BIM_PT_object_psets(Panel):
|
||||
props,
|
||||
self.layout,
|
||||
"Object",
|
||||
filter_keyword=context.scene.GlobalPsetProperties.pset_filter,
|
||||
filter_keyword=global_props.pset_filter,
|
||||
)
|
||||
|
||||
if ObjectPsetsData.data["psets"]:
|
||||
@@ -285,7 +287,7 @@ class BIM_PT_object_psets(Panel):
|
||||
props,
|
||||
self.layout,
|
||||
"Object",
|
||||
filter_keyword=context.scene.GlobalPsetProperties.pset_filter,
|
||||
filter_keyword=global_props.pset_filter,
|
||||
)
|
||||
|
||||
if ObjectPsetsData.data["inherited_psets"]:
|
||||
@@ -299,7 +301,7 @@ class BIM_PT_object_psets(Panel):
|
||||
self.layout,
|
||||
"Object",
|
||||
allow_removing=False,
|
||||
filter_keyword=context.scene.GlobalPsetProperties.pset_filter,
|
||||
filter_keyword=global_props.pset_filter,
|
||||
)
|
||||
|
||||
|
||||
@@ -315,7 +317,8 @@ class BIM_PT_object_qtos(Panel):
|
||||
def draw_header(self, context):
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="") # empty text occupies the left of the row
|
||||
row.prop(context.scene.GlobalPsetProperties, "qto_filter", text="", icon="VIEWZOOM")
|
||||
global_props = tool.Pset.get_global_pset_props()
|
||||
row.prop(global_props, "qto_filter", text="", icon="VIEWZOOM")
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
@@ -339,6 +342,7 @@ class BIM_PT_object_qtos(Panel):
|
||||
op.obj = context.active_object.name
|
||||
op.obj_type = "Object"
|
||||
|
||||
global_props = tool.Pset.get_global_pset_props()
|
||||
if not props.active_pset_id and props.active_pset_name and props.active_pset_type == "QTO":
|
||||
draw_psetqto_ui(
|
||||
context,
|
||||
@@ -347,7 +351,7 @@ class BIM_PT_object_qtos(Panel):
|
||||
props,
|
||||
self.layout,
|
||||
"Object",
|
||||
filter_keyword=context.scene.GlobalPsetProperties.qto_filter,
|
||||
filter_keyword=global_props.qto_filter,
|
||||
)
|
||||
|
||||
if ObjectQtosData.data["qtos"]:
|
||||
@@ -363,7 +367,7 @@ class BIM_PT_object_qtos(Panel):
|
||||
props,
|
||||
self.layout,
|
||||
"Object",
|
||||
filter_keyword=context.scene.GlobalPsetProperties.qto_filter,
|
||||
filter_keyword=global_props.qto_filter,
|
||||
)
|
||||
|
||||
if ObjectQtosData.data["inherited_qsets"]:
|
||||
@@ -377,7 +381,7 @@ class BIM_PT_object_qtos(Panel):
|
||||
self.layout,
|
||||
"Object",
|
||||
allow_removing=False,
|
||||
filter_keyword=context.scene.GlobalPsetProperties.qto_filter,
|
||||
filter_keyword=global_props.qto_filter,
|
||||
)
|
||||
layout = self.layout
|
||||
qtoprops = tool.Qto.get_qto_props()
|
||||
|
||||
@@ -31,12 +31,16 @@ from typing_extensions import assert_never
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bonsai.bim.module.pset.prop import PsetProperties
|
||||
from bonsai.bim.module.pset.prop import PsetProperties, GlobalPsetProperties
|
||||
|
||||
|
||||
class Pset(bonsai.core.tool.Pset):
|
||||
PSET_TYPE = Literal["PSET", "QTO"]
|
||||
|
||||
@classmethod
|
||||
def get_global_pset_props(cls) -> GlobalPsetProperties:
|
||||
return bpy.context.scene.GlobalPsetProperties
|
||||
|
||||
@classmethod
|
||||
def get_element_pset(
|
||||
cls, element: ifcopenshell.entity_instance, pset_name: str
|
||||
|
||||
Reference in New Issue
Block a user