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: 

How to read an ADSKLIB file ?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
TONELLAL
12386 Views, 7 Replies

How to read an ADSKLIB file ?

Hello,

I've created a dialog box where I have a combobox containing materials. This combobox has to be filled with library materials, not with ipt materials. While materials were stored in an xml file, it was easy to read it. Now they are stored in an adsklib file, how can I read it ?

 

7 REPLIES 7
Message 2 of 8
philippe.leefsma
in reply to: TONELLAL

Rename the file in .zip, unzip, and you will find several .xml in the package.

 

This is an unsupported topic, so extracting information from there will need to be achieved on your own.

 

I hope that helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 8
TONELLAL
in reply to: TONELLAL

Thanks Philippe for your answer. I tried to unzip some files, there are a lot of error messages ("Invalid filename in the archive xxx_png") for all custom libraries, for the standard libraries no error messages but it is impossible to use them... If in addition it is unsupported it is not worth...

So, how can I obtain the list of all materials existing in the libraries declared in an ipj file ? I can read materials in an ipt, but ipt and libraries can have their own materials. The purpose is to obtain all libraries materials (even those which are not loaded in the part), and not local materials.

Message 4 of 8
philippe.leefsma
in reply to: TONELLAL

Other than opening the part to read materials in it, I don't see a way to achieve that...

 

You can iterate all local librairies as follow:

 

Public Sub DumpAllAppearancesInAllLibraries()
    ' Open a file to write the results.
    Open "C:\Temp\AllLibAppearanceDump.txt" For Output As #1
    
    ' Iterate through the libraries.
    Dim assetLib As AssetLibrary
    For Each assetLib In ThisApplication.AssetLibraries
        Print #1, "Library" & assetLib.DisplayName
        Print #1, "  DisplayName: " & assetLib.DisplayName
        Print #1, "  FullFileName: " & assetLib.FullFileName
        Print #1, "  InternalName: " & assetLib.InternalName
        Print #1, "  IsReadOnly: " & assetLib.IsReadOnly
        
        Dim appearance As Asset
        For Each appearance In assetLib.AppearanceAssets
            Print #1, "    Appearance"
            Print #1, "      DisplayName: " & appearance.DisplayName
            Print #1, "      Category: " & appearance.Category.DisplayName
            Print #1, "      HasTexture: " & appearance.HasTexture
            Print #1, "      IsReadOnly: " & appearance.IsReadOnly
            Print #1, "      Name: " & appearance.Name
            
            Dim value As AssetValue
            For Each value In appearance
                Call PrintAssetValue(value, 8)
            Next
        Next
    Next
    
    Close #1
    
    MsgBox "Finished writing output to ""C:\Temp\AllLibAppearanceDump.txt"""
End Sub

 Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 5 of 8
TONELLAL
in reply to: philippe.leefsma

Ok ! So it is possible to access to the appearances and materials in the libraries files, by opening the part.

Thanks !

Message 6 of 8
TONELLAL
in reply to: TONELLAL

After some tests, I found I can use ThisApplication.DesignProjectManager.ActivedesignProject.AppearanceLibraries or .MaterialLibraries, to access to the libraries defined in the project file, without opening a part.
Message 7 of 8
damhiep99
in reply to: TONELLAL

Can you do a tutorial how to do it. Thanks

Message 8 of 8
TONELLAL
in reply to: damhiep99

Here's the code for appearances, to put in the Form code :

 

2020-06-23_11h24_39.png

 

Private Sub UserForm_Initialize()
Dim oBiblis As AssetLibraries
Dim oBibli As AssetLibrary
Dim oProjectBiblis As ProjectAssetLibraries
Dim ligne(1)

 

'Get only Appearance libraries referenced by the current ipj
Set oBiblis = ThisApplication.DesignProjectManager.ActiveDesignProject.AppearanceLibraries

 

'Fill the libraries list

For Each oBibli In oBiblis
Liste_biblis.AddItem oBibli.DisplayName
Next oBibli

 

'Initialize the list on the 1st value

Liste_biblis.Value = Liste_biblis.List(1)

 

End Sub

 

'**************************************************

Private Sub Liste_biblis_Change()

Dim oBibli As AssetLibrary
Dim oAppearances As AssetsEnumerator
Dim oAppearance As Asset

 

'Get the name of the library selected in the Libraries list

Set oBibli = ThisApplication.AssetLibraries.item(Liste_biblis.Value)

 

'Get the appearances
Set oAppearances = oBibli.AppearanceAssets

 

'Fill the list
Liste_apparences.Clear

For Each oAppearance In oAppearances
Liste_apparences.AddItem oAppearance.DisplayName
Next oAppearance

 

End Sub

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

Post to forums  

Autodesk Design & Make Report