Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Export to PDF on save i-Logic issues

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
MrGMcD0
932 Views, 2 Replies

Export to PDF on save i-Logic issues

Afternoon All, (if its afternoon for you) Smiley Happy

 

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-------

 

 

 

2 REPLIES 2
Message 2 of 3
MingweiGao
in reply to: MrGMcD0

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?

 



Steven Gao

Sr. SQA Engineer

Message 3 of 3
MrGMcD0
in reply to: MingweiGao

MingweiGao, thank you so much.
As far as I can tell your little modification to the code has solved the problem.
I'll update if the problem re-occurs, but for now this is going to save alot of headaches hunting for missing PDF's!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report