If you ever thought that the Autodesk support and development team doesn’t listen, then I’m here to say its just not true. With the release of Inventor 2012 we noticed what we believed to be a feature regression. It turns out the behavior we had become accustomed to and preferred was as a result of a bug. Naturally, the dev guys at Autodesk prefer to fix bugs than not, so from Inventor 2011 SP1 onwards the behavior we preferred disappeared. Now I’m not sure how we didn’t notice it until the release of 2012 but I will give them the benefit of the doubt, since they do listen to our woes after all.

Using the appropriate channels to voice our inconvenience, I managed to get Autodesk to see the problem with the way they had ‘fixed’ the software. Once we had justified the cost of its affect they set about coming up with a solution for us. All they could do initially was provide some VBA code to fix the affected part files over an over again, at least until the next major release of the software came out (SP1). The fellas over at Being Inventive created a post within days of SP1’s release, they kindly posted a registry file with an explanation of its behavior and how to use it.

Today I noticed Paul Munford from “The CAD Setter Out” blog had posted on Twitter last week, asking about how to fix this problem. So I told him about the Registry mod and the VBA code that I was provided by Autodesk. I realised the code hadn’t been shared by the Autodesk team and since its required so you don’t loose your sanity fixing up old files, I thought I should share it on my new found information outlet (Cheers John). So, courtesy of the Autodesk support guys in Singapore, here it is:

Option Explicit
Public Sub Remove_override()
' Set reference to active document.
' This assumes the active document is an assembly
Dim odoc As Inventor.AssemblyDocument
Set odoc = ThisApplication.ActiveDocument

' Get assembly component definition
Dim oCompDef As Inventor.ComponentDefinition
Set oCompDef = odoc.ComponentDefinition

' Get all occurrences from component definition for Assembly document
Dim oCompOcc As ComponentOccurrence
For Each oCompOcc In oCompDef.Occurrences
' Check if it's child occurrence (leaf node)
If oCompOcc.SubOccurrences.count = 0 Then
Call No_override(oCompOcc)
Else
Call processAllSubOcc(oCompOcc) ' subassembly
End If
Next
odoc.Update
'Save the assembly
'odoc.Save
End Sub

' This function is called for processing sub assembly. It is called recursively
' to iterate through the entire assembly tree.
Private Sub processAllSubOcc(ByVal oCompOcc As ComponentOccurrence)

Dim oSubCompOcc As ComponentOccurrence
For Each oSubCompOcc In oCompOcc.SubOccurrences
' Check if it's child occurrence (leaf node)
If oSubCompOcc.SubOccurrences.count = 0 Then
Call No_override(oSubCompOcc)
Else
Call processAllSubOcc(oSubCompOcc)
End If
Next
End Sub

Private Sub No_override(ByRef oCompOcc As ComponentOccurrence)

'Find the first derived part
If (oCompOcc.Definition.ReferenceComponents.DerivedPartComponents.count > 0) Then
Dim odpartcomp As DerivedPartComponent
Dim odpartdef As DerivedPartDefinition
Set odpartcomp = oCompOcc.Definition.ReferenceComponents.DerivedPartComponents.Item(1)
Set odpartdef = odpartcomp.Definition
' Turn off the color override
odpartdef.UseColorOverridesFromSource = False
'Push the change back to the derived component
odpartcomp.Definition = odpartdef
End If
End Sub

We ended up using a different version of this code because we wanted to point to a folder and fix all the files contained within. However, this one works on a currently open and active assembly. So go ahead, load this beauty up into your VB project, open the main assembly containing all your ‘tainted’ part files and watch all the color styles get reset to what they should be.