mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
Aggregate WorkSchedules to WorkPlans
This commit is contained in:
@@ -9,6 +9,8 @@ classes = (
|
|||||||
operator.RemoveWorkPlan,
|
operator.RemoveWorkPlan,
|
||||||
operator.EnableEditingWorkPlan,
|
operator.EnableEditingWorkPlan,
|
||||||
operator.DisableEditingWorkPlan,
|
operator.DisableEditingWorkPlan,
|
||||||
|
operator.EnableAggregatingWorkSchedule,
|
||||||
|
operator.AggregateWorkSchedule,
|
||||||
operator.AddWorkSchedule,
|
operator.AddWorkSchedule,
|
||||||
operator.EditWorkSchedule,
|
operator.EditWorkSchedule,
|
||||||
operator.RemoveWorkSchedule,
|
operator.RemoveWorkSchedule,
|
||||||
|
|||||||
@@ -130,6 +130,28 @@ class DisableEditingWorkPlan(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
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):
|
class AddWorkSchedule(bpy.types.Operator):
|
||||||
bl_idname = "bim.add_work_schedule"
|
bl_idname = "bim.add_work_schedule"
|
||||||
bl_label = "Add Work Schedule"
|
bl_label = "Add Work Schedule"
|
||||||
|
|||||||
@@ -106,6 +106,21 @@ def updateTaskTimeDateTime(self, context, startfinish):
|
|||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
setattr(self, startfinish, canonicalise_time(startfinish_datetime))
|
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):
|
class Task(PropertyGroup):
|
||||||
name: StringProperty(name="Name", update=updateTaskName)
|
name: StringProperty(name="Name", update=updateTaskName)
|
||||||
@@ -132,7 +147,8 @@ class BIMWorkPlanProperties(PropertyGroup):
|
|||||||
work_plans: CollectionProperty(name="Work Plans", type=WorkPlan)
|
work_plans: CollectionProperty(name="Work Plans", type=WorkPlan)
|
||||||
active_work_plan_index: IntProperty(name="Active Work Plan Index")
|
active_work_plan_index: IntProperty(name="Active Work Plan Index")
|
||||||
active_work_plan_id: IntProperty(name="Active Work Plan Id")
|
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):
|
class BIMWorkScheduleProperties(PropertyGroup):
|
||||||
work_schedule_attributes: CollectionProperty(name="Work Schedule Attributes", type=Attribute)
|
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 = self.layout.row(align=True)
|
||||||
row.label(text="{} Work Plans Found".format(len(Data.work_plans)), icon="TEXT")
|
row.label(text="{} Work Plans Found".format(len(Data.work_plans)), icon="TEXT")
|
||||||
if self.props.is_editing:
|
if self.props.is_editing:
|
||||||
|
|
||||||
row.operator("bim.add_work_plan", text="", icon="ADD")
|
row.operator("bim.add_work_plan", text="", icon="ADD")
|
||||||
row.operator("bim.disable_work_plan_editing_ui", text="", icon="CHECKMARK")
|
row.operator("bim.disable_work_plan_editing_ui", text="", icon="CHECKMARK")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
row.operator("bim.load_work_plans", text="", icon="GREASEPENCIL")
|
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)
|
row.prop(attribute, "enum_value", text=attribute.name)
|
||||||
if attribute.is_optional:
|
if attribute.is_optional:
|
||||||
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
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):
|
class BIM_UL_work_plans(UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
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 = layout.row(align=True)
|
||||||
row.label(text=item.name)
|
row.label(text=item.name)
|
||||||
if context.scene.BIMWorkPlanProperties.active_work_plan_id == item.ifc_definition_id:
|
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.edit_work_plan", text="", icon="CHECKMARK")
|
||||||
row.operator("bim.disable_editing_work_plan", text="", icon="X")
|
row.operator("bim.disable_editing_work_plan", text="", icon="X")
|
||||||
elif context.scene.BIMWorkPlanProperties.active_work_plan_id:
|
elif context.scene.BIMWorkPlanProperties.active_work_plan_id:
|
||||||
|
|||||||
Reference in New Issue
Block a user