#RTCNA Wish 2 granted! Create view for every level for every view type

Jason gets another wish granted, this time to “Create a view for every level for every view type in your project file

public void createViewsForViewTypes()
{
    Document doc = this.ActiveUIDocument.Document;
    using (Transaction t = new Transaction(doc, "Create Views"))
    {
        t.Start();
        foreach (ViewFamilyType vft in new FilteredElementCollector(doc)
                 .OfClass(typeof(ViewFamilyType))
                 .Cast<ViewFamilyType>()
                 .Where(q => q.ViewFamily == ViewFamily.FloorPlan))
        {
            foreach (Level level in new FilteredElementCollector(doc)
                     .OfClass(typeof(Level)))
            {
                ViewPlan newview = ViewPlan.Create(doc, vft.Id, level.Id);
                newview.Name = level.Name + "-" + vft.Name;
            }
        }
        t.Commit();
    }
}
Advertisements

5 thoughts on “#RTCNA Wish 2 granted! Create view for every level for every view type

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s