mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
typing
This commit is contained in:
@@ -35,13 +35,13 @@ from bpy.props import (
|
||||
from typing import Optional, TYPE_CHECKING, Union, Literal
|
||||
|
||||
|
||||
def get_contexts(self, context):
|
||||
def get_contexts(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]:
|
||||
if not RepresentationsData.is_loaded:
|
||||
RepresentationsData.load()
|
||||
return RepresentationsData.data["contexts"]
|
||||
|
||||
|
||||
def update_mode(self, context):
|
||||
def update_mode(self: "BIMGeometryProperties", context: bpy.types.Context) -> None:
|
||||
if self.is_changing_mode:
|
||||
return
|
||||
if context.mode.startswith("EDIT"):
|
||||
@@ -62,7 +62,7 @@ def update_mode(self, context):
|
||||
bpy.ops.bim.override_mode_set_edit("INVOKE_DEFAULT")
|
||||
|
||||
|
||||
def update_representation_obj(self, context):
|
||||
def update_representation_obj(self: "BIMGeometryProperties", context: bpy.types.Context) -> None:
|
||||
for item_obj in self.item_objs:
|
||||
if item_obj.obj:
|
||||
data = item_obj.obj.data
|
||||
@@ -76,13 +76,13 @@ def update_representation_obj(self, context):
|
||||
self.is_changing_mode = False
|
||||
|
||||
|
||||
def get_mode(self, context):
|
||||
def get_mode(self: "BIMGeometryProperties", context: bpy.types.Context) -> list[tuple[str, str, str, str, int]]:
|
||||
if not ViewportData.is_loaded:
|
||||
ViewportData.load()
|
||||
return ViewportData.data["mode"]
|
||||
|
||||
|
||||
def get_styles(self, context):
|
||||
def get_styles(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]:
|
||||
# postponed import to avoid circular import
|
||||
from bonsai.bim.module.material.data import MaterialsData
|
||||
|
||||
@@ -91,13 +91,13 @@ def get_styles(self, context):
|
||||
return MaterialsData.data["styles"]
|
||||
|
||||
|
||||
def get_shape_aspects(self, context):
|
||||
def get_shape_aspects(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]:
|
||||
if not RepresentationsData.is_loaded:
|
||||
RepresentationsData.load()
|
||||
return RepresentationsData.data["shape_aspects"]
|
||||
|
||||
|
||||
def get_material_constituents(self, context, edit_text):
|
||||
def get_material_constituents(self: "ShapeAspect", context: bpy.types.Context, edit_text: str) -> list[str]:
|
||||
from bonsai.bim.module.material.data import ObjectMaterialData
|
||||
|
||||
if not ObjectMaterialData.is_loaded:
|
||||
@@ -105,7 +105,7 @@ def get_material_constituents(self, context, edit_text):
|
||||
return ObjectMaterialData.data["active_material_constituents"]
|
||||
|
||||
|
||||
def get_layers(self, context):
|
||||
def get_layers(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]:
|
||||
from bonsai.bim.module.layer.data import LayersData
|
||||
|
||||
if not LayersData.is_loaded:
|
||||
@@ -113,7 +113,7 @@ def get_layers(self, context):
|
||||
return LayersData.data["layers_enum"]
|
||||
|
||||
|
||||
def get_layers_no_active(self, context):
|
||||
def get_layers_no_active(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]:
|
||||
from bonsai.bim.module.layer.data import LayersData
|
||||
|
||||
if not LayersData.is_loaded:
|
||||
|
||||
@@ -394,7 +394,7 @@ class ObjectMaterialData:
|
||||
return [(m, m, ifcopenshell.util.doc.get_entity_doc(version, m).get("description", "")) for m in material_types]
|
||||
|
||||
@classmethod
|
||||
def active_material_constituents(cls):
|
||||
def active_material_constituents(cls) -> list[str]:
|
||||
material = cls.material
|
||||
if not cls.material or not material.is_a("IfcMaterialConstituentSet"):
|
||||
return []
|
||||
|
||||
@@ -491,7 +491,7 @@ class ShowOpenings(Operator, tool.Ifc.Operator):
|
||||
def _execute(self, context):
|
||||
objs = list(context.selected_objects)
|
||||
# If several parts of an aggregation are selected, the aggregate openings may be queried more than once
|
||||
objects_element_map = set()
|
||||
objects_element_map: set[tuple[bpy.types.Object, ifcopenshell.entity_instance]] = set()
|
||||
while objs:
|
||||
obj = objs.pop(0)
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
@@ -500,6 +500,7 @@ class ShowOpenings(Operator, tool.Ifc.Operator):
|
||||
# Select aggregate recursively
|
||||
if element.Decomposes and (aggregate := element.Decomposes[0].RelatingObject):
|
||||
aggregate_obj = tool.Ifc.get_object(aggregate)
|
||||
assert isinstance(aggregate_obj, bpy.types.Object)
|
||||
objs.append(aggregate_obj)
|
||||
objects_element_map.add((obj, element))
|
||||
|
||||
@@ -509,7 +510,7 @@ class ShowOpenings(Operator, tool.Ifc.Operator):
|
||||
bpy.ops.bim.update_openings_focus()
|
||||
return {"FINISHED"}
|
||||
|
||||
def show_object_openings(self, obj, element):
|
||||
def show_object_openings(self, obj: bpy.types.Object, element: ifcopenshell.entity_instance) -> None:
|
||||
openings_elements = [rel.RelatedOpeningElement for rel in tool.Geometry.get_openings(element)]
|
||||
if not openings_elements:
|
||||
return
|
||||
@@ -531,15 +532,18 @@ class UpdateOpeningsFocus(Operator):
|
||||
preferences = tool.Blender.get_addon_preferences()
|
||||
if preferences.opening_focus_opacity == 100:
|
||||
return {"FINISHED"}
|
||||
openings = set()
|
||||
building_objects = set()
|
||||
openings: set[bpy.types.Object] = set()
|
||||
building_objects: set[bpy.types.Object] = set()
|
||||
props = tool.Model.get_model_props()
|
||||
for opening in props.openings:
|
||||
if opening.obj:
|
||||
openings.add(opening.obj)
|
||||
opening_element = tool.Ifc.get_entity(opening.obj)
|
||||
assert opening_element
|
||||
building_element = opening_element.VoidsElements[0].RelatingBuildingElement
|
||||
building_objects.add(tool.Ifc.get_object(building_element))
|
||||
building_obj = tool.Ifc.get_object(building_element)
|
||||
assert isinstance(building_obj, bpy.types.Object)
|
||||
building_objects.add(building_obj)
|
||||
|
||||
for obj in context.scene.objects:
|
||||
obj.color = [
|
||||
|
||||
Reference in New Issue
Block a user