Imports System.Windows.Forms ' Get current location of this file Dim ExportPath As String = ThisDoc.Path ' Check that this file has been saved and actually exists on disk If String.IsNullOrEmpty(ExportPath) Then MsgBox("This file has not yet been saved and doesn't exist on disk! - please save it first",64, "Cadline iLogic") Return End If ' Define folder browse dialog Dim Dialog = New FolderBrowserDialog() ' Set options for folder browser dialog Dialog.SelectedPath = ExportPath Dialog.ShowNewFolderButton = True Dialog.Description = "Please choose Release Folder" ' Show dialog box If DialogResult.OK = Dialog.ShowDialog() Then ' User clicked 'ok' on dialog box - capture the export path ExportPath = Dialog.SelectedPath & "\" Else ' User clicked 'cancel' on dialog box - exit Return End If iLogicVb.RunExternalRule("SheetName - Drawing") 'Export to XLS 'define oDoc oDoc = ThisDoc.Document 'specify the drawing sheet oSheet = oDoc.Sheets(1) ' first sheet ' say there is a Partslist on the sheet. oPartslist = oSheet.PartsLists(1) ' create a new NameValueMap object oOptionsBOM = ThisApplication.TransientObjects.CreateNameValueMap 'specify an existing template file 'to use For formatting colors, fonts, etc oOptionsBOM.Value("Template") = "Y:\SUPPORT\Excel Templates\Purchasing BOM Template.xls" 'specify the columns to export oOptionsBOM.Value("ExportedColumns") = "ITEM#;QTY;PART#;MATERIAL;DESCRIPTION;COMMENTS;COM CODE;TOTAL WEIGHT" 'specify the start cell oOptionsBOM.Value("StartingCell") = "B11" 'specify the XLS tab name 'here the file name is used oOptionsBOM.Value("TableName") = ThisDoc.FileName(False) 'without extension 'choose to include the parts list title row 'in this example "Ye Old List of Parts" is written to the StartingCell oOptionsBOM.Value("IncludeTitle") = False 'choose to autofit the column width in the xls file oOptionsBOM.Value("AutoFitColumnWidth") = True 'get BOMrget folder path oFolderBOM = Left(ExportPath, InStrRev(ExportPath, "\")) & "BOM" 'Check for the BOM folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolderBOM) Then System.IO.Directory.CreateDirectory(oFolderBOM) End If ' export the Partslist to Excel with options oPartslist.Export(oFolderBOM & "\" & ThisDoc.FileName(False) & ".xls", PartsListFileFormatEnum.kMicrosoftExcel, oOptionsBOM) 'Export to PDF oPath = ThisDoc.Path oFileName = ThisDoc.FileName(False) 'without extension oRevNum = iProperties.Value("Project", "Revision Number") oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocumentPDF = ThisApplication.ActiveDocument oContextPDF = ThisApplication.TransientObjects.CreateTranslationContext oContextPDF.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptionsPDF = ThisApplication.TransientObjects.CreateNameValueMap oDataMediumPDF = ThisApplication.TransientObjects.CreateDataMedium If oPDFAddIn.HasSaveCopyAsOptions(oDataMediumPDF, oContextPDF, oOptionsPDF) Then oOptionsPDF.Value("All_Color_AS_Black") = 1 oOptionsPDF.Value("Remove_Line_Weights") = 1 oOptionsPDF.Value("Vector_Resolution") = 600 oOptionsPDF.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptionsPDF.Value("Custom_Begin_Sheet") = 2 'oOptionsPDF.Value("Custom_End_Sheet") = 4 End If 'get PDF target folder path oFolderPDF = Left(ExportPath, InStrRev(ExportPath, "\")) & "PDF" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolderPDF) Then System.IO.Directory.CreateDirectory(oFolderPDF) End If 'Set the PDF target file name oDataMediumPDF.FileName = oFolderPDF & "\" & oFileName & ".pdf" 'Publish document oPDFAddIn.SaveCopyAs(oDocumentPDF, oContextPDF, oOptionsPDF, oDataMediumPDF) 'Export to AutoCAD DWG ' Get the DWG translator Add-In. Dim DWGAddIn As TranslatorAddIn DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}") 'Set a reference to the active document (the document to be published). Dim oDocument As Document oDocument = ThisApplication.ActiveDocument Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism ' Create a NameValueMap object Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Create a DataMedium object Dim oDataMedium As DataMedium oDataMedium = ThisApplication.TransientObjects.CreateDataMedium ' Check whether the translator has 'SaveCopyAs' options If DWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then Dim strIniFile As String strIniFile = "Y:\Support\AM2015\AM2015 (Stansteel).ini" ' Create the name-value that specifies the ini file to use. oOptions.Value("Export_Acad_IniFile") = strIniFile End If 'get DWG target folder path oFolderDWG = Left(ExportPath, InStrRev(ExportPath, "\")) & "DWG" 'Check for the DWF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolderDWG) Then System.IO.Directory.CreateDirectory(oFolderDWG) End If 'Set the DWF target file name oDataMedium.FileName = oFolderDWG & "\" & "x" & ".dwg" DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)