iLogic printing code tweak from D size to B size

iLogic printing code tweak from D size to B size

chris_badilloK3ZHN
Participant Participant
96 Views
1 Reply
Message 1 of 2

iLogic printing code tweak from D size to B size

chris_badilloK3ZHN
Participant
Participant

Hello, 

 

We found a script that will print our drawings in a convenient way to PDF, however, we use D size for the detail and print on B size 11"x17".  When we send the drawing to the shop, they're having trouble scaling down each print because the iLogic saves the Sheet Size as 34"x22".  Below is the script, is there a way we can tweak this script in order to scale the PDF's, regardless of actual sheet size, to 11"x17"?

 

 

Dim PDFAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") Dim oDoc As Document = ThisApplication.ActiveDocument Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = kFileBrowseIOMechanism Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium oFileName = iProperties.Value("Project", "Part Number") ' Get current location of this file Dim ExportPath As String = ThisDoc.Path ' Define the filename of the file to be exported' In this Case it Is a PDF file extension ExportFilename = oFileName & ".pdf" Dim F As String = iProperties.Value("Project", "Part Number") Dim PFE As String = ExportPath & "\" & ExportFilename oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Sheet_Range") = kPrintAllSheets oDataMedium.FileName = PFE PDFAddIn.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium) Process.Start(PFE)

0 Likes
97 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Hi @chris_badilloK3ZHN.  I'm not sure that will be possible.  When we 'export' an Inventor DrawingDocument (IDW) to a PDF file using the TranslatorAddIn, we do not have an option for specifying 'scale' or 'paper size', no matter if we are exporting manually, or by code.  If we were 'printing' instead of exporting, then we would have that ability, both manually, and by code using the the PrintManager (for model files) or DrawingPrintManager (more specific type for drawings only).

WCrihfield_0-1749140888875.png

Maybe if we were 'printing' to a 'Printer' that is just for PDF's, like the 'Microsoft Print to PDF' printer, this might be possible.  At least that way, you can use the DrawingPrintManager and all its settings, just like printing, but choose that specific Printer instead of the 'default' (local) Printer.

 

Edit:  Below is an iLogic rule code example for printing an Inventor DrawingDocument to a PDF, using the special printer I mentioned.  I pretty much never use this, so I can not remember if there is a better way to 'auto-populate' the file name field of the file dialog that will pop-up asking where to save the file.  I know how to 'post' that data up to Inventor, and how to 'Copy' it into the system Clipboard, but just not that last step.  I think it is because that dialog is a system dialog, instead of an Inventor one.

Sub Main
	Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
	If oDDoc Is Nothing Then Return
	Dim sPDF As String = ThisDoc.PathAndFileName(False) & ".pdf"
	PrintDrawingToPDF(oDDoc, sPDF)
End Sub

Sub PrintDrawingToPDF(oDrawing As DrawingDocument, NewFullFileName As String)
	If NewFullFileName Is Nothing OrElse NewFullFileName = String.Empty Then
		Logger.Debug("PrintDrawingToPDF method was not supplied with a valid file name.")
		Return
	End If
	Dim oDPrintMgr As DrawingPrintManager = oDrawing.PrintManager
	oDPrintMgr.AllColorsAsBlack = False
	oDPrintMgr.ColorMode = PrintColorModeEnum.kPrintDefaultColorMode
	oDPrintMgr.NumberOfCopies = 1
	'oDPrintMgr.Orientation = PrintOrientationEnum.kDefaultOrientation
	'oDPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeDefault
	'oDPrintMgr.PaperHeight = 'only use for custom size
	'oDPrintMgr.PaperWidth = 'only use for custom size
	'oDPrintMgr.PaperSource = -1
	oDPrintMgr.Printer = "Microsoft Print to PDF"
	'oDPrintMgr.PrinterDeviceContext = 
	oDPrintMgr.PrintRange = PrintRangeEnum.kPrintAllSheets
	oDPrintMgr.RemoveLineWeights = False
	'oDPrintMgr.Rotate90Degrees = False
	'oDPrintMgr.Scale = 1.0
	oDPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
	'oDPrintMgr.SetSheetRange(1,4)
	'copy the full file name to the system Clipboard
	'that way we can 'Paste' it into the file dialog that shows
	System.Windows.Forms.Clipboard.SetText(NewFullFileName)
	oDPrintMgr.SubmitPrint()
End Sub

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes