mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 08:16:51 +00:00
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:
@@ -159,6 +159,7 @@ def register():
|
|||||||
bpy.types.Camera.BIMMeshProperties = bpy.props.PointerProperty(type=prop.BIMMeshProperties)
|
bpy.types.Camera.BIMMeshProperties = bpy.props.PointerProperty(type=prop.BIMMeshProperties)
|
||||||
bpy.types.PointLight.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.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():
|
for mod in modules.values():
|
||||||
mod.register()
|
mod.register()
|
||||||
@@ -179,6 +180,7 @@ def unregister():
|
|||||||
del bpy.types.Camera.BIMMeshProperties
|
del bpy.types.Camera.BIMMeshProperties
|
||||||
del bpy.types.PointLight.BIMMeshProperties
|
del bpy.types.PointLight.BIMMeshProperties
|
||||||
bpy.types.SCENE_PT_unit.remove(ui.ifc_units)
|
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())):
|
for mod in reversed(list(modules.values())):
|
||||||
mod.unregister()
|
mod.unregister()
|
||||||
|
|||||||
@@ -23,11 +23,9 @@ import math
|
|||||||
import zipfile
|
import zipfile
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.attribute
|
import ifcopenshell.util.attribute
|
||||||
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
|
||||||
import blenderbim.tool as tool
|
|
||||||
|
|
||||||
|
|
||||||
def draw_attributes(props, layout, copy_operator=None):
|
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 = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM")
|
||||||
op.prop_name = prop_name
|
op.prop_name = prop_name
|
||||||
|
|
||||||
add_entity_url_button(row, getattr(data, prop_name))
|
|
||||||
|
|
||||||
|
def get_enum_items(data, prop_name, context=None):
|
||||||
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):
|
|
||||||
# Retrieve items from a dynamic EnumProperty, which is otherwise not supported
|
# 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
|
# Or throws an error in the console when the items callback returns an empty list
|
||||||
# See https://blender.stackexchange.com/q/215781/86891
|
# See https://blender.stackexchange.com/q/215781/86891
|
||||||
@@ -152,7 +135,7 @@ def get_enum_items(data, prop_name, context):
|
|||||||
return
|
return
|
||||||
if not isinstance(items, (list, tuple)):
|
if not isinstance(items, (list, tuple)):
|
||||||
# items are retrieved through a callback, not a static list :
|
# items are retrieved through a callback, not a static list :
|
||||||
items = items(data, context)
|
items = items(data, context or bpy.context)
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from . import ifc
|
|||||||
from bpy.types import Panel
|
from bpy.types import Panel
|
||||||
from bpy.props import StringProperty, IntProperty, BoolProperty
|
from bpy.props import StringProperty, IntProperty, BoolProperty
|
||||||
from blenderbim.bim.helper import IfcHeaderExtractor
|
from blenderbim.bim.helper import IfcHeaderExtractor
|
||||||
|
from blenderbim.bim.prop import get_ifc_entity_doc_url
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
|
|
||||||
|
|
||||||
@@ -381,3 +382,19 @@ class BIM_PT_misc_object(Panel):
|
|||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
pass
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user