Import BOM structure

Import BOM structure

TONELLAL
Collaborator Collaborator
1,117 Views
6 Replies
Message 1 of 7

Import BOM structure

TONELLAL
Collaborator
Collaborator

Hello

By the UI, you can import the BOM structure via an XML file. Is it possible by API ?

 

0 Likes
1,118 Views
6 Replies
Replies (6)
Message 2 of 7

TONELLAL
Collaborator
Collaborator

Nobody use BOM ?

0 Likes
Message 3 of 7

Mike.Wohletz
Collaborator
Collaborator

As far as I know at this time importing is not something that can be done from the API. I have gone through this before and never even could find a method to call the import form since it does not show to have a command name.

 

0 Likes
Message 4 of 7

Anonymous
Not applicable

Maybe as a workaround you could use the Sendkeys statement to control the UI?

0 Likes
Message 5 of 7

TONELLAL
Collaborator
Collaborator

Good idea... Unfortunately, when you are in the BOM window, there is no keyboard key for the "Import" button...

0 Likes
Message 6 of 7

Anonymous
Not applicable

Hi,

 

Being headstrong I couldn't withstand the challengeSmiley Wink. Below is the code Smiley Happy for importing the xml from within a drawing, specifically from the partslist (with IV2011). Didn't test the other options shown in the code, but that's up to you if needed.

Have fun!

 

Sub ImportBOMxml()
 Dim oDoc As Document
 Set oDoc = ThisApplication.ActiveDocument
 Select Case oDoc.DocumentType
  Case kDrawingDocumentObject
    Dim oPartsList As PartsList
    Set oPartsList = oDoc.ActiveSheet.PartsLists.Item(1)
    oDoc.SelectSet.Clear
    oDoc.SelectSet.Select oPartsList
    Dim oCommandMgr As CommandManager
    Set oCommandMgr = ThisApplication.CommandManager
 
    Dim oCMD As ControlDefinition
    Set oCMD = oCommandMgr.ControlDefinitions.Item("DrawOpenBOMEditorPartListCmd")
    Call oCMD.Execute2(False)

    'DrawOpenBOMEditorComponentCmd      Open Bill of Materials editor for selected assembly
    'DrawOpenBOMEditorPartListCmd       Open Bill of Materials editor for assembly of selected part list
    'DrawOpenBOMEditorViewCmd           Open Bill of Materials editor for assembly of selected view
    'AssemblyBillOfMaterialsCmd         Open Bill of Materials editor from within an assembly
    
    XMLfile = "C:\temp\test.xml"
    SendKeys ("^{TAB}")
    SendKeys ("{LEFT}")
    SendKeys ("{LEFT}")
    SendKeys ("{ENTER}") 'open Import BOM customization dialog
    SendKeys (XMLfile)
    SendKeys ("^{TAB}")
    SendKeys ("^{TAB}")
    SendKeys ("{ENTER}") 'enact Import BOM customization
    SendKeys "%{F4}", True
 End Select
End Sub

0 Likes
Message 7 of 7

TONELLAL
Collaborator
Collaborator

This is exactly what I'm looking for, but this function from a drawing... I need the same thing, but from an assembly. So I  changed "DrawOpenBOMEditorPartListCmd" by "AssemblyBillOfMaterialsCmd" and adapt the code, The problem is the BOM dialog box does not function the same way when you open it from the drawing or from the assembly ! From the drawing, ^tab move the cursor to the buttons (Import, Export or Finish). From the iam, ^tab move from a tab to another tab. There is no keyboard shortcut to go to Import...

0 Likes