Sub Main() 'Define the document Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument Dim acd As AssemblyComponentDefinition = oDoc.ComponentDefinition 'Start Sub to delete all suppressed components Call DeleteSuppressedComponent(acd.Occurrences, acd) 'Get all browser Folders oPane = oDoc.BrowserPanes("Model") oTopNode = oPane.TopNode 'Iterate through the browser folders For Each oFolder In oTopNode.BrowserFolders i = 0 'Iterate through the nodes in the folder oFolderNodes = oFolder.BrowserNode.BrowserNodes For Each oNode As BrowserNode In oFolderNodes 'Count the nodes i = i+1 Next 'Delete the folder if the count = 0 If i = 0 Then oFolder.Delete End If Next 'Path to workplace Dim oPath As String = "C:\Users\aws01\Documents\Library\Pole Configurations\" 'Saving a copy of the assembly components Dim refDocs As DocumentsEnumerator = oDoc.AllReferencedDocuments 'Count all components in assembly Dim compCount As Integer = refDocs.Count 'Iterate through all components Dim refDoc As Document For j = 1 To compCount refDoc = refDocs.Item(j) 'If the component in assembly is part then save it to "Parts" folder If refDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then refDoc.SaveAs(oPath & "Parts\Part" & j & ".ipt", False) 'If the component in assembly is subassembly then save it to "Assembly" folder Else If refDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then refDoc.SaveAs(oPath & "Assembly\Assembly" & j & ".iam", False) End If Next 'Saving a copy of the assembly document oDoc.SaveAs(oPath & "Assembly\PoleConfig.iam", False) '--------------------------------------------------------------------------------------------------- 'Promt user to select file name and folder Test = InputBox("Add File name", "Please Add your file name", "Prefix number - File") 'If the folder doesn't exist, then create it If (Not System.IO.Directory.Exists(Test)) Then System.IO.Directory.CreateDirectory(Test) End If 'Save the DWF file oDoc.SaveAs(oPath & Test & ".dwf", True) End Sub 'Sub to delete all suppressed components Sub DeleteSuppressedComponent(occs As ComponentOccurrences, cd As ComponentDefinition) 'Start Sub to delete all subassembly components Call DeleteSuppressedPatterns(cd) 'Iterate through all components Dim occ As ComponentOccurrence For Each occ In occs 'If the component is suppressed and has no pattern (parent subassembly), then delete it If occ.Suppressed Then If occ.PatternElement Is Nothing Then occ.Delete End If 'If the component isn't suppressed, then start this Sub again for all subcomponents in this component Else Call DeleteSuppressedComponent(occ.SubOccurrences, occ.Definition) End If Next End Sub 'Sub to delete all subassembly components Sub DeleteSuppressedPatterns(cd As ComponentDefinition) 'If the component's type isn't assembly, then exit this Sub If Not TypeOf cd Is AssemblyComponentDefinition Then Exit Sub End If Dim acd As AssemblyComponentDefinition = cd Dim op As OccurrencePattern 'Iterate through all components For Each op In acd.OccurrencePatterns Dim allSuppressed As Boolean = True 'Iterate through all pattern components in relation to currently selected component (see. 3 lines above) Dim ope As OccurrencePatternElement For Each ope In op.OccurrencePatternElements Dim co As ComponentOccurrence 'Iterate through all components in currently selected pattern component For Each co In ope.Occurrences 'If any of the components isn't suppresed then return "False" for variable "allSuppressed" If Not co.Suppressed Then allSuppressed = False Exit For End If Next 'If "allSuppressed" isn't "True", then exit this iteration If Not allSuppressed Then Exit For End If Next 'If "allSuppressed" is "True", then delete the pattern component If allSuppressed Then op.Delete End If Next End Sub