diff --git a/src/blenderbim/blenderbim/bim/module/sequence/__init__.py b/src/blenderbim/blenderbim/bim/module/sequence/__init__.py index 83777c9476..d311e356f8 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/__init__.py @@ -9,6 +9,8 @@ classes = ( operator.RemoveWorkPlan, operator.EnableEditingWorkPlan, operator.DisableEditingWorkPlan, + operator.EnableAggregatingWorkSchedule, + operator.AggregateWorkSchedule, operator.AddWorkSchedule, operator.EditWorkSchedule, operator.RemoveWorkSchedule, diff --git a/src/blenderbim/blenderbim/bim/module/sequence/operator.py b/src/blenderbim/blenderbim/bim/module/sequence/operator.py index 68e5659948..57e408bac9 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/operator.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/operator.py @@ -130,6 +130,28 @@ class DisableEditingWorkPlan(bpy.types.Operator): return {"FINISHED"} +class EnableAggregatingWorkSchedule(bpy.types.Operator): + bl_idname = "bim.enable_aggregating_work_schedules" + bl_label = "Enable Assigning Work Schedules" + + def execute(self, context): + props = context.scene.BIMWorkPlanProperties + props.aggregate_work_schedule = True + return {"FINISHED"} + +class AggregateWorkSchedule(bpy.types.Operator): + bl_idname = "bim.aggregate_work_schedule" + bl_label = "Enable Assigning Work Schedule" + work_schedule: bpy.props.IntProperty() + + def execute(self, context): + ifcopenshell.api.run( + "aggregate.assign_object", + self.file, + **{"relating_object": self.file.by_id(props.active_work_plan_id), "product": self.file.by_id(self.work_schedule)}, + ) + Data.load(IfcStore.get_file()) + class AddWorkSchedule(bpy.types.Operator): bl_idname = "bim.add_work_schedule" bl_label = "Add Work Schedule" diff --git a/src/blenderbim/blenderbim/bim/module/sequence/prop.py b/src/blenderbim/blenderbim/bim/module/sequence/prop.py index c718d2a48f..4ec71209aa 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/prop.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/prop.py @@ -106,6 +106,21 @@ def updateTaskTimeDateTime(self, context, startfinish): Data.load(IfcStore.get_file()) setattr(self, startfinish, canonicalise_time(startfinish_datetime)) +workschedule_enum = [] + +def getWorkSchedules(self, context): + global workschedule_enum + self.file = IfcStore.get_file() + if len(workschedule_enum) == 0 and IfcStore.get_schema(): + workschedule_enum.clear() + workschedule_enum = [("")] + workschedule_enum.extend( + [ + (s.id(), s.Name, "") + for s in self.file.by_type("IfcWorkSchedule") + ] + ) + return workschedule_enum class Task(PropertyGroup): name: StringProperty(name="Name", update=updateTaskName) @@ -132,7 +147,8 @@ class BIMWorkPlanProperties(PropertyGroup): work_plans: CollectionProperty(name="Work Plans", type=WorkPlan) active_work_plan_index: IntProperty(name="Active Work Plan Index") active_work_plan_id: IntProperty(name="Active Work Plan Id") - + work_schedules: EnumProperty(items=getWorkSchedules, name="Quantity Types") + aggregate_work_schedule: BoolProperty(name="Is Aggregating WorkSchedule", default=False) class BIMWorkScheduleProperties(PropertyGroup): work_schedule_attributes: CollectionProperty(name="Work Schedule Attributes", type=Attribute) diff --git a/src/blenderbim/blenderbim/bim/module/sequence/ui.py b/src/blenderbim/blenderbim/bim/module/sequence/ui.py index e09e356ec1..1907eee951 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/ui.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/ui.py @@ -22,8 +22,10 @@ class BIM_PT_work_plans(Panel): row = self.layout.row(align=True) row.label(text="{} Work Plans Found".format(len(Data.work_plans)), icon="TEXT") if self.props.is_editing: + row.operator("bim.add_work_plan", text="", icon="ADD") row.operator("bim.disable_work_plan_editing_ui", text="", icon="CHECKMARK") + else: row.operator("bim.load_work_plans", text="", icon="GREASEPENCIL") @@ -49,7 +51,14 @@ class BIM_PT_work_plans(Panel): row.prop(attribute, "enum_value", text=attribute.name) if attribute.is_optional: row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="") + if self.props.aggregate_work_schedule: + self.draw_aggregating_work_schedule_ui() + def draw_aggregating_work_schedule_ui(self): + row = self.layout.row(align=True) + row.prop(self.props, "work_schedules", text="") + op = row.operator("bim.aggregate_work_schedule", text="", icon="ADD") + # op.work_schedule = self.props.work_schedules class BIM_UL_work_plans(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): @@ -57,6 +66,7 @@ class BIM_UL_work_plans(UIList): row = layout.row(align=True) row.label(text=item.name) if context.scene.BIMWorkPlanProperties.active_work_plan_id == item.ifc_definition_id: + row.operator("bim.enable_aggregating_work_schedules", text="", icon="LINENUMBERS_ON") row.operator("bim.edit_work_plan", text="", icon="CHECKMARK") row.operator("bim.disable_editing_work_plan", text="", icon="X") elif context.scene.BIMWorkPlanProperties.active_work_plan_id: