--- name: ifc-quantity-takeoff description: Extract construction quantities (lengths, areas, volumes, counts) from an IFC file with IfcOpenShell and deliver a CSV plus a summary by storey, type and material. Use when the user asks for quantities, a takeoff, a bill of quantities, "cantidades de obra" or "metrados" from an IFC or BIM model. --- # IFC quantity takeoff ## Inputs - Path to one .ifc file (IFC2X3, IFC4 or IFC4X3). - Optional: the element classes to measure. Default: every IfcElement subclass that has a body representation. ## Procedure 1. Make sure ifcopenshell is installed (pip install ifcopenshell). Print ifcopenshell.version and the schema. Use the API of the installed version; if a call fails, look it up in docs.ifcopenshell.org rather than guessing. 2. Get the length unit scale with ifcopenshell.util.unit.calculate_unit_scale(model) and convert everything to m, m2, m3. 3. For each element collect: GlobalId, class, Name, type (ifcopenshell.util.element.get_type), storey (get_container, walking up to the IfcBuildingStorey), material (get_material). 4. Quantities, in order of preference: - base quantities from Qto sets: ifcopenshell.util.element.get_psets(element, qtos_only=True) -> source = "qto"; - geometry: ifcopenshell.geom.create_shape(settings, element) with world coordinates, then ifcopenshell.util.shape (get_volume, get_footprint_area, get_side_area...) -> source = "computed"; - otherwise source = "none" and record the reason. 5. Write quantities.csv (one row per element) and summary.csv grouped by storey + class + type. 6. Build the check list: elements with source "none", zero or negative values, IfcBuildingElementProxy, and probable duplicates (same type and same placement). ## Output to the user - A short summary table (top rows by quantity) in the chat. - The two CSV files and the check list. - One sentence saying what percentage of elements came from Qto sets and what percentage was computed. ## Never - Never fill a missing quantity with an average or an estimate. - Never mix units in one column. - Never modify the IFC file.