mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
buildingSMART Data Dictionary module: added textfield to change data dictionary url
This commit is contained in:
committed by
Dion Moult
parent
291e815770
commit
a5461c0748
@@ -37,6 +37,7 @@ classes = (
|
||||
ui.BIM_UL_bsdd_classes,
|
||||
ui.BIM_UL_bsdd_properties,
|
||||
ui.BIM_PT_bsdd,
|
||||
ui.BIM_OT_bsdd_reset_baseurl,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
from typing import TYPE_CHECKING, Literal, Union
|
||||
|
||||
import bpy
|
||||
import bsdd
|
||||
from bpy.props import (
|
||||
BoolProperty,
|
||||
CollectionProperty,
|
||||
@@ -73,6 +74,14 @@ 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")
|
||||
@@ -164,6 +173,13 @@ class BIMBSDDProperties(PropertyGroup):
|
||||
)
|
||||
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
|
||||
active_dictionary: str
|
||||
@@ -182,7 +198,8 @@ 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]:
|
||||
return tool.Blender.get_active_uilist_element(self.classes, self.active_class_index)
|
||||
|
||||
@@ -24,6 +24,7 @@ import bpy
|
||||
from bpy.types import Panel, UIList
|
||||
|
||||
import bonsai.tool as tool
|
||||
import bsdd
|
||||
from bonsai.bim.module.bsdd.data import BSDDData
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -50,6 +51,17 @@ 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")
|
||||
@@ -83,6 +95,23 @@ 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(
|
||||
|
||||
Reference in New Issue
Block a user