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: 

Testing if a material exists in a library

4 REPLIES 4
Reply
Message 1 of 5
meGVGMF
194 Views, 4 Replies

Testing if a material exists in a library

Hi,

 

I'm trying to see if the material of the active model state exists in a given library.

 

I thought I'd be able to use the `MaterialAsset.Name` property, which for library ones is a UUID, but seems to be a simple string for, at least, `ThisDoc.Document.ActiveMaterial`.

 

Is it possible to access this UUID somewhere within the `Document` object?

 

Thanks

Labels (6)
4 REPLIES 4
Message 2 of 5
Cadkunde.nl
in reply to: meGVGMF

No clue what UUID is. But if I want to find the material in the library i use something like this:

 

Dim oApp As Inventor.Application = ThisApplication
Dim oDoc As PartDocument = ThisDoc.Document
Dim assetLib As AssetLibrary = oApp.AssetLibraries.Item("Inventor Material Library")

For Each oAsset As Inventor.MaterialAsset In assetLib.MaterialAssets
If oAsset.DisplayName = oDoc.ActiveMaterial.DisplayName Then
	MsgBox("Yay! Found it")
End If
Next
Message 3 of 5
A.Acheson
in reply to: meGVGMF

The only way I know to do this is to loop through the library assets looking for the string value. Can you supply the code your working with? This vba sample for appearance would do just that when asset changed for material. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 4 of 5
meGVGMF
in reply to: Cadkunde.nl

I'm actually trying to get around using `.DisplayName`, because if the name changes the material would go unrecognized.

The universally unique identifier/UUID value of the `.Name` for assets in the library is a 128-bit string in the format 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' that is, for all intents and purposes, unique.

Using this instead would cause fewer false negatives in the comparison and allow for more flexibility in the logic.

Message 5 of 5
meGVGMF
in reply to: A.Acheson

Thanks, but I'm trying to get around using the `.DisplayName` for identification.

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report