Using iLogic to import BOM customization

Using iLogic to import BOM customization

tegstette
Advocate Advocate
4,417 Views
5 Replies
Message 1 of 6

Using iLogic to import BOM customization

tegstette
Advocate
Advocate

Hi

 

I want to import BOM customization into an iam by using iLogic. Is this possible?

 

 

BOM customization.jpg

Best regards
TG

Autodesk Inventor/Vault Professional 2021
Accepted solutions (1)
4,418 Views
5 Replies
Replies (5)
Message 2 of 6

Vladimir.Ananyev
Alumni
Alumni

Inventor API provide you with BOM.ExportBOMCustomization( FileName As String ) method that exports BOM column customization as XML file.  You may use this method in iLogic rule as shown in the following snippet:

 

Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oBOM As BOM = oAsmDef.BOM
 
Dim filename As String = "c:\temp\BOM_Columns.xml"
Call oBOM.ExportBOMCustomization(filename)

 Note:  LoD Master should be active to access BOM object.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 6

tegstette
Advocate
Advocate

Thank you for your answerSmiley Happy

 

First I must say that my iLogic skills are very poor, just so you know... but I try to learnSmiley Embarassed

 

I tried this snippet but got an error message, then I also noticed that this snippet exports the BOM columns and not imports the settings I want? Or do I misunderstand?

 

Here is the error message:

 

Error in rule: BOM, in document: 1-154174.iam

 

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

 

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)

 

at Inventor.BOM.ExportBOMCustomization(String FileName)

 

at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

 

at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

 

I need this snippet as a part of a larger rule. First it should import the BOM-columns that I want and then export the BOM (with my choosen columns) to an excel-file. I make the iLoigic--rule to export of the BOM work, but I first need to import the BOM-columns that I want.

 

 

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
Message 4 of 6

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

You should use BOM.ImportBOMCustomization( FileName As String ) method to import BOM column customization as XML file.  So you may simply replace ExportBOMCustomization  with ImportBOMCustomization substring in your iLogic rule. 

The easiest way to debug your rule is to test its VBA version first. 

The following post published by Adam Nagy could help you to access information on Inventor API objects:  http://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html

 

Here are two VBA samples that could help you to analyze errors.

Activate an assembly document and then run VBA code.

 

Sub BOM_ColumnCustomizasion_Export ()
    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument
    Dim oAsmDef As AssemblyComponentDefinition
    Set oAsmDef = oAsmDoc.ComponentDefinition
    
    Dim oBOM As BOM
    Set oBOM = oAsmDef.BOM
    
    Dim filename As String
    filename = "c:\temp\BOM_Columns.xml"
    Call oBOM.ExportBOMCustomization(filename)

    Beep
End Sub

Sub BOM_ColumnCustomizasion_Import ()
    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument
    Dim oAsmDef As AssemblyComponentDefinition
    Set oAsmDef = oAsmDoc.ComponentDefinition
    
    Dim oBOM As BOM
    Set oBOM = oAsmDef.BOM
    
    Dim filename As String    'assume the file exists
    filename = "c:\temp\BOM_Columns.xml"  
    Call oBOM.ImportBOMCustomization(filename)

    Beep
End Sub

Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 5 of 6

tegstette
Advocate
Advocate

Thank youSmiley Happy

 

Now I got it to workSmiley Happy

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
Message 6 of 6

GeorgK
Advisor
Advisor

Hello Vladimir,


It works only in Inventor 2015. Is there a solution for Inventor 2014?

Georg

0 Likes