Public Sub SuppressComponentreps()
' Set reference to active document.
' This assumes the active document is an assembly
Dim oDoc As Inventor.AssemblyDocument
Dim selset As SelectSet
Dim PartList As New Collection
Dim LODList As New Collection
Dim compOcc As ComponentOccurrence
Dim oCompDef As Inventor.ComponentDefinition
Dim lodrep As LevelOfDetailRepresentation
Dim lod As LevelOfDetailRepresentation
Set oDoc = ThisApplication.ActiveDocument
Set oCompDef = oDoc.ComponentDefinition
oDoc.SelectSet.Clear
MsgBox ("Select a Part or a Subassembly")
Do While oDoc.SelectSet.Count = 0
DoEvents ' Yield to other processes.
Loop
Set selset = oDoc.SelectSet
Dim obj As Object
For Each obj In selset
If TypeOf obj Is ComponentOccurrence Then
PartList.Add obj
End If
Next
oDoc.SelectSet.Clear
MsgBox ("Select the Level of Detail where the component will be active." & Chr(13) & "Master, Components Suppressed, Parts Suppressed and Concent center suppressed won't be treated" & Chr(13) & "Substitutes cannot be treated")
Do While oDoc.SelectSet.Count = 0
DoEvents ' Yield to other processes.
Loop
Dim selSetLOD As SelectSet
Set selSetLOD = oDoc.SelectSet
Dim objLOD As Object
For Each objLOD In selSetLOD
LODList.Add objLOD
Next
Set compOcc = PartList.Item(1)
Set lod = LODList.Item(1)
For Each lodrep In oCompDef.RepresentationsManager.LevelOfDetailRepresentations
If (lodrep.Name = lod.Name) And (lodrep.LevelOfDetail <> kSubstituteLevelOfDetail) Then
lodrep.Activate
If compOcc.Suppressed = True Then
compOcc.Unsuppress
End If
oDoc.Update
oDoc.Save
End If
If (lodrep.LevelOfDetail <> kMasterLevelOfDetail) And (lodrep.LevelOfDetail <> kAllComponentsSuppressedLevelOfDetail) And _
(lodrep.LevelOfDetail <> kAllPartsSuppressedLevelOfDetail) And (lodrep.LevelOfDetail <> kAllContentSuppressedLevelOfDetail) And (lodrep.Name <> lod.Name) And (lodrep.LevelOfDetail <> kSubstituteLevelOfDetail) Then
lodrep.Activate
compOcc.Suppress
oDoc.Update
oDoc.Save
End If
Next
oDoc.Update
End Sub
Pierre Masson Product Support Specialist PS MFG EMEA Autodesk, Inc.