mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 01:11:40 +00:00
bim.attribute_search_values - use enumproperty for data_type
This commit is contained in:
@@ -42,7 +42,7 @@ from mathutils import Vector, Euler
|
||||
from math import radians
|
||||
from pathlib import Path
|
||||
from collections import namedtuple
|
||||
from typing import Union, TYPE_CHECKING
|
||||
from typing import Union, TYPE_CHECKING, Literal, get_args
|
||||
from collections.abc import Iterable
|
||||
from natsort import natsorted
|
||||
|
||||
@@ -1302,7 +1302,7 @@ class ShowSystemInfo(bpy.types.Operator):
|
||||
col.label(text="(The information has been copied to the clipboard.)")
|
||||
|
||||
|
||||
def update_attribute_search_value(self, context):
|
||||
def update_attribute_search_value(self: "BIM_OT_attribute_search_values", context: bpy.types.Context) -> None:
|
||||
should_click_ok = False
|
||||
attr_name, attribute_obj = BIM_OT_attribute_search_values.resolve_data_path(self.data_path)
|
||||
|
||||
@@ -1321,6 +1321,9 @@ def update_attribute_search_value(self, context):
|
||||
context.window.screen = context.window.screen
|
||||
|
||||
|
||||
AttributeSearchDataType = Literal["string", "integer", "float"]
|
||||
|
||||
|
||||
class BIM_OT_attribute_search_values(bpy.types.Operator):
|
||||
"""Search for attribute values. This implementation is based on bim.enum_property_search"""
|
||||
|
||||
@@ -1332,7 +1335,10 @@ class BIM_OT_attribute_search_values(bpy.types.Operator):
|
||||
attribute_name: bpy.props.StringProperty(name="Attribute Name")
|
||||
attribute_ifc_class: bpy.props.StringProperty(name="Attribute IFC Class")
|
||||
data_path: bpy.props.StringProperty(name="Data Path")
|
||||
data_type: bpy.props.StringProperty(name="Data Type")
|
||||
data_type: bpy.props.EnumProperty(
|
||||
name="Data Type",
|
||||
items=[(i, i, "") for i in get_args(AttributeSearchDataType)],
|
||||
)
|
||||
search_value: bpy.props.StringProperty(
|
||||
name="Search",
|
||||
description="Search for attribute values",
|
||||
@@ -1342,6 +1348,9 @@ class BIM_OT_attribute_search_values(bpy.types.Operator):
|
||||
)
|
||||
collection_values: bpy.props.CollectionProperty(type=StrProperty, options={"SKIP_SAVE"})
|
||||
|
||||
if TYPE_CHECKING:
|
||||
data_type: AttributeSearchDataType
|
||||
|
||||
@staticmethod
|
||||
def resolve_data_path(data_path: str) -> tuple[str, "Attribute"]:
|
||||
"""Resolve the data path of an object's attribute to get the attribute name and the object."""
|
||||
|
||||
Reference in New Issue
Block a user