From d3da378ba393b45dea0cb47e2b05e03a67ee1b43 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 17 Aug 2020 21:43:33 +1000 Subject: [PATCH] New UI to add and manage schedules from ODS spreadsheets --- .../blenderbim/bim/__init__.py | 5 +++ .../blenderbim/bim/operator.py | 38 +++++++++++++++++++ src/ifcblenderexport/blenderbim/bim/prop.py | 7 ++++ src/ifcblenderexport/blenderbim/bim/ui.py | 25 ++++++++++++ 4 files changed, 75 insertions(+) diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index eacc07ecd2..6a82216a48 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -186,6 +186,9 @@ if bpy is not None: operator.EditVectorStyle, operator.PurgeProjectClassifications, operator.RemoveSheet, + operator.AddSchedule, + operator.RemoveSchedule, + operator.SelectScheduleFile, prop.StrProperty, prop.Variable, prop.Role, @@ -203,6 +206,7 @@ if bpy is not None: prop.ClashSet, prop.Constraint, prop.Drawing, + prop.Schedule, prop.DrawingStyle, prop.Sheet, prop.BcfTopic, @@ -231,6 +235,7 @@ if bpy is not None: prop.BIMTextProperties, ui.BIM_PT_section_plane, ui.BIM_PT_drawings, + ui.BIM_PT_schedules, ui.BIM_PT_sheets, ui.BIM_PT_bim, ui.BIM_PT_psets, diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index a254527779..3e246cad0d 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -3626,3 +3626,41 @@ class RemoveSheet(bpy.types.Operator): props = bpy.context.scene.DocProperties props.sheets.remove(self.index) return {'FINISHED'} + + +class AddSchedule(bpy.types.Operator): + bl_idname = 'bim.add_schedule' + bl_label = 'Add Schedule' + + def execute(self, context): + new = bpy.context.scene.DocProperties.schedules.add() + new.name = 'SCHEDULE {}'.format(len(bpy.context.scene.DocProperties.schedules)) + return {'FINISHED'} + + +class RemoveSchedule(bpy.types.Operator): + bl_idname = 'bim.remove_schedule' + bl_label = 'Remove Schedule' + index: bpy.props.IntProperty() + + def execute(self, context): + props = bpy.context.scene.DocProperties + props.schedules.remove(self.index) + return {'FINISHED'} + + +class SelectScheduleFile(bpy.types.Operator): + bl_idname = "bim.select_schedule_file" + bl_label = "Select Documentation IFC File" + filepath: bpy.props.StringProperty(subtype="FILE_PATH") + filter_glob: bpy.props.StringProperty(default="*.ods", options={'HIDDEN'}) + index: bpy.props.IntProperty() + + def execute(self, context): + props = bpy.context.scene.DocProperties + props.schedules[props.active_schedule_index].file = self.filepath + return {'FINISHED'} + + def invoke(self, context, event): + context.window_manager.fileselect_add(self) + return {'RUNNING_MODAL'} diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index f90ce188d0..845c906099 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -437,6 +437,11 @@ class Drawing(PropertyGroup): camera: PointerProperty(name='Camera', type=bpy.types.Object) +class Schedule(PropertyGroup): + name: StringProperty(name='Name') + file: StringProperty(name='File') + + class Sheet(PropertyGroup): def set_name(self, new): old = self.get('name') @@ -468,6 +473,8 @@ class DocProperties(PropertyGroup): should_extract: BoolProperty(name="Should Extract", default=True) drawings: CollectionProperty(name='Drawings', type=Drawing) active_drawing_index: IntProperty(name='Active Drawing Index') + schedules: CollectionProperty(name='Schedules', type=Schedule) + active_schedule_index: IntProperty(name='Active Schedule Index') sheets: CollectionProperty(name='Sheets', type=Sheet) active_sheet_index: IntProperty(name='Active Sheet Index') ifc_files: CollectionProperty(name='IFCs', type=StrProperty) diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 56d80f75ac..7cc49ece6e 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -750,6 +750,31 @@ class BIM_PT_drawings(Panel): row.operator('bim.remove_ifc_file', icon='X', text='').index = index +class BIM_PT_schedules(Panel): + bl_label = "ODS Schedules" + bl_idname = "BIM_PT_schedules" + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = 'output' + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + props = bpy.context.scene.DocProperties + + row = layout.row(align=True) + row.operator('bim.add_schedule') + + if props.schedules: + row.operator('bim.remove_schedule', icon='X', text='').index = props.active_schedule_index + + layout.template_list('BIM_UL_generic', '', props, 'schedules', props, 'active_schedule_index') + + row = layout.row() + row.prop(props.schedules[props.active_schedule_index], 'file') + row.operator('bim.select_schedule_file', icon='FILE_FOLDER', text='') + + class BIM_PT_sheets(Panel): bl_label = "SVG Sheets" bl_idname = "BIM_PT_sheets"