Export Rule - PDF, DXF & iLogic using message box
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I require a more efficient manner to export my files, I want code to the do the following.
- Run rule
- message box appears with 5 tick boxes and an export button or cancel
1. Export PDF (all pages) in colour, removed line weights, 400dpi, with the name based on the main drawing into a PDF folder within the project.
2. Export PDF (all drawings as single pages) - I have logic below for this that works fine, refer to iLogic note below.
3. Export DXF (all drawings) in a DXF folder called DXFs in the same project location named as sheet name, will accept the use of an " _ " at the start of the drawing, as my dxf files get called "__drawing 1.dxf" because inventor calls DXF files by "file name" "_" "Sheet Name"
4. Export DXF (1 file) on the active page - file name from sheet name
5. Export PDF (1 file) on the active page - file name from sheet name
Bonus button - Make all view precise - right click on the drawing and click precise can take ages! If there is a better code for this. This should run first.
iLogic Note - PDF separate sheets into multiple PDF files - The iLogic code i have works really well but I think it will need tweaking for this.
- Currently the code is written to close the drawing, I would rather the code end and nothing happen to the drawing
- Creates a folder called Single PDFs in the project location
'['Sub Variables oRefDocs = ThisApplication.ActiveDocument.AllReferencedDocuments Dim oDoc As Document oFolder = ThisDoc.Path oAddIns = ThisApplication.ApplicationAddIns oTG = ThisApplication.TransientObjects'] '['PDF Export '['PDF Options PDFAddIn = oAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = oTG.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = oTG.CreateNameValueMap oDataMedium = oTG.CreateDataMedium oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 4800 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet'] For Each oDoc In oRefDocs idwPathName = Left(oDoc.FullDocumentName, Len(oDoc.FullDocumentName) -3) & "idw" If System.IO.File.Exists(idwPathName) Then oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) For Each oSheet As Sheet In oDrawDoc.Sheets NameUnique = False Count = 1 oSheet.Activate oDataMedium.FileName = oFolder & "\" & Left(oSheet.Name,Len(oSheet.Name) - (Len(oSheet.Name) - InStr(oSheet.Name, ":")) - 1) & ".pdf" TempName = oDataMedium.FileName Do Until NameUnique = True If System.IO.File.Exists(TempName) Then TempName = Left(oDataMedium.FileName,Len(oDataMedium.FileName)-4) & Count & ".pdf" Count = Count + 1 If count > 100 Then NameUnique = True 'stop infinite loop Else NameUnique = True oDataMedium.FileName = TempName End If Loop 'MessageBox.Show("oDataMedium.FileName = " & oDataMedium.FileName, "Title") 'oDataMedium.FileName = oFolder & "\" & Replace(oSheet.Name, ":","-") & ".pdf" Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) Next oDrawDoc.Close(False) End If Next'] MessageBox.Show("PDF Export completed.", "PDF Export", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)