Add Description-ContextMenu Entry to bSDD Properties (#6970)

See #6970 for example.
This commit is contained in:
Christoph Mellüh
2025-08-04 15:52:00 +02:00
committed by GitHub
parent 37c05f763e
commit d2939067bd
5 changed files with 41 additions and 2 deletions
@@ -25,6 +25,7 @@ classes = (
operator.LoadBSDDDictionaries,
operator.SearchBSDDClassifications,
operator.SearchBSDDProperties,
operator.BIM_OT_show_bsdd_description,
prop.BSDDDictionary,
prop.BSDDClassification,
prop.BSDDProperty,
+33 -1
View File
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
import textwrap
import bpy
import bsdd
import bonsai.tool as tool
@@ -105,3 +105,35 @@ class AddBSDDProperties(bpy.types.Operator, tool.Ifc.Operator):
else:
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name=pset_name)
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties=properties)
class BIM_OT_show_bsdd_description(bpy.types.Operator):
bl_idname = "bim.show_bsdd_description"
bl_label = "bSDD Description"
url: bpy.props.StringProperty()
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self, width=450)
def execute(self, context):
return {"FINISHED"}
def draw(self, context):
WIDTH = 80
layout = self.layout
wrapper = textwrap.TextWrapper(width=WIDTH)
result = tool.Bsdd.get_bsdd_property(self.url)
description = result.get("description") or ""
definition = result.get("definition") or ""
if description != definition:
text = wrapper.wrap(f"Description : {description}")
text.append("-" * (WIDTH - 15))
text += wrapper.wrap(f"Definition : {definition}")
else:
text = wrapper.wrap(f"Description : {description}")
for line in text:
layout.label(text=line)
if self.url:
url_op = layout.operator("bim.open_uri", icon="URL", text="Online bSDD Documentation")
url_op.uri = self.url
+1
View File
@@ -147,6 +147,7 @@ class BIM_UL_bsdd_properties(UIList):
active_propname,
) -> None:
if item:
layout.context_pointer_set("active_bsdd_property", item) # used for context menu
row = layout.row(align=True)
name = item.name
if name != item.code:
+5
View File
@@ -36,6 +36,7 @@ import bonsai.bim
import bonsai.tool as tool
from ifcopenshell.util.file import IfcHeaderExtractor
from bonsai.bim.prop import Attribute
from bonsai.bim.module.bsdd.prop import BIMBSDDProperties
from typing import Optional, TYPE_CHECKING, Literal
from natsort import natsorted
@@ -1440,6 +1441,10 @@ def draw_custom_context_menu(self: bpy.types.Menu, context: bpy.types.Context) -
if attr_name:
op = layout.operator("bim.copy_text_to_clipboard", text="Copy Attribute Name", icon="COPYDOWN")
op.text = attr_name
elif isinstance(prop_struct, BIMBSDDProperties) and hasattr(context, "active_bsdd_property"):
# Context Menu for bSDD Properties
op_description = layout.operator("bim.show_bsdd_description", text="bSDD Description", icon="INFO")
op_description.url = context.active_bsdd_property.uri
else:
# Basically context menu for any Blender property will end up here,
# and will check 3 types of docs.
+1 -1
View File
@@ -220,7 +220,7 @@ class Bsdd(bonsai.core.tool.Bsdd):
prop.dictionary_name = dictionary_name
prop.dictionary_namespace_uri = dictionary_namespace_uri
total_results = response.get("count", response.get("classesCount"))
total_results = len(bprops.classifications)
# For now, hard limit at 1000 results because any more and Blender
# starts getting slow and they really should filter better
if offset < 1000 and should_paginate and total_results == limit: