Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

File Dialog Operation for saving PDF Print

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
philip1009
765 Views, 2 Replies

File Dialog Operation for saving PDF Print

I previously had a rule that would export PDF copies of prints without issue:

 

SyntaxEditor Code Snippet

modelname=IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
ofilename=ThisDoc.FileName(False)
opath="O:\CAD\Released Sales Cads\2017\"+iProperties.Value(modelname,"Custom","PRODUCT_LINE")
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
oOptions.Value("All_Color_AS_Black")=0
oOptions.Value("Remove_Line_Weights")=0
oOptions.Value("Vector_Resolution")=4800
oOptions.Value("Sheet_Range")=Inventor.PrintRangeEnum.kPrintAllSheets
odatamedium.FileName=opath & "\" & ofilename & ".pdf"
oPDFAddin.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

 

But the exported PDFs would have a layer visibility section when opened in Adobe Reader, since it's not optional to turn this option off during export, I have to resort to using the "Microsoft Print to PDF" during printing.  Here's the code as I have it now:

 

SyntaxEditor Code Snippet

oPrintMgr=ThisApplication.ActiveDocument.PrintManager
oPrintMgr.Printer="Microsoft Print to PDF"
oPrintMgr.ColorMode=kPrintDefaultColorMode
oPrintMgr.Orientation=kLandscapeOrientation
oPrintMgr.Scale=kPrintBestFitScale
oPrintMgr.PaperSize=kPaperSizeC
oPrintMgr.SubmitPrint
'[ This area needs completion!
pdfname=ThisDoc.FileName(False)
modelname=IO.Path.GetFileName(ThisDoc.ModelDocument.FullFileName)
filepath="O:\CAD\Released Sales Cads\2017\"+iProperties.Value(modelname,"Custom","PRODUCT_LINE")
'Create file dialog operation to automatically select correct folder via "filepath" and correct file name via "pdfname"
']

 

The print options code is working fine, but after that's finished I'm presented with a file dialog box for me to navigate to the folder I want and type in the correct file name.

 

What is the code to automatically save this pdf print using "pdfname" as the filename and "filepath" as the directory to save the file?

 

Thanks for your time.

Tags (3)
2 REPLIES 2
Message 2 of 3
philip1009
in reply to: philip1009

Never mind, I just answered my own question, replace oPrintMgr.SubmitPrint with oPrintMgr.PrintToFile(filepath+"\"+pdfname+".pdf") and it works perfectly.

Message 3 of 3

Hi,

You could use the inventor add in for exporting the file to pdf too.
With this ZOO of the add in you are able to do more in comparison with printing to a printer.
If needed or interested I can show privide you the code .

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report