I'm using ilogic to export my BOM in Microsoft Access Database format. We are using Access 2010. The code I am using is saving the file in an earlier version of Access, so when i open the database I am prompted by Access to have the file converted to the latest (2010) version. It seems to convert ok through Access so I'm not totally stuck, but it would be nice if Ilogic could do the job right on the export so I don't have to be prompted every time. Anyone have any suggestions as to how to specify the correct version of Access in the export code? Below is my code. Also, I've been unable to export my BOM using ilogic from a custom LOD. My assemblies are almost never in a master LOD at the point that I want to export. In my code I have the model switching LOD to master prior to the export, then switching back to custom as a work-around. Any suggestions as to how I can export through ilogic form a custom LOD? The code below works, but takes a while to run because of the LOD switch.
ThisDoc.Save ThisApplication = InventorVb.Application oMyDoc = ThisDoc.ModelDocument Dim oRepMgr As RepresentationsManager oRepMgr = oMyDoc.ComponentDefinition.RepresentationsManager Dim oMasterLOD As LevelOfDetailRepresentation oMasterLOD = oRepMgr.LevelOfDetailRepresentations.Item("Master") oMasterLOD.Activate() ThisBOM.Export("Parts Only", "C:\TEMP\bom_temp\export_inventor_files_here.mdb", kMicrosoftAccessFormat) oMasterLOD = oRepMgr.LevelOfDetailRepresentations.Item("custom") oMasterLOD.Activate()
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
Happy New Year!
I'm quite sure that iLogic ThisBOM.Export is using BOMView.Export underneath.
If you check in the API reference (C:\Program Files\Autodesk\Inventor 2013\Local Help\admapi_17_0.chm) then it has this information on the available options:
>>>>>
Options - Optional input String that specifies the 'Table Name' for kMicrosoftAccess and kMicrosoftExcel file formats. This is the name of the Excel/Access sheet. If not provided, the name of the file is used as the sheet name. For other formats, this argument is ignored.
<<<<<
So unfortunately, it does not seem possible to influcence the file version being used - but I'm chekcing with colleagues and will get back to you if I get any different information on this.
Concerning the second question.
Probably you could open the Master LOD in the background to do what you need like it is done in the following sample code:
I hope this helps.
Cheers,
Becides switching the active LOD, another workaround is that you can open the assembly document with master LOD active in invisible mode, if you already have the document opened with custom LOD active you can try below code:
Sub ExportBOMSample() Dim oDoc As AssemblyDocument Set oDoc = ThisApplication.ActiveDocument ' If the current non-master LOD document is dirty you should save it before you can use the master-LOD document background If oDoc.Dirty Then If MsgBox("You should save the document first!" & vbCrLf & "Would you like to save the document?", vbYesNo) = vbYes Then oDoc.Save Else Exit Sub End If End If Dim sFileName As String sFileName = oDoc.FullFileName Dim oMasterLODDoc As AssemblyDocument Set oMasterLODDoc = ThisApplication.Documents.Open(sFileName, False) Dim oBOM As BOM Set oBOM = oMasterLODDoc.ComponentDefinition.BOM oBOM.PartsOnlyViewEnabled = True Dim oBOMView As BOMView Set oBOMView = oBOM.BOMViews.Item("Parts Only") oBOMView.Export "C:\Temp\BOM.accdb", kMicrosoftAccessFormat oMasterLODDoc.Close True End Sub
Note: To access the master-LOD document's BOM background you should make sure the document is not dirty in custom LOD document, otherwise you should save it first.
Hope it helps!
How to make this BOM renumber?
Can't find what you're looking for? Ask the community or share your knowledge.