Hello,
I tried to translate the API sample to .net (c#). Code snippet:
Inventor.AssetLibraries libraries; libraries = oApp.AssetLibraries; foreach (Inventor.AssetLibrary assetLib in libraries) { output.Add("Library " + assetLib.DisplayName); output.Add(" DisplayName: " + assetLib.DisplayName); output.Add(" FullFileName: " + assetLib.FullFileName); output.Add(" InternalName: " + assetLib.InternalName); output.Add(" IsReadOnly: " + assetLib.IsReadOnly); foreach (Inventor.Asset appearance in assetLib.AppearanceAssets) { output.Add(" Appearance"); output.Add(" DisplayName: " + appearance.DisplayName); output.Add(" Category: " + appearance.Category.DisplayName); output.Add(" HasTexture: " + appearance.HasTexture); output.Add(" IsReadOnly: " + appearance.IsReadOnly); output.Add(" Name: " + appearance.Name); foreach (Inventor.AssetValue value in appearance) { PrintAssetValue(value, 8); } } }
The oApp.AssetLibraries collection contains only one empty library "Favourites" . No matter if a document is open or not. Tested with ....inventor.interop.dll V. 18.
Any help would be great.
Christoph
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
Can you double check in UI if there are other libraries? You can check it in the Appearance/Material Browser, if there is only the Favourites?
yuhanzhang,
it depends on whether a document is opend or not. I need to read appearances when no document is opend. This seems not to be possible.
When a part or assm. is opened, I can read 4 libs.
Christoph
Seems if you just launch Inventor and without openning any document the asset libraries will not be loaded except the Favourites. I logged this issue as 33516 in our TFS, please provide this No. to get its status.
I think you can workaround this issue with below VBA sample:
Sub LoadAssetLibs() Debug.Print ThisApplication.AssetLibraries.Count Dim olib As AssetLibrary For Each olib In ThisApplication.AssetLibraries Debug.Print olib.DisplayName Next Dim oDP As DesignProject Set oDP = ThisApplication.DesignProjectManager.ActiveDesignProject Dim oPAL As ProjectAssetLibrary For Each oPAL In oDP.AppearanceLibraries Call ThisApplication.AssetLibraries.Open(oPAL.LibraryFilename) Next For Each oPAL In oDP.MaterialLibraries Call ThisApplication.AssetLibraries.Open(oPAL.LibraryFilename) Next Debug.Print ThisApplication.AssetLibraries.Count For Each olib In ThisApplication.AssetLibraries Debug.Print olib.DisplayName Next End Sub
Hope this helps.