From fe01d252db798c139d744053a4eb848da764c410 Mon Sep 17 00:00:00 2001 From: "Sigma Dimensions (Yass)" <79010126+myoualid@users.noreply.github.com> Date: Thu, 10 Aug 2023 22:07:34 +0100 Subject: [PATCH] WIP - Scheduling UI improvements --- .../blenderbim/bim/module/cost/ui.py | 5 +- .../bim/module/sequence/__init__.py | 1 + .../blenderbim/bim/module/sequence/data.py | 18 -- .../bim/module/sequence/operator.py | 14 +- .../blenderbim/bim/module/sequence/prop.py | 32 +- .../blenderbim/bim/module/sequence/ui.py | 289 ++++++++++-------- src/blenderbim/blenderbim/core/sequence.py | 5 +- src/blenderbim/blenderbim/core/tool.py | 1 + src/blenderbim/blenderbim/tool/sequence.py | 15 +- .../api/sequence/add_work_schedule.py | 5 +- 10 files changed, 219 insertions(+), 166 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/cost/ui.py b/src/blenderbim/blenderbim/bim/module/cost/ui.py index d48621d940..832e69c871 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/ui.py +++ b/src/blenderbim/blenderbim/bim/module/cost/ui.py @@ -47,8 +47,9 @@ class BIM_PT_cost_schedules(Panel): row.label(text=f"{CostSchedulesData.data['total_cost_schedules']} Cost Schedules Found", icon="TEXT") row.operator("bim.export_cost_schedules", text="Export as spreadsheet", icon="EXPORT") else: - row.label(text="No Cost Schedules Found found.", icon="COMMUNITY") - row = self.layout.row() + row.label(text="No Cost Schedules found.", icon="TEXT") + row = self.layout.row(align=True) + row.alignment = "RIGHT" row.prop(self.props, "cost_schedule_predefined_types") row.operator("bim.add_cost_schedule", icon="ADD", text="Add") diff --git a/src/blenderbim/blenderbim/bim/module/sequence/__init__.py b/src/blenderbim/blenderbim/bim/module/sequence/__init__.py index 8f6fbe4d6c..5eeff32eeb 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/__init__.py @@ -137,6 +137,7 @@ classes = ( ui.BIM_PT_work_schedules, ui.BIM_PT_work_calendars, ui.BIM_PT_task_icom, + ui.BIM_PT_animation_tools, ui.BIM_UL_task_columns, ui.BIM_UL_task_inputs, ui.BIM_UL_task_resources, diff --git a/src/blenderbim/blenderbim/bim/module/sequence/data.py b/src/blenderbim/blenderbim/bim/module/sequence/data.py index 123e51977c..f08a5d79ed 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/data.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/data.py @@ -19,7 +19,6 @@ import bpy import blenderbim.tool as tool import ifcopenshell -from ifcopenshell.util.doc import get_predefined_type_doc import ifcopenshell.util.date as dateutil @@ -37,7 +36,6 @@ class SequenceData: @classmethod def load(cls): cls.data = { - "predefined_types": cls.get_work_schedule_types(), "has_work_plans": cls.has_work_plans(), "has_work_schedules": cls.has_work_schedules(), "has_work_calendars": cls.has_work_calendars(), @@ -230,22 +228,6 @@ class SequenceData: data["NestingIndex"] = rel.RelatedObjects.index(task) cls.data["tasks"][task.id()] = data - @classmethod - def get_work_schedule_types(cls): - results = [] - declaration = tool.Ifc().schema().declaration_by_name("IfcWorkSchedule") - version = tool.Ifc.get_schema() - for attribute in declaration.attributes(): - if attribute.name() == "PredefinedType": - results.extend( - [ - (e, e, get_predefined_type_doc(version, "IfcWorkSchedule", e)) - for e in attribute.type_of_attribute().declared_type().enumeration_items() - ] - ) - break - return results - class WorkScheduleData: data = {} diff --git a/src/blenderbim/blenderbim/bim/module/sequence/operator.py b/src/blenderbim/blenderbim/bim/module/sequence/operator.py index 735430b403..99e5c11df8 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/operator.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/operator.py @@ -129,9 +129,21 @@ class AddWorkSchedule(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.add_work_schedule" bl_label = "Add Work Schedule" bl_options = {"REGISTER", "UNDO"} + name: bpy.props.StringProperty() def _execute(self, context): - core.add_work_schedule(tool.Ifc) + core.add_work_schedule(tool.Ifc, tool.Sequence, name=self.name) + + def draw(self, context): + layout = self.layout + layout.prop(self, "name", text="Name") + self.props = context.scene.BIMWorkScheduleProperties + layout.prop(self.props, "work_schedule_predefined_types", text="Type") + if self.props.work_schedule_predefined_types == "USERDEFINED": + layout.prop(self.props,"object_type", text="Object type") + + def invoke(self, context, event): + return context.window_manager.invoke_props_dialog(self) class EditWorkSchedule(bpy.types.Operator, tool.Ifc.Operator): diff --git a/src/blenderbim/blenderbim/bim/module/sequence/prop.py b/src/blenderbim/blenderbim/bim/module/sequence/prop.py index 07929a4771..81fbf9fba1 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/prop.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/prop.py @@ -20,6 +20,7 @@ import bpy import isodate import ifcopenshell.api import ifcopenshell.util.attribute +from ifcopenshell.util.doc import get_predefined_type_doc import blenderbim.tool as tool import blenderbim.core.sequence as core from blenderbim.bim.ifc import IfcStore @@ -224,10 +225,20 @@ def updateTaskDuration(self, context): def get_schedule_predefined_types(self, context): - if not SequenceData.is_loaded: - SequenceData.load() - return SequenceData.data["predefined_types"] - + results = [] + declaration = tool.Ifc().schema().declaration_by_name("IfcWorkSchedule") + version = tool.Ifc.get_schema() + for attribute in declaration.attributes(): + if attribute.name() == "PredefinedType": + results.extend( + [ + (e, e, get_predefined_type_doc(version, "IfcWorkSchedule", e)) + for e in attribute.type_of_attribute().declared_type().enumeration_items() + if e != "BASELINE" + ] + ) + break + return results def update_visualisation_start(self, context): update_visualisation_start_finish(self, context, "visualisation_start") @@ -292,6 +303,14 @@ def update_filter_by_active_schedule(self, context): tool.Sequence, product=tool.Ifc.get().by_id(context.active_object.BIMObjectProperties.ifc_definition_id) ) +def switch_options(self, context): + if self.should_show_visualisation_ui: + self.should_show_snapshot_ui = False + +def switch_options2(self, context): + if self.should_show_snapshot_ui: + self.should_show_visualisation_ui = False + class Task(PropertyGroup): name: StringProperty(name="Name", update=updateTaskName) identification: StringProperty(name="Identification", update=updateTaskIdentification) @@ -352,6 +371,7 @@ class BIMWorkScheduleProperties(PropertyGroup): work_schedule_predefined_types: EnumProperty( items=get_schedule_predefined_types, name="Predefined Type", default=None ) + object_type: StringProperty(name="Object Type") durations_attributes: CollectionProperty(name="Durations Attributes", type=ISODuration) work_calendars: EnumProperty(items=getWorkCalendars, name="Work Calendars") work_schedule_attributes: CollectionProperty(name="Work Schedule Attributes", type=Attribute) @@ -362,9 +382,9 @@ class BIMWorkScheduleProperties(PropertyGroup): active_task_index: IntProperty(name="Active Task Index", update=update_active_task_index) active_task_id: IntProperty(name="Active Task Id") task_attributes: CollectionProperty(name="Task Attributes", type=Attribute) - should_show_visualisation_ui: BoolProperty(name="Should Show Visualisation UI", default=False) + should_show_visualisation_ui: BoolProperty(name="Should Show Visualisation UI", default=True, update=switch_options) should_show_task_bar_selection: BoolProperty(name="Add to task bar", default=False) - should_show_snapshot_ui: BoolProperty(name="Should Show Snapshot UI", default=False) + should_show_snapshot_ui: BoolProperty(name="Should Show Snapshot UI", default=False, update=switch_options2) should_show_column_ui: BoolProperty(name="Should Show Column UI", default=False) columns: CollectionProperty(name="Columns", type=Attribute) active_column_index: IntProperty(name="Active Column Index") diff --git a/src/blenderbim/blenderbim/bim/module/sequence/ui.py b/src/blenderbim/blenderbim/bim/module/sequence/ui.py index 82ee1e93ca..b945b72e4b 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/ui.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/ui.py @@ -55,11 +55,10 @@ class BIM_PT_work_plans(Panel): def draw_work_plan_ui(self, work_plan): row = self.layout.row(align=True) row.label(text=work_plan["name"], icon="TEXT") - if self.props.active_work_plan_id == work_plan["id"]: if self.props.editing_type == "ATTRIBUTES": row.operator("bim.edit_work_plan", text="", icon="CHECKMARK") - row.operator("bim.disable_editing_work_plan", text="", icon="CANCEL") + row.operator("bim.disable_editing_work_plan", text="Cancel", icon="CANCEL") elif self.props.active_work_plan_id: row.operator("bim.remove_work_plan", text="", icon="X").work_plan = work_plan["id"] else: @@ -116,10 +115,9 @@ class BIM_PT_work_schedules(Panel): WorkScheduleData.load() self.props = context.scene.BIMWorkScheduleProperties self.tprops = context.scene.BIMTaskTreeProperties - self.animation_props = context.scene.BIMAnimationProperties if not self.props.active_work_schedule_id: - row = self.layout.row() + row = self.layout.row(align=True) if SequenceData.data["has_work_schedules"]: row.label( text="{} Work Schedules Found".format(SequenceData.data["number_of_work_schedules_loaded"]), @@ -127,25 +125,25 @@ class BIM_PT_work_schedules(Panel): ) else: row.label(text="No Work Schedules found.", icon="TEXT") - row = self.layout.row(align=True) - row.alignment = "RIGHT" - row.prop(self.props, "work_schedule_predefined_types") - row.operator("bim.add_work_schedule", text="Add new", icon="ADD") + row.operator("bim.add_work_schedule", text="Add", icon="ADD") for work_schedule_id, work_schedule in SequenceData.data["work_schedules"].items(): - self.draw_work_schedule_ui(work_schedule_id, work_schedule) def draw_work_schedule_ui(self, work_schedule_id, work_schedule): - if not work_schedule["PredefinedType"] == "BASELINE": + if work_schedule["PredefinedType"] == "BASELINE": + self.draw_readonly_work_schedule_ui(work_schedule_id) + else: row = self.layout.row(align=True) - row.label(text=work_schedule["Name"] or "Unnamed", icon="LINENUMBERS_ON") if self.props.active_work_schedule_id == work_schedule_id: + row.label( + text="Currently editing: {}[{}]".format(work_schedule["Name"], work_schedule["PredefinedType"]), + icon="LINENUMBERS_ON", + ) if self.props.editing_type == "WORK_SCHEDULE": - row.operator("bim.edit_work_schedule", text="", icon="CHECKMARK") + row.operator("bim.edit_work_schedule", text="Apply", icon="CHECKMARK") elif self.props.editing_type == "TASKS": grid = self.layout.grid_flow(columns=2, even_columns=True) - col = grid.column() row1 = col.row(align=True) row1.alignment = "LEFT" @@ -180,33 +178,23 @@ class BIM_PT_work_schedules(Panel): row1.alignment = "RIGHT" row1.prop(self.props, "should_show_column_ui", text="Schedule Columns", icon="SHORTDISPLAY") row2 = col.row(align=True) - row2.prop( - self.props, "should_show_visualisation_ui", text="Animation Options", icon="CAMERA_STEREO" - ) - row2.prop(self.props, "should_show_snapshot_ui", text="Snapshot Options", icon="CAMERA_STEREO") - row.operator("bim.disable_editing_work_schedule", text="Disable editing", icon="CANCEL") - else: + row.operator("bim.disable_editing_work_schedule", text="Cancel", icon="CANCEL") + if not self.props.active_work_schedule_id: + row.label(text="{}[{}]".format(work_schedule["Name"], work_schedule["PredefinedType"]) or "Unnamed", icon="LINENUMBERS_ON") row.operator( - "bim.enable_editing_work_schedule_tasks", text="", icon="ACTION" + "bim.enable_editing_work_schedule_tasks", text="Tasks", icon="ACTION" ).work_schedule = work_schedule_id row.operator( - "bim.enable_editing_work_schedule", text="", icon="GREASEPENCIL" + "bim.enable_editing_work_schedule", text="Attributes", icon="GREASEPENCIL" ).work_schedule = work_schedule_id - row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = work_schedule_id - + row.operator("bim.remove_work_schedule", text="Delete", icon="X").work_schedule = work_schedule_id if self.props.active_work_schedule_id == work_schedule_id: if self.props.editing_type == "WORK_SCHEDULE": self.draw_editable_work_schedule_ui() elif self.props.editing_type == "TASKS": self.draw_baseline_ui(work_schedule_id) self.draw_column_ui() - if self.props.should_show_visualisation_ui: - self.draw_visualisation_ui() - if self.props.should_show_snapshot_ui: - self.draw_snapshot_ui() self.draw_editable_task_ui(work_schedule_id) - else: - self.draw_readonly_work_schedule_ui(work_schedule_id) def draw_task_operators(self): row = self.layout.row(align=True) @@ -221,7 +209,7 @@ class BIM_PT_work_schedules(Panel): row.operator("bim.edit_task_time", text="", icon="CHECKMARK") elif self.props.editing_task_type == "ATTRIBUTES": row.operator("bim.edit_task", text="", icon="CHECKMARK") - row.operator("bim.disable_editing_task", text="", icon="CANCEL") + row.operator("bim.disable_editing_task", text="Cancel", icon="CANCEL") else: row.prop(self.props, "show_task_operators", text="Edit", icon="GREASEPENCIL") if self.props.show_task_operators: @@ -271,103 +259,6 @@ class BIM_PT_work_schedules(Panel): self.layout.template_list("BIM_UL_task_columns", "", self.props, "columns", self.props, "active_column_index") - def draw_visualisation_ui(self): - row = self.layout.row(align=True) - row.label(text="Start Date/ Date Range:") - row = self.layout.row(align=True) - op = row.operator("bim.datepicker", text=self.props.visualisation_start or "Start Date", icon="REW") - op.target_prop = "BIMWorkScheduleProperties.visualisation_start" - op = row.operator("bim.datepicker", text=self.props.visualisation_finish or "Finish Date", icon="FF") - op.target_prop = "BIMWorkScheduleProperties.visualisation_finish" - op = row.operator("bim.guess_date_range", text="Guess", icon="FILE_REFRESH") - op.work_schedule = self.props.active_work_schedule_id - - row = self.layout.row(align=True) - row.label(text="Speed Settings") - row = self.layout.row(align=True) - row.prop(self.props, "speed_types", text="") - if self.props.speed_types == "FRAME_SPEED": - row.prop(self.props, "speed_animation_frames", text="") - row.prop(self.props, "speed_real_duration", text="") - elif self.props.speed_types == "DURATION_SPEED": - row.prop(self.props, "speed_animation_duration", text="") - row.prop(self.props, "speed_real_duration", text="") - elif self.props.speed_types == "MULTIPLIER_SPEED": - row.prop(self.props, "speed_multiplier", text="") - row = self.layout.row(align=True) - row.label(text="Display Settings") - row = self.layout.row(align=True) - if not self.animation_props.is_editing: - op = row.operator( - "bim.enable_editing_task_animation_colors", text="Customize Object Colors", icon="SEQUENCE_COLOR_04" - ) - else: - op = row.operator( - "bim.disable_editing_task_animation_colors", text="Hide Object Colors", icon="SEQUENCE_COLOR_01" - ) - - row.prop(self.animation_props, "should_show_task_bar_options", text="Task Bar", icon="NLA_PUSHDOWN") - if self.animation_props.should_show_task_bar_options: - row = self.layout.row() - row.label(text="Task Bar Options", icon="NLA_PUSHDOWN") - row.alignment = "LEFT" - row = self.layout.row(align=True) - row.prop(self.props, "should_show_task_bar_selection", text="Enable Selection", icon="NLA_PUSHDOWN") - row.operator("bim.add_task_bars", text="Generate bars", icon="NLA_PUSHDOWN") - - grid = self.layout.grid_flow(columns=2, even_columns=True) - # Column1 - col = grid.column() - - row = col.row(align=True) - row.prop(self.animation_props, "color_progress") - - row = col.row(align=True) - row.prop(self.animation_props, "color_full") - - if self.animation_props.is_editing: - self.draw_visualisation_settings_ui() - - row = self.layout.row(align=True) - op = row.operator("bim.visualise_work_schedule_date_range", text="Create Animation", icon="OUTLINER_OB_CAMERA") - op.work_schedule = self.props.active_work_schedule_id - - def draw_snapshot_ui(self): - row = self.layout.row(align=True) - row.label(text="Create Construction Snapshot:") - row = self.layout.row(align=True) - op = row.operator("bim.datepicker", text=self.props.visualisation_start or "Date", icon="REW") - op.target_prop = "BIMWorkScheduleProperties.visualisation_start" - op = row.operator("bim.visualise_work_schedule_date", text="Create SnapShot", icon="RESTRICT_RENDER_OFF") - op.work_schedule = self.props.active_work_schedule_id - - def draw_visualisation_settings_ui(self): - grid = self.layout.grid_flow(columns=2, even_columns=True) - col = grid.column() - row1 = col.row(align=True) - row1.label(text="INPUT COLORS", icon="COLLECTION_COLOR_01") - row1 = col.row() - row1.template_list( - "BIM_UL_animation_colors", - "", - self.animation_props, - "task_colors_components_inputs", - self.animation_props, - "active_color_component_inputs_index", - ) - col = grid.column() - row1 = col.row(align=True) - row1.label(text="OUTPUT COLORS", icon="COLLECTION_COLOR_04") - row1 = col.row() - row1.template_list( - "BIM_UL_animation_colors", - "", - self.animation_props, - "task_colors_components_outputs", - self.animation_props, - "active_color_component_outputs_index", - ) - def draw_editable_work_schedule_ui(self): draw_attributes(self.props.work_schedule_attributes, self.layout) @@ -424,12 +315,12 @@ class BIM_PT_work_schedules(Panel): if self.props.active_sequence_id == sequence["id"]: if self.props.editing_sequence_type == "ATTRIBUTES": row.operator("bim.edit_sequence_attributes", text="", icon="CHECKMARK") - row.operator("bim.disable_editing_sequence", text="", icon="CANCEL") + row.operator("bim.disable_editing_sequence", text="Cancel", icon="CANCEL") self.draw_editable_sequence_attributes_ui() elif self.props.editing_sequence_type == "LAG_TIME": op = row.operator("bim.edit_sequence_lag_time", text="", icon="CHECKMARK") op.lag_time = sequence["TimeLag"] - row.operator("bim.disable_editing_sequence", text="", icon="CANCEL") + row.operator("bim.disable_editing_sequence", text="Cancel", icon="CANCEL") self.draw_editable_sequence_lag_time_ui() else: if sequence["TimeLag"]: @@ -494,7 +385,7 @@ class BIM_PT_work_schedules(Panel): "id" ] baseline_row.operator( - "bim.enable_editing_work_schedule_tasks", text="", icon="ACTION" + "bim.enable_editing_work_schedule_tasks", text="Display Schedule", icon="ACTION" ).work_schedule = baseline["id"] baseline_row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = baseline["id"] @@ -524,6 +415,140 @@ class BIM_PT_work_schedules(Panel): ) +class BIM_PT_animation_tools(Panel): + bl_label = "Animation Tools" + bl_idname = "BIM_PT_animation_tools" + bl_options = {"DEFAULT_CLOSED"} + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "scene" + bl_parent_id = "BIM_PT_work_schedules" + + @classmethod + def poll(cls, context): + props = context.scene.BIMWorkScheduleProperties + if props.active_work_schedule_id: + return True + return False + + def draw(self, context): + self.props = context.scene.BIMWorkScheduleProperties + self.animation_props = context.scene.BIMAnimationProperties + row = self.layout.row(align=True) + row.alignment = "RIGHT" + row.prop( + self.props, "should_show_visualisation_ui", text="Animation Settings", icon="SETTINGS" + ) + row.prop(self.props, "should_show_snapshot_ui", text="Snapshot Settings", icon="SETTINGS") + if self.props.should_show_visualisation_ui: + self.draw_visualisation_ui() + if self.props.should_show_snapshot_ui: + self.draw_snapshot_ui() + + def draw_visualisation_ui(self): + row = self.layout.row(align=True) + row.label(text="Start Date/ Date Range:", icon="CAMERA_DATA") + row = self.layout.row(align=True) + row.alignment = "RIGHT" + op = row.operator("bim.datepicker", text=self.props.visualisation_start or "Start Date", icon="REW") + op.target_prop = "BIMWorkScheduleProperties.visualisation_start" + op = row.operator("bim.datepicker", text=self.props.visualisation_finish or "Finish Date", icon="FF") + op.target_prop = "BIMWorkScheduleProperties.visualisation_finish" + op = row.operator("bim.guess_date_range", text="Guess", icon="FILE_REFRESH") + op.work_schedule = self.props.active_work_schedule_id + + row = self.layout.row(align=True) + row.label(text="Speed Settings") + row = self.layout.row(align=True) + row.alignment = "RIGHT" + row.prop(self.props, "speed_types", text="") + if self.props.speed_types == "FRAME_SPEED": + row.prop(self.props, "speed_animation_frames", text="") + row.prop(self.props, "speed_real_duration", text="") + elif self.props.speed_types == "DURATION_SPEED": + row.prop(self.props, "speed_animation_duration", text="") + row.prop(self.props, "speed_real_duration", text="") + elif self.props.speed_types == "MULTIPLIER_SPEED": + row.prop(self.props, "speed_multiplier", text="") + row = self.layout.row(align=True) + row.label(text="Display Settings") + row = self.layout.row(align=True) + row.alignment = "RIGHT" + if not self.animation_props.is_editing: + op = row.operator( + "bim.enable_editing_task_animation_colors", text="Customize Object Colors", icon="SEQUENCE_COLOR_04" + ) + else: + op = row.operator( + "bim.disable_editing_task_animation_colors", text="Hide Object Colors", icon="SEQUENCE_COLOR_01" + ) + + row.prop(self.animation_props, "should_show_task_bar_options", text="Task Bar", icon="NLA_PUSHDOWN") + if self.animation_props.should_show_task_bar_options: + row = self.layout.row() + row.label(text="Task Bar Options", icon="NLA_PUSHDOWN") + row.alignment = "LEFT" + row = self.layout.row(align=True) + row.prop(self.props, "should_show_task_bar_selection", text="Enable Selection", icon="NLA_PUSHDOWN") + row.operator("bim.add_task_bars", text="Generate bars", icon="NLA_PUSHDOWN") + + grid = self.layout.grid_flow(columns=2, even_columns=True) + # Column1 + col = grid.column() + + row = col.row(align=True) + row.prop(self.animation_props, "color_progress") + + row = col.row(align=True) + row.prop(self.animation_props, "color_full") + + if self.animation_props.is_editing: + self.draw_visualisation_settings_ui() + + row = self.layout.row(align=True) + row.alignment = "RIGHT" + op = row.operator("bim.visualise_work_schedule_date_range", text="Create Animation", icon="OUTLINER_OB_CAMERA") + op.work_schedule = self.props.active_work_schedule_id + + def draw_snapshot_ui(self): + row = self.layout.row(align=True) + row.label(text="Date of Snapshot:", icon="CAMERA_STEREO") + row = self.layout.row(align=True) + row.alignment = "RIGHT" + op = row.operator("bim.datepicker", text=self.props.visualisation_start or "Date", icon="PROP_PROJECTED") + op.target_prop = "BIMWorkScheduleProperties.visualisation_start" + row = self.layout.row(align=True) + row.alignment = "RIGHT" + op = row.operator("bim.visualise_work_schedule_date", text="Create SnapShot", icon="CAMERA_STEREO") + op.work_schedule = self.props.active_work_schedule_id + + def draw_visualisation_settings_ui(self): + grid = self.layout.grid_flow(columns=2, even_columns=True) + col = grid.column() + row1 = col.row(align=True) + row1.label(text="INPUT COLORS", icon="COLLECTION_COLOR_01") + row1 = col.row() + row1.template_list( + "BIM_UL_animation_colors", + "", + self.animation_props, + "task_colors_components_inputs", + self.animation_props, + "active_color_component_inputs_index", + ) + col = grid.column() + row1 = col.row(align=True) + row1.label(text="OUTPUT COLORS", icon="COLLECTION_COLOR_04") + row1 = col.row() + row1.template_list( + "BIM_UL_animation_colors", + "", + self.animation_props, + "task_colors_components_outputs", + self.animation_props, + "active_color_component_outputs_index", + ) + class BIM_PT_task_icom(Panel): bl_label = "Task ICOM" bl_idname = "BIM_PT_task_icom" @@ -846,7 +871,7 @@ class BIM_PT_work_calendars(Panel): if self.props.active_work_calendar_id == work_calendar_id: if self.props.editing_type == "ATTRIBUTES": row.operator("bim.edit_work_calendar", text="", icon="CHECKMARK") - row.operator("bim.disable_editing_work_calendar", text="", icon="CANCEL") + row.operator("bim.disable_editing_work_calendar", text="Cancel", icon="CANCEL") elif self.props.active_work_calendar_id: row.operator("bim.remove_work_calendar", text="", icon="X").work_calendar = work_calendar_id else: @@ -884,7 +909,7 @@ class BIM_PT_work_calendars(Panel): row.label(text="{} - {}".format(work_time["Start"] or "*", work_time["Finish"] or "*")) if self.props.active_work_time_id == work_time["id"]: row.operator("bim.edit_work_time", text="", icon="CHECKMARK") - row.operator("bim.disable_editing_work_time", text="", icon="CANCEL") + row.operator("bim.disable_editing_work_time", text="Cancel", icon="CANCEL") elif self.props.active_work_time_id: op = row.operator("bim.remove_work_time", text="", icon="X") op.work_time = work_time["id"] diff --git a/src/blenderbim/blenderbim/core/sequence.py b/src/blenderbim/blenderbim/core/sequence.py index 1a68ffd9ea..5d8bb01936 100644 --- a/src/blenderbim/blenderbim/core/sequence.py +++ b/src/blenderbim/blenderbim/core/sequence.py @@ -50,8 +50,9 @@ def enable_editing_work_plan_schedules(sequence, work_plan=None): sequence.enable_editing_work_plan_schedules(work_plan) -def add_work_schedule(ifc): - return ifc.run("sequence.add_work_schedule") +def add_work_schedule(ifc, sequence, name=None): + predefined_type, object_type = sequence.get_user_predefined_type() + return ifc.run("sequence.add_work_schedule", name=name, predefined_type=predefined_type, object_type=object_type) def remove_work_schedule(ifc, work_schedule=None): diff --git a/src/blenderbim/blenderbim/core/tool.py b/src/blenderbim/blenderbim/core/tool.py index 44b14a3e3c..9d644f1a81 100644 --- a/src/blenderbim/blenderbim/core/tool.py +++ b/src/blenderbim/blenderbim/core/tool.py @@ -719,6 +719,7 @@ class Sequence: def get_task_time_attributes(cls): pass def get_task_time(cls, task): pass def get_tasks_for_product(cls, product, work_schedule): pass + def get_user_predefined_type(cls): pass def get_work_calendar_attributes(cls): pass def get_work_plan_attributes(cls): pass def get_work_schedule_attributes(cls): pass diff --git a/src/blenderbim/blenderbim/tool/sequence.py b/src/blenderbim/blenderbim/tool/sequence.py index eef330f713..39fc55cc99 100644 --- a/src/blenderbim/blenderbim/tool/sequence.py +++ b/src/blenderbim/blenderbim/tool/sequence.py @@ -811,10 +811,9 @@ class Sequence(blenderbim.core.tool.Sequence): @classmethod def update_visualisation_date(cls, start_date, finish_date): def canonicalise_time(time): - if not time: - return "-" return time.strftime("%d/%m/%y") - + if not (start_date and finish_date): + return props = bpy.context.scene.BIMWorkScheduleProperties props.visualisation_start = canonicalise_time(start_date) props.visualisation_finish = canonicalise_time(finish_date) @@ -1607,4 +1606,12 @@ class Sequence(blenderbim.core.tool.Sequence): @classmethod def is_sort_reversed(cls): - return bpy.context.scene.BIMWorkScheduleProperties.is_sort_reversed \ No newline at end of file + return bpy.context.scene.BIMWorkScheduleProperties.is_sort_reversed + + @classmethod + def get_user_predefined_type(cls): + predefined_type = bpy.context.scene.BIMWorkScheduleProperties.work_schedule_predefined_types + object_type = None + if predefined_type == "USERDEFINED": + object_type = bpy.context.scene.BIMWorkScheduleProperties.object_type + return predefined_type, object_type \ No newline at end of file diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py index ec63d53b3d..a9c775d338 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py @@ -27,6 +27,7 @@ class Usecase: file, name="Unnamed", predefined_type="NOTDEFINED", + object_type=None, start_time=None, work_plan=None, ): @@ -77,6 +78,7 @@ class Usecase: self.settings = { "name": name, "predefined_type": predefined_type, + "object_type": object_type, "start_time": start_time or datetime.now(), "work_plan": work_plan, } @@ -98,7 +100,8 @@ class Usecase: work_schedule.StartTime = ifcopenshell.util.date.datetime2ifc( self.settings["start_time"], "IfcDateTime" ) - + if self.settings["object_type"]: + work_schedule.ObjectType = self.settings["object_type"] if self.settings["work_plan"]: ifcopenshell.api.run( "aggregate.assign_object",