mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
BBIM 4D Features to:
- Display nested task resources/task inputs of the active task - Show list of tasks related to the current object selection - Highlight, in the WorkSchedule panel, tasks related to the current object selection
This commit is contained in:
@@ -20,7 +20,6 @@ import bpy
|
|||||||
from . import ui, prop, operator
|
from . import ui, prop, operator
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
operator.HighlightProductRelatedTask,
|
|
||||||
operator.ExpandAllTasks,
|
operator.ExpandAllTasks,
|
||||||
operator.ContractAllTasks,
|
operator.ContractAllTasks,
|
||||||
operator.AddSummaryTask,
|
operator.AddSummaryTask,
|
||||||
@@ -113,6 +112,8 @@ classes = (
|
|||||||
operator.VisualiseWorkScheduleDateRange,
|
operator.VisualiseWorkScheduleDateRange,
|
||||||
operator.LoadTaskAnimationColors,
|
operator.LoadTaskAnimationColors,
|
||||||
operator.DisableEditingTaskAnimationColors,
|
operator.DisableEditingTaskAnimationColors,
|
||||||
|
operator.LoadProductTasks,
|
||||||
|
operator.HighlightTask,
|
||||||
prop.WorkPlan,
|
prop.WorkPlan,
|
||||||
prop.BIMWorkPlanProperties,
|
prop.BIMWorkPlanProperties,
|
||||||
prop.Task,
|
prop.Task,
|
||||||
@@ -140,6 +141,8 @@ classes = (
|
|||||||
ui.BIM_PT_4D_Tools,
|
ui.BIM_PT_4D_Tools,
|
||||||
ui.BIM_PT_Task_Bar_Creator,
|
ui.BIM_PT_Task_Bar_Creator,
|
||||||
ui.BIM_UL_animation_colors,
|
ui.BIM_UL_animation_colors,
|
||||||
|
ui.BIM_UL_product_input_tasks,
|
||||||
|
ui.BIM_UL_product_output_tasks,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ def parse_duration_as_blender_props(dt, simplify=True):
|
|||||||
seconds = getattr(dt, "seconds", 0)
|
seconds = getattr(dt, "seconds", 0)
|
||||||
hours, seconds = divmod(seconds, 3600)
|
hours, seconds = divmod(seconds, 3600)
|
||||||
minutes, seconds = divmod(seconds, 60)
|
minutes, seconds = divmod(seconds, 60)
|
||||||
days = getattr(dt, "days",0)
|
days = getattr(dt, "days", 0)
|
||||||
months = int(getattr(dt, "months", 0))
|
months = int(getattr(dt, "months", 0))
|
||||||
years = int(getattr(dt, "years", 0))
|
years = int(getattr(dt, "years", 0))
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -454,10 +454,7 @@ class UnassignProcess(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
core.unassign_input_products(
|
core.unassign_input_products(
|
||||||
tool.Ifc,
|
tool.Ifc, tool.Sequence, tool.Spatial, task=tool.Ifc.get().by_id(self.task)
|
||||||
tool.Sequence,
|
|
||||||
tool.Spatial,
|
|
||||||
task=tool.Ifc.get().by_id(self.task)
|
|
||||||
)
|
)
|
||||||
elif self.related_object_type == "CONTROL":
|
elif self.related_object_type == "CONTROL":
|
||||||
pass # TODO
|
pass # TODO
|
||||||
@@ -1006,6 +1003,7 @@ class VisualiseWorkScheduleDate(bpy.types.Operator):
|
|||||||
core.visualise_work_schedule_date(tool.Sequence, work_schedule=tool.Ifc.get().by_id(self.work_schedule))
|
core.visualise_work_schedule_date(tool.Sequence, work_schedule=tool.Ifc.get().by_id(self.work_schedule))
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class GuessDateRange(bpy.types.Operator, tool.Ifc.Operator):
|
class GuessDateRange(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.guess_date_range"
|
bl_idname = "bim.guess_date_range"
|
||||||
bl_label = "Guess Work Schedule Date Range"
|
bl_label = "Guess Work Schedule Date Range"
|
||||||
@@ -1024,7 +1022,10 @@ class VisualiseWorkScheduleDateRange(bpy.types.Operator):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
has_start, has_finish = bpy.context.scene.BIMWorkScheduleProperties.visualisation_start, bpy.context.scene.BIMWorkScheduleProperties.visualisation_finish
|
has_start, has_finish = (
|
||||||
|
bpy.context.scene.BIMWorkScheduleProperties.visualisation_start,
|
||||||
|
bpy.context.scene.BIMWorkScheduleProperties.visualisation_finish,
|
||||||
|
)
|
||||||
return bool(has_start and has_finish) and not "-" in (has_start, has_finish)
|
return bool(has_start and has_finish) and not "-" in (has_start, has_finish)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
@@ -1230,17 +1231,6 @@ class CalculateTaskDuration(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
core.calculate_task_duration(tool.Ifc, tool.Sequence, task=tool.Ifc.get().by_id(self.task))
|
core.calculate_task_duration(tool.Ifc, tool.Sequence, task=tool.Ifc.get().by_id(self.task))
|
||||||
|
|
||||||
|
|
||||||
class HighlightProductRelatedTask(bpy.types.Operator, tool.Ifc.Operator):
|
|
||||||
bl_idname = "bim.highlight_product_related_task"
|
|
||||||
bl_label = "Highlights the Related Task"
|
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
|
||||||
bl_description = "Finds the related Task"
|
|
||||||
product_type: bpy.props.StringProperty()
|
|
||||||
|
|
||||||
def _execute(self, context):
|
|
||||||
core.highlight_product_related_task(tool.Sequence, tool.Spatial, product_type=self.product_type)
|
|
||||||
|
|
||||||
|
|
||||||
class ExpandAllTasks(bpy.types.Operator, tool.Ifc.Operator):
|
class ExpandAllTasks(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.expand_all_tasks"
|
bl_idname = "bim.expand_all_tasks"
|
||||||
bl_label = "Expands All Tasks"
|
bl_label = "Expands All Tasks"
|
||||||
@@ -1293,6 +1283,7 @@ class DisableEditingTaskAnimationColors(bpy.types.Operator):
|
|||||||
core.disable_editing_task_animation_colors(tool.Sequence)
|
core.disable_editing_task_animation_colors(tool.Sequence)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class CopyTask(bpy.types.Operator, tool.Ifc.Operator):
|
class CopyTask(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.duplicate_task"
|
bl_idname = "bim.duplicate_task"
|
||||||
bl_label = "Copy Task"
|
bl_label = "Copy Task"
|
||||||
@@ -1301,3 +1292,38 @@ class CopyTask(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
core.duplicate_task(tool.Ifc, tool.Sequence, task=tool.Ifc.get().by_id(self.task))
|
core.duplicate_task(tool.Ifc, tool.Sequence, task=tool.Ifc.get().by_id(self.task))
|
||||||
|
|
||||||
|
|
||||||
|
class LoadProductTasks(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.load_product_tasks"
|
||||||
|
bl_label = "Load Product Tasks"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
if not tool.Ifc.get():
|
||||||
|
return False
|
||||||
|
if not context.active_object:
|
||||||
|
return False
|
||||||
|
if not context.active_object.BIMObjectProperties.ifc_definition_id:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
core.load_product_tasks(
|
||||||
|
tool.Sequence, product=tool.Ifc.get().by_id(context.active_object.BIMObjectProperties.ifc_definition_id)
|
||||||
|
)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class HighlightTask(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.highlight_task"
|
||||||
|
bl_label = "Highlight Task"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
task: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
r = core.highlight_task(tool.Sequence, task=tool.Ifc.get().by_id(self.task))
|
||||||
|
if isinstance(r, str):
|
||||||
|
self.report({"WARNING"}, r)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -96,6 +96,14 @@ def update_active_task_outputs(self, context):
|
|||||||
bpy.ops.bim.load_task_outputs()
|
bpy.ops.bim.load_task_outputs()
|
||||||
|
|
||||||
|
|
||||||
|
def update_active_task_resources(self, context):
|
||||||
|
bpy.ops.bim.load_task_resources()
|
||||||
|
|
||||||
|
|
||||||
|
def update_active_task_inputs(self, context):
|
||||||
|
bpy.ops.bim.load_task_inputs()
|
||||||
|
|
||||||
|
|
||||||
def updateTaskName(self, context):
|
def updateTaskName(self, context):
|
||||||
props = context.scene.BIMWorkScheduleProperties
|
props = context.scene.BIMWorkScheduleProperties
|
||||||
if not props.is_task_update_enabled or self.name == "Unnamed":
|
if not props.is_task_update_enabled or self.name == "Unnamed":
|
||||||
@@ -389,9 +397,13 @@ class BIMWorkScheduleProperties(PropertyGroup):
|
|||||||
active_task_input_index: IntProperty(name="Active Task Input Index")
|
active_task_input_index: IntProperty(name="Active Task Input Index")
|
||||||
task_outputs: CollectionProperty(name="Task Outputs", type=TaskProduct)
|
task_outputs: CollectionProperty(name="Task Outputs", type=TaskProduct)
|
||||||
active_task_output_index: IntProperty(name="Active Task Output Index")
|
active_task_output_index: IntProperty(name="Active Task Output Index")
|
||||||
is_nested_task_outputs: BoolProperty(
|
show_nested_outputs: BoolProperty(name="Show Nested Tasks", default=False, update=update_active_task_outputs)
|
||||||
name="Is Nested Task Outputs", default=False, update=update_active_task_outputs
|
show_nested_resources: BoolProperty(name="Show Nested Tasks", default=False, update=update_active_task_resources)
|
||||||
)
|
show_nested_inputs: BoolProperty(name="Show Nested Tasks", default=False, update=update_active_task_inputs)
|
||||||
|
product_input_tasks: CollectionProperty(name="Product Task Inputs", type=TaskProduct)
|
||||||
|
product_output_tasks: CollectionProperty(name="Product Task Outputs", type=TaskProduct)
|
||||||
|
active_product_output_task_index: IntProperty(name="Active Product Output Task Index")
|
||||||
|
active_product_input_task_index: IntProperty(name="Active Product Input Task Index")
|
||||||
|
|
||||||
|
|
||||||
class BIMTaskTreeProperties(PropertyGroup):
|
class BIMTaskTreeProperties(PropertyGroup):
|
||||||
|
|||||||
@@ -433,6 +433,8 @@ class BIM_PT_task_icom(Panel):
|
|||||||
op = row2.operator("bim.select_task_related_inputs", icon="RESTRICT_SELECT_OFF", text="")
|
op = row2.operator("bim.select_task_related_inputs", icon="RESTRICT_SELECT_OFF", text="")
|
||||||
op.task = task.ifc_definition_id
|
op.task = task.ifc_definition_id
|
||||||
|
|
||||||
|
row2 = col.row()
|
||||||
|
row2.prop(self.props, "show_nested_inputs", text="Show Nested")
|
||||||
row2 = col.row()
|
row2 = col.row()
|
||||||
row2.template_list("BIM_UL_task_inputs", "", self.props, "task_inputs", self.props, "active_task_input_index")
|
row2.template_list("BIM_UL_task_inputs", "", self.props, "task_inputs", self.props, "active_task_input_index")
|
||||||
|
|
||||||
@@ -456,6 +458,9 @@ class BIM_PT_task_icom(Panel):
|
|||||||
op.related_object_type = "RESOURCE"
|
op.related_object_type = "RESOURCE"
|
||||||
op.resource = self.props.task_resources[self.props.active_task_resource_index].ifc_definition_id
|
op.resource = self.props.task_resources[self.props.active_task_resource_index].ifc_definition_id
|
||||||
|
|
||||||
|
row2 = col.row()
|
||||||
|
row2.prop(self.props, "show_nested_resources", text="Show Nested")
|
||||||
|
|
||||||
row2 = col.row()
|
row2 = col.row()
|
||||||
row2.template_list(
|
row2.template_list(
|
||||||
"BIM_UL_task_resources", "", self.props, "task_resources", self.props, "active_task_resource_index"
|
"BIM_UL_task_resources", "", self.props, "task_resources", self.props, "active_task_resource_index"
|
||||||
@@ -481,7 +486,7 @@ class BIM_PT_task_icom(Panel):
|
|||||||
op = row2.operator("bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text="Select")
|
op = row2.operator("bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text="Select")
|
||||||
op.task = task.ifc_definition_id
|
op.task = task.ifc_definition_id
|
||||||
row2 = col.row()
|
row2 = col.row()
|
||||||
row2.prop(self.props, "is_nested_task_outputs", text="Show Nested")
|
row2.prop(self.props, "show_nested_outputs", text="Show Nested")
|
||||||
row2 = col.row()
|
row2 = col.row()
|
||||||
row2.template_list(
|
row2.template_list(
|
||||||
"BIM_UL_task_outputs", "", self.props, "task_outputs", self.props, "active_task_output_index"
|
"BIM_UL_task_outputs", "", self.props, "task_outputs", self.props, "active_task_output_index"
|
||||||
@@ -534,6 +539,26 @@ class BIM_UL_task_outputs(UIList):
|
|||||||
row.prop(item, "name", emboss=False, text="")
|
row.prop(item, "name", emboss=False, text="")
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_UL_product_input_tasks(UIList):
|
||||||
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
|
if item:
|
||||||
|
row = layout.row(align=True)
|
||||||
|
op = row.operator("bim.highlight_task", text="", icon="STYLUS_PRESSURE")
|
||||||
|
op.task = item.ifc_definition_id
|
||||||
|
row.split(factor=0.8)
|
||||||
|
row.label(text=item.name)
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_UL_product_output_tasks(UIList):
|
||||||
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
|
if item:
|
||||||
|
row = layout.row(align=True)
|
||||||
|
op = row.operator("bim.highlight_task", text="", icon="STYLUS_PRESSURE")
|
||||||
|
op.task = item.ifc_definition_id
|
||||||
|
row.split(factor=0.8)
|
||||||
|
row.label(text=item.name)
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_tasks(UIList):
|
class BIM_UL_tasks(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):
|
||||||
if item:
|
if item:
|
||||||
@@ -798,14 +823,32 @@ class BIM_PT_4D_Tools(Panel):
|
|||||||
bl_category = "4D/5D Toolkit"
|
bl_category = "4D/5D Toolkit"
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
|
self.props = context.scene.BIMWorkScheduleProperties
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.operator(
|
row.operator("bim.load_product_tasks", text="Load Tasks", icon="FILE_REFRESH")
|
||||||
"bim.highlight_product_related_task", text="Find Input-related Task ", icon="STYLUS_PRESSURE"
|
|
||||||
).product_type = "Input"
|
grid = self.layout.grid_flow(columns=2, even_columns=True)
|
||||||
row = self.layout.row()
|
col1 = grid.column()
|
||||||
row.operator(
|
col1.label(text="Product Input Tasks")
|
||||||
"bim.highlight_product_related_task", text="Go to Output-related Task ", icon="STYLUS_PRESSURE"
|
col1.template_list(
|
||||||
).product_type = "Output"
|
"BIM_UL_product_input_tasks",
|
||||||
|
"",
|
||||||
|
self.props,
|
||||||
|
"product_input_tasks",
|
||||||
|
self.props,
|
||||||
|
"active_product_input_task_index",
|
||||||
|
)
|
||||||
|
|
||||||
|
col2 = grid.column()
|
||||||
|
col2.label(text="Product Output Tasks")
|
||||||
|
col2.template_list(
|
||||||
|
"BIM_UL_product_output_tasks",
|
||||||
|
"",
|
||||||
|
self.props,
|
||||||
|
"product_output_tasks",
|
||||||
|
self.props,
|
||||||
|
"active_product_output_task_index",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_Task_Bar_Creator(Panel):
|
class BIM_PT_Task_Bar_Creator(Panel):
|
||||||
|
|||||||
@@ -454,6 +454,13 @@ def calculate_task_duration(ifc, sequence, task=None):
|
|||||||
sequence.load_task_properties()
|
sequence.load_task_properties()
|
||||||
|
|
||||||
|
|
||||||
|
def highlight_task(sequence, task=None):
|
||||||
|
work_schedule = sequence.get_work_schedule(task)
|
||||||
|
is_work_schedule_active = sequence.is_work_schedule_active(work_schedule)
|
||||||
|
if is_work_schedule_active:
|
||||||
|
sequence.highlight_task(task)
|
||||||
|
|
||||||
|
|
||||||
def highlight_product_related_task(sequence, spatial, product_type=None):
|
def highlight_product_related_task(sequence, spatial, product_type=None):
|
||||||
products = spatial.get_selected_products()
|
products = spatial.get_selected_products()
|
||||||
if products:
|
if products:
|
||||||
@@ -514,3 +521,6 @@ def visualise_work_schedule_date(sequence, work_schedule=None):
|
|||||||
def generate_gantt_chart(sequence, work_schedule):
|
def generate_gantt_chart(sequence, work_schedule):
|
||||||
json = sequence.create_tasks_json(work_schedule)
|
json = sequence.create_tasks_json(work_schedule)
|
||||||
sequence.generate_gantt_browser_chart(json)
|
sequence.generate_gantt_browser_chart(json)
|
||||||
|
|
||||||
|
def load_product_tasks(sequence, product=None):
|
||||||
|
sequence.load_product_tasks(product)
|
||||||
@@ -422,7 +422,18 @@ class Sequence(blenderbim.core.tool.Sequence):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_task_inputs(cls, task):
|
def get_task_inputs(cls, task):
|
||||||
return ifcopenshell.util.sequence.get_task_inputs(task)
|
is_deep = bpy.context.scene.BIMWorkScheduleProperties.show_nested_inputs
|
||||||
|
return ifcopenshell.util.sequence.get_task_inputs(task, is_deep)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_task_outputs(cls, task):
|
||||||
|
is_deep = bpy.context.scene.BIMWorkScheduleProperties.show_nested_outputs
|
||||||
|
return ifcopenshell.util.sequence.get_task_outputs(task, is_deep)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_task_resources(cls, task):
|
||||||
|
is_deep = bpy.context.scene.BIMWorkScheduleProperties.show_nested_resources
|
||||||
|
return ifcopenshell.util.sequence.get_task_resource(task, is_deep)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_task_inputs(cls, inputs):
|
def load_task_inputs(cls, inputs):
|
||||||
@@ -459,7 +470,7 @@ class Sequence(blenderbim.core.tool.Sequence):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_task_outputs(cls, task):
|
def get_task_outputs(cls, task):
|
||||||
is_deep = bpy.context.scene.BIMWorkScheduleProperties.is_nested_task_outputs
|
is_deep = bpy.context.scene.BIMWorkScheduleProperties.show_nested_outputs
|
||||||
return ifcopenshell.util.sequence.get_task_outputs(task, is_deep)
|
return ifcopenshell.util.sequence.get_task_outputs(task, is_deep)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -777,7 +788,7 @@ class Sequence(blenderbim.core.tool.Sequence):
|
|||||||
displayed_tasks = [item.ifc_definition_id for item in task_props.tasks]
|
displayed_tasks = [item.ifc_definition_id for item in task_props.tasks]
|
||||||
if not task.id() in displayed_tasks:
|
if not task.id() in displayed_tasks:
|
||||||
expand_ancestors(task)
|
expand_ancestors(task)
|
||||||
task_index = [item.ifc_definition_id for item in task_props.tasks].index(task.id()) or 0
|
task_index = displayed_tasks.index(task.id()) or 0
|
||||||
bpy.context.scene.BIMWorkScheduleProperties.active_task_index = task_index
|
bpy.context.scene.BIMWorkScheduleProperties.active_task_index = task_index
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -1500,3 +1511,18 @@ class Sequence(blenderbim.core.tool.Sequence):
|
|||||||
f.write(pystache.render(t.read(), {"json_data": json.dumps(task_json)}))
|
f.write(pystache.render(t.read(), {"json_data": json.dumps(task_json)}))
|
||||||
webbrowser.open("file://" + os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"))
|
webbrowser.open("file://" + os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load_product_tasks(cls, product):
|
||||||
|
props = bpy.context.scene.BIMWorkScheduleProperties
|
||||||
|
props.is_task_update_enabled = False
|
||||||
|
props.product_input_tasks.clear()
|
||||||
|
props.product_output_tasks.clear()
|
||||||
|
task_inputs, task_ouputs = ifcopenshell.util.sequence.get_tasks_for_product(product)
|
||||||
|
for task in task_inputs or []:
|
||||||
|
new = props.product_input_tasks.add()
|
||||||
|
new.name = task.Name or "Unnamed"
|
||||||
|
new.ifc_definition_id = task.id()
|
||||||
|
for task in task_ouputs or []:
|
||||||
|
new = props.product_output_tasks.add()
|
||||||
|
new.name = task.Name or "Unnamed"
|
||||||
|
new.ifc_definition_id = task.id()
|
||||||
|
|||||||
@@ -326,26 +326,45 @@ def get_task_outputs(task, is_deep=False):
|
|||||||
if not is_deep:
|
if not is_deep:
|
||||||
return get_direct_task_outputs(task)
|
return get_direct_task_outputs(task)
|
||||||
else:
|
else:
|
||||||
nested_tasks = get_all_nested_tasks(task)
|
|
||||||
return [
|
return [
|
||||||
output
|
output
|
||||||
for nested_task in nested_tasks
|
for nested_task in get_all_nested_tasks(task)
|
||||||
for output in get_direct_task_outputs(nested_task)
|
for output in get_direct_task_outputs(nested_task)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_task_inputs(task, is_deep=False):
|
||||||
|
if not is_deep:
|
||||||
|
return [object for rel in task.OperatesOn if rel.is_a("IfcRelAssignsToProcess") for object in rel.RelatedObjects if object.is_a("IfcProduct")]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
output
|
||||||
|
for nested_task in get_all_nested_tasks(task)
|
||||||
|
for output in [object for rel in nested_task.OperatesOn if rel.is_a("IfcRelAssignsToProcess") for object in rel.RelatedObjects if object.is_a("IfcProduct")]
|
||||||
|
]
|
||||||
|
|
||||||
def get_task_inputs(task):
|
def get_task_resources(task, is_deep=False):
|
||||||
inputs = []
|
if not is_deep:
|
||||||
for rel in task.OperatesOn:
|
return [object for rel in task.OperatesOn if rel.is_a("IfcRelAssignsToProcess") for object in rel.RelatedObjects if object.is_a("IfcResource")]
|
||||||
for object in rel.RelatedObjects:
|
else:
|
||||||
if object.is_a("IfcProduct"):
|
return [
|
||||||
inputs.append(object)
|
output
|
||||||
return inputs
|
for nested_task in get_all_nested_tasks(task)
|
||||||
|
for output in [object for rel in nested_task.OperatesOn if rel.is_a("IfcRelAssignsToProcess") for object in rel.RelatedObjects if object.is_a("IfcResource")]
|
||||||
|
]
|
||||||
|
|
||||||
def has_task_outputs(task):
|
def has_task_outputs(task):
|
||||||
return len(get_task_outputs(task)) > 0
|
return len(get_task_outputs(task)) > 0
|
||||||
|
|
||||||
|
|
||||||
def has_task_inputs(task):
|
def has_task_inputs(task):
|
||||||
return len(get_task_inputs(task)) > 0
|
return len(get_task_inputs(task)) > 0
|
||||||
|
|
||||||
|
def get_tasks_for_product(product):
|
||||||
|
inputs = []
|
||||||
|
outputs = []
|
||||||
|
for assignment in product.HasAssignments:
|
||||||
|
if assignment.is_a("IfcRelAssignsToProcess") and assignment.RelatingProcess.is_a("IfcTask"):
|
||||||
|
inputs.append(assignment.RelatingProcess)
|
||||||
|
for reference in product.ReferencedBy:
|
||||||
|
if reference.is_a("IfcRelAssignsToProduct") and reference.RelatedObjects[0].is_a("IfcTask"):
|
||||||
|
outputs.extend([obj for obj in reference.RelatedObjects if obj.is_a("IfcTask")])
|
||||||
|
return inputs, outputs
|
||||||
Reference in New Issue
Block a user