mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Remove info mode and streamline entity url fetching
This commit is contained in:
@@ -23,7 +23,7 @@ import math
|
|||||||
import zipfile
|
import zipfile
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.attribute
|
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 geometry
|
||||||
from mathutils import Vector
|
from mathutils import Vector
|
||||||
from blenderbim.bim.ifc import IfcStore
|
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 = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM")
|
||||||
op.prop_name = prop_name
|
op.prop_name = prop_name
|
||||||
|
|
||||||
if bpy.context.preferences.addons["blenderbim"].preferences.info_mode:
|
add_entity_url_button(row, getattr(data, prop_name))
|
||||||
schema = tool.Ifc.schema()
|
|
||||||
if schema is not None:
|
|
||||||
schema = str(schema)
|
def add_entity_url_button(layout, entity):
|
||||||
schema = next(identifier for identifier in IfcStore.schema_identifiers if identifier in schema)
|
if entity:
|
||||||
docs = {}
|
try:
|
||||||
entity = getattr(data, prop_name)
|
url = get_ifc_entity_doc_url(entity)
|
||||||
if entity:
|
except KeyError:
|
||||||
try:
|
# TODO : support attributes, pset, etc.
|
||||||
docs = get_entity_doc(schema, entity)
|
pass
|
||||||
except KeyError:
|
else:
|
||||||
# TODO : support attributes, pset, etc.
|
|
||||||
pass
|
|
||||||
url = docs.get("spec_url", "")
|
|
||||||
if url:
|
if url:
|
||||||
op_row = row.row(align=True)
|
url_op = layout.operator("bim.open_webbrowser", icon="INFO", text="")
|
||||||
url_op = op_row.operator("bim.open_webbrowser", icon="INFO", text="")
|
|
||||||
url_op.url = url
|
url_op.url = url
|
||||||
op_row.enabled = bool(url)
|
|
||||||
|
|
||||||
|
|
||||||
def get_enum_items(data, prop_name, context):
|
def get_enum_items(data, prop_name, context):
|
||||||
|
|||||||
@@ -104,15 +104,21 @@ def cache_string(s):
|
|||||||
|
|
||||||
cache_string.data = {}
|
cache_string.data = {}
|
||||||
|
|
||||||
def get_ifc_entity_description(ifc_entity):
|
|
||||||
|
def get_ifc_entity_docs(ifc_entity):
|
||||||
schema = tool.Ifc.get_schema()
|
schema = tool.Ifc.get_schema()
|
||||||
if schema is not None:
|
if schema is not None:
|
||||||
schema = str(schema)
|
return get_entity_doc(schema, ifc_entity)
|
||||||
schema = next(identifier for identifier in IfcStore.schema_identifiers if identifier in schema)
|
|
||||||
docs = get_entity_doc(schema, ifc_entity)
|
|
||||||
description = docs.get("description", "")
|
def get_ifc_entity_description(ifc_entity):
|
||||||
return description
|
docs = get_ifc_entity_docs(ifc_entity)
|
||||||
return ""
|
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):
|
def get_predefined_type_descriptions(ifc_class_enum):
|
||||||
|
|||||||
@@ -115,9 +115,6 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
name="Should Make A Cha-Ching Sound When Project Costs Updates", default=False
|
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)
|
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):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
@@ -177,7 +174,6 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("bim.configure_visibility")
|
row.operator("bim.configure_visibility")
|
||||||
layout.row().prop(self, "info_mode")
|
|
||||||
|
|
||||||
|
|
||||||
def ifc_units(self, context):
|
def ifc_units(self, context):
|
||||||
|
|||||||
Reference in New Issue
Block a user