- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to make something that will do two separate but related things:
- I need to find a way to determine if a part document's material is specified by/originates from a certain material library;
- 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.
I found this forum post which describes how to access the associated material libraries of a project, 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.
Is there any way to do this?
Thanks
Solved! Go to Solution.
- Related tags:
-
iLogic
-
Libraries
-
library
-
library editing
-
library management
-
material
-
Materials
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here's what I found:
Comparison with library:
For materials within each model state: `oDoc.ComponentDefinition.ModelStates`, `.Activate` each and get `mat = oDoc.ActiveMaterial`
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.
Purging unused:
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)