Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom Sort Error at Top Level Assembly

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Zackery.Breeland
127 Views, 2 Replies

Custom Sort Error at Top Level Assembly

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
		
Tags (3)
2 REPLIES 2
Message 2 of 3

Hi @Zackery.Breeland 

Can you share the error message more Info tab? Is the renumbering partually working? As a work around you could wrap the renumbered process in a try catch and setup an indicater document name or row to identify where it fails. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3

Below is the More Info tab:

System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.BOMView.Renumber(Int32 StartValue, Int32 Increment, Object BOMRowsToRenumber)
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

The number and sort seems to be working for every sub-assembly within the top level.  But the confusing part is if I open one of the more complex sub-assemblies within the top level and run the same rule it still sorts and numbers the sub-assemblies, does not sort or renumber itself and does not pop up that same error.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report