Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Write out all appearance information to a file. API Sample

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
C-Hoppen
579 Views, 5 Replies

Write out all appearance information to a file. API Sample

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

 

 

Tags (1)
5 REPLIES 5
Message 2 of 6
YuhanZhang
in reply to: C-Hoppen

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.

Message 3 of 6
C-Hoppen
in reply to: YuhanZhang

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

Message 4 of 6
YuhanZhang
in reply to: C-Hoppen

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.

Message 5 of 6
YuhanZhang
in reply to: C-Hoppen

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.

Message 6 of 6
C-Hoppen
in reply to: YuhanZhang

Thanks a lot!

Christoph

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report