Various fixes to IfcCostSchedule PDF export (#6983)

* IfcCostSchedue PDF export: changed Output type from off to auto

* Fixed currency value

* Fix summary total if no nested structure present
This commit is contained in:
carlopav
2025-08-04 10:46:20 +02:00
committed by GitHub
parent 4d42512b6a
commit e00a865bce
3 changed files with 11 additions and 11 deletions
@@ -940,12 +940,12 @@ class ExportCostSchedulesToPDF(bpy.types.Operator, ExportHelper):
default=True,
)
force_schedule_type: bpy.props.EnumProperty(
name="Force output type",
description="Force the output to this type\nalso if it is not coincident with the cost schedule Predefined Type",
name="Output type",
description='Force the output to this type.\n"Auto" defaults to selected cost schedule Predefined Type',
items=[
(
"OFF",
"Off",
"AUTO",
"By PredefinedType",
"Uses Cost Schedule Predefined Type",
),
(
@@ -959,7 +959,7 @@ class ExportCostSchedulesToPDF(bpy.types.Operator, ExportHelper):
"Forces the output as a schedule of rates",
),
],
default="OFF",
default="AUTO",
)
def draw(self, context):
+4 -4
View File
@@ -626,19 +626,19 @@ class Ifc5DPdfWriter(Ifc5Dwriter):
cost_schedule_name = self.cost_schedule.Name or "Unnamed"
if self.force_schedule_type in ("PRICEDBILLOFQUANTITIES", "SCHEDULEOFRATES"):
schedule_type = self.force_schedule_type
elif self.force_schedule_type is None or self.force_schedule_type == "OFF":
elif self.force_schedule_type is None or self.force_schedule_type == "AUTO":
schedule_type = self.cost_schedule.PredefinedType
if schedule_type not in HANDLED_COST_SCHEDULE_TYPES:
schedule_type = "PRICEDBILLOFQUANTITIES"
else:
raise ValueError(
"force_schedule_type can be set to OFF, PRICEDBILLOFQUANTITIES, SCHEDULEOFRATES values only."
"force_schedule_type can be set to AUTO, PRICEDBILLOFQUANTITIES, SCHEDULEOFRATES values only."
)
project_monetary_unit = self.file.by_type("IfcMonetaryUnit")
if project_monetary_unit:
project_currency = project_monetary_unit[0].Currency
else:
project_currency = '""'
project_currency = ""
# export csv file
csv_file_writer = Ifc5DCsvWriter(file=self.file, output=temp_dir, cost_schedule=self.cost_schedule)
@@ -660,7 +660,7 @@ class Ifc5DPdfWriter(Ifc5Dwriter):
typst_main_content += ' schedule_name: "{}",\n'.format(cost_schedule_name)
typst_main_content += ' schedule_description: "{}",\n'.format(self.cost_schedule.Description or "")
typst_main_content += ' schedule_type: "{}",\n'.format(schedule_type)
typst_main_content += " project_currency: {},\n".format(project_currency)
typst_main_content += ' project_currency: "{}",\n'.format(project_currency)
for option_name, default_value in DEFAULT_OPTIONS.items():
value = self.options.get(option_name, default_value)
if isinstance(value, bool):
@@ -342,8 +342,8 @@
) = {
let data = csv(path, delimiter: delimiter, row-type: dictionary)
let new_rows = data.map(item => arrange_summary_row(item, options))
let general_total = data.filter(row => row.at("Index") == "1")
.map(row => float(row.at("TotalPrice")))
let general_total = data.filter(row => row.at("ItemIsASum") == "False")
.map(row => float(row.at("RateSubtotal", default: 0.0))*float(row.at("Quantity", default: 0.0)))
.sum(default: 0.00)
set text(size: 10pt)