mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +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 math import radians
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from collections import namedtuple
|
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 collections.abc import Iterable
|
||||||
from natsort import natsorted
|
from natsort import natsorted
|
||||||
|
|
||||||
@@ -1302,7 +1302,7 @@ class ShowSystemInfo(bpy.types.Operator):
|
|||||||
col.label(text="(The information has been copied to the clipboard.)")
|
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
|
should_click_ok = False
|
||||||
attr_name, attribute_obj = BIM_OT_attribute_search_values.resolve_data_path(self.data_path)
|
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
|
context.window.screen = context.window.screen
|
||||||
|
|
||||||
|
|
||||||
|
AttributeSearchDataType = Literal["string", "integer", "float"]
|
||||||
|
|
||||||
|
|
||||||
class BIM_OT_attribute_search_values(bpy.types.Operator):
|
class BIM_OT_attribute_search_values(bpy.types.Operator):
|
||||||
"""Search for attribute values. This implementation is based on bim.enum_property_search"""
|
"""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_name: bpy.props.StringProperty(name="Attribute Name")
|
||||||
attribute_ifc_class: bpy.props.StringProperty(name="Attribute IFC Class")
|
attribute_ifc_class: bpy.props.StringProperty(name="Attribute IFC Class")
|
||||||
data_path: bpy.props.StringProperty(name="Data Path")
|
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(
|
search_value: bpy.props.StringProperty(
|
||||||
name="Search",
|
name="Search",
|
||||||
description="Search for attribute values",
|
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"})
|
collection_values: bpy.props.CollectionProperty(type=StrProperty, options={"SKIP_SAVE"})
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
data_type: AttributeSearchDataType
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_data_path(data_path: str) -> tuple[str, "Attribute"]:
|
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."""
|
"""Resolve the data path of an object's attribute to get the attribute name and the object."""
|
||||||
|
|||||||
Reference in New Issue
Block a user