Try this.. Tell us the last "Part X" message you see before getting the errror..
Likely makes it to part 3 but lets see..
Probably something bad about one of the faces.. Hard to tell without seeing the file...
You can also throw this at the beginning and see how it does and if there is a face it seems to miss reporting on or whatever.
On Error Resume Next
'code to get the area of each face based on its color
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
MessageBox.Show("Part 1", "Made it")
Dim oFaces As Faces
oFaces = oPartDoc.ComponentDefinition.SurfaceBodies(1).Faces
MessageBox.Show("Part 2", "Made it")
Dim Colors As Object
Colors = CreateObject("Scripting.Dictionary")
MessageBox.Show("Part 3", "Made it")
Dim oFace As Face
For Each oFace In oFaces
Colors(oFace.Appearance.DisplayName) = Colors(oFace.Appearance.DisplayName) + oFace.Evaluator.Area
Next
MessageBox.Show("Part 4", "Made it")
For Each Item In Colors
MessageBox.Show("Color: " & Item & vbLf & "Area: " &Colors(Item) & "cm^2", "Surface Area by Color")
Next
-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570
Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269