<?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: Purge Unused Images in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9068845#M39421</link>
    <description>&lt;P&gt;Pierre,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for image instance did you try to add the filter : .WhereElementIsNotElementType() ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that will catch only the instances.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope it will help&lt;/P&gt;</description>
    <pubDate>Sat, 05 Oct 2019 15:36:51 GMT</pubDate>
    <dc:creator>Yien_Chao</dc:creator>
    <dc:date>2019-10-05T15:36:51Z</dc:date>
    <item>
      <title>Purge Unused Images</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9067171#M39420</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I can't correctly purge unsed images.&lt;/P&gt;&lt;P&gt;I'd like to got the same result as the tool called "Manage Images"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I want to purge, for example&amp;nbsp; : TextNotes, I can use this method (founded in &lt;A href="https://thebuildingcoder.typepad.com/blog/2010/11/purge-unused-text-note-types.html" target="_blank" rel="noopener"&gt;BuildingCoder&lt;/A&gt; thx) :&lt;/P&gt;&lt;P&gt;I collect all TextNotes type&lt;/P&gt;&lt;P&gt;I collect all TextNote instances, and for each instance I remove the ID of the Type in my Collection of TextNotes Type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;FilteredElementCollector collector = new FilteredElementCollector(BIM_Extracteur._doc);
//all textNotesTypes
ICollection&amp;lt;ElementId&amp;gt; textNotesTypes = collector.OfClass(typeof(TextNoteType)).ToElementIds().ToList();
			
//all TextNotes Instances
FilteredElementCollector textNotes = new FilteredElementCollector(BIM_Extracteur._doc).OfClass(typeof(TextNote));
 			
foreach( TextNote textNote in textNotes )
{
bool removed = textNotesTypes.Remove(textNote.TextNoteType.Id);
}&lt;/PRE&gt;&lt;P&gt;But, with Images, it is more difficult and strange look :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For imagesType, it works fine&amp;nbsp; :the command is&amp;nbsp; :&lt;/P&gt;&lt;PRE&gt;ICollection&amp;lt;ElementId&amp;gt; ImagesTypes = collector.OfClass(typeof(ImageType)).ToElementIds().ToList();&lt;/PRE&gt;&lt;P&gt;But, for Images Instance, there is no Image type because image instance is typeof Element.&lt;/P&gt;&lt;P&gt;If I use this :&lt;/P&gt;&lt;PRE&gt;FilteredElementCollector ImagesCollector = new FilteredElementCollector(BIM_Extracteur._doc);
ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_RasterImages);	
ICollection&amp;lt;Element&amp;gt; images= collector.WherePasses(filter).ToElements();&lt;/PRE&gt;&lt;P&gt;The result is ImageType only&lt;/P&gt;&lt;P&gt;and when I use this :&lt;/P&gt;&lt;PRE&gt;ICollection&amp;lt;Element&amp;gt; images = new FilteredElementCollector(BIM_Extracteur._doc).OfCategory(BuiltInCategory.OST_RasterImages).ToElements();&lt;/PRE&gt;&lt;P&gt;Result is ImageType and Element for OST_RasterImage why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, if I got an image also used in Image parameter of my objets, that mean, I have to make a new filter to get all elements in all categories where image parameter containing my ImageType id?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure to be very clear......sorry&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 13:11:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9067171#M39420</guid>
      <dc:creator>SONA-ARCHITECTURE</dc:creator>
      <dc:date>2019-10-04T13:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Purge Unused Images</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9068845#M39421</link>
      <description>&lt;P&gt;Pierre,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for image instance did you try to add the filter : .WhereElementIsNotElementType() ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that will catch only the instances.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope it will help&lt;/P&gt;</description>
      <pubDate>Sat, 05 Oct 2019 15:36:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9068845#M39421</guid>
      <dc:creator>Yien_Chao</dc:creator>
      <dc:date>2019-10-05T15:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Purge Unused Images</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9069854#M39422</link>
      <description>&lt;P&gt;Thank you, Yien, for the very relevant hint.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just what I also wanted to suggest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Building Coder has discussed a number of aspects of purging different group of elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A summary is provided here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2017/11/purge-and-detecting-an-empty-view.html" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/2017/11/purge-and-detecting-an-empty-view.html&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two more discussions have been added since then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2018/08/purge-unused-using-performance-adviser.html" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/2018/08/purge-unused-using-performance-adviser.html&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2018/09/reference-intersector-and-deleting-reference-planes.html#6" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/2018/09/reference-intersector-and-deleting-reference-planes.html#6&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really should summarise these all in an own dedicated topic group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since then, yet a few more related discussion include:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Purge unused --&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/purge-unused-via-the-api/m-p/8815515" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/revit-api-forum/purge-unused-via-the-api/m-p/8815515&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Purging Types and Families -- &lt;A href="https://boostyourbim.wordpress.com/2016/10/20/rtceur-api-wish-1-purging-types-and-families" target="_blank" rel="noopener"&gt;https://boostyourbim.wordpress.com/2016/10/20/rtceur-api-wish-1-purging-types-and-families&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Purge unused materials -- &lt;A href="https://boostyourbim.wordpress.com/2016/10/21/purge-unused-materials-for-another-rtceur-api-wish" target="_blank" rel="noopener"&gt;https://boostyourbim.wordpress.com/2016/10/21/purge-unused-materials-for-another-rtceur-api-wish&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Comment on performance advisor approach -- &lt;A href="https://thebuildingcoder.typepad.com/blog/2018/08/purge-unused-using-performance-adviser.html#comment-4464788538" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/2018/08/purge-unused-using-performance-adviser.html#comment-4464788538&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Oliver Green ported the VB code using the performance advisor to IronPython in case anyone fancies a copy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&amp;nbsp;&lt;A href="https://github.com/OliverEGreen/CodeSamples/blob/master/PurgeRevitViaAPI.py" target="_blank" rel="noopener"&gt;https://github.com/OliverEGreen/CodeSamples/blob/master/PurgeRevitViaAPI.py&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://github.com/OliverEGreen/CodeSamples/blob/master/PurgeRevitViaAPI.cs" target="_blank" rel="noopener"&gt;https://github.com/OliverEGreen/CodeSamples/blob/master/PurgeRevitViaAPI.cs&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://github.com/OliverEGreen/CodeSamples" target="_blank" rel="noopener"&gt;https://github.com/OliverEGreen/CodeSamples&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mike Turpin @ThatBIMthing added:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Got excited when i saw your post that there was a new solution then realised it was what i was already using &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;. I used this in my purge node in “turtle” dynamo package.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="gtx-trans" style="position: absolute; left: 307px; top: 803.5px;"&gt;
&lt;DIV class="gtx-trans-icon"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sun, 06 Oct 2019 20:22:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9069854#M39422</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-10-06T20:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: Purge Unused Images</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9070867#M39423</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Thx Jeremy for all those links.&lt;/P&gt;&lt;P&gt;Thx Yien&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I can get all Image Instances.&lt;/P&gt;&lt;PRE&gt;ICollection&amp;lt;Element&amp;gt; images = new FilteredElementCollector(BIM_Extracteur._doc).
WhereElementIsNotElementType().
OfCategory(BuiltInCategory.OST_RasterImages).ToElements();

&lt;/PRE&gt;&lt;P&gt;I'm asking how Revit do for getting this kind ok list ?&lt;/P&gt;&lt;P&gt;'Cose I've got Generic models with Image property type added in those object.&lt;/P&gt;&lt;P&gt;I assume I have to use filter for all elements wich have an Image type parameter....&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-inline" image-alt="screenshot_291.png" style="width: 598px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/685163iD40879FD35E135C6/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot_291.png" alt="screenshot_291.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 12:46:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9070867#M39423</guid>
      <dc:creator>SONA-ARCHITECTURE</dc:creator>
      <dc:date>2019-10-07T12:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: Purge Unused Images</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9071230#M39424</link>
      <description>&lt;P&gt;I thought make a Document.Delete and counting elements deleted in a ICollection&amp;lt;Autodesk.Revit.DB.ElementId&amp;gt; deletedIdSet but no way...&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 15:18:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9071230#M39424</guid>
      <dc:creator>SONA-ARCHITECTURE</dc:creator>
      <dc:date>2019-10-07T15:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Purge Unused Images</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9072460#M39425</link>
      <description>&lt;P&gt;Dear Pierre,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not understand exactly what you are trying to achieve, nor what problems you are encountering.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 07:13:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9072460#M39425</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-10-08T07:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Purge Unused Images</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9073866#M39426</link>
      <description>&lt;P&gt;Jeremy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry Jeremy for not being clear enough ..&lt;/P&gt;&lt;P&gt;In fact, I would like to know if an image is not used (as an image stuck on a view or as an image assigned to a parameter I hope it's clearer now.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 16:24:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9073866#M39426</guid>
      <dc:creator>SONA-ARCHITECTURE</dc:creator>
      <dc:date>2019-10-08T16:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Purge Unused Images</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9073900#M39427</link>
      <description>&lt;P&gt;Yes, that much is clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A number of different approaches and attempts to resolve very similar questions have been presented and discussed in the links listed above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not clear on which of those you have tested, why they fail for you, and if so, how.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might clarify things if you share a minimal reproducible case:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 16:31:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9073900#M39427</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-10-08T16:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Purge Unused Images</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9073958#M39428</link>
      <description>&lt;P&gt;Thx Jeremy&lt;/P&gt;&lt;P&gt;I'm going to explorer solutions and I'll give you a feedback.&lt;/P&gt;&lt;P&gt;Many thanks for your disponibility&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 16:57:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9073958#M39428</guid>
      <dc:creator>SONA-ARCHITECTURE</dc:creator>
      <dc:date>2019-10-08T16:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Purge Unused Images</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9672037#M39429</link>
      <description>&lt;P&gt;I'm so curious... what are you doing in this screenshot?&amp;nbsp; I love legos!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 13:26:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/purge-unused-images/m-p/9672037#M39429</guid>
      <dc:creator>scott.deascentis</dc:creator>
      <dc:date>2020-08-04T13:26:02Z</dc:date>
    </item>
  </channel>
</rss>

