"Check none nameTags steel columns in Model \n\n\n Updated : 01-05-2024 \n\n Shared by : TUMCIVIL"
__author__ = 'TUMCIVIL'
__version__ = '1.0.0'
__title__ = ' Check none nameTags steel columns'
# for timing -------------------------------------------------------------------
import pyrevit.coreutils as cor
from pyrevit.coreutils import Timer
timer = Timer()
# ------------------------------------------------------------------------------
import sys
import re
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB.Structure import *
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument


def checkParameter(parameter):
    storageType = parameter.StorageType
    if (storageType.ToString() == "ElementId"):
        value = parameter.AsValueString()
    return value




if __name__ == '__main__':
    columns = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_StructuralColumns) \
        .WhereElementIsNotElementType() \
        .ToElements()

    if len(columns)!= 0:
        out = []
        rows = 0
        familyType = []
        for e in columns:
            p = []
            strType = e.StructuralMaterialType
            if strType == StructuralMaterialType.Steel:
                id = e.Id
                name1 = e.Name
                for j in e.Parameters:
                        if j.IsShared and j.Definition.Name == "Name Tags":
                            nameTags = e.get_Parameter(j.GUID).AsString()

                # family2 = e.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)
                # value2 = checkParameter(family2)
                # nameColumn = e.LookupParameter("Name Column").AsString()
                # size = e.LookupParameter("Size").AsString()
                # location = e.LookupParameter("Location").AsString()
                # strengthCon = e.LookupParameter("Strength Concrete").AsString()
                # group = e.LookupParameter("Group").AsString()
                # fireproofingName = e.LookupParameter("3-HR Fireproofing Name").AsString()

                p.append(id)  # Id 0
                p.append(name1)  # Name 1
                p.append(nameTags)  # nameTags 2
                # p.append(nameColumn)  # Name Column 2
                # p.append(size)  # size 3
                # p.append(location)  # Location 4
                # p.append(strengthCon)  # Stength Concrete 5
                # p.append(group)  # group Column 6
                # p.append(fireproofingName)  # Name fireproofing 7

                out.append(p)

            
        # print("out= {}".format(out))
        if len(out)!= 0:
            print("2   :  SUPER-STRUCTURE WORKS")
            print("====" * 20)

            # k = [v for v in out if (v[2] == None or v[3] == None or v[4] == None or v[5] == None or v[6] == None) and bool(re.match("Pile",v[1])) == False]
            k = [v for v in out if (v[2] == None or v[2] == "")]
            nk = len(k)
            print("Reports Warning!")
            print("STRUCTURAL STEEL COLUMNS :")
            print("None nameTags = {} items".format(nk))
            if nk != 0:
                for i in k:
                    print("Id = {}".format(i[0]))
                print("Remark : this results excluded none nameTags Concrete Structural Column")
            else:
                print("Completed; Good job!")
                print("Remark : this results excluded none nameTags Concrete Structural Column")
            # sys.exit()
        else:
            print ("***None STRUCTURAL STEEL COLUMNS in Model***")
    else:
        print ("***None STRUCTURAL STEEL COLUMNS in Model***")


# for timing -------------------------------------------------------------------
print("====" * 20)
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)
# ------------------------------------------------------------------------------