mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Add popup window when clicking Ifc description in right click context menu
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
import os
|
||||
import bpy
|
||||
import json
|
||||
import textwrap
|
||||
import time
|
||||
import logging
|
||||
import webbrowser
|
||||
@@ -28,7 +29,7 @@ import blenderbim.tool as tool
|
||||
from . import schema
|
||||
from blenderbim.bim import import_ifc
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.prop import StrProperty
|
||||
from blenderbim.bim.prop import StrProperty, get_ifc_entity_doc_url
|
||||
from blenderbim.bim.ui import IFCFileSelector
|
||||
from blenderbim.bim.helper import get_enum_items
|
||||
from mathutils import Vector, Matrix, Euler
|
||||
@@ -688,11 +689,26 @@ class EditBlenderCollection(bpy.types.Operator):
|
||||
class BIM_OT_show_description(bpy.types.Operator):
|
||||
bl_idname = "bim.show_description"
|
||||
bl_label = "Description"
|
||||
ifc_class: bpy.props.StringProperty()
|
||||
description: 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):
|
||||
layout = self.layout
|
||||
wrapper = textwrap.TextWrapper(width=80)
|
||||
for line in wrapper.wrap(self.description):
|
||||
layout.label(text=line)
|
||||
url = get_ifc_entity_doc_url(self.ifc_class)
|
||||
if url:
|
||||
url_op = layout.operator("bim.open_webbrowser", icon="URL", text="Online IFC Documentation")
|
||||
url_op.url = url
|
||||
|
||||
@classmethod
|
||||
def description(cls, context, properties):
|
||||
return properties.description
|
||||
|
||||
@@ -129,12 +129,13 @@ def get_predefined_type_description(entity, predefined_type):
|
||||
|
||||
|
||||
HARDCODED_ATTRIBUTE_DESCRIPTIONS = {
|
||||
"GlobalId": "Unique Entity Identifier",
|
||||
"Name": "TODO",
|
||||
"Description": "TODO",
|
||||
"PredefinedType": "TODO",
|
||||
"ObjectType": "TODO",
|
||||
"Tag": "TODO",
|
||||
"GlobalId": "Assignment of a globally unique identifier within the entire software world.",
|
||||
"OwnerHistory": "Assignment of the information about the current ownership of that object, including owning actor, application, local identification and information captured about the recent changes of the object, NOTE only the last modification in stored - either as addition, deletion or modification.",
|
||||
"Name": "Optional name for use by the participating software systems or users. For some subtypes of IfcRoot the insertion of the Name attribute may be required. This would be enforced by a where rule. ",
|
||||
"Description": "Optional description, provided for exchanging informative comments.",
|
||||
"PredefinedType": "Predefined generic type for a window that is specified in an enumeration. There may be a property set given specificly for the predefined types. NOTE The PredefinedType shall only be used, if no IfcWindowType is assigned, providing its own IfcWindowType.PredefinedType.",
|
||||
"ObjectType": "The type denotes a particular type that indicates the object further. The use has to be established at the level of instantiable subtypes. In particular it holds the user defined type, if the enumeration of the attribute PredefinedType is set to USERDEFINED.",
|
||||
"Tag": "The tag (or label) identifier at the particular instance of a product, e.g. the serial number, or the position number. It is the identifier at the occurrence level.",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -404,7 +404,6 @@ def draw_custom_context_menu(self, context):
|
||||
url_op = layout.operator("bim.open_webbrowser", icon="URL", text="Online IFC Documentation")
|
||||
url_op.url = url
|
||||
if description:
|
||||
op_description = layout.operator(
|
||||
"bim.show_description", text="Hover for Description", icon="INFO", emboss=False
|
||||
)
|
||||
op_description = layout.operator("bim.show_description", text="IFC Description", icon="INFO")
|
||||
op_description.description = description
|
||||
op_description.ifc_class = getattr(context.button_pointer, "ifc_class", "")
|
||||
|
||||
Reference in New Issue
Block a user