Remove info mode and streamline entity url fetching

This commit is contained in:
Gorgious56
2022-10-19 18:42:05 +02:00
parent 3334ea5c10
commit 89f64eacef
3 changed files with 26 additions and 29 deletions
+13 -18
View File
@@ -23,7 +23,7 @@ import math
import zipfile
import ifcopenshell
import ifcopenshell.util.attribute
from ifcopenshell.util.doc import get_entity_doc, get_attribute_doc, get_property_set_doc, get_property_doc
from blenderbim.bim.prop import get_ifc_entity_doc_url
from mathutils import geometry
from mathutils import Vector
from blenderbim.bim.ifc import IfcStore
@@ -126,25 +126,20 @@ def prop_with_search(layout, data, prop_name, **kwargs):
op = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM")
op.prop_name = prop_name
if bpy.context.preferences.addons["blenderbim"].preferences.info_mode:
schema = tool.Ifc.schema()
if schema is not None:
schema = str(schema)
schema = next(identifier for identifier in IfcStore.schema_identifiers if identifier in schema)
docs = {}
entity = getattr(data, prop_name)
if entity:
try:
docs = get_entity_doc(schema, entity)
except KeyError:
# TODO : support attributes, pset, etc.
pass
url = docs.get("spec_url", "")
add_entity_url_button(row, getattr(data, prop_name))
def add_entity_url_button(layout, entity):
if entity:
try:
url = get_ifc_entity_doc_url(entity)
except KeyError:
# TODO : support attributes, pset, etc.
pass
else:
if url:
op_row = row.row(align=True)
url_op = op_row.operator("bim.open_webbrowser", icon="INFO", text="")
url_op = layout.operator("bim.open_webbrowser", icon="INFO", text="")
url_op.url = url
op_row.enabled = bool(url)
def get_enum_items(data, prop_name, context):
+13 -7
View File
@@ -104,15 +104,21 @@ def cache_string(s):
cache_string.data = {}
def get_ifc_entity_description(ifc_entity):
def get_ifc_entity_docs(ifc_entity):
schema = tool.Ifc.get_schema()
if schema is not None:
schema = str(schema)
schema = next(identifier for identifier in IfcStore.schema_identifiers if identifier in schema)
docs = get_entity_doc(schema, ifc_entity)
description = docs.get("description", "")
return description
return ""
return get_entity_doc(schema, ifc_entity)
def get_ifc_entity_description(ifc_entity):
docs = get_ifc_entity_docs(ifc_entity)
return docs.get("description", "") if docs is not None else ""
def get_ifc_entity_doc_url(ifc_entity):
docs = get_ifc_entity_docs(ifc_entity)
return docs.get("spec_url", "") if docs is not None else ""
def get_predefined_type_descriptions(ifc_class_enum):
-4
View File
@@ -115,9 +115,6 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
name="Should Make A Cha-Ching Sound When Project Costs Updates", default=False
)
lock_grids_on_import: BoolProperty(name="Will lock grids upon import", default=True)
info_mode: BoolProperty(
default=True, name="Info Mode", description="Display additional helpful tooltips and information"
)
def draw(self, context):
layout = self.layout
@@ -177,7 +174,6 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
row = layout.row()
row.operator("bim.configure_visibility")
layout.row().prop(self, "info_mode")
def ifc_units(self, context):