Hello,
Is it possible, when you select a library, to detect if it is a Material or an Appearances library ?
Available libraries are obtained with ThisApplication.AssetLibraries.
I get the library with "oLib = ThisApplication.AssetLibraries("Lib name")".
I can set the library using "ThisApplication.ActiveAppearanceLibrary = oLib" or "ThisApplication.ActiveMaterialLibrary = oLib", but only if oLib is respectively an AppearanceLibrary or a MaterialLibrary.
The problem is how to know if oLib is a MaterialLibrary or an AppearanceLibrary ?
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
Actually an asset library file can contain both appearance and material asset data. And if an asset library contains the material asset data then it contains both appearance and material assets, but an asset library can contain only appearance asset data. So we can assign any asset library to the ThisApplication.ActiveAppearanceLibrary, for ThisApplication.ActiveMaterialLibrary in my opinion it should accept any asset library too but seems it fails to accept specific asset library(like the C:\Program Files (x86)\Common Files\Autodesk Shared\Materials\2015\assetlibrary_base.adsklib which is installed along with Inventor), I will log this issue.
Currently what I can suggest is that you can check if an asset library has MaterialAssets(MaterialAssets.Count), if it has no material asset then don't assign it to ThisApplication.ActiveMaterialLibrary. Hope this helps.
Ok, that's function !
I thought the error was due to a difference between Material library and Appearence library, in fact it was because the selected library could contains no materials.