mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
bsdd - expose bsdd props descriptions to ui
Example - https://imgur.com/a/xUUeuF5
This commit is contained in:
@@ -60,10 +60,14 @@ class SearchBSDDClass(bpy.types.Operator):
|
||||
class GetBSDDClassificationProperties(bpy.types.Operator):
|
||||
bl_idname = "bim.get_bsdd_classification_properties"
|
||||
bl_label = "Search bSDD Class Properties"
|
||||
bl_description = "Search for bSDD class properties for the currently selected class"
|
||||
bl_description = (
|
||||
"Search for bSDD class properties for the currently selected class. All non-IFC properties are skipped"
|
||||
)
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
properties_found = core.get_class_properties(bsdd.Client(), tool.Bsdd)
|
||||
self.report({"INFO"}, f"{properties_found} properties found for the active classification.")
|
||||
pset_data = core.get_class_properties(bsdd.Client(), tool.Bsdd)
|
||||
psets_found = len(pset_data)
|
||||
props_found = sum(len(pset) for pset in pset_data.values())
|
||||
self.report({"INFO"}, f"{psets_found} psets found ({props_found} props) for the active classification.")
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from typing import TYPE_CHECKING, Optional, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import bpy
|
||||
@@ -26,14 +26,14 @@ if TYPE_CHECKING:
|
||||
import blenderbim.tool as tool
|
||||
|
||||
|
||||
def get_class_properties(client: bsdd.Client, bsdd: tool.Bsdd) -> int:
|
||||
def get_class_properties(client: bsdd.Client, bsdd: tool.Bsdd) -> dict[str, dict[str, Any]]:
|
||||
bsdd.clear_class_psets()
|
||||
data = bsdd.get_active_class_data(client)
|
||||
pset_dict = bsdd.get_property_dict(data)
|
||||
if pset_dict is None:
|
||||
return 0
|
||||
return {}
|
||||
bsdd.create_class_psets(pset_dict)
|
||||
return len(pset_dict)
|
||||
return pset_dict
|
||||
|
||||
|
||||
def load_bsdd(client: bsdd.Client, bsdd: tool.Bsdd) -> None:
|
||||
|
||||
@@ -38,6 +38,8 @@ class Bsdd(blenderbim.core.tool.Bsdd):
|
||||
new2.data_type = "enum"
|
||||
else:
|
||||
new2.data_type = data_type_map[data["data_type"]]
|
||||
new2.description = data["description"]
|
||||
new2.ifc_class = data["ifc_class"]
|
||||
|
||||
@classmethod
|
||||
def create_classes(cls, class_dict: list[bsdd.ClassSearchResponseClassContractV1]) -> None:
|
||||
@@ -89,6 +91,10 @@ class Bsdd(blenderbim.core.tool.Bsdd):
|
||||
if not properties:
|
||||
return None
|
||||
|
||||
ifc_class = class_data.get("relatedIfcEntityNames") or ""
|
||||
if ifc_class:
|
||||
ifc_class = ifc_class[0]
|
||||
|
||||
psets = {}
|
||||
for prop in properties:
|
||||
if prop.get("propertyDictionaryName") != "IFC":
|
||||
@@ -105,7 +111,14 @@ class Bsdd(blenderbim.core.tool.Bsdd):
|
||||
possible_values = prop.get("allowedValues", []) or []
|
||||
possible_values = [v["value"] for v in possible_values]
|
||||
|
||||
psets[pset][prop["name"]] = {"data_type": prop["dataType"], "possible_values": possible_values}
|
||||
description = prop.get("description", "")
|
||||
|
||||
psets[pset][prop["name"]] = {
|
||||
"data_type": prop["dataType"],
|
||||
"possible_values": possible_values,
|
||||
"description": description,
|
||||
"ifc_class": ifc_class,
|
||||
}
|
||||
return psets
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -31,6 +31,8 @@ __version__ = version = "0.0.0"
|
||||
Status = Literal["Preview", "Active", "Inactive"]
|
||||
ClassTypes = Literal["Class", "GroupOfProperties", "AlternativeUse", "Material"]
|
||||
|
||||
# NOTE: Some values in TypedDicts are actually not guaranteed to be provided
|
||||
# and should be typed with NotRequired.
|
||||
|
||||
class DictionaryContractV1(TypedDict):
|
||||
uri: str
|
||||
|
||||
Reference in New Issue
Block a user