Thursday, April 02, 2015

Convert View Names on Sheets to UPPERCASE

Here is a quick little Revit Macro that will change all the View names on Sheets to UPPERCASE. This helps when browsing through the Project Browser to identify which views are placed on Sheets. It is one directional at the moment, so if a view that is already UPPERCASE is not on a sheet anymore it won't change it back to lowercase. If I add this in the future I will post an update then.


public void SheetViewNamesToUppercase()
{
    Document doc =  this.ActiveUIDocument.Document;
   
    using(Transaction t = new Transaction(doc, "Sheet View Names to Uppercase"))
    {
        t.Start();
       
        foreach(ViewSheet vs in new FilteredElementCollector(doc).OfClass(typeof(ViewSheet)))
        {
            foreach(ElementId eid in vs.GetAllPlacedViews())
            {
                try
                {
                    View v = doc.GetElement(eid) as View;
                    v.Name = v.Name.ToUpper();
                }
                catch
                {                           
                }
               
            }
        }
       
        foreach (ViewSchedule vsc in new FilteredElementCollector(doc).OfClass(typeof(ViewSchedule)))
        {
            foreach (ScheduleSheetInstance ssi in new FilteredElementCollector(doc).OfClass(typeof(ScheduleSheetInstance)))
            {
                if (vsc.Name == ssi.Name)
                {
                    try
                    {
                        vsc.Name = vsc.Name.ToUpper();
                    }
                    catch
                    {                               
                    }
                   
                }
            }
        }

        t.Commit();
    }
}

3 comments:

  1. Nice work Troy. It was great to see this in action at LA RUG last night!

    ReplyDelete
  2. Nice work Troy. It was great to see this Add in at the LARUG last night. Thanks for sharing!

    ReplyDelete
  3. Troy,

    Thanks for sharing.

    Regards

    ReplyDelete