Add support for product inputs into tasks, such as for movements on site

This commit is contained in:
Dion Moult
2021-06-15 20:55:43 +10:00
parent 76e2f688e5
commit 68233a8fb2
3 changed files with 65 additions and 10 deletions
@@ -60,6 +60,8 @@ classes = (
operator.RemoveTaskCalendar, operator.RemoveTaskCalendar,
operator.AssignProduct, operator.AssignProduct,
operator.UnassignProduct, operator.UnassignProduct,
operator.AssignProcess,
operator.UnassignProcess,
operator.GenerateGanttChart, operator.GenerateGanttChart,
operator.ImportP6, operator.ImportP6,
operator.ImportMSP, operator.ImportMSP,
@@ -637,18 +637,18 @@ class AssignProduct(bpy.types.Operator):
bl_idname = "bim.assign_product" bl_idname = "bim.assign_product"
bl_label = "Assign Product" bl_label = "Assign Product"
task: bpy.props.IntProperty() task: bpy.props.IntProperty()
related_product: bpy.props.StringProperty() relating_product: bpy.props.StringProperty()
def execute(self, context): def execute(self, context):
related_products = ( relating_products = (
[bpy.data.objects.get(self.related_product)] if self.related_product else bpy.context.selected_objects [bpy.data.objects.get(self.relating_product)] if self.relating_product else bpy.context.selected_objects
) )
for related_product in related_products: for relating_product in relating_products:
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
ifcopenshell.api.run( ifcopenshell.api.run(
"sequence.assign_product", "sequence.assign_product",
self.file, self.file,
relating_product=self.file.by_id(related_product.BIMObjectProperties.ifc_definition_id), relating_product=self.file.by_id(relating_product.BIMObjectProperties.ifc_definition_id),
related_object=self.file.by_id(self.task), related_object=self.file.by_id(self.task),
) )
Data.load(self.file) Data.load(self.file)
@@ -659,24 +659,69 @@ class UnassignProduct(bpy.types.Operator):
bl_idname = "bim.unassign_product" bl_idname = "bim.unassign_product"
bl_label = "Unassign Product" bl_label = "Unassign Product"
task: bpy.props.IntProperty() task: bpy.props.IntProperty()
related_product: bpy.props.StringProperty() relating_product: bpy.props.StringProperty()
def execute(self, context): def execute(self, context):
related_products = ( relating_products = (
[bpy.data.objects.get(self.related_product)] if self.related_product else bpy.context.selected_objects [bpy.data.objects.get(self.relating_product)] if self.relating_product else bpy.context.selected_objects
) )
for related_product in related_products: for relating_product in relating_products:
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
ifcopenshell.api.run( ifcopenshell.api.run(
"sequence.unassign_product", "sequence.unassign_product",
self.file, self.file,
relating_product=self.file.by_id(related_product.BIMObjectProperties.ifc_definition_id), relating_product=self.file.by_id(relating_product.BIMObjectProperties.ifc_definition_id),
related_object=self.file.by_id(self.task), related_object=self.file.by_id(self.task),
) )
Data.load(self.file) Data.load(self.file)
return {"FINISHED"} return {"FINISHED"}
class AssignProcess(bpy.types.Operator):
bl_idname = "bim.assign_process"
bl_label = "Assign Process"
task: bpy.props.IntProperty()
related_object: bpy.props.StringProperty()
def execute(self, context):
related_objects = (
[bpy.data.objects.get(self.related_object)] if self.related_object else bpy.context.selected_objects
)
for related_object in related_objects:
self.file = IfcStore.get_file()
ifcopenshell.api.run(
"sequence.assign_process",
self.file,
related_object=self.file.by_id(related_object.BIMObjectProperties.ifc_definition_id),
relating_process=self.file.by_id(self.task),
)
Data.load(self.file)
return {"FINISHED"}
class UnassignProcess(bpy.types.Operator):
bl_idname = "bim.unassign_process"
bl_label = "Unassign Process"
task: bpy.props.IntProperty()
related_object: bpy.props.StringProperty()
def execute(self, context):
related_objects = (
[bpy.data.objects.get(self.related_object)] if self.related_object else bpy.context.selected_objects
)
for related_object in related_objects:
self.file = IfcStore.get_file()
ifcopenshell.api.run(
"sequence.unassign_process",
self.file,
related_object=self.file.by_id(related_object.BIMObjectProperties.ifc_definition_id),
relating_process=self.file.by_id(self.task),
)
Data.load(self.file)
return {"FINISHED"}
class GenerateGanttChart(bpy.types.Operator): class GenerateGanttChart(bpy.types.Operator):
bl_idname = "bim.generate_gantt_chart" bl_idname = "bim.generate_gantt_chart"
bl_label = "Generate Gantt Chart" bl_label = "Generate Gantt Chart"
@@ -306,6 +306,14 @@ class BIM_UL_tasks(UIList):
if context.active_object: if context.active_object:
oprops = context.active_object.BIMObjectProperties oprops = context.active_object.BIMObjectProperties
row = layout.row(align=True) row = layout.row(align=True)
if oprops.ifc_definition_id in Data.tasks[item.ifc_definition_id]["OperatesOn"]:
op = row.operator("bim.unassign_process", text="", icon="MARKER_HLT", emboss=False)
op.task = item.ifc_definition_id
else:
op = row.operator("bim.assign_process", text="", icon="MARKER", emboss=False)
op.task = item.ifc_definition_id
if oprops.ifc_definition_id in Data.tasks[item.ifc_definition_id]["RelatingProducts"]: if oprops.ifc_definition_id in Data.tasks[item.ifc_definition_id]["RelatingProducts"]:
op = row.operator("bim.unassign_product", text="", icon="KEYFRAME_HLT", emboss=False) op = row.operator("bim.unassign_product", text="", icon="KEYFRAME_HLT", emboss=False)
op.task = item.ifc_definition_id op.task = item.ifc_definition_id