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.
Solved! Go to Solution.
Solved by philip1009. Go to Solution.
Never mind, I just answered my own question, replace oPrintMgr.SubmitPrint with oPrintMgr.PrintToFile(filepath+"\"+pdfname+".pdf") and it works perfectly.
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.