mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
bsdd search to check whether query is long enough
It's an API requirement and using shorter queries was giving confusing results. https://github.com/buildingSMART/bSDD/blob/master/Documentation/bSDD%20OpenAPI.yaml
This commit is contained in:
@@ -50,6 +50,14 @@ class SearchBSDDClass(bpy.types.Operator):
|
||||
bl_description = "Search for bSDD classes by the provided keyword"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
# Requirement by buildingSMART bSDD api.
|
||||
if len(context.scene.BIMBSDDProperties.keyword) < 3:
|
||||
cls.poll_message_set("Search query has to be at least 3 characters long.")
|
||||
return False
|
||||
return True
|
||||
|
||||
def execute(self, context):
|
||||
keyword = context.scene.BIMBSDDProperties.keyword
|
||||
classes_found = core.search_class(keyword, bsdd.Client(), tool.Bsdd)
|
||||
|
||||
@@ -60,7 +60,7 @@ class BIMBSDDProperties(PropertyGroup):
|
||||
active_domain_index: IntProperty(name="Active Domain Index")
|
||||
classifications: CollectionProperty(name="Classifications", type=BSDDClassification)
|
||||
active_classification_index: IntProperty(name="Active Classification Index")
|
||||
keyword: StringProperty(name="Keyword")
|
||||
keyword: StringProperty(name="Keyword", description="Query for bsdd classes search, case and accent insensitive")
|
||||
should_filter_ifc_class: BoolProperty(
|
||||
name="Filter Active IFC Class",
|
||||
description="Whether to search only for bSDD classes that match active object's IFC class",
|
||||
|
||||
@@ -47,7 +47,7 @@ def load_bsdd(client: bsdd.Client, bsdd: tool.Bsdd) -> None:
|
||||
|
||||
def search_class(keyword: str, client: bsdd.Client, bsdd: tool.Bsdd) -> int:
|
||||
bsdd.clear_classes()
|
||||
related_entities = bsdd.get_related_ifc_entities(keyword)
|
||||
related_entities = bsdd.get_related_ifc_entities()
|
||||
active_dictionary_uri = bsdd.get_active_dictionary_uri()
|
||||
classes = bsdd.search_class(client, keyword, [active_dictionary_uri], related_entities)
|
||||
bsdd.create_classes(classes)
|
||||
|
||||
@@ -121,11 +121,9 @@ class Bsdd(bonsai.core.tool.Bsdd):
|
||||
return psets
|
||||
|
||||
@classmethod
|
||||
def get_related_ifc_entities(cls, keyword: str) -> list[str]:
|
||||
def get_related_ifc_entities(cls) -> list[str]:
|
||||
active_object = bpy.context.active_object
|
||||
related_ifc_entities = []
|
||||
if len(keyword) < 3:
|
||||
return []
|
||||
if cls.should_filter_ifc_class() and active_object:
|
||||
element = tool.Ifc.get_entity(active_object)
|
||||
if element:
|
||||
|
||||
Reference in New Issue
Block a user