In R2009 you could manually override the inclusion of components despite the fact that an associative viewrep was used in a derived assembly.
Starting from R2010 onwards , Inventor no longer allows the manual inclusion override when an associative viewrep is used.
If you leave the derived assembly in R2009 this is not really a problem. The problem arises when such a derived assembly is migrated to R2010 or R2011 and gets edited . After edit (and without changing anything in the editor) , the number of included components will be different in R2010/R2011 compared to R2009! Here is an example of such a situation.
Solution for R2010/R2011:
Run below macro on the derived assembly.
The macro corrects the derived assembly for use in R2010/R2011 and automatically saves the file to the same filename. Note this macro will not work in R2009.
'==========================================
Sub extract_derived_component_state()
Dim oPartdoc As PartDocument
Set oPartdoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
Set oDef = oPartdoc.ComponentDefinition
'We assume that we work with the first derived assembly.
'Since 2011 multiple derive operations are possible in a single ipt
Dim oDerivedComp As DerivedAssemblyComponent
If oDef.ReferenceComponents.DerivedAssemblyComponents.Count = 0 Then
Exit Sub
Else
Set oDerivedComp = oDef.ReferenceComponents.DerivedAssemblyComponents(1)
End If
Dim oDerivedDef As DerivedAssemblyDefinition
Set oDerivedDef = oDerivedComp.Definition
'Scan through all occurences
Dim occ As DerivedAssemblyOccurrence
Dim state() As Long
Dim i As Integer
i = 0
For Each occ In oDerivedDef.Occurrences
ReDim Preserve state(i)
state(i) = occ.InclusionOption
Debug.Print state(i)
i = i + 1
Next occ
'Remove associativity flag
Dim viewrep As String
viewrep = oDerivedDef.ActiveDesignViewRepresentation
oDerivedDef.ActiveDesignViewRepresentation = ""
'Reset the occurence state the way it was before changing the viewrep
i = 0
For Each occ In oDerivedDef.Occurrences
occ.InclusionOption = state(i)
i = i + 1
Next occ
'Push the change so that it becomes visible in the derived dialog
oDerivedComp.Definition = oDerivedDef
'Save the part
ThisApplication.SilentOperation = True
oPartdoc.Save
ThisApplication.SilentOperation = False
End Sub
'===================================================
Comments