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

Find Face with FaceColor Attributes with iLogic

The below code works great when used within a part file, but when I add the part to an assembly, the part errors. For example, a single line of iLogic code in the assembly to change the width of the part will cause the part file to run its iLogic code, and error. When I comment out the below code, the part updates correctly in the assembly. I think the error is in the "com.autodesk.inventor.FaceAttributes" line, but I don't know how else I can find each face to update. 

 

    Dim oPartDoc As PartDocument 
    oPartDoc = ThisApplication.ActiveDocument 

    ' Get all of the faces that have the "FaceColor" attribute. 
    Dim oFaces As ObjectCollection 
    oFaces = oPartDoc.AttributeManager.FindObjects( "com.autodesk.inventor.FaceAttributes", "FaceColor")

    ' Iterate through all faces that have colors and change. 
    Dim oFace As Face
    Dim oAssets as Assets
    oAssets = oPartDoc.Assets
	
    Dim oAsset as Asset
    oAsset = oAssets.Item("Bamboo")
    
    For Each oFace In oFaces 
         oFace.Appearance = oAsset
    Next 

 image.png