BOM configurations using iLogic

BOM configurations using iLogic

Anonymous
Not applicable
1,515 Views
9 Replies
Message 1 of 10

BOM configurations using iLogic

Anonymous
Not applicable

I thought this one would be easy but is causing me some trouble. I have several BOM configurations that I need to export out of inventor. Right now I import the xml. file to get the configuration I want then check it before exporting the file. Is there a way to import the xml. file using iLogic?

 

My plan is to have the different BOM configurations set up as external rules and using a global form I can click on whatever BOM configurations I need to use. This way I just open the BOM and it’s ready to view or export.

 

 new picure.JPG

 

I tried to change some code I found on here but just not getting me anywhere (code below). I would appreciate any help you might be able to give.

 

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

 

thanks

JD 

0 Likes
Accepted solutions (2)
1,516 Views
9 Replies
Replies (9)
Message 2 of 10

frederic.vandenplas
Collaborator
Collaborator
Accepted solution

 

Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oBOM As BOM = oAsmDef.BOM
 
Dim filename As String = "Fullfilename of the xml"
Call oBOM.importBOMCustomization(filename)

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 3 of 10

Anonymous
Not applicable

Thank you. That is exactly what I needed 

0 Likes
Message 4 of 10

Anonymous
Not applicable

Is there a way to open the BOM on the structure tab when this rule has been run?

0 Likes
Message 5 of 10

frederic.vandenplas
Collaborator
Collaborator

The BOM is allways opened at the tab that was activated when closing the BOM editor.

Maybe in the reg editor there is some option to do this?

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 6 of 10

Anonymous
Not applicable

It doesn’t have to open on that tab. I just want to be able to use the code below and want it to open the BOM to view with the same rule.

 

SyntaxEditor Code Snippet

Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oBOM As BOM = oAsmDef.BOM
 
Dim filename As String = "P:\Engineering\Inventor\BOM List\Profit Key BOM.xml"
Call oBOM.importBOMCustomization(filename)

 

0 Likes
Message 7 of 10

frederic.vandenplas
Collaborator
Collaborator

Hi,

 

Then this is what you need

'Open BOM editor dialog box
Dim oCtrlDef As ControlDefinition
oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd")
oCtrlDef.Execute

If you want to print all commandnames, there is a snippet in de vba help that does this, very helpfull and i have this file all the time with me Smiley Wink

 

Sub PrintCommandNames()
    Dim oControlDefs As ControlDefinitions
    Set oControlDefs = ThisApplication.CommandManager.ControlDefinitions

    Dim oControlDef As ControlDefinition
    
    Open "C:\temp\CommandNames.txt" For Output As #1

    Print #1, Tab(10); "Command Name"; Tab(75); "Description"; vbNewLine
    
    For Each oControlDef In oControlDefs

        Print #1, oControlDef.InternalName; Tab(55); oControlDef.DescriptionText
        
    Next
    Close #1
End Sub
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 8 of 10

Anonymous
Not applicable

Thank you so much for your help. I’m still having a little trouble. Below is the code I’m using in visual basic for a button command. It is not understanding “Thisapplication” command. Frederic you code worked great when run in a rule. I just can get it to work in the application I’m trying to make. I would appreciate if you could look this code over to see what I’m doing wrong. I know that it’s close.

Thank you

 

SyntaxEditor Code Snippet

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If _invApp.Documents.Count = 0 Then
            MsgBox("Need to open an Assembly document")
            Return
        End If

        If _invApp.ActiveDocument.DocumentType <> _
        DocumentTypeEnum.kAssemblyDocumentObject Then
            MsgBox("Need to have an Assembly document active")
            Return
        End If

        Dim asmDoc As AssemblyDocument
        asmDoc = _invApp.ActiveDocument

        Dim oAsmDoc As AssemblyDocument = _invApp.ActiveDocument
        Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
        Dim oBOM As BOM = oAsmDef.BOM

        Dim filename As String = "P:\Engineering\Inventor\BOM List\Profit Key BOM.xml"
        Call oBOM.ImportBOMCustomization(filename)

        'Open BOM editor dialog box
        Dim oCtrlDef As ControlDefinition
        oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd")
        oCtrlDef.Execute()

  End Sub

 

0 Likes
Message 9 of 10

frederic.vandenplas
Collaborator
Collaborator
Accepted solution

Hi,

 

Thisapplication works in vba & illogic, just replace it with your _invApp and it will work if you _invApp is properly declared

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 10 of 10

Anonymous
Not applicable

Thank you. I know it was something simple that I was over looking. Thanks again for your help.

0 Likes