Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Hi @SanjivKapila ,
try using the below link
https://thebuildingcoder.typepad.com/blog/2017/11/purge-and-detecting-an-empty-view.html#2
Hi Naveen
Thanks for your reply, but I'm not trying to detect empty views, rather I'm trying to delete unused views without harming any sheet. Any view placed on the sheet should not be deleted. The issues I'm facing are: dependent views get deleted if we delete the parent view, i'm using the CanBePlacedOnSheet method: but it deletes legends and other views which can be placed on multiple sheets..
Is there a way to collect all the views on the sheets and subtract it from the main collection of views and delete the resulting collection by applying some conditions..
Yes, you can easily achieve that.
Look at GetAllPlacedViews:
https://www.revitapidocs.com/2020/816db942-4e9c-7278-7f59-53048becc46a.htm
Create a list of all placed view by asking all sheets for their placed views.
Any view that is not contained in that list is unplaced.
Not Sure Why, but i end up deleting all the legend views even though some are placed on the sheets.
Check the ViewType property and make sure it does not equal Legend.
if(view.ViewType != ViewType.Legend) { Add to list }
You can also check to see if the BIP VIEWPORT_DETAIL_NUMBER and/or VIEWPORT_SHEET_NUMBER are empty.
Also you may want to look for View Templates as well.
if(!view.IsTemplate) { Add to list }
And a big one I ran into is making sure not to delete the Patent of any dependent views because typically they are not on sheets.
if(view.GetPrimaryViewId == ElementId.InvalidElementId) { Add to list } else { Remove from list }
There's a great plug-in from Ideate called SheetManager, which lets you isolate unplaced views.
I found a tool that does this. Use pyrevit plugin, and use the Wipe tool
Can't find what you're looking for? Ask the community or share your knowledge.