You are on page 1of 4

Deze site gebruikt cookies van Google om services te leveren, advertenties te personaliseren en verkeer te

analyseren. Informatie over je gebruik van deze site wordt gedeeld met Google. Als je deze site gebruikt, ga je
From the Trenches with Autodesk Inventor
akkoord met het gebruik van cookies.
MEER INFORMATIE IK SNAP HET
Tips, tricks & solutions from daily life with Inventor

Home Inventor Tutorials Inventor Links Mastering Inventor Companion Files

Thursday, July 7, 2011 Translate This Site

iLogic To Save PDF Files To a New Subfolder Select Language


Powered by Translate
Issue:
You want to save a PDF of each Inventor drawing file in a PDF folder based on the path of the the current
drawing file. You'd also like to append the revision number to the PDF file name.
About Me

Curtis Waguespack
I've used Inventor daily, “in the
trenches” of a real world
design environment. I've also
used AutoCAD and Inventor to
design a wide range of manufactured
products in the past. In addition to this real
world experience I’ve written and co
written multiple editions of the Mastering
For instance, you are working on a file called 47-912.idw with the Revision Number iProperty set to 3, Autodesk Inventor series and have taught
located in: Inventor to professionals in the classroom.
I hope to share some of the useful tips and
J:\Engineering\Designs\DWG\
tricks I've learned in the past and stumble
and you want to have a PDF saved out as such: across in the future on this blog.
J:\Engineering\Designs\PDF\47-912 Rev3.pdf
View my complete profile
Solution:
You can use the following iLogic rule to accomplish this:
Mastering Autodesk Inventor
'------start of iLogic------- Series Books
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") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
Looking for a Book on Inventor? Click the
End If
image above to follow the link.
'get PDF target folder path
oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF"

'Check for the PDF folder and create it if it does not exist
Search This Blog
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder) Search
End If

'Set the PDF target file name


oDataMedium.FileName = oFolder & "\" & oFileName & _ Popular Subjects on this Blog
" Rev" & oRevNum & ".pdf"
Autodesk Inventor iLogic (46)
'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
Inventor IDW (5)
'------end of iLogic-------
Autodesk Inventor Frame Generator (4)

Sketch (4)

Autodesk Inventor iProperties (2)


Here is another variation that saves each sheet of the PDF out individually:

'------start of iLogic------- Subscribe To From the Trenches


oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ Posts
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument Comments
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
Archives (What did you miss?)
'Define the drawing
Dim oDrawing As DrawingDocument ► 2017 (2)
oDrawing = ThisDoc.Document
► 2014 (7)
Dim oSheet As Sheet
Dim lPos As Long ► 2013 (10)
Dim rPos As Long
► 2012 (16)
Dim sLen As Long
Dim sSheetName As String ▼ 2011 (73)
Dim iSheetNumber As Integer
► October (1)
'step through each drawing sheet
For Each oSheet In oDrawing.Sheets
► August (5)
▼ July (2)
'find the seperator in the sheet name:number
lPos = InStr(oSheet.Name, ":") iLogic To Save PDF Files To
'find the number of characters in the sheet name a New Subfolder
sLen = Len(oSheet.Name)
'find the sheet name Simulate this!
sSheetName = Left(oSheet.Name, lPos -1)
'find the sheet number ► June (9)
iSheetNumber = Right(oSheet.Name, sLen -lPos)
► May (8)
'set PDF Options
If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
► April (10)
oOptions.Value("All_Color_AS_Black") = 1 ► March (17)
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400 ► February (8)
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange
oOptions.Value("Custom_Begin_Sheet") = iSheetNumber ► January (13)
oOptions.Value("Custom_End_Sheet") = iSheetNumber
End If

'get PDF target folder path


oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF" Popular Posts
'Check for the PDF folder and create it if it does not exist Part Modeling Practice
If Not System.IO.Directory.Exists(oFolder) Then Drawings for Inventor
    System.IO.Directory.CreateDirectory(oFolder)
Are you looking for a few
End If
dimensioned drawings to
practice your Inventor
modeling with? I've put together 24 sheets
'Set the PDF target file name
oDataMedium.FileName = oFolder & "\" & oFileName & " " & sSheetName & " " & iSheetNumber  &
of detailed ...
".pdf"
Understanding Autodesk
'Publish document Inventor Frame Generator,
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) Bill Of Materials and Part
Numbers
Next Issue: With the help of the
'------end of iLogic------- Frame Generator you've used Inventor to
successfully design a frame. The problem
is in the way that Invento...
Note: You might also find this post of interest:
iLogic Code for Parts Lists, Title Blocks and Saving out a PDF Understanding Bend
Allowance and Bend
Dedcution in Inventor
Issue: You want to better
understand the difference
Labels: Autodesk Inventor iLogic between Bend Allowance and Bend
Deduction and how they relate to Inventor
sheet metal p...

Inventor 101: Simple Fully


Constrained Sketches
Newer Post Home Older Post
Issue: You've been using
Inventor for a while now, but
View mobile version you find it frustrating and find
yourself spending almost as much time
fixing yo...
iLogic To Save PDF Files To
a New Subfolder
Issue: You want to save a
PDF of each Inventor
drawing file in a PDF folder
based on the path of the the current
drawing file. You'd al...

Inventor Background Color


as White: Improved
Issue: You'd like to use a
solid white back ground in
Inventor because it allows
you to take quick screen captures for use
in il...

Change The Origin of an


Imported Model
Issue: You've imported a part
model from a STEP, IGES or
some other file format, but
find that it was not modeled about the part
0,0,0 ...

Built for Speed: Running


iLogic Rules Automatically
When Saved, For New and
Existing (pre-iLogic) Inventor
Files
Issue: You've created what is possibly the
best collection of iLogic rules ever! And
you'd like the rules to run on your existing
p...

Where are the Inventor 2012


Tutorial and Help Files?
Issue: You've installed
Inventor 2012 (or a later
version) and everything went
well. But for some reason the help files
and tutorials f...

Using Excel and iLogic to


Retrieve Part Numbers From
a Drawing Log
Issue: Because you don't use
Vault and don't use an MRP
or ERP system you utilize a simple
spreadsheet as a part number log to
reco...

Autodesk Inventor Forum Topics

How to make a trim between two surfaces


with VBA? - andresmpajaro

How to do a Trim Surface operation


between two surfaces in
vba? - andresmpajaro

Normalizing Imported Models in Inventor


2019 - tts197

Problems creating runoff for


mold - jdoty36287

Inventor View 2019 inventorview.exe


process stays running after closing the
gui - nlbisd

Autodesk Inventor Customization


Forum Topics

Не могу активизировать продукт.


возникает ошибка. - korobeynikova909

Sheet Metal Rule Error - lAkleinsasser


How to make a trim between surfaces with
VBA for Inventor? - andresmpajaro

Suppress a linked parameter in a


part - tmayesPUD23

Set Joint Angular Limits ilogic - jzcrouse

Last 12 Posts

Powered by Blogger.

You might also like