<?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: Compare materials with those in certain library; Purge unused materials within part document in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/compare-materials-with-those-in-certain-library-purge-unused/m-p/11499531#M144190</link>
    <description>&lt;P&gt;Here's what I found:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Comparison with library:&lt;/P&gt;&lt;P&gt;For materials within each model state: `oDoc.ComponentDefinition.ModelStates`, `.Activate` each and get `mat = oDoc.ActiveMaterial`&lt;/P&gt;&lt;P&gt;For selecting the library to compare against: `library = ThisApplication.AssetLibraries(libraryName)` and instead of trying to find the origin, just `try`ing to change with `library(mat.DisplayName)` and defaulting to something else if not found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Purging unused:&lt;/P&gt;&lt;P&gt;For locally stored materials: `ThisDoc.Document.MaterialAssets` and `.Delete` each where `Not` `.IsUsed` (this only keeps the currently active model state's material, but the others are added back on each activation respectively)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Oct 2022 16:00:34 GMT</pubDate>
    <dc:creator>meGVGMF</dc:creator>
    <dc:date>2022-10-21T16:00:34Z</dc:date>
    <item>
      <title>Compare materials with those in certain library; Purge unused materials within part document</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/compare-materials-with-those-in-certain-library-purge-unused/m-p/11493889#M144060</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to make something that will do two separate but related things:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I need to find a way to determine if a part document's material is specified by/originates from a certain material library;&lt;/LI&gt;&lt;LI&gt;And I also need to find a way to purge any materials local to a part file which are not used by any of its model states.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found this forum post which describes &lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-selection-of-material-libary/td-p/8369040" target="_blank" rel="noopener"&gt;how to access the associated material libraries of a project&lt;/A&gt;, but the objects here appear to be just references to, and not a way to access any of the data contained within, the library files themselves.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 16:03:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/compare-materials-with-those-in-certain-library-purge-unused/m-p/11493889#M144060</guid>
      <dc:creator>meGVGMF</dc:creator>
      <dc:date>2022-10-19T16:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Compare materials with those in certain library; Purge unused materials within part document</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/compare-materials-with-those-in-certain-library-purge-unused/m-p/11499531#M144190</link>
      <description>&lt;P&gt;Here's what I found:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Comparison with library:&lt;/P&gt;&lt;P&gt;For materials within each model state: `oDoc.ComponentDefinition.ModelStates`, `.Activate` each and get `mat = oDoc.ActiveMaterial`&lt;/P&gt;&lt;P&gt;For selecting the library to compare against: `library = ThisApplication.AssetLibraries(libraryName)` and instead of trying to find the origin, just `try`ing to change with `library(mat.DisplayName)` and defaulting to something else if not found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Purging unused:&lt;/P&gt;&lt;P&gt;For locally stored materials: `ThisDoc.Document.MaterialAssets` and `.Delete` each where `Not` `.IsUsed` (this only keeps the currently active model state's material, but the others are added back on each activation respectively)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 16:00:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/compare-materials-with-those-in-certain-library-purge-unused/m-p/11499531#M144190</guid>
      <dc:creator>meGVGMF</dc:creator>
      <dc:date>2022-10-21T16:00:34Z</dc:date>
    </item>
  </channel>
</rss>

