moved change of bsdd baseurl change to addon settings

This commit is contained in:
Sebastian Schilling
2026-02-17 15:10:13 +01:00
committed by Dion Moult
parent a5461c0748
commit 418d410b5c
5 changed files with 9 additions and 47 deletions
@@ -37,7 +37,6 @@ classes = (
ui.BIM_UL_bsdd_classes,
ui.BIM_UL_bsdd_properties,
ui.BIM_PT_bsdd,
ui.BIM_OT_bsdd_reset_baseurl,
)
-17
View File
@@ -19,7 +19,6 @@
from typing import TYPE_CHECKING, Literal, Union
import bpy
import bsdd
from bpy.props import (
BoolProperty,
CollectionProperty,
@@ -74,14 +73,6 @@ def update_active_class_index(self: "BIMBSDDProperties", context: bpy.types.Cont
BSDDData.data["active_dictionary"] = BSDDData.active_dictionary()
def update_bsdd_baseurl(self: "BIMBSDDProperties", context: bpy.types.Context) -> None:
try:
tool.Bsdd.client = bsdd.Client()
if hasattr(tool.Bsdd.client, "baseurl"):
tool.Bsdd.client.baseurl = self.bsdd_baseurl
except Exception:
pass
class BSDDDictionary(PropertyGroup):
uri: StringProperty(name="URI")
default_language_code: StringProperty(name="Language")
@@ -172,13 +163,6 @@ class BIMBSDDProperties(PropertyGroup):
default=False,
)
classification_psets: CollectionProperty(name="Classification Psets", type=BSDDPset)
bsdd_baseurl: StringProperty(
name="Other URL:",
description="URL from another Dictionary with bSDD API",
default="",
update=update_bsdd_baseurl,
)
if TYPE_CHECKING:
active_dictionary: str
@@ -198,7 +182,6 @@ class BIMBSDDProperties(PropertyGroup):
should_filter_ifc_class: bool
use_only_ifc_properties: bool
classification_psets: bpy.types.bpy_prop_collection_idprop[BSDDPset]
bsdd_baseurl: str
@property
def active_class(self) -> Union[BSDDClassification, None]:
-29
View File
@@ -51,17 +51,6 @@ class BIM_PT_bsdd(Panel):
props = tool.Bsdd.get_bsdd_props()
assert self.layout
layout = self.layout
try:
if not props.bsdd_baseurl:
try:
props.bsdd_baseurl = tool.Bsdd.client.baseurl
except Exception:
props.bsdd_baseurl = bsdd.Client().baseurl
except Exception:
pass
row = layout.row(align=True)
row.prop(props, "bsdd_baseurl", text="Other URL", emboss=True)
row.operator("bim.bsdd_reset_baseurl", icon="LOOP_BACK", text="")
if len(props.dictionaries):
row = self.layout.row()
row.operator("bim.load_bsdd_dictionaries", icon="FILE_REFRESH")
@@ -95,24 +84,6 @@ class BIM_PT_bsdd(Panel):
row = self.layout.row()
row.operator("bim.load_bsdd_dictionaries")
class BIM_OT_bsdd_reset_baseurl(bpy.types.Operator):
bl_idname = "bim.bsdd_reset_baseurl"
bl_label = "Reset bSDD Base URL"
bl_description = "Resets the bSDD base URL to the default value"
def execute(self, context):
import bsdd
props = tool.Bsdd.get_bsdd_props()
props.bsdd_baseurl = ""
try:
tool.Bsdd.client = bsdd.Client()
if hasattr(tool.Bsdd.client, "baseurl"):
tool.Bsdd.client.baseurl = default_url
except Exception:
pass
self.report({'INFO'}, "bSDD base URL reset.")
return {'FINISHED'}
class BIM_UL_bsdd_dictionaries(UIList):
def draw_item(
self,
+5
View File
@@ -660,6 +660,10 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
bsdd_load_test_dictionaries: BoolProperty(
name="Load Test Dictionaries", description="Load dictionaries that are for testing only", default=False
)
bsdd_baseurl: StringProperty(
name="bSDD API Base URL", description="Base URL for data dictionary API requests, e.g. https://api.bsdd.buildingsmart.org/api/",
default="https://api.bsdd.buildingsmart.org/api/",
)
should_disable_undo_on_save: BoolProperty(
name="Disable Undo When Saving (Faster saves, no undo for you!)", default=False
)
@@ -972,6 +976,7 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
layout.prop(self, "bsdd_load_preview_dictionaries")
layout.prop(self, "bsdd_load_inactive_dictionaries")
layout.prop(self, "bsdd_load_test_dictionaries")
layout.prop(self, "bsdd_baseurl")
def draw_extras_settings(self, layout: bpy.types.UILayout, context: bpy.types.Context) -> None:
layout.prop(self, "container_hide_show_isolate")
+4
View File
@@ -123,6 +123,10 @@ class Bsdd(bonsai.core.tool.Bsdd):
@classmethod
def get_dictionaries(cls) -> list[bsdd.DictionaryContractV1]:
prefs = tool.Blender.get_addon_preferences()
baseurl = getattr(prefs, "bsdd_baseurl", "https://api.bsdd.buildingsmart.org/api/")
cls.client = bsdd.Client()
if hasattr(cls.client, "baseurl"):
cls.client.baseurl = baseurl
response = cls.client.get_dictionary(include_test_dictionaries=prefs.bsdd_load_test_dictionaries)
dicts = response.get("dictionaries") or []
statuses = ["Active"]