mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
BBIM feature to load nested tasks outputs, and select all nested task outputs
This commit is contained in:
@@ -83,6 +83,7 @@ classes = (
|
||||
operator.ImportPP,
|
||||
operator.LoadTaskInputs,
|
||||
operator.LoadTaskOutputs,
|
||||
operator.LoadNestedTasksOutputs,
|
||||
operator.LoadTaskProperties,
|
||||
operator.LoadTaskResources,
|
||||
operator.RecalculateSchedule,
|
||||
@@ -127,6 +128,7 @@ 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,
|
||||
)
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import re
|
||||
import os
|
||||
import bpy
|
||||
import json
|
||||
@@ -25,15 +24,10 @@ import calendar
|
||||
import isodate
|
||||
import pystache
|
||||
import webbrowser
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.date
|
||||
import ifcopenshell.util.sequence
|
||||
import blenderbim.core.sequence as core
|
||||
import blenderbim.tool as tool
|
||||
import blenderbim.bim.helper
|
||||
import blenderbim.bim.module.sequence.helper as helper
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
from dateutil import parser, relativedelta
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from bpy_extras.io_utils import ImportHelper
|
||||
@@ -1022,10 +1016,10 @@ 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))
|
||||
|
||||
core.select_task_outputs(tool.Ifc, tool.Sequence, task=tool.Ifc.get().by_id(self.task), type=self.type)
|
||||
|
||||
class SelectTaskRelatedInputs(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.select_task_related_inputs"
|
||||
@@ -1510,6 +1504,15 @@ class LoadTaskOutputs(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
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):
|
||||
|
||||
@@ -90,6 +90,7 @@ 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()
|
||||
|
||||
|
||||
@@ -350,7 +351,8 @@ 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)
|
||||
active_nested_task_output_index: IntProperty(name="Active Nested Tasks Output Index")
|
||||
|
||||
class BIMDuration(PropertyGroup):
|
||||
duration_days: IntProperty(name="Days ")
|
||||
|
||||
@@ -427,7 +427,7 @@ class BIM_PT_task_icom(Panel):
|
||||
col = grid.column()
|
||||
|
||||
row2 = col.row(align=True)
|
||||
row2.label(text="Outputs")
|
||||
row2.label(text="Task Outputs")
|
||||
total_task_outputs = len(self.props.task_outputs)
|
||||
|
||||
if context.selected_objects:
|
||||
@@ -440,14 +440,23 @@ class BIM_PT_task_icom(Panel):
|
||||
output_id = self.props.task_outputs[self.props.active_task_output_index].ifc_definition_id
|
||||
op.relating_product = output_id
|
||||
|
||||
op = row2.operator("bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text="")
|
||||
op = row2.operator("bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text="Select")
|
||||
op.task = task.ifc_definition_id
|
||||
|
||||
op.type = 'CURRENT_TASK'
|
||||
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):
|
||||
@@ -462,7 +471,6 @@ class BIM_UL_task_columns(UIList):
|
||||
|
||||
class BIM_UL_task_inputs(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
props = context.scene.BIMWorkScheduleProperties
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
row.prop(item, "name", emboss=False, text="")
|
||||
@@ -471,7 +479,6 @@ class BIM_UL_task_inputs(UIList):
|
||||
|
||||
class BIM_UL_task_resources(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
props = context.scene.BIMWorkScheduleProperties
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
row.prop(item, "name", emboss=False, text="")
|
||||
@@ -479,7 +486,13 @@ class BIM_UL_task_resources(UIList):
|
||||
|
||||
class BIM_UL_task_outputs(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
props = context.scene.BIMWorkScheduleProperties
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
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="")
|
||||
|
||||
@@ -267,7 +267,12 @@ def load_task_outputs(sequence):
|
||||
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()
|
||||
inputs = sequence.get_task_inputs(task)
|
||||
@@ -423,8 +428,12 @@ def disable_editing_rel_sequence(sequence):
|
||||
sequence.disable_editing_rel_sequence()
|
||||
|
||||
|
||||
def select_task_outputs(ifc, sequence, task=None):
|
||||
outputs = sequence.get_task_outputs(task)
|
||||
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)
|
||||
sequence.select_task_products(outputs)
|
||||
|
||||
|
||||
|
||||
@@ -487,7 +487,9 @@ class Sequence:
|
||||
def get_active_work_schedule_id(cls): pass
|
||||
def get_selected_resource(cls): pass
|
||||
def expand_task(cls, task): pass
|
||||
def expand_all_tasks(cls): pass
|
||||
def contract_task(cls, task): pass
|
||||
def contract_all_tasks(cls): pass
|
||||
def disable_work_schedule(cls): pass
|
||||
def disable_selecting_deleted_task(cls): pass
|
||||
def get_checked_tasks(cls): pass
|
||||
@@ -507,8 +509,10 @@ 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_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
|
||||
|
||||
@@ -461,14 +461,33 @@ class Sequence(blenderbim.core.tool.Sequence):
|
||||
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):
|
||||
props = bpy.context.scene.BIMWorkScheduleProperties
|
||||
task_props = bpy.context.scene.BIMTaskTreeProperties
|
||||
return tool.Ifc.get().by_id(task_props.tasks[props.active_task_index].ifc_definition_id)
|
||||
|
||||
@classmethod
|
||||
def get_nested_tasks(cls, task):
|
||||
return helper.get_nested_tasks(task)
|
||||
|
||||
@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")]
|
||||
return outputs
|
||||
|
||||
@classmethod
|
||||
def get_task_resources(cls, task):
|
||||
|
||||
Reference in New Issue
Block a user