How to read an ADSKLIB file ?

How to read an ADSKLIB file ?

TONELLAL
Collaborator Collaborator
13,518 Views
7 Replies
Message 1 of 8

How to read an ADSKLIB file ?

TONELLAL
Collaborator
Collaborator

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 ?

 

0 Likes
Accepted solutions (1)
13,519 Views
7 Replies
Replies (7)
Message 2 of 8

philippe.leefsma
Alumni
Alumni

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

0 Likes
Message 3 of 8

TONELLAL
Collaborator
Collaborator

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.

0 Likes
Message 4 of 8

philippe.leefsma
Alumni
Alumni
Accepted solution

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

0 Likes
Message 5 of 8

TONELLAL
Collaborator
Collaborator

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

Thanks !

0 Likes
Message 6 of 8

TONELLAL
Collaborator
Collaborator
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.
0 Likes
Message 7 of 8

Anonymous
Not applicable

Can you do a tutorial how to do it. Thanks

0 Likes
Message 8 of 8

TONELLAL
Collaborator
Collaborator

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

0 Likes