Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

VBA : detect Matrial or Appearance library

TONELLAL
Collaborator

VBA : detect Matrial or Appearance library

TONELLAL
Collaborator
Collaborator

Hello,

Is it possible, when you select a library, to detect if it is a Material or an Appearances library ?

 

Available libraries are obtained with ThisApplication.AssetLibraries.

I get the library with "oLib = ThisApplication.AssetLibraries("Lib name")".

I can set the library using "ThisApplication.ActiveAppearanceLibrary = oLib" or "ThisApplication.ActiveMaterialLibrary = oLib", but only if oLib is respectively an AppearanceLibrary or a MaterialLibrary.

The problem is how to know if oLib is a MaterialLibrary or an AppearanceLibrary  ?

0 Likes
Reply
Accepted solutions (1)
866 Views
2 Replies
Replies (2)

YuhanZhang
Autodesk
Autodesk
Accepted solution

Actually an asset library file can contain both appearance and material asset data. And if an asset library contains the material asset data then it contains both appearance and material assets, but an asset library can contain only appearance asset data. So we can assign any asset library to the ThisApplication.ActiveAppearanceLibrary, for ThisApplication.ActiveMaterialLibrary in my opinion it should accept any asset library too but seems it fails to accept specific asset library(like the C:\Program Files (x86)\Common Files\Autodesk Shared\Materials\2015\assetlibrary_base.adsklib which is installed along with Inventor), I will log this issue. 

 

Currently what I can suggest is that you can check if an asset library has MaterialAssets(MaterialAssets.Count), if it has no material asset then don't assign it to  ThisApplication.ActiveMaterialLibrary. 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

TONELLAL
Collaborator
Collaborator

Ok, that's function !

I thought the error was due to a difference between Material library and Appearence library, in fact it was because the selected library could contains no materials.

0 Likes