Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: Anonymous

So I thought I would expand a little further in case someone in the future comes across this and wants to do something similar. Some of our drawings are on different size sheets (Letter, 11x17, ANSI D) so i'm reading the sheet size from each drawing file and converting that according to the PaperSize Enumerator from the programming help. The code isn't perfect - if anything in the "Try" section fails, it will say "File Not Found" even if it actually did find the file. But this is a very good start to what we need to accomplish.

 

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oDrawingView As DrawingView
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim oPartList As PartsList

oPartList = oSheet.PartsLists(1)
 
oDrgPrintMgr = oDrawDoc.PrintManager
oDrgPrintMgr.Printer = "PDFCreator"
oDrgPrintMgr.PrintRange = kPrintAllSheets
oDrgPrintMgr.AllColorsAsBlack = False
oDrgPrintMgr.ScaleMode = kPrintBestFitScale 'oDrgPrintMgr.ScaleMode = kPrintModel
oDrgPrintMgr.ColorMode = kPrintDefaultColorMode
oDrgPrintMgr.PaperSize = SizeActiveSheet
oDrgPrintMgr.SubmitPrint

Dim drawBomRow As DrawingBOMRow
Dim refDoc As Document

For Each oPartListRow In oPartList.PartsListRows
	If oPartListRow.Visible = "True" And oPartListRow.Custom = "False" Then
		Try
		drawBomRow = oPartListRow.ReferencedRows.Item(1)
		refDoc = drawBomRow.BOMRow.ComponentDefinitions.Item(1).Document
		FilePath = refDoc.FullFileName()
		FilePath = Left(FilePath,Len(FilePath)-3) & "idw"
		ThisApplication.Documents.Open(FilePath,True)
		Dim oDrawDoc2 As DrawingDocument = ThisApplication.ActiveDocument
		
		'use PaperSizeEnum from inventor programming help
		PageSize = oDrawDoc2.ActiveSheet.Size
		If PageSize = 9990 Then
			PageSize = 14347
		End If
		If PageSize = 9987 Then
			PageSize = 14353
		End If
		If PageSize = 9988 Then
			PageSize = 14338
		End If
		
		oDrgPrintMgr2 = oDrawDoc2.PrintManager
		oDrgPrintMgr2.Printer = "PDFCreator"
		oDrgPrintMgr2.PrintRange = kPrintAllSheets
		oDrgPrintMgr2.AllColorsAsBlack = False
		oDrgPrintMgr2.ScaleMode = kPrintBestFitScale 'oDrgPrintMgr.ScaleMode = kPrintModel
		oDrgPrintMgr2.ColorMode = kPrintDefaultColorMode
		oDrgPrintMgr2.PaperSize = PageSize
		oDrgPrintMgr2.SubmitPrint
		ThisApplication.ActiveDocument.Close(True)
		Catch
		drawBomRow = oPartListRow.ReferencedRows.Item(1)
		refDoc = drawBomRow.BOMRow.ComponentDefinitions.Item(1).Document
		FilePath = refDoc.FullFileName()
		FilePath = Left(FilePath,Len(FilePath)-3) & "idw"
		MessageBox.Show(FilePath, "File Not Found")		
		End Try
	End If
Next