# -*- coding: utf-8 -*-
# IMPORTS
# ==================================================
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
from Autodesk.Revit.UI import *
from Autodesk.Revit.DB.Structure import *
from Autodesk.Revit.DB.Structure import Rebar as rb

# VARIABLES
# ==================================================
doc   = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
app      = __revit__.Application
rvt_year = int(app.VersionNumber)

def rebar_unobscured(bool = True):
    view = doc.ActiveView
    rebars = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Rebar) \
        .WhereElementIsNotElementType() \
        .ToElements()
    # print("rebar = {}".format(rebars))
    # rebarElement = Rebar()
    t = Transaction(doc,"Rebar Visible")
    t.Start()
    for rebarElement in rebars:
        rebarElement.SetUnobscuredInView(view,bool)
        # rebarElement.SetUnobscuredInView(view,False)
        # rebarElement.SetSolidInView(view,True)
    t.Commit()
