Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I made a code to run at the top level assembly which would parse through all sub-assemblies and set BOMs based on a template and then Sort and Renumber. I keep getting an unspecified error when I run it at the top level, but it seems to work fine when run at any of the sub-assy levels. The code is below, and it seems like the issue is caused from the Renumber function.
'Define top level assembly as active document Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument oADocDef = oADoc.ComponentDefinition 'Creating List of all Sub-Assy within Assembly Dim oAssy As Document Dim oAssyList As New List(Of Document) For Each oAssy In oADoc.AllReferencedDocuments If oAssy.DocumentType.Equals(kAssemblyDocumentObject) 'Confirm the assembly is a Job Specific assembly If Left(oAssy.PropertySets.Item(3).Item("Part Number").Value, 1) = "H" Then oAssyList.Add(oAssy) End If End If Next ' Set a reference to the BOM For Each oAssy In oAssyList Dim oBOM As BOM = oAssy.ComponentDefinition.BOM 'Import BOM Order Template to Match GP BOM Required Columns oBOM.ImportBOMCustomization("\\revginc.net\FIRE-GRP\FIRE-HL_Company_Engineering_Docs\Inventor 2013 Files\Templates\Body BOM Order Template.xml") oBOM.StructuredViewEnabled = True oBOM.StructuredViewFirstLevelOnly = False 'Sort BOMs for Vee Drawings (Decription & Length Ascending) Dim oStructuredBOMView As BOMView oStructuredBOMView = oBOM.BOMViews.Item("Structured") Call oStructuredBOMView.Sort("Description", True, "LENGTH", True) Call oStructuredBOMView.Renumber(1,1) Next
Solved! Go to Solution.