mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Feature to create IfcTask trees for entities of IfcWorkSchedule
This commit is contained in:
@@ -9,7 +9,6 @@ classes = (
|
|||||||
operator.RemoveWorkPlan,
|
operator.RemoveWorkPlan,
|
||||||
operator.EnableEditingWorkPlan,
|
operator.EnableEditingWorkPlan,
|
||||||
operator.DisableEditingWorkPlan,
|
operator.DisableEditingWorkPlan,
|
||||||
operator.LoadWorkSchedules,
|
|
||||||
operator.DisableWorkScheduleEditingUI,
|
operator.DisableWorkScheduleEditingUI,
|
||||||
operator.AddWorkSchedule,
|
operator.AddWorkSchedule,
|
||||||
operator.EditWorkSchedule,
|
operator.EditWorkSchedule,
|
||||||
@@ -26,17 +25,19 @@ classes = (
|
|||||||
operator.EnableEditingWorkCalendar,
|
operator.EnableEditingWorkCalendar,
|
||||||
operator.DisableEditingWorkCalendar,
|
operator.DisableEditingWorkCalendar,
|
||||||
operator.AddTask,
|
operator.AddTask,
|
||||||
|
operator.AddSummaryTask,
|
||||||
|
operator.ExpandTask,
|
||||||
|
operator.ContractTask,
|
||||||
|
operator.RemoveTask,
|
||||||
prop.WorkPlan,
|
prop.WorkPlan,
|
||||||
prop.BIMWorkPlanProperties,
|
prop.BIMWorkPlanProperties,
|
||||||
prop.Task,
|
prop.Task,
|
||||||
prop.WorkSchedule,
|
|
||||||
prop.BIMWorkScheduleProperties,
|
prop.BIMWorkScheduleProperties,
|
||||||
prop.WorkCalendar,
|
prop.WorkCalendar,
|
||||||
prop.BIMWorkCalendarProperties,
|
prop.BIMWorkCalendarProperties,
|
||||||
ui.BIM_PT_work_plans,
|
ui.BIM_PT_work_plans,
|
||||||
ui.BIM_UL_work_plans,
|
ui.BIM_UL_work_plans,
|
||||||
ui.BIM_PT_work_schedules,
|
ui.BIM_PT_work_schedules,
|
||||||
ui.BIM_UL_work_schedules,
|
|
||||||
ui.BIM_PT_work_calendars,
|
ui.BIM_PT_work_calendars,
|
||||||
ui.BIM_UL_work_calendars,
|
ui.BIM_UL_work_calendars,
|
||||||
ui.BIM_UL_tasks,
|
ui.BIM_UL_tasks,
|
||||||
|
|||||||
@@ -123,23 +123,6 @@ class DisableEditingWorkPlan(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class LoadWorkSchedules(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.load_work_schedules"
|
|
||||||
bl_label = "Load Work Schedules"
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
props = context.scene.BIMWorkScheduleProperties
|
|
||||||
while len(props.work_schedules) > 0:
|
|
||||||
props.work_schedules.remove(0)
|
|
||||||
for ifc_definition_id, work_schedule in Data.work_schedules.items():
|
|
||||||
new = props.work_schedules.add()
|
|
||||||
new.ifc_definition_id = ifc_definition_id
|
|
||||||
new.name = work_schedule["Name"] or "Unnamed"
|
|
||||||
props.is_editing = True
|
|
||||||
bpy.ops.bim.disable_editing_work_schedule()
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class DisableWorkScheduleEditingUI(bpy.types.Operator):
|
class DisableWorkScheduleEditingUI(bpy.types.Operator):
|
||||||
bl_idname = "bim.disable_work_schedule_editing_ui"
|
bl_idname = "bim.disable_work_schedule_editing_ui"
|
||||||
bl_label = "Disable WorkSchedule Editing UI"
|
bl_label = "Disable WorkSchedule Editing UI"
|
||||||
@@ -156,7 +139,6 @@ class AddWorkSchedule(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
ifcopenshell.api.run("sequence.add_work_schedule", IfcStore.get_file())
|
ifcopenshell.api.run("sequence.add_work_schedule", IfcStore.get_file())
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
bpy.ops.bim.load_work_schedules()
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -182,7 +164,7 @@ class EditWorkSchedule(bpy.types.Operator):
|
|||||||
**{"work_schedule": self.file.by_id(props.active_work_schedule_id), "attributes": attributes}
|
**{"work_schedule": self.file.by_id(props.active_work_schedule_id), "attributes": attributes}
|
||||||
)
|
)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
bpy.ops.bim.load_work_schedules()
|
bpy.ops.bim.disable_editing_work_schedule()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -194,10 +176,11 @@ class RemoveWorkSchedule(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"sequence.remove_work_schedule", self.file, **{"work_schedule": self.file.by_id(self.work_schedule)}
|
"sequence.remove_work_schedule",
|
||||||
|
self.file,
|
||||||
|
work_schedule= self.file.by_id(self.work_schedule)
|
||||||
)
|
)
|
||||||
Data.load(self.file)
|
Data.load(self.file)
|
||||||
bpy.ops.bim.load_work_schedules()
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -207,9 +190,10 @@ class EnableEditingWorkSchedule(bpy.types.Operator):
|
|||||||
work_schedule: bpy.props.IntProperty()
|
work_schedule: bpy.props.IntProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
props = context.scene.BIMWorkScheduleProperties
|
self.props = context.scene.BIMWorkScheduleProperties
|
||||||
while len(props.work_schedule_attributes) > 0:
|
self.props.active_work_schedule_id = self.work_schedule
|
||||||
props.work_schedule_attributes.remove(0)
|
while len(self.props.work_schedule_attributes) > 0:
|
||||||
|
self.props.work_schedule_attributes.remove(0)
|
||||||
|
|
||||||
data = Data.work_schedules[self.work_schedule]
|
data = Data.work_schedules[self.work_schedule]
|
||||||
|
|
||||||
@@ -217,7 +201,7 @@ class EnableEditingWorkSchedule(bpy.types.Operator):
|
|||||||
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
||||||
if data_type == "entity":
|
if data_type == "entity":
|
||||||
continue
|
continue
|
||||||
new = props.work_schedule_attributes.add()
|
new = self.props.work_schedule_attributes.add()
|
||||||
new.name = attribute.name()
|
new.name = attribute.name()
|
||||||
new.is_null = data[attribute.name()] is None
|
new.is_null = data[attribute.name()] is None
|
||||||
new.is_optional = attribute.optional()
|
new.is_optional = attribute.optional()
|
||||||
@@ -230,10 +214,30 @@ class EnableEditingWorkSchedule(bpy.types.Operator):
|
|||||||
new.enum_items = json.dumps(ifcopenshell.util.attribute.get_enum_items(attribute))
|
new.enum_items = json.dumps(ifcopenshell.util.attribute.get_enum_items(attribute))
|
||||||
if data[attribute.name()]:
|
if data[attribute.name()]:
|
||||||
new.enum_value = data[attribute.name()]
|
new.enum_value = data[attribute.name()]
|
||||||
props.active_work_schedule_id = self.work_schedule
|
self.props.active_work_schedule_id = self.work_schedule
|
||||||
bpy.ops.bim.load_tasks(work_schedule=self.work_schedule)
|
|
||||||
|
while len(self.props.tasks) > 0:
|
||||||
|
self.props.tasks.remove(0)
|
||||||
|
|
||||||
|
self.contracted_tasks = json.loads(self.props.contracted_tasks)
|
||||||
|
for related_object_id in Data.work_schedules[self.work_schedule]["RelatedObjects"]:
|
||||||
|
self.create_new_task_li(related_object_id, 0)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
def create_new_task_li(self, related_object_id, level_index):
|
||||||
|
task = Data.tasks[related_object_id]
|
||||||
|
new = self.props.tasks.add()
|
||||||
|
new.name = task["Name"] or "Unnamed"
|
||||||
|
new.ifc_definition_id = related_object_id
|
||||||
|
new.is_expanded = related_object_id not in self.contracted_tasks
|
||||||
|
new.level_index = level_index
|
||||||
|
if task["RelatedObjects"]:
|
||||||
|
new.has_children = True
|
||||||
|
if new.is_expanded:
|
||||||
|
for related_object_id in task["RelatedObjects"]:
|
||||||
|
self.create_new_task_li(related_object_id, level_index + 1)
|
||||||
|
# return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class DisableEditingWorkSchedule(bpy.types.Operator):
|
class DisableEditingWorkSchedule(bpy.types.Operator):
|
||||||
bl_idname = "bim.disable_editing_work_schedule"
|
bl_idname = "bim.disable_editing_work_schedule"
|
||||||
@@ -392,13 +396,80 @@ class DisableTaskEditingUI(bpy.types.Operator):
|
|||||||
class AddTask(bpy.types.Operator):
|
class AddTask(bpy.types.Operator):
|
||||||
bl_idname = "bim.add_task"
|
bl_idname = "bim.add_task"
|
||||||
bl_label = "Add Task"
|
bl_label = "Add Task"
|
||||||
|
task: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMWorkScheduleProperties
|
||||||
|
self.file = IfcStore.get_file()
|
||||||
|
ifcopenshell.api.run("sequence.add_task", self.file, **{
|
||||||
|
"parent_task": self.file.by_id(self.task)
|
||||||
|
})
|
||||||
|
Data.load(self.file)
|
||||||
|
bpy.ops.bim.enable_editing_work_schedule(work_schedule = props.active_work_schedule_id)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class AddSummaryTask(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.add_summary_task"
|
||||||
|
bl_label = "Add Task"
|
||||||
work_schedule: bpy.props.IntProperty()
|
work_schedule: bpy.props.IntProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMWorkScheduleProperties
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
task = ifcopenshell.api.run("sequence.add_task", self.file)
|
ifcopenshell.api.run("sequence.add_task", self.file, **{
|
||||||
control = self.file.by_id(self.work_schedule)
|
"work_schedule": self.file.by_id(self.work_schedule)
|
||||||
ifcopenshell.api.run("control.assign_control", self.file, related_object=task, relating_control=control)
|
})
|
||||||
Data.load(self.file)
|
Data.load(self.file)
|
||||||
bpy.ops.bim.enable_editing_work_schedule(work_schedule = self.work_schedule)
|
bpy.ops.bim.enable_editing_work_schedule(work_schedule = props.active_work_schedule_id)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class ExpandTask(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.expand_task"
|
||||||
|
bl_label = "Expand Task"
|
||||||
|
task: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMWorkScheduleProperties
|
||||||
|
self.file = IfcStore.get_file()
|
||||||
|
contracted_tasks = json.loads(props.contracted_tasks)
|
||||||
|
contracted_tasks.remove(self.task)
|
||||||
|
props.contracted_tasks = json.dumps(contracted_tasks)
|
||||||
|
Data.load(self.file)
|
||||||
|
bpy.ops.bim.enable_editing_work_schedule(work_schedule = props.active_work_schedule_id)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class ContractTask(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.contract_task"
|
||||||
|
bl_label = "Contract Task"
|
||||||
|
task: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMWorkScheduleProperties
|
||||||
|
self.file = IfcStore.get_file()
|
||||||
|
contracted_tasks = json.loads(props.contracted_tasks)
|
||||||
|
contracted_tasks.append(self.task)
|
||||||
|
props.contracted_tasks = json.dumps(contracted_tasks)
|
||||||
|
Data.load(self.file)
|
||||||
|
bpy.ops.bim.enable_editing_work_schedule(work_schedule = props.active_work_schedule_id)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class RemoveTask(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.remove_task"
|
||||||
|
bl_label = "Remove Task"
|
||||||
|
task: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMWorkScheduleProperties
|
||||||
|
self.file = IfcStore.get_file()
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"sequence.remove_task",
|
||||||
|
self.file,
|
||||||
|
task=IfcStore.get_file().by_id(self.task),
|
||||||
|
)
|
||||||
|
Data.load(self.file)
|
||||||
|
bpy.ops.bim.enable_editing_work_schedule(work_schedule = props.active_work_schedule_id)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ class Task(PropertyGroup):
|
|||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
identification: StringProperty(name="Identification")
|
identification: StringProperty(name="Identification")
|
||||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||||
|
has_children: BoolProperty(name="Has Children")
|
||||||
|
is_expanded: BoolProperty(name="Is Expanded")
|
||||||
|
level_index: IntProperty(name="Level Index")
|
||||||
|
|
||||||
class WorkPlan(PropertyGroup):
|
class WorkPlan(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
@@ -32,19 +34,15 @@ class BIMWorkPlanProperties(PropertyGroup):
|
|||||||
active_work_plan_id: IntProperty(name="Active Work Plan Id")
|
active_work_plan_id: IntProperty(name="Active Work Plan Id")
|
||||||
|
|
||||||
|
|
||||||
class WorkSchedule(PropertyGroup):
|
|
||||||
name: StringProperty(name="Name")
|
|
||||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
|
||||||
|
|
||||||
|
|
||||||
class BIMWorkScheduleProperties(PropertyGroup):
|
class BIMWorkScheduleProperties(PropertyGroup):
|
||||||
work_schedule_attributes: CollectionProperty(name="Work Schedule Attributes", type=Attribute)
|
work_schedule_attributes: CollectionProperty(name="Work Schedule Attributes", type=Attribute)
|
||||||
is_editing: BoolProperty(name="Is Editing", default=False)
|
is_editing: BoolProperty(name="Is Editing", default=False)
|
||||||
work_schedules: CollectionProperty(name="Work Schedules", type=WorkSchedule)
|
|
||||||
active_work_schedule_index: IntProperty(name="Active Work Schedules Index")
|
active_work_schedule_index: IntProperty(name="Active Work Schedules Index")
|
||||||
active_work_schedule_id: IntProperty(name="Active Work Schedules Id")
|
active_work_schedule_id: IntProperty(name="Active Work Schedules Id")
|
||||||
tasks: CollectionProperty(name="Tasks", type=Task)
|
tasks: CollectionProperty(name="Tasks", type=Task)
|
||||||
active_task_index: IntProperty(name="Active Task Index")
|
active_task_index: IntProperty(name="Active Task Index")
|
||||||
|
contracted_tasks: StringProperty(name="Contracted Task Items", default="[]")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class WorkCalendar(PropertyGroup):
|
class WorkCalendar(PropertyGroup):
|
||||||
|
|||||||
@@ -80,31 +80,33 @@ class BIM_PT_work_schedules(Panel):
|
|||||||
return IfcStore.get_file()
|
return IfcStore.get_file()
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
|
self.props = context.scene.BIMWorkScheduleProperties
|
||||||
|
|
||||||
if not Data.is_loaded:
|
if not Data.is_loaded:
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
self.props = context.scene.BIMWorkScheduleProperties
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text="{} Work Schedules Found".format(len(Data.work_schedules)), icon="TEXT")
|
row.label(text="{} Work Schedules Found".format(len(Data.work_schedules)), icon="TEXT")
|
||||||
if self.props.is_editing:
|
row = self.layout.row()
|
||||||
row.operator("bim.add_work_schedule", text="", icon="ADD")
|
row.operator("bim.add_work_schedule", icon="ADD")
|
||||||
row.operator("bim.disable_work_schedule_editing_ui", text="", icon="CHECKMARK")
|
|
||||||
else:
|
|
||||||
row.operator("bim.load_work_schedules", text="", icon="GREASEPENCIL")
|
|
||||||
|
|
||||||
if self.props.is_editing:
|
for work_schedule_id, work_schedule in Data.work_schedules.items():
|
||||||
self.layout.template_list(
|
row = self.layout.row(align=True)
|
||||||
"BIM_UL_work_schedules",
|
row.label(text=work_schedule["Name"] or "Unnamed", icon="LINENUMBERS_ON")
|
||||||
"",
|
|
||||||
self.props,
|
|
||||||
"work_schedules",
|
|
||||||
self.props,
|
|
||||||
"active_work_schedule_index",
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.props.active_work_schedule_id:
|
if self.props.active_work_schedule_id and self.props.active_work_schedule_id == work_schedule_id:
|
||||||
self.draw_editable_ui(context)
|
row.operator("bim.edit_work_schedule", text="", icon="CHECKMARK")
|
||||||
|
row.operator("bim.disable_editing_work_schedule", text="", icon="X")
|
||||||
|
elif self.props.active_work_schedule_id:
|
||||||
|
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = work_schedule_id
|
||||||
|
else:
|
||||||
|
row.operator("bim.enable_editing_work_schedule", text="", icon="GREASEPENCIL").work_schedule = work_schedule_id
|
||||||
|
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = work_schedule_id
|
||||||
|
|
||||||
def draw_editable_ui(self, context):
|
if self.props.active_work_schedule_id == work_schedule_id:
|
||||||
|
self.draw_editable_work_schedule_ui(work_schedule_id, work_schedule)
|
||||||
|
|
||||||
|
def draw_editable_work_schedule_ui(self, work_schedule_id, work_schedule):
|
||||||
for attribute in self.props.work_schedule_attributes:
|
for attribute in self.props.work_schedule_attributes:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
if attribute.data_type == "string":
|
if attribute.data_type == "string":
|
||||||
@@ -114,13 +116,9 @@ class BIM_PT_work_schedules(Panel):
|
|||||||
if attribute.is_optional:
|
if attribute.is_optional:
|
||||||
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
||||||
|
|
||||||
self.draw_task_ui(context)
|
|
||||||
|
|
||||||
def draw_task_ui(self, context):
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text="{} Tasks Found".format(len(Data.tasks)), icon="ACTION")
|
row.label(text="X Summary Tasks")
|
||||||
row.operator("bim.add_task", text="", icon="ADD").work_schedule = self.props.active_work_schedule_id
|
row.operator("bim.add_summary_task", text="", icon="ADD").work_schedule = work_schedule_id
|
||||||
|
|
||||||
self.layout.template_list(
|
self.layout.template_list(
|
||||||
"BIM_UL_tasks",
|
"BIM_UL_tasks",
|
||||||
"",
|
"",
|
||||||
@@ -130,21 +128,23 @@ class BIM_PT_work_schedules(Panel):
|
|||||||
"active_task_index",
|
"active_task_index",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class BIM_UL_tasks(UIList):
|
||||||
class BIM_UL_work_schedules(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:
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text=item.name)
|
for i in range(0, item.level_index):
|
||||||
if context.scene.BIMWorkScheduleProperties.active_work_schedule_id == item.ifc_definition_id:
|
row.label(text="", icon="BLANK1")
|
||||||
row.operator("bim.edit_work_schedule", text="", icon="CHECKMARK")
|
if item.has_children:
|
||||||
row.operator("bim.disable_editing_work_schedule", text="", icon="X")
|
if item.is_expanded:
|
||||||
elif context.scene.BIMWorkScheduleProperties.active_work_schedule_id:
|
row.operator("bim.contract_task", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN").task = item.ifc_definition_id
|
||||||
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = item.ifc_definition_id
|
else:
|
||||||
|
row.operator("bim.expand_task", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT").task = item.ifc_definition_id
|
||||||
else:
|
else:
|
||||||
op = row.operator("bim.enable_editing_work_schedule", text="", icon="GREASEPENCIL")
|
row.label(text="", icon="DOT")
|
||||||
op.work_schedule = item.ifc_definition_id
|
row.label(text=item.name)
|
||||||
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = item.ifc_definition_id
|
op = row.operator("bim.add_task", text="", icon="ADD")
|
||||||
|
op.task = item.ifc_definition_id
|
||||||
|
row.operator("bim.remove_task", text="", icon="X").task = item.ifc_definition_id
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_work_calendars(Panel):
|
class BIM_PT_work_calendars(Panel):
|
||||||
@@ -209,12 +209,3 @@ class BIM_UL_work_calendars(UIList):
|
|||||||
op = row.operator("bim.enable_editing_work_calendar", text="", icon="GREASEPENCIL")
|
op = row.operator("bim.enable_editing_work_calendar", text="", icon="GREASEPENCIL")
|
||||||
op.work_calendar = item.ifc_definition_id
|
op.work_calendar = item.ifc_definition_id
|
||||||
row.operator("bim.remove_work_calendar", text="", icon="X").work_calendar = item.ifc_definition_id
|
row.operator("bim.remove_work_calendar", text="", icon="X").work_calendar = item.ifc_definition_id
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_tasks(UIList):
|
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
|
||||||
if item:
|
|
||||||
row = layout.row(align=True)
|
|
||||||
if item.identification:
|
|
||||||
layout.label(text=item.identification)
|
|
||||||
layout.label(text=item.name)
|
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {
|
self.settings = {
|
||||||
"name": None,
|
"work_schedule": None,
|
||||||
"predefined_type": "NOTDEFINED",
|
"parent_task": None,
|
||||||
"is_milestone": False,
|
|
||||||
"identification": "none",
|
|
||||||
"predecessor_to": None,
|
|
||||||
"successor_from": None,
|
|
||||||
}
|
}
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
@@ -20,8 +16,23 @@ class Usecase:
|
|||||||
"root.create_entity",
|
"root.create_entity",
|
||||||
self.file,
|
self.file,
|
||||||
ifc_class="IfcTask",
|
ifc_class="IfcTask",
|
||||||
predefined_type=self.settings["predefined_type"],
|
name= None,
|
||||||
name=self.settings["name"],
|
predefined_type= "NOTDEFINED",
|
||||||
|
identification= "none",
|
||||||
)
|
)
|
||||||
task.IsMilestone = self.settings["is_milestone"]
|
task.IsMilestone = False
|
||||||
|
if self.settings["work_schedule"]:
|
||||||
|
self.file.create_entity(
|
||||||
|
"IfcRelAssignsToControl",
|
||||||
|
**{
|
||||||
|
"GlobalId": ifcopenshell.guid.new(),
|
||||||
|
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||||
|
"RelatedObjects": [task],
|
||||||
|
"RelatingControl": self.settings["work_schedule"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
elif self.settings["parent_task"]:
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"nest.assign_object", self.file, object=task, relating_object=self.settings["parent_task"]
|
||||||
|
)
|
||||||
return task
|
return task
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class Data:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_work_calendars(cls):
|
def load_work_calendars(cls):
|
||||||
|
cls.work_calendars = {}
|
||||||
for work_calendar in cls._file.by_type("IfcWorkCalendar"):
|
for work_calendar in cls._file.by_type("IfcWorkCalendar"):
|
||||||
data = work_calendar.get_info()
|
data = work_calendar.get_info()
|
||||||
del data["OwnerHistory"]
|
del data["OwnerHistory"]
|
||||||
@@ -72,4 +73,9 @@ class Data:
|
|||||||
def load_tasks(cls):
|
def load_tasks(cls):
|
||||||
cls.tasks = {}
|
cls.tasks = {}
|
||||||
for task in cls._file.by_type("IfcTask"):
|
for task in cls._file.by_type("IfcTask"):
|
||||||
cls.tasks[task.id()] = {"Name": task.Name, "Identification": task.Identification or ""}
|
data = task.get_info()
|
||||||
|
del data["OwnerHistory"]
|
||||||
|
data["RelatedObjects"] = []
|
||||||
|
for rel in task.IsNestedBy:
|
||||||
|
[data["RelatedObjects"].append(o.id()) for o in rel.RelatedObjects if o.is_a("IfcTask")]
|
||||||
|
cls.tasks[task.id()] = data
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, **settings):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {"task": None}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
# TODO: do a deep purge
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"project.unassign_declaration",
|
||||||
|
self.file,
|
||||||
|
definition=self.settings["task"],
|
||||||
|
relating_context=self.file.by_type("IfcContext")[0],
|
||||||
|
)
|
||||||
|
self.file.remove(self.settings["task"])
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
|
|||||||
Reference in New Issue
Block a user