buildingSMART Data Dictionary module: use pSets from different data dictionary sources (#7764)

* buildingSMART Data Dictionary module: added textfield to change data dictionary url

* moved change of bsdd baseurl change to addon settings

* Receiving Psets from other dictionary sources has been made available by dynamizing the  identifier_url using the client baseurl

* Remove unnecessary blank lines in prop.py

* Remove unused import of bsdd module
This commit is contained in:
Sebastian Schilling
2026-03-15 02:56:04 +01:00
committed by GitHub
parent b14da14614
commit 256e4d2191
3 changed files with 17 additions and 6 deletions
-1
View File
@@ -83,7 +83,6 @@ class BIM_PT_bsdd(Panel):
row = self.layout.row()
row.operator("bim.load_bsdd_dictionaries")
class BIM_UL_bsdd_dictionaries(UIList):
def draw_item(
self,
+1 -1
View File
@@ -262,7 +262,7 @@ class BIM_PT_object_psets(Panel):
row = self.layout.row(align=True)
prop_with_search(row, props, "pset_name", text="")
if props.pset_name != "BBIM_BSDD" and not props.pset_name.startswith(tool.Bsdd.identifier_url):
if props.pset_name != "BBIM_BSDD" and not props.pset_name.startswith(tool.Bsdd.identifier_url()):
op = row.operator("bim.add_pset", icon="ADD", text="")
op.obj = obj.name
op.obj_type = "Object"
+16 -4
View File
@@ -36,11 +36,23 @@ if TYPE_CHECKING:
class Bsdd(bonsai.core.tool.Bsdd):
identifier_url = "https://identifier.buildingsmart.org"
default_identifier_url = "https://identifier.buildingsmart.org"
default_api_url = "https://api.bsdd.buildingsmart.org/api/"
client = bsdd.Client()
bsdd_classes: dict[str, dict] = {}
bsdd_properties: dict[str, dict] = {}
@classmethod
def identifier_url(cls) -> str:
"""Derives the identifier base URL from the current client baseurl.
Falls back to the standard bSDD identifier URL when using the default API."""
if cls.client.baseurl == cls.default_api_url:
return cls.default_identifier_url
from urllib.parse import urlparse
parsed = urlparse(cls.client.baseurl)
return f"{parsed.scheme}://{parsed.netloc}"
@classmethod
def get_bsdd_props(cls) -> BIMBSDDProperties:
assert (scene := bpy.context.scene)
@@ -269,7 +281,7 @@ class Bsdd(bonsai.core.tool.Bsdd):
for obj in tool.Blender.get_selected_objects(include_active=True):
if element := tool.Ifc.get_entity(obj):
for reference in ifcopenshell.util.classification.get_references(element):
if (uri := reference.Location) and uri.startswith(cls.identifier_url):
if (uri := reference.Location) and uri.startswith(cls.identifier_url()):
classes.add((reference[1] or reference[2] or "Unnamed", uri))
dictionary_uris = (
@@ -383,7 +395,7 @@ class Bsdd(bonsai.core.tool.Bsdd):
def get_applicable_psets(cls, element: ifcopenshell.entity_instance):
uris = set()
for reference in ifcopenshell.util.classification.get_references(element):
if (uri := reference.Location) and uri.startswith(cls.identifier_url):
if (uri := reference.Location) and uri.startswith(cls.identifier_url()):
uris.add(uri)
psets = set()
for uri in uris:
@@ -399,7 +411,7 @@ class Bsdd(bonsai.core.tool.Bsdd):
def is_applicable(cls, pset_uri: str, element: ifcopenshell.entity_instance) -> bool:
uris = set()
for reference in ifcopenshell.util.classification.get_references(element):
if (uri := reference.Location) and uri.startswith(cls.identifier_url):
if (uri := reference.Location) and uri.startswith(cls.identifier_url()):
uris.add(uri)
class_uri, pset_name = pset_uri.rsplit("#", 1)
return class_uri in uris