mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-07 12:56:26 +00:00
ligten up add cost schedule UI
This commit is contained in:
@@ -33,9 +33,26 @@ class AddCostSchedule(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
bl_label = "Add Cost Schedule"
|
bl_label = "Add Cost Schedule"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
bl_description = "Add a new cost schedule"
|
bl_description = "Add a new cost schedule"
|
||||||
|
name: bpy.props.StringProperty()
|
||||||
|
object_type: bpy.props.StringProperty()
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
core.add_cost_schedule(tool.Ifc, predefined_type=context.scene.BIMCostProperties.cost_schedule_predefined_types)
|
core.add_cost_schedule(
|
||||||
|
tool.Ifc,
|
||||||
|
name=self.name,
|
||||||
|
predefined_type=context.scene.BIMCostProperties.cost_schedule_predefined_types,
|
||||||
|
object_type=self.object_type,
|
||||||
|
)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.prop(self, "name", text="Name")
|
||||||
|
layout.prop(context.scene.BIMCostProperties, "cost_schedule_predefined_types", text="Type")
|
||||||
|
if context.scene.BIMCostProperties.cost_schedule_predefined_types == "USERDEFINED":
|
||||||
|
layout.prop(self, "object_type", text="Object type")
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
return context.window_manager.invoke_props_dialog(self)
|
||||||
|
|
||||||
|
|
||||||
class EditCostSchedule(bpy.types.Operator, tool.Ifc.Operator):
|
class EditCostSchedule(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
@@ -646,7 +663,9 @@ class ExportCostSchedules(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
cost_schedule = tool.Ifc.get().by_id(self.cost_schedule) if self.cost_schedule else None
|
cost_schedule = tool.Ifc.get().by_id(self.cost_schedule) if self.cost_schedule else None
|
||||||
r = core.export_cost_schedules(tool.Cost, filepath=self.filepath, format=self.format, cost_schedule=cost_schedule)
|
r = core.export_cost_schedules(
|
||||||
|
tool.Cost, filepath=self.filepath, format=self.format, cost_schedule=cost_schedule
|
||||||
|
)
|
||||||
if isinstance(r, str):
|
if isinstance(r, str):
|
||||||
self.report({"ERROR"}, r)
|
self.report({"ERROR"}, r)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -41,20 +41,19 @@ class BIM_PT_cost_schedules(Panel):
|
|||||||
CostSchedulesData.load()
|
CostSchedulesData.load()
|
||||||
|
|
||||||
self.props = context.scene.BIMCostProperties
|
self.props = context.scene.BIMCostProperties
|
||||||
row = self.layout.row()
|
row = self.layout.row(align=True)
|
||||||
if not self.props.active_cost_schedule_id:
|
if not self.props.active_cost_schedule_id:
|
||||||
if CostSchedulesData.data["total_cost_schedules"]:
|
if CostSchedulesData.data["total_cost_schedules"]:
|
||||||
row.label(text=f"{CostSchedulesData.data['total_cost_schedules']} Cost Schedules Found", icon="TEXT")
|
row.label(text=f"{CostSchedulesData.data['total_cost_schedules']} Cost Schedules Found", icon="TEXT")
|
||||||
row.operator("bim.export_cost_schedules", text="Export as spreadsheet", icon="EXPORT")
|
|
||||||
else:
|
else:
|
||||||
row.label(text="No Cost Schedules found.", icon="TEXT")
|
row.label(text="No Cost Schedules found.", icon="TEXT")
|
||||||
row = self.layout.row(align=True)
|
row.operator("bim.add_cost_schedule", icon="ADD", text="")
|
||||||
row.alignment = "RIGHT"
|
|
||||||
row.prop(self.props, "cost_schedule_predefined_types")
|
|
||||||
row.operator("bim.add_cost_schedule", icon="ADD", text="Add")
|
|
||||||
|
|
||||||
for schedule in CostSchedulesData.data["schedules"]:
|
for schedule in CostSchedulesData.data["schedules"]:
|
||||||
self.draw_cost_schedule_ui(schedule)
|
self.draw_cost_schedule_ui(schedule)
|
||||||
|
row2 = self.layout.row()
|
||||||
|
row2.alignment = "RIGHT"
|
||||||
|
row2.operator("bim.export_cost_schedules", text="Export all", icon="EXPORT")
|
||||||
|
|
||||||
def draw_cost_schedule_ui(self, cost_schedule):
|
def draw_cost_schedule_ui(self, cost_schedule):
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
@@ -665,8 +664,6 @@ class BIM_UL_cost_items_trait:
|
|||||||
op.new_index = cost_item["NestingIndex"] - 1
|
op.new_index = cost_item["NestingIndex"] - 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_cost_items(BIM_UL_cost_items_trait, UIList):
|
class BIM_UL_cost_items(BIM_UL_cost_items_trait, UIList):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.contract_operator = "bim.contract_cost_item"
|
self.contract_operator = "bim.contract_cost_item"
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ class EditResourceQuantity(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
class ImportResources(bpy.types.Operator, tool.Ifc.Operator, ImportHelper):
|
class ImportResources(bpy.types.Operator, tool.Ifc.Operator, ImportHelper):
|
||||||
bl_idname = "import_resources.bim"
|
bl_idname = "import_resources.bim"
|
||||||
bl_label = "Import P6"
|
bl_label = "Import Resources"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
filename_ext = ".csv"
|
filename_ext = ".csv"
|
||||||
filter_glob: bpy.props.StringProperty(default="*.csv", options={"HIDDEN"})
|
filter_glob: bpy.props.StringProperty(default="*.csv", options={"HIDDEN"})
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ def parse_datetime(value):
|
|||||||
def parse_duration(value):
|
def parse_duration(value):
|
||||||
return ifcopenshell.util.date.parse_duration(value)
|
return ifcopenshell.util.date.parse_duration(value)
|
||||||
|
|
||||||
|
|
||||||
def canonicalise_time(time):
|
def canonicalise_time(time):
|
||||||
if not time:
|
if not time:
|
||||||
return "-"
|
return "-"
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class BIM_PT_work_plans(Panel):
|
|||||||
row.label(text=f"{WorkPlansData.data['total_work_plans']} Work Plans Found", icon="TEXT")
|
row.label(text=f"{WorkPlansData.data['total_work_plans']} Work Plans Found", icon="TEXT")
|
||||||
else:
|
else:
|
||||||
row.label(text="No Work Plans found.", icon="TEXT")
|
row.label(text="No Work Plans found.", icon="TEXT")
|
||||||
row.operator("bim.add_work_plan", icon="ADD", text="")
|
row.operator("bim.add_work_plan", icon="", text="")
|
||||||
for work_plan in WorkPlansData.data["work_plans"]:
|
for work_plan in WorkPlansData.data["work_plans"]:
|
||||||
self.draw_work_plan_ui(work_plan)
|
self.draw_work_plan_ui(work_plan)
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ class BIM_PT_work_schedules(Panel):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
row.label(text="No Work Schedules found.", icon="TEXT")
|
row.label(text="No Work Schedules found.", icon="TEXT")
|
||||||
row.operator("bim.add_work_schedule", text="Add", icon="ADD")
|
row.operator("bim.add_work_schedule", text="", icon="ADD")
|
||||||
|
|
||||||
for work_schedule_id, work_schedule in SequenceData.data["work_schedules"].items():
|
for work_schedule_id, work_schedule in SequenceData.data["work_schedules"].items():
|
||||||
self.draw_work_schedule_ui(work_schedule_id, work_schedule)
|
self.draw_work_schedule_ui(work_schedule_id, work_schedule)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
def add_cost_schedule(ifc, predefined_type):
|
def add_cost_schedule(ifc, name, predefined_type,object_type):
|
||||||
ifc.run("cost.add_cost_schedule", predefined_type=predefined_type)
|
ifc.run("cost.add_cost_schedule", name=name, predefined_type=predefined_type, object_type=object_type)
|
||||||
|
|
||||||
|
|
||||||
def edit_cost_schedule(ifc, cost, cost_schedule):
|
def edit_cost_schedule(ifc, cost, cost_schedule):
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, name=None, predefined_type="NOTDEFINED"):
|
def __init__(self, file, name=None, predefined_type="NOTDEFINED", object_type=None):
|
||||||
"""Add a new cost schedule
|
"""Add a new cost schedule
|
||||||
|
|
||||||
A cost schedule is a group of cost items which typically represent a
|
A cost schedule is a group of cost items which typically represent a
|
||||||
@@ -54,7 +54,7 @@ class Usecase:
|
|||||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||||
"""
|
"""
|
||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {"name": name, "predefined_type": predefined_type}
|
self.settings = {"name": name, "predefined_type": predefined_type, "object_type": object_type}
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
cost_schedule = ifcopenshell.api.run(
|
cost_schedule = ifcopenshell.api.run(
|
||||||
@@ -65,4 +65,6 @@ class Usecase:
|
|||||||
name=self.settings["name"],
|
name=self.settings["name"],
|
||||||
)
|
)
|
||||||
cost_schedule.UpdateDate = ifcopenshell.util.date.datetime2ifc(datetime.now(), "IfcDateTime")
|
cost_schedule.UpdateDate = ifcopenshell.util.date.datetime2ifc(datetime.now(), "IfcDateTime")
|
||||||
|
if self.settings["object_type"]:
|
||||||
|
cost_schedule.ObjectType = self.settings["object_type"]
|
||||||
return cost_schedule
|
return cost_schedule
|
||||||
|
|||||||
Reference in New Issue
Block a user