mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
New assign / unassign declaration usecase, minor code & formatting cleanup
This commit is contained in:
@@ -16,11 +16,12 @@ class LoadWorkPlans(bpy.types.Operator):
|
|||||||
for ifc_definition_id, work_plan in Data.work_plans.items():
|
for ifc_definition_id, work_plan in Data.work_plans.items():
|
||||||
new = props.work_plans.add()
|
new = props.work_plans.add()
|
||||||
new.ifc_definition_id = ifc_definition_id
|
new.ifc_definition_id = ifc_definition_id
|
||||||
new.name = work_plan["Name"] or "Unnamed"
|
new.name = work_plan["Name"] or "Unnamed"
|
||||||
props.is_editing = True
|
props.is_editing = True
|
||||||
bpy.ops.bim.disable_editing_work_plan()
|
bpy.ops.bim.disable_editing_work_plan()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class DisableWorkPlanEditingUI(bpy.types.Operator):
|
class DisableWorkPlanEditingUI(bpy.types.Operator):
|
||||||
bl_idname = "bim.disable_work_plan_editing_ui"
|
bl_idname = "bim.disable_work_plan_editing_ui"
|
||||||
bl_label = "Disable WorkPlan Editing UI"
|
bl_label = "Disable WorkPlan Editing UI"
|
||||||
@@ -58,25 +59,28 @@ class EditWorkPlan(bpy.types.Operator):
|
|||||||
attributes[attribute.name] = attribute.enum_value
|
attributes[attribute.name] = attribute.enum_value
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"sequence.edit_work_plan", self.file, **{"work_plan": self.file.by_id(props.active_work_plan_id), "attributes": attributes}
|
"sequence.edit_work_plan",
|
||||||
|
self.file,
|
||||||
|
**{"work_plan": self.file.by_id(props.active_work_plan_id), "attributes": attributes}
|
||||||
)
|
)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
bpy.ops.bim.load_work_plans()
|
bpy.ops.bim.load_work_plans()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class RemoveWorkPlan(bpy.types.Operator):
|
class RemoveWorkPlan(bpy.types.Operator):
|
||||||
bl_idname = "bim.remove_work_plan"
|
bl_idname = "bim.remove_work_plan"
|
||||||
bl_label = "Remove Work Plan"
|
bl_label = "Remove Work Plan"
|
||||||
work_plan: bpy.props.IntProperty()
|
work_plan: bpy.props.IntProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
props = context.scene.BIMWorkPlanProperties
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
ifcopenshell.api.run("sequence.remove_work_plan", self.file, **{"work_plan": self.file.by_id(self.work_plan)})
|
ifcopenshell.api.run("sequence.remove_work_plan", self.file, **{"work_plan": self.file.by_id(self.work_plan)})
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
bpy.ops.bim.load_work_plans()
|
bpy.ops.bim.load_work_plans()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class EnableEditingWorkPlan(bpy.types.Operator):
|
class EnableEditingWorkPlan(bpy.types.Operator):
|
||||||
bl_idname = "bim.enable_editing_work_plan"
|
bl_idname = "bim.enable_editing_work_plan"
|
||||||
bl_label = "Enable Editing Work Plan"
|
bl_label = "Enable Editing Work Plan"
|
||||||
@@ -98,7 +102,9 @@ class EnableEditingWorkPlan(bpy.types.Operator):
|
|||||||
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()
|
||||||
new.data_type = data_type
|
new.data_type = data_type
|
||||||
if data_type == "string":
|
if attribute.name() in ["CreationDate", "StartTime", "FinishTime"]:
|
||||||
|
new.string_value = "" if new.is_null else data[attribute.name()].isoformat()
|
||||||
|
elif data_type == "string":
|
||||||
new.string_value = "" if new.is_null else data[attribute.name()]
|
new.string_value = "" if new.is_null else data[attribute.name()]
|
||||||
elif data_type == "enum":
|
elif data_type == "enum":
|
||||||
new.enum_items = json.dumps(ifcopenshell.util.attribute.get_enum_items(attribute))
|
new.enum_items = json.dumps(ifcopenshell.util.attribute.get_enum_items(attribute))
|
||||||
@@ -107,6 +113,7 @@ class EnableEditingWorkPlan(bpy.types.Operator):
|
|||||||
props.active_work_plan_id = self.work_plan
|
props.active_work_plan_id = self.work_plan
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class DisableEditingWorkPlan(bpy.types.Operator):
|
class DisableEditingWorkPlan(bpy.types.Operator):
|
||||||
bl_idname = "bim.disable_editing_work_plan"
|
bl_idname = "bim.disable_editing_work_plan"
|
||||||
bl_label = "Disable Editing Work Plan"
|
bl_label = "Disable Editing Work Plan"
|
||||||
@@ -115,6 +122,7 @@ class DisableEditingWorkPlan(bpy.types.Operator):
|
|||||||
context.scene.BIMWorkPlanProperties.active_work_plan_id = 0
|
context.scene.BIMWorkPlanProperties.active_work_plan_id = 0
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class LoadWorkSchedules(bpy.types.Operator):
|
class LoadWorkSchedules(bpy.types.Operator):
|
||||||
bl_idname = "bim.load_work_schedules"
|
bl_idname = "bim.load_work_schedules"
|
||||||
bl_label = "Load Work Schedules"
|
bl_label = "Load Work Schedules"
|
||||||
@@ -125,12 +133,13 @@ class LoadWorkSchedules(bpy.types.Operator):
|
|||||||
props.work_schedules.remove(0)
|
props.work_schedules.remove(0)
|
||||||
for ifc_definition_id, work_schedule in Data.work_schedules.items():
|
for ifc_definition_id, work_schedule in Data.work_schedules.items():
|
||||||
new = props.work_schedules.add()
|
new = props.work_schedules.add()
|
||||||
new.ifc_definition_id = ifc_definition_id or "Unnamed"
|
new.ifc_definition_id = ifc_definition_id
|
||||||
new.name = work_schedule["Name"]
|
new.name = work_schedule["Name"] or "Unnamed"
|
||||||
props.is_editing = True
|
props.is_editing = True
|
||||||
bpy.ops.bim.disable_editing_work_schedule()
|
bpy.ops.bim.disable_editing_work_schedule()
|
||||||
return {"FINISHED"}
|
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"
|
||||||
@@ -145,7 +154,7 @@ class AddWorkSchedule(bpy.types.Operator):
|
|||||||
bl_label = "Add Work Schedule"
|
bl_label = "Add Work Schedule"
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
result = 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()
|
bpy.ops.bim.load_work_schedules()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -167,27 +176,31 @@ class EditWorkSchedule(bpy.types.Operator):
|
|||||||
elif attribute.data_type == "enum":
|
elif attribute.data_type == "enum":
|
||||||
attributes[attribute.name] = attribute.enum_value
|
attributes[attribute.name] = attribute.enum_value
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
ifcopenshell.api.run("sequence.edit_work_schedule", self.file, **{
|
ifcopenshell.api.run(
|
||||||
"work_schedule": self.file.by_id(props.active_work_schedule_id),
|
"sequence.edit_work_schedule",
|
||||||
"attributes": attributes
|
self.file,
|
||||||
})
|
**{"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.load_work_schedules()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class RemoveWorkSchedule(bpy.types.Operator):
|
class RemoveWorkSchedule(bpy.types.Operator):
|
||||||
bl_idname = "bim.remove_work_schedule"
|
bl_idname = "bim.remove_work_schedule"
|
||||||
bl_label = "Remove Work Schedule"
|
bl_label = "Remove Work Schedule"
|
||||||
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()
|
||||||
ifcopenshell.api.run("sequence.remove_work_schedule", self.file, **{"work_schedule": self.file.by_id(self.work_schedule)})
|
ifcopenshell.api.run(
|
||||||
Data.load(IfcStore.get_file())
|
"sequence.remove_work_schedule", self.file, **{"work_schedule": self.file.by_id(self.work_schedule)}
|
||||||
|
)
|
||||||
|
Data.load(self.file)
|
||||||
bpy.ops.bim.load_work_schedules()
|
bpy.ops.bim.load_work_schedules()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class EnableEditingWorkSchedule(bpy.types.Operator):
|
class EnableEditingWorkSchedule(bpy.types.Operator):
|
||||||
bl_idname = "bim.enable_editing_work_schedule"
|
bl_idname = "bim.enable_editing_work_schedule"
|
||||||
bl_label = "Enable Editing Work Schedule"
|
bl_label = "Enable Editing Work Schedule"
|
||||||
@@ -209,7 +222,9 @@ class EnableEditingWorkSchedule(bpy.types.Operator):
|
|||||||
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()
|
||||||
new.data_type = data_type
|
new.data_type = data_type
|
||||||
if data_type == "string":
|
if attribute.name() in ["CreationDate", "StartTime", "FinishTime"]:
|
||||||
|
new.string_value = "" if new.is_null else data[attribute.name()].isoformat()
|
||||||
|
elif data_type == "string":
|
||||||
new.string_value = "" if new.is_null else data[attribute.name()]
|
new.string_value = "" if new.is_null else data[attribute.name()]
|
||||||
elif data_type == "enum":
|
elif data_type == "enum":
|
||||||
new.enum_items = json.dumps(ifcopenshell.util.attribute.get_enum_items(attribute))
|
new.enum_items = json.dumps(ifcopenshell.util.attribute.get_enum_items(attribute))
|
||||||
@@ -238,12 +253,13 @@ class LoadWorkCalendars(bpy.types.Operator):
|
|||||||
props.work_calendars.remove(0)
|
props.work_calendars.remove(0)
|
||||||
for ifc_definition_id, work_calendar in Data.work_calendars.items():
|
for ifc_definition_id, work_calendar in Data.work_calendars.items():
|
||||||
new = props.work_calendars.add()
|
new = props.work_calendars.add()
|
||||||
new.ifc_definition_id = ifc_definition_id or "Unnamed"
|
new.ifc_definition_id = ifc_definition_id
|
||||||
new.name = work_calendar["Name"]
|
new.name = work_calendar["Name"] or "Unnamed"
|
||||||
props.is_editing = True
|
props.is_editing = True
|
||||||
bpy.ops.bim.disable_editing_work_calendar()
|
bpy.ops.bim.disable_editing_work_calendar()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class DisableWorkCalendarEditingUI(bpy.types.Operator):
|
class DisableWorkCalendarEditingUI(bpy.types.Operator):
|
||||||
bl_idname = "bim.disable_work_calendar_editing_ui"
|
bl_idname = "bim.disable_work_calendar_editing_ui"
|
||||||
bl_label = "Disable WorkCalendar Editing UI"
|
bl_label = "Disable WorkCalendar Editing UI"
|
||||||
@@ -258,7 +274,7 @@ class AddWorkCalendar(bpy.types.Operator):
|
|||||||
bl_label = "Add Work Calendar"
|
bl_label = "Add Work Calendar"
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
result = ifcopenshell.api.run("sequence.add_work_calendar", IfcStore.get_file())
|
ifcopenshell.api.run("sequence.add_work_calendar", IfcStore.get_file())
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
bpy.ops.bim.load_work_calendars()
|
bpy.ops.bim.load_work_calendars()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -280,27 +296,31 @@ class EditWorkCalendar(bpy.types.Operator):
|
|||||||
elif attribute.data_type == "enum":
|
elif attribute.data_type == "enum":
|
||||||
attributes[attribute.name] = attribute.enum_value
|
attributes[attribute.name] = attribute.enum_value
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
ifcopenshell.api.run("sequence.edit_work_calendar", self.file, **{
|
ifcopenshell.api.run(
|
||||||
"work_calendar": self.file.by_id(props.active_work_calendar_id),
|
"sequence.edit_work_calendar",
|
||||||
"attributes": attributes
|
self.file,
|
||||||
})
|
**{"work_calendar": self.file.by_id(props.active_work_calendar_id), "attributes": attributes}
|
||||||
|
)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
bpy.ops.bim.load_work_calendars()
|
bpy.ops.bim.load_work_calendars()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class RemoveWorkCalendar(bpy.types.Operator):
|
class RemoveWorkCalendar(bpy.types.Operator):
|
||||||
bl_idname = "bim.remove_work_calendar"
|
bl_idname = "bim.remove_work_calendar"
|
||||||
bl_label = "Remove Work Plan"
|
bl_label = "Remove Work Plan"
|
||||||
work_calendar: bpy.props.IntProperty()
|
work_calendar: bpy.props.IntProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
props = context.scene.BIMWorkCalendarProperties
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
ifcopenshell.api.run("sequence.remove_work_calendar", self.file, **{"work_calendar": self.file.by_id(self.work_calendar)})
|
ifcopenshell.api.run(
|
||||||
Data.load(IfcStore.get_file())
|
"sequence.remove_work_calendar", self.file, **{"work_calendar": self.file.by_id(self.work_calendar)}
|
||||||
|
)
|
||||||
|
Data.load(self.file)
|
||||||
bpy.ops.bim.load_work_calendars()
|
bpy.ops.bim.load_work_calendars()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class EnableEditingWorkCalendar(bpy.types.Operator):
|
class EnableEditingWorkCalendar(bpy.types.Operator):
|
||||||
bl_idname = "bim.enable_editing_work_calendar"
|
bl_idname = "bim.enable_editing_work_calendar"
|
||||||
bl_label = "Enable Editing Work Plan"
|
bl_label = "Enable Editing Work Plan"
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ class BIM_PT_work_plans(Panel):
|
|||||||
def draw_editable_ui(self, context):
|
def draw_editable_ui(self, context):
|
||||||
for attribute in self.props.work_plan_attributes:
|
for attribute in self.props.work_plan_attributes:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(attribute, "string_value", text=attribute.name)
|
if attribute.data_type == "string":
|
||||||
|
row.prop(attribute, "string_value", text=attribute.name)
|
||||||
|
elif attribute.data_type == "enum":
|
||||||
|
row.prop(attribute, "enum_value", text=attribute.name)
|
||||||
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="")
|
||||||
|
|
||||||
@@ -104,10 +107,14 @@ class BIM_PT_work_schedules(Panel):
|
|||||||
def draw_editable_ui(self, context):
|
def draw_editable_ui(self, context):
|
||||||
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)
|
||||||
row.prop(attribute, "string_value", text=attribute.name)
|
if attribute.data_type == "string":
|
||||||
|
row.prop(attribute, "string_value", text=attribute.name)
|
||||||
|
elif attribute.data_type == "enum":
|
||||||
|
row.prop(attribute, "enum_value", text=attribute.name)
|
||||||
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="")
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_work_schedules(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:
|
||||||
@@ -123,6 +130,7 @@ class BIM_UL_work_schedules(UIList):
|
|||||||
op.work_schedule = item.ifc_definition_id
|
op.work_schedule = item.ifc_definition_id
|
||||||
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = item.ifc_definition_id
|
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = item.ifc_definition_id
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_work_calendars(Panel):
|
class BIM_PT_work_calendars(Panel):
|
||||||
bl_label = "IFC Work Calendars"
|
bl_label = "IFC Work Calendars"
|
||||||
bl_idname = "BIM_PT_work_calendars"
|
bl_idname = "BIM_PT_work_calendars"
|
||||||
@@ -163,10 +171,14 @@ class BIM_PT_work_calendars(Panel):
|
|||||||
def draw_editable_ui(self, context):
|
def draw_editable_ui(self, context):
|
||||||
for attribute in self.props.work_calendar_attributes:
|
for attribute in self.props.work_calendar_attributes:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(attribute, "string_value", text=attribute.name)
|
if attribute.data_type == "string":
|
||||||
|
row.prop(attribute, "string_value", text=attribute.name)
|
||||||
|
elif attribute.data_type == "enum":
|
||||||
|
row.prop(attribute, "enum_value", text=attribute.name)
|
||||||
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="")
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_work_calendars(UIList):
|
class BIM_UL_work_calendars(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:
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ class Usecase:
|
|||||||
self.file.remove(decomposes)
|
self.file.remove(decomposes)
|
||||||
|
|
||||||
if is_decomposed_by:
|
if is_decomposed_by:
|
||||||
related_objects = list(is_decomposed_by.RelatedObjects)
|
related_objects = set(is_decomposed_by.RelatedObjects)
|
||||||
related_objects.append(self.settings["product"])
|
related_objects.add(self.settings["product"])
|
||||||
is_decomposed_by.RelatedObjects = related_objects
|
is_decomposed_by.RelatedObjects = list(related_objects)
|
||||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": is_decomposed_by})
|
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": is_decomposed_by})
|
||||||
else:
|
else:
|
||||||
is_decomposed_by = self.file.create_entity(
|
is_decomposed_by = self.file.create_entity(
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import ifcopenshell
|
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, **settings):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {
|
||||||
|
"definition": None,
|
||||||
|
"relating_context": None,
|
||||||
|
}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
declares = None
|
||||||
|
if self.settings["relating_context"].Declares:
|
||||||
|
declares = self.settings["relating_context"].Declares[0]
|
||||||
|
|
||||||
|
has_context = None
|
||||||
|
if self.settings["definition"].HasContext:
|
||||||
|
has_context = self.settings["definition"].HasContext[0]
|
||||||
|
|
||||||
|
if has_context and has_context == declares:
|
||||||
|
return
|
||||||
|
|
||||||
|
if has_context:
|
||||||
|
related_definitions = list(has_context.RelatedDefinitions)
|
||||||
|
related_definitions.remove(self.settings["definition"])
|
||||||
|
if related_definitions:
|
||||||
|
has_context.RelatedDefinitions = related_definitions
|
||||||
|
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": has_context})
|
||||||
|
else:
|
||||||
|
self.file.remove(has_context)
|
||||||
|
|
||||||
|
if declares:
|
||||||
|
related_definitions = set(declares.RelatedDefinitions)
|
||||||
|
related_definitions.add(self.settings["definition"])
|
||||||
|
declares.RelatedDefinitions = list(related_definitions)
|
||||||
|
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": declares})
|
||||||
|
else:
|
||||||
|
declares = self.file.create_entity(
|
||||||
|
"IfcRelDeclares",
|
||||||
|
**{
|
||||||
|
"GlobalId": ifcopenshell.guid.new(),
|
||||||
|
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||||
|
"RelatedDefinitions": [self.settings["definition"]],
|
||||||
|
"RelatingContext": self.settings["relating_context"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return declares
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, **settings):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {
|
||||||
|
"definition": None,
|
||||||
|
"relating_context": None,
|
||||||
|
}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
if not self.settings["definition"].HasContext:
|
||||||
|
return
|
||||||
|
rel = self.settings["definition"].HasContext[0]
|
||||||
|
related_definitions = set(rel.RelatedDefinitions) or set()
|
||||||
|
related_definitions.remove(self.settings["definition"])
|
||||||
|
if len(related_definitions):
|
||||||
|
rel.RelatedDefinitions = list(related_definitions)
|
||||||
|
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||||
|
else:
|
||||||
|
self.file.remove(rel)
|
||||||
@@ -27,7 +27,7 @@ class Usecase:
|
|||||||
pset = self.file.create_entity(
|
pset = self.file.create_entity(
|
||||||
"IfcPropertySet", **{"GlobalId": ifcopenshell.guid.new(), "Name": self.settings["Name"]}
|
"IfcPropertySet", **{"GlobalId": ifcopenshell.guid.new(), "Name": self.settings["Name"]}
|
||||||
)
|
)
|
||||||
has_property_sets = list(self.settings["product"].HasPropertySets)
|
has_property_sets = list(self.settings["product"].HasPropertySets or [])
|
||||||
has_property_sets.append(pset)
|
has_property_sets.append(pset)
|
||||||
self.settings["product"].HasPropertySets = has_property_sets
|
self.settings["product"].HasPropertySets = has_property_sets
|
||||||
elif self.settings["product"].is_a("IfcMaterialDefinition"):
|
elif self.settings["product"].is_a("IfcMaterialDefinition"):
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.util.date
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
|
|
||||||
|
|
||||||
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": "Unnamed", "predefined_type": "NOTDEFINED", "working_times": [], "exception_times": []}
|
||||||
"name": "Unnamed",
|
|
||||||
"predefined_type": "NOTDEFINED",
|
|
||||||
"working_times":[],
|
|
||||||
"exception_times":[]
|
|
||||||
}
|
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
@@ -23,26 +16,8 @@ class Usecase:
|
|||||||
predefined_type=self.settings["predefined_type"],
|
predefined_type=self.settings["predefined_type"],
|
||||||
name=self.settings["name"],
|
name=self.settings["name"],
|
||||||
)
|
)
|
||||||
working_time = self.file.create_entity("IfcWorkTime", **{"Name":"DefaultWorkingTime"})
|
|
||||||
self.settings["working_times"].append(working_time)
|
|
||||||
work_calendar.WorkingTimes = self.settings["working_times"]
|
|
||||||
|
|
||||||
exception_time = self.file.create_entity("IfcWorkTime", **{"Name":"DefaultExceptionTime"})
|
|
||||||
self.settings["exception_times"].append(exception_time)
|
|
||||||
work_calendar.ExceptionTimes = self.settings["exception_times"]
|
|
||||||
|
|
||||||
context = self.file.by_type("IfcContext")[0]
|
context = self.file.by_type("IfcContext")[0]
|
||||||
if context.Declares:
|
ifcopenshell.api.run(
|
||||||
rel_declares = context.Declares[0]
|
"project.assign_declaration", self.file, definition=work_calendar, relating_context=context
|
||||||
ifcopenshell.api.run("owner.update_owner_history", self.file, element=rel_declares)
|
)
|
||||||
else:
|
|
||||||
rel_declares = self.file.create_entity("IfcRelDeclares", **{
|
|
||||||
"GlobalId": ifcopenshell.guid.new(),
|
|
||||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
|
||||||
"RelatingContext": context
|
|
||||||
})
|
|
||||||
related_definitions = list(rel_declares.RelatedDefinitions or [])
|
|
||||||
related_definitions.append(work_calendar)
|
|
||||||
rel_declares.RelatedDefinitions = related_definitions
|
|
||||||
|
|
||||||
return work_calendar
|
return work_calendar
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import ifcopenshell
|
|
||||||
import ifcopenshell.api
|
|
||||||
import ifcopenshell.util.date
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
|
||||||
def __init__(self, file, **settings):
|
|
||||||
self.file = file
|
|
||||||
self.settings = {
|
|
||||||
"object": None,
|
|
||||||
"name":None,
|
|
||||||
"recurrence_pattern": None,
|
|
||||||
"start": datetime.now(),
|
|
||||||
"finish": datetime.now() + timedelta(days=365)
|
|
||||||
}
|
|
||||||
for key, value in settings.items():
|
|
||||||
self.settings[key] = value
|
|
||||||
|
|
||||||
def execute(self):
|
|
||||||
working_time = self.file.create_entity("IfcWorkTime", **{
|
|
||||||
"Name": self.settings["name"],
|
|
||||||
"Start": ifcopenshell.util.date.datetime2ifc(self.settings["start"], "IfcTime"),
|
|
||||||
"Finish": ifcopenshell.util.date.datetime2ifc(self.settings["finish"], "IfcTime")
|
|
||||||
})
|
|
||||||
|
|
||||||
#TODO Implement user settings for recurrence pattern
|
|
||||||
working_time.RecurrencePattern = ifcopenshell.api.run("time.add_recurrence_pattern", self.file)
|
|
||||||
|
|
||||||
if self.settings["object"].is_a('IfcWorkCalendar'):
|
|
||||||
if self.settings["object"].WorkingTimes:
|
|
||||||
working_times = list(self.settings["object"].WorkingTimes)
|
|
||||||
working_times.append(working_time)
|
|
||||||
self.settings["object"].WorkingTimes = working_times
|
|
||||||
else:
|
|
||||||
self.settings["object"].WorkingTimes = [working_time]
|
|
||||||
return working_time
|
|
||||||
@@ -25,18 +25,7 @@ class Usecase:
|
|||||||
work_plan.StartTime = ifcopenshell.util.date.datetime2ifc(self.settings["start_time"], "IfcDateTime")
|
work_plan.StartTime = ifcopenshell.util.date.datetime2ifc(self.settings["start_time"], "IfcDateTime")
|
||||||
|
|
||||||
context = self.file.by_type("IfcContext")[0]
|
context = self.file.by_type("IfcContext")[0]
|
||||||
if context.Declares:
|
ifcopenshell.api.run(
|
||||||
rel_declares = context.Declares[0]
|
"project.assign_declaration", self.file, definition=work_plan, relating_context=context
|
||||||
ifcopenshell.api.run("owner.update_owner_history", self.file, element=rel_declares)
|
)
|
||||||
else:
|
|
||||||
rel_declares = self.file.create_entity("IfcRelDeclares", **{
|
|
||||||
"GlobalId": ifcopenshell.guid.new(),
|
|
||||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
|
||||||
"RelatingContext": context
|
|
||||||
})
|
|
||||||
|
|
||||||
related_definitions = list(rel_declares.RelatedDefinitions or [])
|
|
||||||
related_definitions.append(work_plan)
|
|
||||||
rel_declares.RelatedDefinitions = related_definitions
|
|
||||||
|
|
||||||
return work_plan
|
return work_plan
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ from datetime import datetime
|
|||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {"name": "Unnamed", "predefined_type": "NOTDEFINED", "start_time": datetime.now(), "work_plan":None}
|
self.settings = {
|
||||||
|
"name": "Unnamed",
|
||||||
|
"predefined_type": "NOTDEFINED",
|
||||||
|
"start_time": datetime.now(),
|
||||||
|
"work_plan": None,
|
||||||
|
}
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
@@ -25,23 +30,16 @@ class Usecase:
|
|||||||
work_schedule.StartTime = ifcopenshell.util.date.datetime2ifc(self.settings["start_time"], "IfcDateTime")
|
work_schedule.StartTime = ifcopenshell.util.date.datetime2ifc(self.settings["start_time"], "IfcDateTime")
|
||||||
|
|
||||||
if self.settings["work_plan"]:
|
if self.settings["work_plan"]:
|
||||||
rel_aggregates = ifcopenshell.api.run("aggregate.assign_object", self.file, **{
|
ifcopenshell.api.run(
|
||||||
"product": work_schedule,
|
"aggregate.assign_object",
|
||||||
"relating_object": self.settings["work_plan"]
|
self.file,
|
||||||
})
|
**{"product": work_schedule, "relating_object": self.settings["work_plan"]}
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
|
# TODO: this is an ambiguity by buildingSMART
|
||||||
|
# See https://forums.buildingsmart.org/t/is-the-ifcworkschedule-project-declaration-mutually-exclusive-to-aggregation-within-a-relating-ifcworkplan/3510
|
||||||
context = self.file.by_type("IfcContext")[0]
|
context = self.file.by_type("IfcContext")[0]
|
||||||
if context.Declares:
|
ifcopenshell.api.run(
|
||||||
rel_declares = context.Declares[0]
|
"project.assign_declaration", self.file, definition=work_schedule, relating_context=context
|
||||||
ifcopenshell.api.run("owner.update_owner_history", self.file, element=rel_declares)
|
)
|
||||||
else:
|
|
||||||
rel_declares = self.file.create_entity("IfcRelDeclares", **{
|
|
||||||
"GlobalId": ifcopenshell.guid.new(),
|
|
||||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
|
||||||
"RelatingContext": context
|
|
||||||
})
|
|
||||||
related_definitions = list(rel_declares.RelatedDefinitions or [])
|
|
||||||
related_definitions.append(work_schedule)
|
|
||||||
rel_declares.RelatedDefinitions = related_definitions
|
|
||||||
|
|
||||||
return work_schedule
|
return work_schedule
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, **settings):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {"work_calendar": None, "type": "WorkingTimes", "name": None}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
work_time = self.file.create_entity("IfcWorkTime", **{"Name": self.settings["name"]})
|
||||||
|
if self.settings["type"] == "WorkingTimes":
|
||||||
|
working_times = list(self.settings["work_calendar"].WorkingTimes or [])
|
||||||
|
working_times.append(work_time)
|
||||||
|
self.settings["work_calendar"].WorkingTimes = working_times
|
||||||
|
elif self.settings["type"] == "ExceptionTimes":
|
||||||
|
exception_times = list(self.settings["work_calendar"].ExceptionTimes or [])
|
||||||
|
exception_times.append(work_time)
|
||||||
|
self.settings["work_calendar"].WorkingTimes = exception_times
|
||||||
|
return work_time
|
||||||
@@ -1,31 +1,26 @@
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {
|
self.settings = {"work_schedule": None, "work_plan": None}
|
||||||
"work_schedule": None,
|
|
||||||
"work_plan":None,
|
|
||||||
}
|
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
###Project declaration should be removed if the workschedule is assigned to a project.####
|
# TODO: this is an ambiguity by buildingSMART
|
||||||
if self.settings["work_schedule"].HasContext:
|
# See https://forums.buildingsmart.org/t/is-the-ifcworkschedule-project-declaration-mutually-exclusive-to-aggregation-within-a-relating-ifcworkplan/3510
|
||||||
rel_declares = self.settings["work_schedule"].HasContext[0]
|
ifcopenshell.api.run(
|
||||||
related_definitions = list(rel_declares.RelatedDefinitions)
|
"project.unassign_declaration",
|
||||||
related_definitions.remove(self.settings["work_schedule"])
|
self.file,
|
||||||
rel_declares.RelatedDefinitions = related_definitions
|
definition=self.settings["work_schedule"],
|
||||||
if self.settings["work_plan"].IsDecomposedBy:
|
relating_context=self.file.by_type("IfcContext")[0],
|
||||||
rel_aggregates = self.settings["work_plan"].IsDecomposedBy[0]
|
)
|
||||||
related_objects = list(rel_aggregates.RelatedObjects or [])
|
rel_aggregates = ifcopenshell.api.run(
|
||||||
related_objects.append(self.settings["work_schedule"])
|
"aggregate.assign_object",
|
||||||
rel_aggregates.RelatedObjects = related_objects
|
self.file,
|
||||||
else:
|
**{"product": self.settings["work_schedule"], "relating_object": self.settings["work_plan"]}
|
||||||
rel_aggregates = ifcopenshell.api.run("aggregate.assign_object", self.file, **{
|
)
|
||||||
"product": self.settings["work_schedule"],
|
|
||||||
"relating_object": self.settings["work_plan"]
|
|
||||||
})
|
|
||||||
return rel_aggregates
|
return rel_aggregates
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import ifcopenshell.util.date
|
import ifcopenshell.util.date
|
||||||
|
|
||||||
|
|
||||||
class Data:
|
class Data:
|
||||||
is_loaded = False
|
is_loaded = False
|
||||||
work_plans = {}
|
work_plans = {}
|
||||||
@@ -23,7 +24,7 @@ class Data:
|
|||||||
cls.load_work_schedules()
|
cls.load_work_schedules()
|
||||||
cls.load_work_calendars()
|
cls.load_work_calendars()
|
||||||
cls.load_tasks()
|
cls.load_tasks()
|
||||||
cls.is_loaded=True
|
cls.is_loaded = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_work_plans(cls):
|
def load_work_plans(cls):
|
||||||
@@ -33,10 +34,10 @@ class Data:
|
|||||||
del data["OwnerHistory"]
|
del data["OwnerHistory"]
|
||||||
if data["Creators"]:
|
if data["Creators"]:
|
||||||
data["Creators"] = [p.id() for p in data["Creators"]]
|
data["Creators"] = [p.id() for p in data["Creators"]]
|
||||||
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"]).isoformat()
|
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"])
|
||||||
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"]).isoformat()
|
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"])
|
||||||
if data["FinishTime"]:
|
if data["FinishTime"]:
|
||||||
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"]).isoformat()
|
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"])
|
||||||
cls.work_plans[work_plan.id()] = data
|
cls.work_plans[work_plan.id()] = data
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -47,10 +48,10 @@ class Data:
|
|||||||
del data["OwnerHistory"]
|
del data["OwnerHistory"]
|
||||||
if data["Creators"]:
|
if data["Creators"]:
|
||||||
data["Creators"] = [p.id() for p in data["Creators"]]
|
data["Creators"] = [p.id() for p in data["Creators"]]
|
||||||
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"]).isoformat()
|
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"])
|
||||||
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"]).isoformat()
|
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"])
|
||||||
if data["FinishTime"]:
|
if data["FinishTime"]:
|
||||||
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"]).isoformat()
|
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"])
|
||||||
cls.work_schedules[work_schedule.id()] = data
|
cls.work_schedules[work_schedule.id()] = data
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -58,24 +59,8 @@ class Data:
|
|||||||
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"]
|
||||||
##### HOW DO WE NEST ENTITIES SUCH AS WORKTIME? ####
|
|
||||||
##### HOW TO ALLOW DISPLAY OF TIME? AND DATES? ####
|
|
||||||
del data["WorkingTimes"]
|
del data["WorkingTimes"]
|
||||||
del data["ExceptionTimes"]
|
del data["ExceptionTimes"]
|
||||||
# if data["WorkingTimes"]:
|
|
||||||
# for worktime in data["WorkingTimes"]:
|
|
||||||
# worktime_data = {}
|
|
||||||
# if worktime.Start:
|
|
||||||
# worktime_data["start"] = ifcopenshell.util.date.ifc2datetime(worktime.Start).isoformat()
|
|
||||||
# if worktime.Start:
|
|
||||||
# worktime_data["finish"] = ifcopenshell.util.date.ifc2datetime(worktime.Start).isoformat()
|
|
||||||
# worktime = worktime_data
|
|
||||||
# if data["ExceptionTimes"]:
|
|
||||||
# for exceptiontime in data["ExceptionTimes"]:
|
|
||||||
# exceptiontime_data = {}
|
|
||||||
# exceptiontime_data["start"] = ifcopenshell.util.date.ifc2datetime(exceptiontime.Finish).isoformat()
|
|
||||||
# exceptiontime_data["finish"] = ifcopenshell.util.date.ifc2datetime(exceptiontime.Finish).isoformat()
|
|
||||||
# exceptiontime = exceptiontime_data
|
|
||||||
cls.work_calendars[work_calendar.id()] = data
|
cls.work_calendars[work_calendar.id()] = data
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import ifcopenshell.util.date
|
||||||
|
|
||||||
|
|
||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, **settings):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {"recurrence_pattern": None, "attributes": {}}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
for name, value in self.settings["attributes"].items():
|
||||||
|
if name == "TimePeriods" and value:
|
||||||
|
periods = []
|
||||||
|
for period in value:
|
||||||
|
periods.append(self.file.create_entity("IfcTimePeriod", **{
|
||||||
|
"StartTime": ifcopenshell.util.date.datetime2ifc(period[0]),
|
||||||
|
"EndTime": ifcopenshell.util.date.datetime2ifc(period[1])
|
||||||
|
}))
|
||||||
|
value = periods
|
||||||
|
setattr(self.settings["recurrence_pattern"], name, value)
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {
|
self.settings = {"work_calendar": None, "attributes": {}}
|
||||||
"work_calendar": None,
|
|
||||||
"attributes": {}
|
|
||||||
}
|
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {
|
self.settings = {"work_plan": None, "attributes": {}}
|
||||||
"work_plan": None,
|
|
||||||
"attributes": {}
|
|
||||||
}
|
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {
|
self.settings = {"work_schedule": None, "attributes": {}}
|
||||||
"work_schedule": None,
|
|
||||||
"attributes": {}
|
|
||||||
}
|
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import ifcopenshell.util.date
|
||||||
|
|
||||||
|
|
||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, **settings):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {"work_time": None, "attributes": {}}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
for name, value in self.settings["attributes"].items():
|
||||||
|
if name in ["Start", "Finish"]:
|
||||||
|
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDate")
|
||||||
|
setattr(self.settings["work_time"], name, value)
|
||||||
@@ -7,8 +7,10 @@ class Usecase:
|
|||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
# TODO: do a deep purge
|
# TODO: do a deep purge
|
||||||
if self.settings["work_calendar"].HasContext:
|
ifcopenshell.api.run(
|
||||||
rel_declares = self.settings["work_calendar"].HasContext[0]
|
"project.unassign_declaration",
|
||||||
if len(rel_declares.RelatedDefinitions) == 1:
|
self.file,
|
||||||
self.file.remove(rel_declares)
|
definition=self.settings["work_calendar"],
|
||||||
|
relating_context=self.file.by_type("IfcContext")[0],
|
||||||
|
)
|
||||||
self.file.remove(self.settings["work_calendar"])
|
self.file.remove(self.settings["work_calendar"])
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ class Usecase:
|
|||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
# TODO: do a deep purge
|
# TODO: do a deep purge
|
||||||
if self.settings["work_plan"].HasContext:
|
ifcopenshell.api.run(
|
||||||
rel_declares = self.settings["work_plan"].HasContext[0]
|
"project.unassign_declaration",
|
||||||
if len(rel_declares.RelatedDefinitions) == 1:
|
self.file,
|
||||||
self.file.remove(rel_declares)
|
definition=self.settings["work_plan"],
|
||||||
|
relating_context=self.file.by_type("IfcContext")[0],
|
||||||
|
)
|
||||||
self.file.remove(self.settings["work_plan"])
|
self.file.remove(self.settings["work_plan"])
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ class Usecase:
|
|||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
# TODO: do a deep purge
|
# TODO: do a deep purge
|
||||||
if self.settings["work_schedule"].HasContext:
|
ifcopenshell.api.run(
|
||||||
rel_declares = self.settings["work_schedule"].HasContext[0]
|
"project.unassign_declaration",
|
||||||
if len(rel_declares.RelatedDefinitions) == 1:
|
self.file,
|
||||||
self.file.remove(rel_declares)
|
definition=self.settings["work_schedule"],
|
||||||
|
relating_context=self.file.by_type("IfcContext")[0],
|
||||||
|
)
|
||||||
self.file.remove(self.settings["work_schedule"])
|
self.file.remove(self.settings["work_schedule"])
|
||||||
|
|||||||
@@ -1,21 +1,18 @@
|
|||||||
import ifcopenshell
|
|
||||||
import ifcopenshell.api
|
|
||||||
from datetime import time
|
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {"recurrence_type": 'WEEKLY'}
|
self.settings = {"parent": None, "recurrence_type": "WEEKLY"}
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
|
recurrence = self.file.createIfcRecurrencePattern(self.settings["recurrence_type"])
|
||||||
|
|
||||||
recurrence = self.file.createIfcRecurrencePattern(self.settings['recurrence_type'])
|
if self.settings["parent"].is_a("IfcWorkTime") and self.settings["parent"].RecurrencePattern:
|
||||||
#recurrence.WeekdayComponent = [self.file.createIfcDayInWeekNumber(1),self.file.createIfcDayInWeekNumber(2)]
|
if len(self.file.get_inverse(self.settings["parent"].RecurrencePattern)) == 1:
|
||||||
recurrence.TimePeriods = [
|
self.file.remove(self.settings["parent"].RecurrencePattern)
|
||||||
self.file.createIfcTimePeriod(time(8).isoformat(),time(12).isoformat()),
|
self.settings["parent"].RecurrencePattern = recurrence
|
||||||
self.file.createIfcTimePeriod(time(13).isoformat(),time(17).isoformat())
|
elif self.settings["parent"].is_a("IfcTaskTimeRecurring"):
|
||||||
]
|
if len(self.file.get_inverse(self.settings["parent"].Recurrence)) == 1:
|
||||||
return recurrence
|
self.file.remove(self.settings["parent"].Recurrence)
|
||||||
|
self.settings["parent"].Recurrence = recurrence
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ class Usecase():
|
|||||||
# TODO: handle unit rewriting, which is complicated
|
# TODO: handle unit rewriting, which is complicated
|
||||||
else:
|
else:
|
||||||
unit_assignment = self.file.createIfcUnitAssignment([u["ifc"] for u in self.settings.values()])
|
unit_assignment = self.file.createIfcUnitAssignment([u["ifc"] for u in self.settings.values()])
|
||||||
self.file.by_type("IfcProject")[0].UnitsInContext = unit_assignment
|
if self.file.schema == "IFC2X3":
|
||||||
|
self.file.by_type("IfcProject")[0].UnitsInContext = unit_assignment
|
||||||
|
else:
|
||||||
|
self.file.by_type("IfcContext")[0].UnitsInContext = unit_assignment
|
||||||
return unit_assignment
|
return unit_assignment
|
||||||
|
|
||||||
def create_metric_unit(self, unit_type, data):
|
def create_metric_unit(self, unit_type, data):
|
||||||
|
|||||||
Reference in New Issue
Block a user