One of the things that I do before sharing our Revit model with consultants is to clean it up from as many unnecessary views as possible. That considerably reduces the size of the model and it is usually considered a good practice to do so. The truth is that often you can leave just a single view in the project because all that maters is the geometry. However when sharing model while in DDs and CDs I normally leave only the production sheets and only the views that are placed on the sheets. Now, you can go over those and delete them manually and if you have tons of views of all kinds that might take a while or you could write a very short Python script for that particular purpose. So, below is the scrip that I use to remove all the views from the project that are not on the sheets. Enjoy Python Shell and Revit API…
PS (I also remove views by attributes with this script and if you look at the commented lines you will see what I am talking about, but as is for the purpose of simplicity the Python script below gets rid of all views that are not on sheets)
Warning! Make sure you don’t run this script on your central model – detach it from central first. Because once the views are gone – they are GONE! Don’t tell me that I didn’t warn you – use it at your own risk.
import clr import math clr.AddReference('RevitAPI') clr.AddReference('RevitAPIUI') from Autodesk.Revit.DB import *app = __revit__.Application doc = __revit__.ActiveUIDocument.Document uidoc = __revit__.ActiveUIDocument collector1 = FilteredElementCollector(doc) collector1.OfCategory(BuiltInCategory.OST_Views) elSet1 = collector1.ToElements() par1 = 'Sheet Number' #par2 = 'Production/Working' viewSet = list()for el in elSet1: if el.CanBePrinted: if el.get_Parameter(par1)==None: #if el.get_Parameter(par1)!=startswith('A'): viewSet.append(el) print 'Working Views Deleted:' print len(viewSet) t = Transaction(doc, 'Delete Views') t.Start() for el in viewSet: doc.Delete(el) t.Commit()