mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +00:00
New basic UI to view tasks in an IFC file
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import bpy
|
||||
from . import ui, prop, operator
|
||||
|
||||
classes = (
|
||||
operator.LoadTasks,
|
||||
operator.DisableTaskEditingUI,
|
||||
prop.Task,
|
||||
prop.BIMTaskProperties,
|
||||
ui.BIM_PT_tasks,
|
||||
ui.BIM_UL_tasks,
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
bpy.types.Scene.BIMTaskProperties = bpy.props.PointerProperty(type=prop.BIMTaskProperties)
|
||||
|
||||
|
||||
def unregister():
|
||||
del bpy.types.Scene.BIMTaskProperties
|
||||
@@ -0,0 +1,18 @@
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class Data:
|
||||
is_loaded = False
|
||||
tasks = {}
|
||||
|
||||
@classmethod
|
||||
def purge(cls):
|
||||
cls.is_loaded = False
|
||||
cls.tasks = {}
|
||||
|
||||
@classmethod
|
||||
def load(cls):
|
||||
cls.tasks = {}
|
||||
for task in IfcStore.get_file().by_type("IfcTask"):
|
||||
cls.tasks[task.id()] = {"Name": task.Name, "Identification": task.Identification or ""}
|
||||
cls.is_loaded=True
|
||||
@@ -0,0 +1,29 @@
|
||||
import bpy
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.module.sequence.data import Data
|
||||
|
||||
|
||||
class LoadTasks(bpy.types.Operator):
|
||||
bl_idname = "bim.load_tasks"
|
||||
bl_label = "Load Tasks"
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMTaskProperties
|
||||
while len(props.tasks) > 0:
|
||||
props.tasks.remove(0)
|
||||
for ifc_definition_id, task in Data.tasks.items():
|
||||
new = props.tasks.add()
|
||||
new.ifc_definition_id = ifc_definition_id
|
||||
new.name = task["Name"]
|
||||
new.identification = task["Identification"]
|
||||
props.is_editing = True
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class DisableTaskEditingUI(bpy.types.Operator):
|
||||
bl_idname = "bim.disable_task_editing_ui"
|
||||
bl_label = "Disable Task Editing UI"
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.BIMTaskProperties.is_editing = False
|
||||
return {"FINISHED"}
|
||||
@@ -0,0 +1,26 @@
|
||||
import bpy
|
||||
from blenderbim.bim.prop import StrProperty, Attribute
|
||||
from blenderbim.bim.module.sequence.data import Data
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
PointerProperty,
|
||||
StringProperty,
|
||||
EnumProperty,
|
||||
BoolProperty,
|
||||
IntProperty,
|
||||
FloatProperty,
|
||||
FloatVectorProperty,
|
||||
CollectionProperty,
|
||||
)
|
||||
|
||||
|
||||
class Task(PropertyGroup):
|
||||
name: StringProperty(name="Name")
|
||||
identification: StringProperty(name="Identification")
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
|
||||
|
||||
class BIMTaskProperties(PropertyGroup):
|
||||
is_editing: BoolProperty(name="Is Editing", default=False)
|
||||
tasks: CollectionProperty(name="Available Library References", type=Task)
|
||||
active_task_index: IntProperty(name="Active Task Index")
|
||||
@@ -0,0 +1,53 @@
|
||||
from bpy.types import Panel, UIList
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.module.sequence.data import Data
|
||||
|
||||
|
||||
class BIM_PT_tasks(Panel):
|
||||
bl_label = "IFC Tasks"
|
||||
bl_idname = "BIM_PT_tasks"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
bl_context = "scene"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
|
||||
def draw(self, context):
|
||||
if not Data.is_loaded:
|
||||
Data.load()
|
||||
self.props = context.scene.BIMTaskProperties
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="{} Tasks Found".format(len(Data.tasks)), icon="ACTION")
|
||||
if self.props.is_editing:
|
||||
row.operator("bim.disable_task_editing_ui", text="", icon="CHECKMARK")
|
||||
else:
|
||||
row.operator("bim.load_tasks", text="", icon="GREASEPENCIL")
|
||||
|
||||
if self.props.is_editing:
|
||||
self.layout.template_list(
|
||||
"BIM_UL_tasks",
|
||||
"",
|
||||
self.props,
|
||||
"tasks",
|
||||
self.props,
|
||||
"active_task_index",
|
||||
)
|
||||
|
||||
if self.props.active_task_index:
|
||||
self.draw_editable_ui(context)
|
||||
|
||||
def draw_editable_ui(self, context):
|
||||
pass
|
||||
|
||||
|
||||
class BIM_UL_tasks(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
if item.identification:
|
||||
layout.label(text=item.identification)
|
||||
layout.label(text=item.name)
|
||||
Reference in New Issue
Block a user