Write out all appearance information to a file. API Sample

Write out all appearance information to a file. API Sample

C-Hoppen
Advocate Advocate
792 Views
5 Replies
Message 1 of 6

Write out all appearance information to a file. API Sample

C-Hoppen
Advocate
Advocate

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

 

 

0 Likes
Accepted solutions (1)
793 Views
5 Replies
Replies (5)
Message 2 of 6

YuhanZhang
Autodesk
Autodesk

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?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 6

C-Hoppen
Advocate
Advocate

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

0 Likes
Message 4 of 6

YuhanZhang
Autodesk
Autodesk

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.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 6

YuhanZhang
Autodesk
Autodesk
Accepted solution

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.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 6 of 6

C-Hoppen
Advocate
Advocate

Thanks a lot!

Christoph

0 Likes