Issue with listing material assets from custom library

Issue with listing material assets from custom library

nmunro
Collaborator Collaborator
366 Views
3 Replies
Message 1 of 4

Issue with listing material assets from custom library

nmunro
Collaborator
Collaborator

Re: Inventor forum post - Solved: Odd Material-001, Material-002, Material-003, etc???? - Autodesk Community - Inventor

 

Getting material asset display names is still an issue when the ActiveMaterialLibrary is a custom user library.

 

Opening a part file with a custom material library and running the following VBA code results in the printout in the image following the code.

 

 

Public Sub LibTest()

    Dim lib As AssetLibrary
    Set lib = ThisApplication.ActiveMaterialLibrary
    
    For i = 1 To lib.MaterialAssets.Count
        Debug.Print i & "  " & lib.MaterialAssets(i).DisplayName
    Next i
    
End Sub

 

 

 

Partial debug window

 
Debug1.png
 

Many of the materials have a "Material-xxx", "MaterialInv-xxx", or "MaterialSim-xxx" display name.

 

If the user then drops down the Material List in Inventor

 

Debug2.png

 

And then runs the same macro, the display names have updated to the expected values.

 

Debug3.png

 

So, what is the process to force this update before extracting the display names? They are obviously materials that are being referenced from the Autodesk and Inventor material libraries.

 

 

 

 

 

 

        


https://c3mcad.com

0 Likes
367 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @nmunro.  Just a thought, for a temporary workaround until this gets resolved properly...have you tried setting the ThisApplication.ActiveMaterialLibrary to a different 'AssetLibrary', then back to the one you want, then do a document update, before trying to list out the material display names.  Seems like something logical to try, that might help correct what seems to be a memory related issue.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

nmunro
Collaborator
Collaborator

Thanks for the suggestions. I have tried a number of approaches without success, including your suggested workflow. It appears that Inventor does not resolve the material library when it is first loaded, waiting until it is first accessed. Now looking at a manual reminder for users to force the update or a complex asynchronous timer approach to run a command that will force the update.  

 

        


https://c3mcad.com

0 Likes
Message 4 of 4

nmunro
Collaborator
Collaborator

What ever happened to the three business day guaranteed response for ADN member questions? 

        


https://c3mcad.com

0 Likes