mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Task Output selection improvements - allow recursive nesting and add checkbox to toggle between nested and non-nested
This commit is contained in:
@@ -83,7 +83,6 @@ classes = (
|
||||
operator.ImportPP,
|
||||
operator.LoadTaskInputs,
|
||||
operator.LoadTaskOutputs,
|
||||
operator.LoadNestedTasksOutputs,
|
||||
operator.LoadTaskProperties,
|
||||
operator.LoadTaskResources,
|
||||
operator.RecalculateSchedule,
|
||||
@@ -128,7 +127,6 @@ classes = (
|
||||
ui.BIM_UL_task_inputs,
|
||||
ui.BIM_UL_task_resources,
|
||||
ui.BIM_UL_task_outputs,
|
||||
ui.BIM_UL_nested_task_outputs,
|
||||
ui.BIM_UL_tasks,
|
||||
ui.BIM_PT_SequenceToolKit,
|
||||
)
|
||||
|
||||
@@ -1016,10 +1016,9 @@ class SelectTaskRelatedProducts(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_label = "Select All Output Products"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
task: bpy.props.IntProperty()
|
||||
type: bpy.props.StringProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
core.select_task_outputs(tool.Ifc, tool.Sequence, task=tool.Ifc.get().by_id(self.task), type=self.type)
|
||||
core.select_task_outputs(tool.Ifc, tool.Sequence, task=tool.Ifc.get().by_id(self.task))
|
||||
|
||||
class SelectTaskRelatedInputs(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.select_task_related_inputs"
|
||||
@@ -1505,15 +1504,6 @@ class LoadTaskOutputs(bpy.types.Operator):
|
||||
core.load_task_outputs(tool.Sequence)
|
||||
return {"FINISHED"}
|
||||
|
||||
class LoadNestedTasksOutputs(bpy.types.Operator):
|
||||
bl_idname = "bim.load_nested_tasks_outputs"
|
||||
bl_label = "Load Task Outputs"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
core.load_nested_tasks_outputs(tool.Sequence)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class CalculateTaskDuration(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.calculate_task_duration"
|
||||
|
||||
@@ -90,9 +90,10 @@ def update_active_task_index(self, context):
|
||||
bpy.ops.bim.load_task_inputs()
|
||||
bpy.ops.bim.load_task_resources()
|
||||
bpy.ops.bim.load_task_outputs()
|
||||
bpy.ops.bim.load_nested_tasks_outputs()
|
||||
blenderbim.bim.module.pset.data.refresh()
|
||||
|
||||
def update_active_task_outputs(self, context):
|
||||
bpy.ops.bim.load_task_outputs()
|
||||
|
||||
def updateTaskName(self, context):
|
||||
props = context.scene.BIMWorkScheduleProperties
|
||||
@@ -351,7 +352,7 @@ class BIMWorkScheduleProperties(PropertyGroup):
|
||||
active_task_input_index: IntProperty(name="Active Task Input Index")
|
||||
task_outputs: CollectionProperty(name="Task Outputs", type=TaskProduct)
|
||||
active_task_output_index: IntProperty(name="Active Task Output Index")
|
||||
nested_task_outputs: CollectionProperty(name="Nested Task Outputs", type=TaskProduct)
|
||||
is_nested_task_outputs: BoolProperty(name="Is Nested Task Outputs", default=False, update=update_active_task_outputs)
|
||||
active_nested_task_output_index: IntProperty(name="Active Nested Tasks Output Index")
|
||||
|
||||
class BIMDuration(PropertyGroup):
|
||||
|
||||
@@ -441,22 +441,13 @@ class BIM_PT_task_icom(Panel):
|
||||
op.relating_product = output_id
|
||||
|
||||
op = row2.operator("bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text="Select")
|
||||
op.task = task.ifc_definition_id
|
||||
op.type = 'CURRENT_TASK'
|
||||
op.task = task.ifc_definition_id
|
||||
row2 = col.row()
|
||||
row2.prop(self.props, "is_nested_task_outputs", text="Show Nested")
|
||||
row2 = col.row()
|
||||
row2.template_list(
|
||||
"BIM_UL_task_outputs", "", self.props, "task_outputs", self.props, "active_task_output_index"
|
||||
)
|
||||
# Column3 // Row3
|
||||
row3 = col.row()
|
||||
row3.label(text="Nested Tasks Outputs")
|
||||
op = row3.operator("bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text="Select")
|
||||
op.type = 'NESTED_TASKS'
|
||||
op.task = task.ifc_definition_id
|
||||
row3 = col.row()
|
||||
row3.template_list(
|
||||
"BIM_UL_nested_task_outputs", "", self.props, "nested_task_outputs", self.props, "active_nested_task_output_index"
|
||||
)
|
||||
|
||||
class BIM_UL_task_columns(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
@@ -491,13 +482,6 @@ class BIM_UL_task_outputs(UIList):
|
||||
row.prop(item, "name", emboss=False, text="")
|
||||
|
||||
|
||||
class BIM_UL_nested_task_outputs(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
row.prop(item, "name", emboss=False, text="")
|
||||
|
||||
|
||||
class BIM_UL_tasks(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
if item:
|
||||
|
||||
@@ -266,12 +266,7 @@ def load_task_outputs(sequence):
|
||||
task = sequence.get_highlighted_task()
|
||||
outputs = sequence.get_task_outputs(task)
|
||||
sequence.load_task_outputs(outputs)
|
||||
|
||||
def load_nested_tasks_outputs(sequence):
|
||||
task = sequence.get_highlighted_task()
|
||||
nested_tasks = sequence.get_nested_tasks(task)
|
||||
outputs = sequence.get_nested_tasks_outputs(nested_tasks)
|
||||
sequence.load_nested_tasks_outputs(outputs)
|
||||
|
||||
|
||||
def load_task_inputs(sequence):
|
||||
task = sequence.get_highlighted_task()
|
||||
@@ -428,12 +423,8 @@ def disable_editing_rel_sequence(sequence):
|
||||
sequence.disable_editing_rel_sequence()
|
||||
|
||||
|
||||
def select_task_outputs(ifc, sequence, task=None, type=None):
|
||||
if type == 'CURRENT_TASK':
|
||||
outputs = sequence.get_task_outputs(task)
|
||||
elif type == 'NESTED_TASKS':
|
||||
tasks = sequence.get_nested_tasks(task)
|
||||
outputs = sequence.get_nested_tasks_outputs(tasks)
|
||||
def select_task_outputs(ifc, sequence, task=None):
|
||||
outputs = sequence.get_task_outputs(task)
|
||||
sequence.select_task_products(outputs)
|
||||
|
||||
|
||||
|
||||
@@ -473,7 +473,8 @@ class Selector:
|
||||
class Sequence:
|
||||
def get_work_plan_attributes(cls): pass
|
||||
def load_work_plan_attributes(cls, work_plan): pass
|
||||
def get_nested_tasks(cls, task):pass
|
||||
def get_direct_nested_tasks(cls, task):pass
|
||||
def get_all_nested_tasks(cls, task): pass
|
||||
def enable_editing_work_plan(cls, work_plan): pass
|
||||
def disable_editing_work_plan(cls): pass
|
||||
def enable_editing_work_plan_schedules(cls, work_plan): pass
|
||||
@@ -509,10 +510,9 @@ class Sequence:
|
||||
def get_task_inputs(cls, task): pass
|
||||
def load_task_inputs(cls, inputs): pass
|
||||
def load_task_outputs(cls, outputs): pass
|
||||
def load_nested_task_outputs(cls, outputs): pass
|
||||
def get_highlighted_task(cls): pass
|
||||
def get_direct_task_outputs(cls, task): pass
|
||||
def get_task_outputs(cls, task): pass
|
||||
def get_nested_task_outputs(cls, tasks): pass
|
||||
def get_task_resources(cls, task):pass
|
||||
def enable_editing_work_calendar_times(cls, work_calendar): pass
|
||||
def load_work_calendar_attributes(cls, work_calendar): pass
|
||||
|
||||
@@ -455,15 +455,6 @@ class Sequence(blenderbim.core.tool.Sequence):
|
||||
new.ifc_definition_id = output.id()
|
||||
new.name = output.Name or "Unnamed"
|
||||
|
||||
@classmethod
|
||||
def load_nested_tasks_outputs(cls, outputs):
|
||||
props = bpy.context.scene.BIMWorkScheduleProperties
|
||||
props.nested_task_outputs.clear()
|
||||
if outputs:
|
||||
for output in outputs:
|
||||
new = props.nested_task_outputs.add()
|
||||
new.ifc_definition_id = output.id()
|
||||
new.name = output.Name or "Unnamed"
|
||||
|
||||
@classmethod
|
||||
def get_highlighted_task(cls):
|
||||
@@ -472,22 +463,26 @@ class Sequence(blenderbim.core.tool.Sequence):
|
||||
return tool.Ifc.get().by_id(task_props.tasks[props.active_task_index].ifc_definition_id)
|
||||
|
||||
@classmethod
|
||||
def get_nested_tasks(cls, task):
|
||||
def get_direct_nested_tasks(cls, task):
|
||||
return helper.get_nested_tasks(task)
|
||||
|
||||
@classmethod
|
||||
def get_all_nested_tasks(cls, task):
|
||||
for nested_task in helper.get_nested_tasks(task):
|
||||
yield nested_task
|
||||
yield from cls.get_all_nested_tasks(nested_task)
|
||||
|
||||
@classmethod
|
||||
def get_direct_task_outputs(cls, task):
|
||||
return[rel.RelatingProduct for rel in task.HasAssignments if rel.is_a("IfcRelAssignsToProduct")]
|
||||
|
||||
@classmethod
|
||||
def get_task_outputs(cls, task):
|
||||
return [rel.RelatingProduct for rel in task.HasAssignments if rel.is_a("IfcRelAssignsToProduct")]
|
||||
|
||||
@classmethod
|
||||
def get_nested_tasks_outputs(cls, tasks):
|
||||
outputs = []
|
||||
for subtask in tasks:
|
||||
[
|
||||
outputs.append(rel.RelatingProduct)
|
||||
for rel in subtask.HasAssignments
|
||||
if rel.is_a("IfcRelAssignsToProduct")
|
||||
]
|
||||
if bpy.context.scene.BIMWorkScheduleProperties.is_nested_task_outputs:
|
||||
nested_tasks = cls.get_all_nested_tasks(task)
|
||||
outputs = [output for nested_task in nested_tasks for output in cls.get_direct_task_outputs(nested_task)]
|
||||
else:
|
||||
outputs = cls.get_direct_task_outputs(task)
|
||||
return outputs
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user