"Cleaning data concrete footing in Model \n\n\n Updated : 01-05-2024 \n\n Shared by : TUMCIVIL"
__author__ = 'TUMCIVIL'
__version__ = '1.0.0'
__title__ = ' Cleaning Data Footing'
# for timing -------------------------------------------------------------------
import pyrevit.coreutils as cor
from pyrevit.coreutils import Timer
timer = Timer()
# ------------------------------------------------------------------------------
import sys
import csv
import codecs
import os.path as op
from collections import defaultdict

from pyrevit import PyRevitException
from pyrevit import forms
from pyrevit import coreutils
from pyrevit import revit, DB, HOST_APP
from pyrevit import script
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB.Structure import *
import re

doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument

def footing():
    foundations = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_StructuralFoundation) \
        .WhereElementIsNotElementType() \
        .ToElements()

    out = []
    for e in foundations:
        q1 = 0.0
        q2 = 0.0
        q3 = 0.0
        q4 = 0.0
        q5 = 0.0
        q6 = 0.0
        q7 = ""
        q8 = ""
        q9 = ""
        q10 = ""
        q11 = ""
        q12 = 0.0
        q13 = UnitUtils.ConvertToInternalUnits(1000.0,UnitTypeId.Millimeters)
        t = Transaction(doc, 'change parameter')
        t.Start()
        try:
            e.LookupParameter("Elevation at Top Edge").Set(q1)
            e.LookupParameter("Dig Soil from edge").Set(q2)
            e.LookupParameter("Lean Thickness").Set(q3)
            e.LookupParameter("Sand Thickness").Set(q4)
            e.LookupParameter("Offset Lean").Set(q5)
            e.LookupParameter("Offset Sand").Set(q6)
            e.LookupParameter("Location").Set(q7)
            e.LookupParameter("Name Footing").Set(q8)
            e.LookupParameter("Name Pile").Set(q9)
            e.LookupParameter("Size").Set(q10)
            e.LookupParameter("Strength Concrete").Set(q11)
            e.LookupParameter("Pile Cutoff").Set(q12)
            e.LookupParameter("Pile Length").Set(q13)


        except:
            # TaskDialog.Show('error', 'error message')
            pass
        t.Commit()

if __name__ == "__main__":
    footing()

# for timing -------------------------------------------------------------------
print("====" * 20)
print("CLEANING DATA FOOTING COMPLETELY !")
endtime = timer.get_time()
print("Time been used = {} sec.".format(endtime))
currentDate = cor.current_date()
currentTime = cor.current_time()
print ("Date : {} ; {}".format(currentDate,currentTime))
print ("Credited by : {}".format(__author__))
print("====" * 20)
# ------------------------------------------------------------------------------