MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / write

Method write

src/ifc5d/ifc5d/ifc5Dspreadsheet.py:597–687  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

595 self.options = options
596
597 def write(self) -> None:
598 import os
599 import shutil
600 import tempfile
601
602 import typst
603
604 import ifc5d
605
606 DEFAULT_OPTIONS = {
607 "nested_structure_depth": 0,
608 "parent_to_new_page_up_to_depth": 0,
609 "show_only_parents": False,
610 "should_print_cover": False,
611 "should_print_cost_ids": True,
612 "should_print_description": False,
613 "should_print_each_quantity": True,
614 "should_print_each_cost_value": False,
615 "should_print_rates": True,
616 "should_print_summary": True,
617 }
618
619 HANDLED_COST_SCHEDULE_TYPES = (
620 # Commented predefined types are not handled at the moment
621 # "BUDGET",
622 # "COSTPLAN",
623 # "ESTIMATE",
624 # "TENDER",
625 "PRICEDBILLOFQUANTITIES",
626 "UNPRICEDBILLOFQUANTITIES",
627 "SCHEDULEOFRATES",
628 # "USERDEFINED",
629 # "NOTDEFINED"
630 )
631
632 with tempfile.TemporaryDirectory() as temp_dir:
633 cost_schedule_name = self.cost_schedule.Name or "Unnamed"
634 if self.force_schedule_type in ("PRICEDBILLOFQUANTITIES", "SCHEDULEOFRATES"):
635 schedule_type = self.force_schedule_type
636 elif self.force_schedule_type is None or self.force_schedule_type == "AUTO":
637 schedule_type = self.cost_schedule.PredefinedType
638 if schedule_type not in HANDLED_COST_SCHEDULE_TYPES:
639 schedule_type = "PRICEDBILLOFQUANTITIES"
640 else:
641 raise ValueError(
642 "force_schedule_type can be set to AUTO, PRICEDBILLOFQUANTITIES, SCHEDULEOFRATES values only."
643 )
644 project_monetary_unit = self.file.by_type("IfcMonetaryUnit")
645 if project_monetary_unit:
646 project_currency = project_monetary_unit[0].Currency
647 else:
648 project_currency = ""
649
650 # export csv file
651 csv_file_writer = Ifc5DCsvWriter(file=self.file, output=temp_dir, cost_schedule=self.cost_schedule)
652 csv_file_writer.write()
653 csv_file_name = cost_schedule_name + ".csv"
654

Callers 1

Calls 10

writeMethod · 0.95
Ifc5DCsvWriterClass · 0.85
formatMethod · 0.80
lowerMethod · 0.80
openFunction · 0.50
by_typeMethod · 0.45
joinMethod · 0.45
itemsMethod · 0.45
getMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected