Aggregate WorkSchedules to WorkPlans

This commit is contained in:
bosonprojets
2021-04-28 02:17:08 +00:00
parent 56046dd6f9
commit c3cc5881df
4 changed files with 51 additions and 1 deletions
@@ -9,6 +9,8 @@ classes = (
operator.RemoveWorkPlan,
operator.EnableEditingWorkPlan,
operator.DisableEditingWorkPlan,
operator.EnableAggregatingWorkSchedule,
operator.AggregateWorkSchedule,
operator.AddWorkSchedule,
operator.EditWorkSchedule,
operator.RemoveWorkSchedule,
@@ -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"
@@ -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)
@@ -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: