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 Drawing to PDF

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
rlester
513 Views, 4 Replies

Export Drawing to PDF

I want to export a pdf file when saving my drawings, but I want the pdf file on a diffierent engineering drive. I found this code but don't know where to place my file path. Sorry trying to learn iLogic.

 

2014 Inventor Professional.

 

'------start of iLogic-------
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
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


'Define the drawing
Dim oDrawing As DrawingDocument
oDrawing = ThisDoc.Document


Dim oSheet As Sheet
Dim lPos As Long
Dim rPos As Long
Dim sLen As Long
Dim sSheetName As String
Dim iSheetNumber As Integer


'step through each drawing sheet
For Each oSheet In oDrawing.Sheets


'find the seperator in the sheet name:number
lPos = InStr(oSheet.Name, ":")
'find the number of characters in the sheet name
sLen = Len(oSheet.Name)
'find the sheet name
sSheetName = Left(oSheet.Name, lPos -1)
'find the sheet number
iSheetNumber = Right(oSheet.Name, sLen -lPos)


'set PDF Options
If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange
oOptions.Value("Custom_Begin_Sheet") = iSheetNumber
oOptions.Value("Custom_End_Sheet") = iSheetNumber
End If


'get PDF target folder path
oFolder = Left(oPath, InStrRev(oPath, "\")) & "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 & " " & sSheetName & " " & iSheetNumber  & ".pdf"


'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)


Next

4 REPLIES 4
Message 2 of 5
Curtis_Waguespack
in reply to: rlester

Hi rlester,

You should be able to change:

 

'get PDF target folder path

oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF"

 

to:

 

'get PDF target folder path

oFolder = "Q:\Temp\MyFolder\Engineering\PDF Folder"

 

Where "Q:\Temp\MyFolder\Engineering\PDF Folder" is the folder path that you want the PDFs to be saved to.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 3 of 5
rlester
in reply to: Curtis_Waguespack

Thanks a million that worked great. Maybe someday I will understand how to read iLogic.

 

Thanks again.

Message 4 of 5
jtylerbc
in reply to: rlester

FYI, since you're trying to learn iLogic:

 

The original version of the code you posted looks for the folder location of the drawing file, then puts the PDF in a subfolder (named PDF).

 

Example:

 

If the drawing is located in C:\Drawings,

PDF will be located in C:\Drawings\PDF

 

That is why that line of code looked so much more complicated, and is one reason why you didn't immediately see a place to change the save path.  The original code isn't given a path - it finds the path on its own based on the location of the Inventor drawing.

Message 5 of 5
rlester
in reply to: jtylerbc

Thanks for the FYI, that makes sense. Anything that I can learn will help in the future.

 

Really appreciate the quick response and the help.

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

Post to forums  

Autodesk Design & Make Report