mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 18:22:30 +00:00
WIP experimental layout for authoring tool with Carlos and Vukas
This commit is contained in:
@@ -118,17 +118,6 @@ def prop_with_search(layout, data, prop_name, **kwargs):
|
|||||||
op.prop_name = prop_name
|
op.prop_name = prop_name
|
||||||
|
|
||||||
|
|
||||||
def layout_with_margins(layout, margin_left=0.025, margin_right=None):
|
|
||||||
margin_right = margin_left if margin_right is None else margin_right
|
|
||||||
split = layout.split(factor=margin_left, align=True)
|
|
||||||
cols = [split.column() for _ in range(2)]
|
|
||||||
cols[0].label(text="")
|
|
||||||
subsplit = cols[-1].split(factor=(1. - margin_right), align=True)
|
|
||||||
subcol = subsplit.column()
|
|
||||||
subsplit.column().label(text="")
|
|
||||||
return subcol
|
|
||||||
|
|
||||||
|
|
||||||
def get_enum_items(data, prop_name, context):
|
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
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
import math
|
import math
|
||||||
from bpy.types import Panel, Operator
|
from bpy.types import Panel, Operator
|
||||||
from blenderbim.bim.module.model.data import AuthoringData
|
from blenderbim.bim.module.model.data import AuthoringData
|
||||||
from blenderbim.bim.helper import prop_with_search, layout_with_margins, close_operator_panel
|
from blenderbim.bim.helper import prop_with_search, close_operator_panel
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_authoring(Panel):
|
class BIM_PT_authoring(Panel):
|
||||||
@@ -58,45 +58,29 @@ class DisplayConstrTypesUI(Operator):
|
|||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
props = context.scene.BIMModelProperties
|
props = context.scene.BIMModelProperties
|
||||||
header_data = self.draw_header(props)
|
self.draw_header(props)
|
||||||
if props.unfold_relating_types:
|
if props.unfold_relating_types:
|
||||||
self.draw_by_ifc_class(props, header_data)
|
self.draw_by_ifc_class(props)
|
||||||
else:
|
else:
|
||||||
self.draw_by_ifc_class_and_type(props, header_data)
|
self.draw_by_ifc_class_and_type(props)
|
||||||
|
self.draw_footer(props)
|
||||||
|
|
||||||
def draw_header(self, props):
|
def draw_header(self, props):
|
||||||
layout = self.layout
|
|
||||||
inner_layout = layout
|
|
||||||
inner_layout.row().separator(factor=0.75)
|
|
||||||
split = inner_layout.split(align=True, factor=2.0 / 3)
|
|
||||||
col1 = split.column(align=True)
|
|
||||||
row = col1.row()
|
|
||||||
row.prop(data=props, property="unfold_relating_types", text="Preview All Construction Types")
|
|
||||||
col1.row().separator(factor=1)
|
|
||||||
row = col1.row()
|
|
||||||
row.label(text="Select Construction Type:")
|
|
||||||
col1.row().separator(factor=1.5)
|
|
||||||
enabled = True
|
|
||||||
if AuthoringData.data["ifc_classes"]:
|
if AuthoringData.data["ifc_classes"]:
|
||||||
row = col1.row()
|
row = self.layout.row()
|
||||||
row.label(text="", icon="FILE_VOLUME")
|
row.label(text="", icon="FILE_VOLUME")
|
||||||
prop_with_search(row, props, "ifc_class", text="")
|
prop_with_search(row, props, "ifc_class", text="")
|
||||||
col1.row().separator()
|
|
||||||
else:
|
|
||||||
enabled = False
|
|
||||||
col2 = split.column(align=True)
|
|
||||||
subsplit = col2.split(factor=0.8)
|
|
||||||
subcol = [subsplit.column() for _ in range(2)][-1]
|
|
||||||
subcol.operator("bim.help_relating_types", text="", icon="QUESTION")
|
|
||||||
col2.row().separator(factor=1)
|
|
||||||
return {"enabled": enabled, "layout": inner_layout, "col1": col1, "col2": col2}
|
|
||||||
|
|
||||||
def draw_by_ifc_class(self, props, header_data):
|
def draw_footer(self, props):
|
||||||
enabled, layout = [header_data[key] for key in ["enabled", "layout"]]
|
row = self.layout.row()
|
||||||
|
row.prop(data=props, property="unfold_relating_types", text="Show more")
|
||||||
|
row.operator("bim.help_relating_types", text="", icon="QUESTION")
|
||||||
|
|
||||||
|
def draw_by_ifc_class(self, props):
|
||||||
ifc_class = props.ifc_class
|
ifc_class = props.ifc_class
|
||||||
num_cols = 3
|
num_cols = 3
|
||||||
layout.row().separator(factor=0.25)
|
self.layout.row().separator(factor=0.25)
|
||||||
flow = layout.grid_flow(row_major=True, columns=num_cols, even_columns=True, even_rows=True, align=True)
|
flow = self.layout.grid_flow(row_major=True, columns=num_cols, even_columns=True, even_rows=True, align=True)
|
||||||
relating_types = AuthoringData.relating_types()
|
relating_types = AuthoringData.relating_types()
|
||||||
num_types = len(relating_types)
|
num_types = len(relating_types)
|
||||||
for idx, (relating_type_id, name, desc) in enumerate(relating_types):
|
for idx, (relating_type_id, name, desc) in enumerate(relating_types):
|
||||||
@@ -106,14 +90,12 @@ class DisplayConstrTypesUI(Operator):
|
|||||||
row.label(text=name, icon="FILE_3D")
|
row.label(text=name, icon="FILE_3D")
|
||||||
row.alignment = "CENTER"
|
row.alignment = "CENTER"
|
||||||
row = box.row()
|
row = box.row()
|
||||||
if enabled:
|
preview_constr_types = AuthoringData.data["preview_constr_types"]
|
||||||
preview_constr_types = AuthoringData.data["preview_constr_types"]
|
if ifc_class in preview_constr_types:
|
||||||
if ifc_class in preview_constr_types:
|
preview_ifc_class = preview_constr_types[ifc_class]
|
||||||
preview_ifc_class = preview_constr_types[ifc_class]
|
if relating_type_id in preview_ifc_class:
|
||||||
if relating_type_id in preview_ifc_class:
|
icon_id = preview_ifc_class[relating_type_id]["icon_id"]
|
||||||
icon_id = preview_ifc_class[relating_type_id]["icon_id"]
|
row.template_icon(icon_value=icon_id, scale=6.0)
|
||||||
row.template_icon(icon_value=icon_id, scale=6.0)
|
|
||||||
box.row().separator(factor=0.2)
|
|
||||||
row = box.row()
|
row = box.row()
|
||||||
op = row.operator("bim.add_constr_type_instance", icon="ADD")
|
op = row.operator("bim.add_constr_type_instance", icon="ADD")
|
||||||
op.from_invoke = True
|
op.from_invoke = True
|
||||||
@@ -121,39 +103,26 @@ class DisplayConstrTypesUI(Operator):
|
|||||||
if relating_type_id.isnumeric():
|
if relating_type_id.isnumeric():
|
||||||
op.relating_type_id = int(relating_type_id)
|
op.relating_type_id = int(relating_type_id)
|
||||||
factor = 2 if idx + 1 < math.ceil(num_types / num_cols) else 1.5
|
factor = 2 if idx + 1 < math.ceil(num_types / num_cols) else 1.5
|
||||||
outer_col.row().separator(factor=factor)
|
|
||||||
last_row_cols = num_types % num_cols
|
last_row_cols = num_types % num_cols
|
||||||
if last_row_cols != 0:
|
if last_row_cols != 0:
|
||||||
for _ in range(num_cols - last_row_cols):
|
for _ in range(num_cols - last_row_cols):
|
||||||
flow.column()
|
flow.column()
|
||||||
|
|
||||||
def draw_by_ifc_class_and_type(self, props, header_data):
|
def draw_by_ifc_class_and_type(self, props):
|
||||||
enabled, col1, col2 = [header_data[key] for key in ["enabled", "col1", "col2"]]
|
|
||||||
ifc_class = props.ifc_class
|
ifc_class = props.ifc_class
|
||||||
relating_type_id = props.relating_type_id
|
relating_type_id = props.relating_type_id
|
||||||
if AuthoringData.data["relating_types_ids"]:
|
if AuthoringData.data["relating_types_ids"]:
|
||||||
row = col1.row()
|
row = self.layout.row()
|
||||||
row.label(text="", icon="FILE_3D")
|
row.label(text="", icon="FILE_3D")
|
||||||
prop_with_search(row, props, "relating_type_id", text="")
|
prop_with_search(row, props, "relating_type_id", text="")
|
||||||
col1.row().separator()
|
box = self.layout.box()
|
||||||
else:
|
box.template_icon(icon_value=props.icon_id, scale=7)
|
||||||
enabled = False
|
row = self.layout.row()
|
||||||
col1.row().separator(factor=4.75)
|
|
||||||
row = col1.row()
|
|
||||||
row.enabled = enabled
|
|
||||||
row.label(text="", icon="BLANK1")
|
|
||||||
op = row.operator("bim.add_constr_type_instance", icon="ADD")
|
op = row.operator("bim.add_constr_type_instance", icon="ADD")
|
||||||
op.from_invoke = True
|
op.from_invoke = True
|
||||||
op.ifc_class = ifc_class
|
op.ifc_class = ifc_class
|
||||||
if relating_type_id.isnumeric():
|
if relating_type_id.isnumeric():
|
||||||
op.relating_type_id = int(relating_type_id)
|
op.relating_type_id = int(relating_type_id)
|
||||||
col2.row().separator(factor=1.25)
|
|
||||||
split = col2.split(factor=0.025)
|
|
||||||
col = [split.column() for _ in range(2)][-1]
|
|
||||||
box = col.box()
|
|
||||||
if enabled:
|
|
||||||
box.template_icon(icon_value=props.icon_id, scale=5.6)
|
|
||||||
col1.row().separator(factor=1)
|
|
||||||
|
|
||||||
|
|
||||||
class HelpConstrTypes(Operator):
|
class HelpConstrTypes(Operator):
|
||||||
@@ -176,15 +145,15 @@ class HelpConstrTypes(Operator):
|
|||||||
row.label(text="BlenderBIM Help", icon="BLENDER")
|
row.label(text="BlenderBIM Help", icon="BLENDER")
|
||||||
layout.row().separator(factor=0.5)
|
layout.row().separator(factor=0.5)
|
||||||
|
|
||||||
row = layout_with_margins(layout.row()).row()
|
row = layout.row().row()
|
||||||
row.label(text="Overview:", icon="KEYTYPE_MOVING_HOLD_VEC")
|
row.label(text="Overview:", icon="KEYTYPE_MOVING_HOLD_VEC")
|
||||||
self.draw_lines(layout, self.message_summary)
|
self.draw_lines(layout, self.message_summary)
|
||||||
layout.row().separator()
|
layout.row().separator()
|
||||||
|
|
||||||
row = layout_with_margins(layout.row()).row()
|
row = layout.row().row()
|
||||||
row.label(text="Further support:", icon="KEYTYPE_MOVING_HOLD_VEC")
|
row.label(text="Further support:", icon="KEYTYPE_MOVING_HOLD_VEC")
|
||||||
layout.row().separator(factor=0.5)
|
layout.row().separator(factor=0.5)
|
||||||
row = layout_with_margins(layout).row()
|
row = layout.row()
|
||||||
op = row.operator("bim.open_upstream", text="Homepage", icon="HOME")
|
op = row.operator("bim.open_upstream", text="Homepage", icon="HOME")
|
||||||
op.page = "home"
|
op.page = "home"
|
||||||
op = row.operator("bim.open_upstream", text="Docs", icon="DOCUMENTS")
|
op = row.operator("bim.open_upstream", text="Docs", icon="DOCUMENTS")
|
||||||
@@ -196,7 +165,7 @@ class HelpConstrTypes(Operator):
|
|||||||
layout.row().separator()
|
layout.row().separator()
|
||||||
|
|
||||||
def draw_lines(self, layout, lines):
|
def draw_lines(self, layout, lines):
|
||||||
box = layout_with_margins(layout).box()
|
box = layout.box()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.label(text=f" {line}")
|
row.label(text=f" {line}")
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
import os
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
import blenderbim.bim.module.type.prop as type_prop
|
import blenderbim.bim.module.type.prop as type_prop
|
||||||
|
from blenderbim.bim.helper import prop_with_search, close_operator_panel
|
||||||
from bpy.types import WorkSpaceTool
|
from bpy.types import WorkSpaceTool
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from blenderbim.bim.module.model.data import AuthoringData
|
from blenderbim.bim.module.model.data import AuthoringData
|
||||||
@@ -65,43 +66,55 @@ class BimTool(WorkSpaceTool):
|
|||||||
ifc_classes = AuthoringData.data["ifc_classes"]
|
ifc_classes = AuthoringData.data["ifc_classes"]
|
||||||
relating_types_ids = AuthoringData.data["relating_types_ids"]
|
relating_types_ids = AuthoringData.data["relating_types_ids"]
|
||||||
|
|
||||||
if is_tool_header:
|
|
||||||
row.operator("bim.help_relating_types", text="", icon="QUESTION")
|
|
||||||
|
|
||||||
if ifc_classes and is_tool_header:
|
|
||||||
row.label(text="", icon="BLANK1")
|
|
||||||
row.operator("bim.display_constr_types", icon="COLLAPSEMENU")
|
|
||||||
|
|
||||||
ifc_class = props.ifc_class
|
ifc_class = props.ifc_class
|
||||||
relating_type_id = props.relating_type_id
|
relating_type_id = props.relating_type_id
|
||||||
relating_type = AuthoringData.relating_type_name_by_id(ifc_class, relating_type_id)
|
relating_type = AuthoringData.relating_type_name_by_id(ifc_class, relating_type_id)
|
||||||
|
|
||||||
if is_tool_header:
|
if is_tool_header:
|
||||||
row.label(text="", icon="BLANK1")
|
|
||||||
row = layout.row(align=True)
|
|
||||||
row.label(text="", icon="EVENT_SHIFT")
|
|
||||||
row.label(text="", icon="EVENT_A")
|
|
||||||
if ifc_classes:
|
if ifc_classes:
|
||||||
row.label(text=f" Add")
|
|
||||||
row.label(text="", icon="FILE_VOLUME")
|
row.label(text="", icon="FILE_VOLUME")
|
||||||
row.label(text=ifc_class)
|
row.label(text=ifc_class)
|
||||||
row.label(text="", icon="FILE_3D")
|
row.label(text="", icon="FILE_3D")
|
||||||
row.label(text=f"{relating_type} ")
|
row.label(text=f"{relating_type} ")
|
||||||
else:
|
row.operator("bim.display_constr_types", icon="TRIA_DOWN", text="")
|
||||||
row.label(text=f" Add instance")
|
row.operator("bim.display_constr_types", icon="VIEW_ORTHO", text="")
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
|
row.label(text="", icon="EVENT_A")
|
||||||
|
row.label(text=f" Add")
|
||||||
else:
|
else:
|
||||||
txt_ifc_class = ifc_class if ifc_classes else "No Construction Class"
|
txt_ifc_class = ifc_class if ifc_classes else "No Construction Class"
|
||||||
txt_relating_type = relating_type if relating_types_ids else "No Construction Type"
|
txt_relating_type = relating_type if relating_types_ids else "No Construction Type"
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text="Selected Construction Type:")
|
|
||||||
row = layout.row(align=True)
|
|
||||||
row.label(text=txt_ifc_class, icon="FILE_VOLUME")
|
row.label(text=txt_ifc_class, icon="FILE_VOLUME")
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text=txt_relating_type, icon="FILE_3D")
|
row.label(text=txt_relating_type, icon="FILE_3D")
|
||||||
row = layout.row(align=True)
|
|
||||||
row.label(text="", icon="EVENT_SHIFT")
|
if AuthoringData.data["ifc_classes"]:
|
||||||
row.label(text="", icon="EVENT_A")
|
row = layout.row()
|
||||||
row.label(text=f" Add Type Instance")
|
row.label(text="", icon="FILE_VOLUME")
|
||||||
|
prop_with_search(row, props, "ifc_class", text="")
|
||||||
|
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
|
row.label(text="", icon="EVENT_A")
|
||||||
|
row.label(text=f" Add Type Instance")
|
||||||
|
|
||||||
|
ifc_class = props.ifc_class
|
||||||
|
relating_type_id = props.relating_type_id
|
||||||
|
if AuthoringData.data["relating_types_ids"]:
|
||||||
|
row = layout.row()
|
||||||
|
row.label(text="", icon="FILE_3D")
|
||||||
|
prop_with_search(row, props, "relating_type_id", text="")
|
||||||
|
|
||||||
|
box = layout.box()
|
||||||
|
box.template_icon(icon_value=props.icon_id, scale=7)
|
||||||
|
row = layout.row()
|
||||||
|
op = row.operator("bim.add_constr_type_instance", icon="ADD")
|
||||||
|
op.from_invoke = True
|
||||||
|
op.ifc_class = ifc_class
|
||||||
|
if relating_type_id.isnumeric():
|
||||||
|
op.relating_type_id = int(relating_type_id)
|
||||||
|
|
||||||
if AuthoringData.data["ifc_classes"]:
|
if AuthoringData.data["ifc_classes"]:
|
||||||
if ifc_class == "IfcWallType":
|
if ifc_class == "IfcWallType":
|
||||||
@@ -133,6 +146,16 @@ class BimTool(WorkSpaceTool):
|
|||||||
row.label(text="", icon="EVENT_SHIFT")
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
row.label(text="Extend", icon="EVENT_E")
|
row.label(text="Extend", icon="EVENT_E")
|
||||||
|
|
||||||
|
if props.ifc_class in (
|
||||||
|
"IfcCableCarrierSegmentType",
|
||||||
|
"IfcCableSegmentType",
|
||||||
|
"IfcDuctSegmentType",
|
||||||
|
"IfcPipeSegmentType",
|
||||||
|
):
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
|
row.label(text="Extend", icon="EVENT_E")
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text="", icon="EVENT_SHIFT")
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
row.label(text="Opening", icon="EVENT_O")
|
row.label(text="Opening", icon="EVENT_O")
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ class AppendLibraryElement(bpy.types.Operator):
|
|||||||
ifc_importer.material_creator.load_existing_materials()
|
ifc_importer.material_creator.load_existing_materials()
|
||||||
self.import_type_materials(element, ifc_importer)
|
self.import_type_materials(element, ifc_importer)
|
||||||
self.import_type_styles(element, ifc_importer)
|
self.import_type_styles(element, ifc_importer)
|
||||||
ifc_importer.create_type_product(element)
|
ifc_importer.create_element_type(element)
|
||||||
ifc_importer.place_objects_in_collections()
|
ifc_importer.place_objects_in_collections()
|
||||||
|
|
||||||
def import_type_materials(self, element, ifc_importer):
|
def import_type_materials(self, element, ifc_importer):
|
||||||
|
|||||||
Reference in New Issue
Block a user