mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 22:31:55 +00:00
Implement unassigning products to tasks
This commit is contained in:
@@ -40,6 +40,7 @@ classes = (
|
||||
operator.DisableEditingTaskTime,
|
||||
operator.EditTaskTime,
|
||||
operator.AssignProduct,
|
||||
operator.UnassignProduct,
|
||||
prop.WorkPlan,
|
||||
prop.BIMWorkPlanProperties,
|
||||
prop.Task,
|
||||
|
||||
@@ -761,3 +761,25 @@ class AssignProduct(bpy.types.Operator):
|
||||
)
|
||||
Data.load(self.file)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class UnassignProduct(bpy.types.Operator):
|
||||
bl_idname = "bim.unassign_product"
|
||||
bl_label = "Unassign Product"
|
||||
task: bpy.props.IntProperty()
|
||||
related_product: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
related_products = (
|
||||
[bpy.data.objects.get(self.related_product)] if self.related_product else bpy.context.selected_objects
|
||||
)
|
||||
for related_product in related_products:
|
||||
self.file = IfcStore.get_file()
|
||||
ifcopenshell.api.run(
|
||||
"sequence.unassign_product",
|
||||
self.file,
|
||||
relating_product=self.file.by_id(related_product.BIMObjectProperties.ifc_definition_id),
|
||||
related_object=self.file.by_id(self.task),
|
||||
)
|
||||
Data.load(self.file)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -261,6 +261,16 @@ class BIM_UL_tasks(UIList):
|
||||
row.prop(item, "finish", emboss=False, text="")
|
||||
row.prop(item, "duration", emboss=False, text="")
|
||||
|
||||
if context.active_object:
|
||||
oprops = context.active_object.BIMObjectProperties
|
||||
row = layout.row(align=True)
|
||||
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.task = item.ifc_definition_id
|
||||
else:
|
||||
op = row.operator("bim.assign_product", text="", icon="KEYFRAME", emboss=False)
|
||||
op.task = item.ifc_definition_id
|
||||
|
||||
if props.active_task_id == item.ifc_definition_id:
|
||||
if props.active_task_time_id:
|
||||
row.operator("bim.edit_task_time", text="", icon="CHECKMARK")
|
||||
@@ -293,5 +303,3 @@ class BIM_UL_tasks(UIList):
|
||||
row.operator("bim.enable_editing_task", text="", icon="GREASEPENCIL").task = item.ifc_definition_id
|
||||
row.operator("bim.add_task", text="", icon="ADD").task = item.ifc_definition_id
|
||||
row.operator("bim.remove_task", text="", icon="X").task = item.ifc_definition_id
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.assign_product", text="ADD", icon="OUTLINER_COLLECTION").task = item.ifc_definition_id
|
||||
|
||||
Reference in New Issue
Block a user