You can now access the ifc classes online docs from the right click context menu

+ Remove the ugly buttons in the interface
This commit is contained in:
Gorgious56
2022-10-28 08:19:35 +02:00
parent e602f16ed3
commit 5fb7f33fb0
3 changed files with 21 additions and 19 deletions
@@ -159,6 +159,7 @@ def register():
bpy.types.Camera.BIMMeshProperties = bpy.props.PointerProperty(type=prop.BIMMeshProperties)
bpy.types.PointLight.BIMMeshProperties = bpy.props.PointerProperty(type=prop.BIMMeshProperties)
bpy.types.SCENE_PT_unit.append(ui.ifc_units)
bpy.types.UI_MT_button_context_menu.append(ui.draw_custom_context_menu)
for mod in modules.values():
mod.register()
@@ -179,6 +180,7 @@ def unregister():
del bpy.types.Camera.BIMMeshProperties
del bpy.types.PointLight.BIMMeshProperties
bpy.types.SCENE_PT_unit.remove(ui.ifc_units)
bpy.types.UI_MT_button_context_menu.remove(ui.draw_custom_context_menu)
for mod in reversed(list(modules.values())):
mod.unregister()
+2 -19
View File
@@ -23,11 +23,9 @@ import math
import zipfile
import ifcopenshell
import ifcopenshell.util.attribute
from blenderbim.bim.prop import get_ifc_entity_doc_url
from mathutils import geometry
from mathutils import Vector
from blenderbim.bim.ifc import IfcStore
import blenderbim.tool as tool
def draw_attributes(props, layout, copy_operator=None):
@@ -126,23 +124,8 @@ def prop_with_search(layout, data, prop_name, **kwargs):
op = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM")
op.prop_name = prop_name
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:
url_op = layout.operator("bim.open_webbrowser", icon="INFO", text="")
url_op.url = url
def get_enum_items(data, prop_name, context):
def get_enum_items(data, prop_name, context=None):
# Retrieve items from a dynamic EnumProperty, which is otherwise not supported
# Or throws an error in the console when the items callback returns an empty list
# See https://blender.stackexchange.com/q/215781/86891
@@ -152,7 +135,7 @@ def get_enum_items(data, prop_name, context):
return
if not isinstance(items, (list, tuple)):
# items are retrieved through a callback, not a static list :
items = items(data, context)
items = items(data, context or bpy.context)
return items
+17
View File
@@ -23,6 +23,7 @@ from . import ifc
from bpy.types import Panel
from bpy.props import StringProperty, IntProperty, BoolProperty
from blenderbim.bim.helper import IfcHeaderExtractor
from blenderbim.bim.prop import get_ifc_entity_doc_url
import blenderbim.tool as tool
@@ -381,3 +382,19 @@ class BIM_PT_misc_object(Panel):
def draw(self, context):
pass
def draw_custom_context_menu(self, context):
layout = self.layout
layout.separator()
# https://blender.stackexchange.com/a/275555/86891
prop_value = getattr(context.button_pointer, context.button_prop.identifier)
try:
url = get_ifc_entity_doc_url(prop_value)
except KeyError:
# TODO : support attributes, pset, etc.
pass
else:
if url:
url_op = layout.operator("bim.open_webbrowser", icon="URL", text="Open IFC Documentation")
url_op.url = url