From 035b6d00c5843d90de8d99e9441e44f3ad9be336 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 22 Oct 2024 12:15:29 +0500 Subject: [PATCH] bim.align_wall.align_type - use enum --- src/bonsai/bonsai/bim/module/model/wall.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/wall.py b/src/bonsai/bonsai/bim/module/model/wall.py index 35425e01d4..2fdeb8fcab 100644 --- a/src/bonsai/bonsai/bim/module/model/wall.py +++ b/src/bonsai/bonsai/bim/module/model/wall.py @@ -15,6 +15,8 @@ # # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . +# +# pyright: reportUnnecessaryTypeIgnoreComment=error import bpy import copy @@ -39,7 +41,7 @@ from mathutils import Vector, Matrix from bonsai.bim.module.model.opening import FilledOpeningGenerator from bonsai.bim.module.model.decorator import PolylineDecorator, ProductDecorator from bonsai.bim.module.model.polyline import PolylineOperator -from typing import Optional +from typing import Optional, assert_never, TYPE_CHECKING, get_args, Literal from lark import Lark, Transformer @@ -61,11 +63,18 @@ class AlignWall(bpy.types.Operator): bl_idname = "bim.align_wall" bl_label = "Align Wall" bl_options = {"REGISTER", "UNDO"} - bl_description = """ Align the selected walls to the last selected wall: + bl_description = """ Align the selected walls to the active wall: 'Ext.': align to the EXTERIOR face 'C/L': align to wall CENTERLINE 'Int.': align to the INTERIOR face""" - align_type: bpy.props.StringProperty() + + AlignType = Literal["CENTERLINE", "EXTERIOR", "INTERIOR"] + align_type: bpy.props.EnumProperty( # type: ignore [reportRedeclaration] + items=((i, i, "") for i in get_args(AlignType)) + ) + + if TYPE_CHECKING: + align_type: AlignType @classmethod def poll(cls, context): @@ -84,6 +93,8 @@ class AlignWall(bpy.types.Operator): aligner.align_first_layer() elif self.align_type == "INTERIOR": aligner.align_last_layer() + else: + assert_never(self.align_type) tool.Ifc.edit(obj) return {"FINISHED"}