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.
Hi,
Being headstrong I couldn't withstand the challenge
. Below is the code
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
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...