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

Hi @Jonathan.CharltonE35Y2 

 

So in your code you are not setting the material at all. You are trying to send a material asset to an iproperty. There is a dedicated ilogic function for material but those snippets do not work great in assembly contexts so the API route is easier in my opinion.  

 

What you need to do is to copy an asset from the asset library to each part then set the active material. 

 

Here is an example of how to do this in a part file.  Ensure you have the same library currently in use. When you are happy it is working for the part. Then transfer this method to the referenced document loop of your assembly. Any question just post up the modified code.

Dim oDoc As PartDocument = ThisApplication.ActiveDocument

    Dim assetLib As AssetLibrary  = ThisApplication.AssetLibraries.Item("Inventor Material Library")
 	
	ThisApplication.ActiveMaterialLibrary = assetLib
   
    Dim MaterialName As String = "Gold"
   
    Try
	Dim localMaterial As MaterialAsset = oDoc.MaterialAssets.Item(MaterialName)
 	Catch
    Dim libMaterial As MaterialAsset = assetLib.MaterialAssets.Item(MaterialName)
	libMaterial.CopyTo(oDoc)
	End Try
	
	oDoc.ActiveMaterial = oDoc.MaterialAssets.Item(MaterialName)
 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan