Now define the Results section. {placeholder}
# ---- Results Sec ----

import json

# 1. Fläche aus RFEM-Ergebnissen lesen
surface_data = ResultTables.SurfacesGeometry()
total_area = SumValues(surface_data, 'surface_area')  # in m²

# 2. Dicke annehmen oder aus Modell laden
thickness = 0.30  # [m] – alternativ: hole aus Modell, falls definiert

# 3. Betonvolumen berechnen
concrete_volume = total_area * thickness  # [m³]

# 4. Bewehrungsanteil annehmen (z. B. 80 kg/m³)
reinforcement_kg_per_m3 = 80  # [kg/m³]
reinforcement_mass = concrete_volume * reinforcement_kg_per_m3  # [kg]

# 5. CO₂-Faktoren definieren
co2_per_m3_concrete = 720   # [kg CO₂ / m³]
co2_per_kg_steel = 1.8      # [kg CO₂ / kg]

# 6. CO₂ berechnen
concrete_co2 = concrete_volume * co2_per_m3_concrete
steel_co2 = reinforcement_mass * co2_per_kg_steel
total_co2 = concrete_co2 + steel_co2

# 7. Kosten (optional)
cost_concrete_per_m3 = 100     # €/m³ (z. B.)
cost_steel_per_kg = 2.5        # €/kg
total_cost = concrete_volume * cost_concrete_per_m3 + reinforcement_mass * cost_steel_per_kg

# 8. Ergebnisse anzeigen
print("Gesamtfläche:", round(total_area, 2), "m²")
print("Betonvolumen:", round(concrete_volume, 2), "m³")
print("Stahlmasse:", round(reinforcement_mass, 2), "kg")
print("Beton CO₂:", round(concrete_co2, 1), "kg")
print("Stahl CO₂:", round(steel_co2, 1), "kg")
print("Gesamt CO₂:", round(total_co2, 1), "kg")
print("Gesamtkosten:", round(total_cost, 2), "€")

# 9. Export als JSON
results_dict = {
    "fläche_m2": round(total_area, 2),
    "beton_m3": round(concrete_volume, 2),
    "stahl_kg": round(reinforcement_mass, 2),
    "co2_beton": round(concrete_co2, 1),
    "co2_stahl": round(steel_co2, 1),
    "co2_total": round(total_co2, 1),
    "kosten_total": round(total_cost, 2)
}

with open("co2_kosten_ergebnis.json", "w") as f:
    json.dump(results_dict, f, indent=2)

