mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Example of UI if we sentence-cased IFC classes. Good or bad? Please comment at https://community.osarch.org/discussion/comment/16493
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# from datetime import date
|
||||
import re
|
||||
import bpy
|
||||
import json
|
||||
import math
|
||||
@@ -31,6 +32,11 @@ import blenderbim.tool as tool
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
|
||||
def uncamel(s):
|
||||
s = re.sub('([a-z0-9])([A-Z])', r'\1 \2', s[3:] if s.startswith("Ifc") else s)
|
||||
return re.sub('([A-Z])([A-Z][a-z])', r'\1 \2', s)
|
||||
|
||||
|
||||
def draw_attributes(props, layout, copy_operator=None, popup_active_attribute=None):
|
||||
"""you can set attribute active in popup with `active_attribute`
|
||||
meaning you will be able to type into attribute's field without having to click
|
||||
|
||||
@@ -21,6 +21,7 @@ import bpy
|
||||
import ifcopenshell.util.element
|
||||
from ifcopenshell.util.doc import get_entity_doc, get_predefined_type_doc
|
||||
import blenderbim.tool as tool
|
||||
import blenderbim.bim.helper
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
|
||||
@@ -70,7 +71,7 @@ class IfcClassData:
|
||||
"IfcAnnotation",
|
||||
"IfcRelSpaceBoundary",
|
||||
]
|
||||
return [(e, e, (get_entity_doc(version, e) or {}).get("description", "")) for e in products]
|
||||
return [(e, blenderbim.bim.helper.uncamel(e), (get_entity_doc(version, e) or {}).get("description", "")) for e in products]
|
||||
|
||||
@classmethod
|
||||
def ifc_classes(cls):
|
||||
@@ -86,7 +87,7 @@ class IfcClassData:
|
||||
# Yeah, weird isn't it.
|
||||
names.remove("IfcOpeningStandardCase")
|
||||
version = tool.Ifc.get_schema()
|
||||
return [(c, c, (get_entity_doc(version, c) or {}).get("description", "")) for c in sorted(names)]
|
||||
return [(c, blenderbim.bim.helper.uncamel(c), (get_entity_doc(version, c) or {}).get("description", "")) for c in sorted(names)]
|
||||
|
||||
@classmethod
|
||||
def ifc_predefined_types(cls):
|
||||
@@ -163,9 +164,10 @@ class IfcClassData:
|
||||
if not element:
|
||||
return
|
||||
name = element.is_a()
|
||||
name = blenderbim.bim.helper.uncamel(name)
|
||||
predefined_type = ifcopenshell.util.element.get_predefined_type(element)
|
||||
if predefined_type:
|
||||
name += f"[{predefined_type}]"
|
||||
name += f" [{predefined_type}]"
|
||||
return name
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user