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: 

VBA : detect Matrial or Appearance library

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
TONELLAL
726 Views, 2 Replies

VBA : detect Matrial or Appearance library

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  ?

2 REPLIES 2
Message 2 of 3
YuhanZhang
in reply to: TONELLAL

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.

Message 3 of 3
TONELLAL
in reply to: YuhanZhang

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.

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

Post to forums  

Autodesk Design & Make Report