Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete unused views (Views not placed on sheets)

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
SanjivKapila
13108 Views, 11 Replies

Delete unused views (Views not placed on sheets)

I'm trying to delete unused views with following conditions: 1. View should not have any dependent views 2. Views which can be placed on multiple sheets (eg Legends) should not be deleted if they are placed on at least one sheet. 3. Unused ViewSchedules should also get deleted Attached code is an unsuccessful attempt at achieving this.
Tags (1)
11 REPLIES 11
Message 2 of 12

Hi @SanjivKapila ,

try using the below link

https://thebuildingcoder.typepad.com/blog/2017/11/purge-and-detecting-an-empty-view.html#2 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 12

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..

Message 4 of 12
jeremytammik
in reply to: SanjivKapila

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.

  



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 12
SanjivKapila
in reply to: jeremytammik

Not Sure Why, but i end up deleting all the legend views even though some are placed on the sheets.

Message 6 of 12
Sean_Page
in reply to: SanjivKapila

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
}
Message 7 of 12

There's a great plug-in from Ideate called SheetManager, which lets you isolate unplaced views. 

 

image.png

Message 8 of 12
tylerVD3L4
in reply to: SanjivKapila

Can you share the solution and where I would input the code in Revit?

Message 9 of 12
tylerVD3L4
in reply to: SanjivKapila

I found a tool that does this. Use pyrevit plugin, and use the Wipe tool

Message 10 of 12

Can you just use the "Browser Organisation":

trevorritchieC68GZ_0-1675723042301.png

 

trevorritchieC68GZ_0-1675723107663.png

 

Message 11 of 12

Does it smartly hide parent views that aren't on sheets?

Message 12 of 12
archcad2019
in reply to: SanjivKapila

how i can use this option in revit ? please provide me with steps

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community