<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Deleting unpurgeable viewport types through API in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/11220213#M42419</link>
    <description>&lt;P&gt;For some reason, when I try to run this function with pyRevit, no viewports come up, although I do have a few in my project. Would you happen to know why ?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jun 2022 19:04:53 GMT</pubDate>
    <dc:creator>priscillia_champagne</dc:creator>
    <dc:date>2022-06-07T19:04:53Z</dc:date>
    <item>
      <title>Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790238#M42408</link>
      <description>&lt;P&gt;When you copy views (including schedules) from one project to another, it brings in the default viewport type of that project. That viewport type becomes unpurgeable. So if you do this with enough files, you get a whole bunch of unpurgeable viewport types in your project.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have a few of these unpurgeable viewport types in our template and I'm looking for a way to clean this up without being forced to recreate the template, which would take me weeks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone any ideas on how I could achieve this through the API (if possible at all)?&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 14:56:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790238#M42408</guid>
      <dc:creator>pieterschiettecatte</dc:creator>
      <dc:date>2019-05-14T14:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790326#M42409</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Pieter,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your query.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In general, you can delete any database element using the Document.Delete method:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="http://www.revitapidocs.com/2019/dd023de2-cf2b-03ca-6f45-89b5e867fe92.htm" target="_blank" rel="noopener"&gt;http://www.revitapidocs.com/2019/dd023de2-cf2b-03ca-6f45-89b5e867fe92.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Have you tried using that on the viewport types you want to get rid of?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You should be able to determine their element ids somehow, e.g., using RevitLookup or other means, and then hard-code them into a call to Document.Delete.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What happens if you do so?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 15:31:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790326#M42409</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-05-14T15:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790387#M42410</link>
      <description>&lt;P&gt;It worked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can't believe it was that simple.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For anyone coming across this topic through google:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;First, find the viewport Type ID using Revit Lookup
&lt;UL&gt;
&lt;LI&gt;assign viewport you want to delete to a view on a sheet&lt;/LI&gt;
&lt;LI&gt;select the viewport&lt;/LI&gt;
&lt;LI&gt;use 'snoop current selection'&lt;/LI&gt;
&lt;LI&gt;doubleclik GetTypeId&lt;/LI&gt;
&lt;LI&gt;copy the id&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;You can use dynamo to do the deleting. See screenshot of the graph:&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dynamo delete viewport.JPG" style="width: 607px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/636359i102108A64F53A5D3/image-dimensions/607x115?v=v2" width="607" height="115" role="button" title="dynamo delete viewport.JPG" alt="dynamo delete viewport.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two&amp;nbsp;&lt;STRONG&gt;big warnings&lt;/STRONG&gt; though:&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;if you have views placed on sheets using that viewport, they will be deleted from the sheet (to be expected I guess)&lt;/LI&gt;
&lt;LI&gt;however, this one is a lot trickier: if you have schedules using that viewtype, they will be deleted from the file. Yes, from the file, not just from the sheet. And you might ask: I thought schedules don't have viewports ... I would say ... yes that's what I thought as well...&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/413917"&gt;@jeremytammik&lt;/a&gt;&amp;nbsp; do you have any suggestions on how to prevent this last issue? I have no idea how to change the viewport of a schedule? I can't even find a reference to it in RevitLookup. It seems other users have reported the same unexpected behavior as well:&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/unused-revit-system-viewports/td-p/7176217" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/unused-revit-system-viewports/td-p/7176217&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My theory is this: when you transfer schedules, sheets etc from other files you also bring in the default viewport of that file. It seems that that viewport is forever 'attached' to those schedules/sheets now. When you use the API to delete these elements, it also deleted the schedules/sheets you initially brought over.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 15:53:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790387#M42410</guid>
      <dc:creator>pieterschiettecatte</dc:creator>
      <dc:date>2019-05-14T15:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790418#M42411</link>
      <description>&lt;P&gt;Wait a minute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is not just limited to schedules. It happens to all viewtypes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example: I brought in some drafting views from another model, which triggered the creation of an extra viewport type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I put those drafting views on a sheet, changed the viewport type to my desired one, and then ran the dynamo script to get rid of the old viewport. All the imported drafting views were deleted from the file, although as far as I can see in RevitLookup, they no longer have a connection to that viewport type.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 16:04:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790418#M42411</guid>
      <dc:creator>pieterschiettecatte</dc:creator>
      <dc:date>2019-05-14T16:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790464#M42412</link>
      <description>&lt;P&gt;Congratulations on the simple solution and sorry to hear about the serious complications.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One thing you definitely ought to monitor is the return value of the call to Delete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is a list of all element ids that were deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to avoid deleting other object (unexpectedly?), you should ensure that the list only contains one element, the id of the thing you want to delete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe the&amp;nbsp;GetDependentElements also returns those additional element ids with no need to call Delete?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2019/03/retrieving-and-snooping-dependent-elements.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2019/03/retrieving-and-snooping-dependent-elements.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, I have no idea how to clean up those unwanted dependencies before deleting the unwanted elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe the viewport type does not contain any reference to the schedule, but only vice versa: does the schedule contain a reference to the viewport type?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 16:24:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790464#M42412</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-05-14T16:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790474#M42413</link>
      <description>&lt;P&gt;Unfortunately, the ViewSchedule ViewType property is read-only:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.revitapidocs.com/2019/76bee86d-3c34-7ee1-4349-cd7abcbf3d78.htm" target="_blank"&gt;http://www.revitapidocs.com/2019/76bee86d-3c34-7ee1-4349-cd7abcbf3d78.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 16:27:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790474#M42413</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-05-14T16:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790734#M42414</link>
      <description>&lt;P&gt;Hey Jeremy,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's weird. It's not just the schedule viewtype. It seems to apply to all type of views.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I purge the unwanted viewport types from my template, I lose about half of my views (a few hundreds details and schedules). I think all of the views were at some point transferred from other projects (or are duplicates of views that were).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;None of these views are using the deleted viewport types though. And as far as I can tell, Revit Lookup doesn't show any relationships what so ever between the deleted viewports, and the views that are deleted with it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm a bit confused by it really.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 18:22:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8790734#M42414</guid>
      <dc:creator>pieterschiettecatte</dc:creator>
      <dc:date>2019-05-14T18:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8901766#M42415</link>
      <description>&lt;P&gt;Update for everyone who's interested in this topic: PyRevit has a tool that makes the unpurgeable viewports purgeable. Not sure how they do it, but their code is on github.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, their approach doesn't have the side-effects of deleting views/schedules.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 17:16:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/8901766#M42415</guid>
      <dc:creator>pieterschiettecatte</dc:creator>
      <dc:date>2019-07-10T17:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/9644903#M42416</link>
      <description>&lt;P&gt;This absolutely works! I employed the "get all viewport types" block -&amp;gt; list create - &amp;gt; Element name. Pinned the output so that I can see which elements id's to type into the code block.&lt;/P&gt;&lt;P&gt;Well done!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 16:08:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/9644903#M42416</guid>
      <dc:creator>bsulliv</dc:creator>
      <dc:date>2020-07-20T16:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/10630367#M42417</link>
      <description>&lt;P&gt;I am not sure why it happens, but I ran into this and wanted to figure it out and I was moving views from several old files into one and it was brining all kinds of junk with it.&amp;nbsp; Here is the solution I came up with, however I am not sure why the Viewport Type retains dependency on the Views even through the VP Type was changed in the UI, but you have to complete a ChangeTypeId() on the Viewports to make it stick.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Dependent Elements_2021-09-17_01-24-23.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/966670i6404C602B373E632/image-size/large?v=v2&amp;amp;px=999" role="button" title="Dependent Elements_2021-09-17_01-24-23.png" alt="Dependent Elements_2021-09-17_01-24-23.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/community/screencast/48edf5b4-24f2-4bc4-8a44-8fea7a908c3d" target="_blank" rel="noopener"&gt;Embeded Viewport Type | Revit | Autodesk Knowledge Network&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 18:50:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/10630367#M42417</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2021-09-17T18:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/10836825#M42418</link>
      <description>&lt;P&gt;This is to add on to the script from above. I needed to know which was the correct viewports to delete. Seems to work just fine. But it is a manual process to type in the ID number.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curtisridenour_0-1640124627435.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1003875iAFD936418CD6FCC9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curtisridenour_0-1640124627435.png" alt="curtisridenour_0-1640124627435.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank You&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3646272"&gt;@pieterschiettecatte&lt;/a&gt;&amp;nbsp;for the simple solution.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 22:12:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/10836825#M42418</guid>
      <dc:creator>curtisridenour</dc:creator>
      <dc:date>2021-12-21T22:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/11220213#M42419</link>
      <description>&lt;P&gt;For some reason, when I try to run this function with pyRevit, no viewports come up, although I do have a few in my project. Would you happen to know why ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 19:04:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/11220213#M42419</guid>
      <dc:creator>priscillia_champagne</dc:creator>
      <dc:date>2022-06-07T19:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/12738482#M42420</link>
      <description>&lt;P&gt;PyRevit did the trick by swapping the unpurgeable from one type to another. Does anyone know what the exact problem is? What is depending on that unpurgeable viewport type and what need to be done in the API? Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2024 21:50:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/12738482#M42420</guid>
      <dc:creator>KEVIN_W_MAK_WSP</dc:creator>
      <dc:date>2024-04-27T21:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/12738688#M42421</link>
      <description>&lt;P&gt;I've been studying the &lt;A href="https://github.com/eirannejad/pyRevit/blob/3fe70d935df807a19593b06da6e3d60ee2f4eafc/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/Wipe%20Unpurgable Viewport Types.pushbutton/script.py#L82" target="_blank" rel="noopener"&gt;pyRevit code for purging viewports&lt;/A&gt;, and it's intriguing how the developer approached the task. It seems their aim was to gather a collection of all viewport types from the document. However, identifying viewport types directly posed a challenge because they lack a defined category or specific class. Instead, they are categorized under the ElementType class, which serves as a base class for all element types in Revit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To overcome this obstacle, pyRevit implemented a try-catch mechanism. By attempting to switch a viewport instance type to another type, they could determine if it belonged to the category of viewport types. Once pyRevit collected these types, it filtered out the viewport instance type IDs from the potentially purgable IDs and proceeded to delete them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Considering alternative approaches, one could explore the possibility of identifying purgable viewports indirectly by targeting existing parameters. For example, since ViewportType is a system family and all must possess the "Show Extension Line" parameter (BuiltInParameter.VIEWPORT_ATTR_SHOW_EXTENSION_LINE), we can use this parameter as a filter rule to identify all types that possess it. Fortunatly, this parameter is a bool parameter, which its value is either 0 or 1, then we can use (&lt;A href="https://www.revitapidocs.com/2016/f17be87a-a682-5fcc-8ebc-1449952461ff.htm" target="_blank" rel="noopener"&gt;ParameterFilterRuleFactory&lt;/A&gt;.CreateGreaterOrEqualRule) and supply a value 0 for checking.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With a list of viewport types established, the next step involves iterating through each type to retrieve the associated viewports using the &lt;A href="https://www.revitapidocs.com/2024/56e875d3-014b-a996-69c3-e6ed9b885f5c.htm" target="_blank" rel="noopener"&gt;GetDependentElements(ElementFilter)&lt;/A&gt; method.&lt;/P&gt;&lt;P&gt;Here's an example to illustrate the process:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// create filterRule to be used in collection
var rule = ParameterFilterRuleFactory.CreateGreaterOrEqualRule(
                    new ElementId(BuiltInParameter.VIEWPORT_ATTR_SHOW_EXTENSION_LINE),0
);

// get all elements that comply to this rule
var viewPortTypes = new FilteredElementCollector(doc)
	.WhereElementIsElementType()
	.OfCategory(BuiltInCategory.INVALID)
	.WherePasses(new ElementParameterFilter(rule));

// now for each viewportType find a viewport instance dependent
List&amp;lt;ElementId&amp;gt; purgeableIds = new List&amp;lt;ElementId&amp;gt;();
foreach (var viewportType in viewPortTypes)
{
	var viewports = viewportType.GetDependentElements(
		new ElementCategoryFilter(BuiltInCategory.OST_Viewports)
	);
	if (!viewports.Any())
	{
		purgeableIds.Add(viewportType.Id);
	}
}

// show a list of all purgeable Ids
MessageBox.Show(
string.Join("\r\n", purgeableIds.Select(o =&amp;gt; o.Value.ToString()))
);
// ... handle these ids&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I just tested it on 2025, would be glad to know if there are some holes in this method.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Apr 2024 06:50:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/12738688#M42421</guid>
      <dc:creator>Moustafa_K</dc:creator>
      <dc:date>2024-04-28T06:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/12741221#M42422</link>
      <description>&lt;P&gt;Your code works on my end; it allows me to get all purgeable viewport types in the project. I can use the reverse logic to get all unpurgeable and get their dependent element Id's.&lt;BR /&gt;&lt;BR /&gt;And thanks for sharing the path to the pyRevit purge viewport code. This is going to be a great help too!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 14:46:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/12741221#M42422</guid>
      <dc:creator>KEVIN_W_MAK_WSP</dc:creator>
      <dc:date>2024-04-29T14:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/12741245#M42423</link>
      <description>&lt;P&gt;so glad it helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 14:51:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/12741245#M42423</guid>
      <dc:creator>Moustafa_K</dc:creator>
      <dc:date>2024-04-29T14:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/12741256#M42424</link>
      <description>&lt;P&gt;Here is what I use to get Viewport Types. It may not be super language stable, but it works great for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;FilterRule rule = ParameterFilterRuleFactory.CreateEqualsRule(new ElementId((Int64)BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM), "Viewport");
ElementParameterFilter filter = new ElementParameterFilter(rule);
IList&amp;lt;ElementType&amp;gt; viewportTypes;
using(FilteredElementCollector fec = new FilteredElementCollector(doc).OfClass(typeof(ElementType)).WherePasses(filter))
{
	viewportTypes = fec.Cast&amp;lt;ElementType&amp;gt;().ToList();
}
return viewportTypes;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 29 Apr 2024 14:57:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/12741256#M42424</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2024-04-29T14:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting unpurgeable viewport types through API</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/14068086#M85416</link>
      <description>&lt;P&gt;I have the problem that when i remove some of the viewports, other stuff gets removed, such as Sheets or legends, even when before the removal i reassigned every view to a valid viewport not to be removed. Anyone have a solution for this?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2026 21:29:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-unpurgeable-viewport-types-through-api/m-p/14068086#M85416</guid>
      <dc:creator>Admin.CTI</dc:creator>
      <dc:date>2026-03-26T21:29:08Z</dc:date>
    </item>
  </channel>
</rss>

