Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
TGibson7A8HD
479 Views, 9 Replies

Batch PDF multiple IDWs with Ilogic Size Issue

I have two Ilogic codes I use. One for exporting the open IDW as a PDF and one for Batch Exporting all in a selected folder to PDFs.

Single Export code actually calls for the sizing of the print

Batch Export code is calling for something other than printing, and I cant figure out where to incorporate print settings.

My workspace in Inventor is 34"x22" for modeling purposes, but our printers for real paper are 11"x17" and when printing a PDF sized 34"x22" to a real printer paper size 11"x17"  it has 4" margins and is visually cluttered on the paper.

 

I am trying to figure out a way to make the Batch Export to include either scaling 50% or forcing the paper size to 11x17 so the resulting PDFs are all 11x17, just like as if I had done the single export.

 

This is the first string, that functions PERFECTLY, but only does the open IDW.

 

'Save IDW as PDF

If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
	MsgBox("This Rule must be Run from a Drawing File", 64,"iLogic Message")
	Exit Sub
End If

Dim oDrawDoc As Document
oDrawDoc = ThisApplication.ActiveDocument
 
 Dim oPrintMgr As PrintManager
 oPrintMgr = oDrawDoc.PrintManager
 'specify your printer name
 oPrintMgr.Printer = "CutePDF Writer"
 
oPrintMgr.PrintRange = kPrintAllSheets
oPrintMgr.AllColorsAsBlack = True
oPrintMgr.Orientation = kPortraitOrientation
oPrintMgr.Scale = kPrintBestFitScale
oPrintMgr.PaperSize = kPaperSizeLedger
oPrintMgr.SubmitPrint



'	oDoc = ThisDoc.Document

'	Dim oFileDlg As Inventor.FileDialog = Nothing
'	InventorVb.Application.CreateFileDialog(oFileDlg)
'	oFileDlg.InitialDirectory = ThisDoc.WorkspacePath()
'	oFileDlg.FileName = iProperties.Value("Project", "Part Number")
'	oFileDlg.CancelError = True
'	On Error Resume Next
'	oFileDlg.ShowSave()
'		If Err.Number <> 0 Then
'		MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled")
'		ElseIf oFileDlg.FileName <> "" Then
'		MyFile = oFileDlg.FileName & ".pdf"
'		End If

'  ' Get the PDF translator Add-In. 
'  Dim oPDFTrans As TranslatorAddIn 
'  	  oPDFTrans = ThisApplication.ApplicationAddIns.ItemById( _ 
'                          "{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") 
'  If oPDFTrans Is Nothing Then 
'    MsgBox ("Could not access PDF translator.", 64, "iLogic Message")
'    Exit Sub 
'  End If  

'  ' Create some objects that are used to pass information to the translator Add-In.  
'  Dim oContext As TranslationContext 
'      oContext = ThisApplication.TransientObjects.CreateTranslationContext 
'  Dim oOptions As NameValueMap 
'      oOptions = ThisApplication.TransientObjects.CreateNameValueMap 
'  Dim oData As DataMedium 
'      oData = ThisApplication.TransientObjects.CreateDataMedium

'  If oPDFTrans.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then 
'    oOptions.Value("Sheet_Range") = kPrintAllSheets
'    oContext.Type = kFileBrowseIOMechanism 
'    oData.FileName = MyFile
'  End If
	
'   ' Call the translator. 
'        oPDFTrans.SaveCopyAs(ThisApplication.ActiveDocument,oContext, oOptions, oData) 

		


 

 

And this Below is the Batch editor that prints in true size,  this is the one i need to edit to include the resize but i am not sure how.

 

'PDF all IDW in Directory.iLogicVb:

    Dim oFileDlg As Inventor.FileDialog = Nothing
	InventorVb.Application.CreateFileDialog(oFileDlg)
	oFileDlg.InitialDirectory = "C:\$Workspace\Engineering Data"
	oFileDlg.CancelError = True
	oFileDlg.MultiSelectEnabled = False
	oFileDlg.Filter = "All Files (*.*)|*.*"
	oFileDlg.DialogTitle = "Choose a Directory with IDW's and/or Sub-Directories with IDW's"
	
	On Error Resume Next
	oFileDlg.ShowOpen()
	If Err.Number <> 0 Then
		Return
	ElseIf oFileDlg.FileName <> "" Then
		oPath = System.IO.Path.GetDirectoryName(oFileDlg.FileName)
	End If
    
    If MsgBox("This will write PDF files from all idw files in this location: " & vbCr & vbCr & _
		oPath & vbCr & vbCr & " *** Are you sure you want to do this? ***", vbOKCancel + vbExclamation, _
		"Batch Write PDF Files") = vbCancel Then Exit Sub
    
    'get PDF target folder path
    oFolder = 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
    
    Dim MyFiles As String()
    ' Sets up the variable "MyFile" to be each file in the directory
    ' This example looks for all the files that have an .idw extension.
    ' This can be changed to whatever extension is needed. Also, this
    ' macro searches the current directory and all sub-directories. 
    
    MyFiles = System.IO.Directory.GetFiles(oPath, "*.idw", System.IO.SearchOption.AllDirectories)
    
   ' Starts the Loop, which will Continue Until there are no more files found.
    For Each MyFile As String In MyFiles
        ' Opens the file and saves as PDF. This can be
        ' changed to any procedure that would be needed to run on every
        ' file in the directory such as opening each file.
		
        ThisApplication.SilentOperation = True
        Dim partDoc As Document = ThisApplication.Documents.Open(MyFile, False)
			
        On Error Resume Next
		  
        	If partDoc.DocumentType = kDrawingDocumentObject Then
			
				oFileName = IO.Path.GetFileName(partDoc.FullFileName)		
				oFileName = Left(oFileName, Len(oFileName) -4)		
				oFileName = oFolder & "\" & oFileName & ".pdf"
        		oPDFAddIn = partDoc.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") = 0
            		oOptions.Value("Remove_Line_Weights") = 1
            		oOptions.Value("Vector_Resolution") = 400
            		oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
            		'oOptions.Value("Custom_Begin_Sheet") = 1
            		'oOptions.Value("Custom_End_Sheet") = 4
        		End If
				oDataMedium.FileName = oFileName
				partDoc.SaveAs(oFileName, True)
			End If
			
        	partDoc.Close(False)
        	partDoc = Nothing
			ThisApplication.SilentOperation = False

    Next

Shell("explorer.exe " & oFolder,vbNormalFocus)

 

Any Insite would be great, I've searched the forums and find lots of relevant posts but nothing that I can get working.

 

[Inventor 2020, Updated. 

Intel Xeon e5-1620

26gb ram

Quadro K4000]