Afternoon All, (if its afternoon for you)
I have an issue with my i-Logic which is based on Curtis Waguespack's Export to PDF on save code.
I havent found anyone else having the same issue, so could be my own fault. Please point it out if so.
As is, it works well and fulfils everything I want from it, however there is a niggling issue with it.
If I were to create a new assembly and drawing, the drawing would save to PDF perfectly under a new PDF folder as below.
Model1 / 1.iam
Model1 / 1.idw
Model1 / PDF / 1.pdf
But if I now go to save another drawing of a different assembly/part which is saved in its own folder, the PDF will export to the last "SAVED" assembly/part folder. As below.
Model 2 / 2.iam
Model 2 / 2.idw
exports to
Model 1 / PDF / 2.pdf
If not to solve this problem, is there anyway I would be able to show a dialogue box showing the file save path so that it is immediately obvious that the pdf is going the the wrong folder?
I've tried my best sofar, but it hasnt been enough. I'm far from proficient with i-Logic and any help would be really appreciated.
Code below.
Cheers,
'------start of iLogic------- oPath = ThisDoc.Path oFileName = ThisDoc.FileName(False) 'without extension oRevNum = iProperties.Value("Project", "Revision Number") oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then 'oOptions.Value("All_Color_AS_Black") = 0 'oOptions.Value("Remove_Line_Weights") = 0 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 End If 'get PDF target folder path oFolder = Left(oPath, InStrRev(oPath, "ThisDoc.Path")) & "PDF" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & _ " Rev" & oRevNum & ".pdf" On Error Goto handlePDFLock 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) '-------------------------------------------------------------------------------------------------------------------- Exit Sub handlePDFLock: MessageBox.Show("PDF could not be saved, most likely someone else has it open", "No PDF for you " & ThisApplication.GeneralOptions.UserName & "!") Resume Next 'Show message box MessageBox.Show("Drawing saved and PDF Exported to LAST EDITED document folder/PDF", "Save I-logic") '------end of iLogic-------
Solved! Go to Solution.
Solved by MingweiGao. Go to Solution.
Hello,
A little suprise for me is after I changed the following line:
oFolder = Left(oPath, InStrRev(oPath, "ThisDoc.Path")) & "PDF"
to-
oFolder = oPath & "\PDF"
It seems OK for me. Can you have a try and do some validations?