@WCrihfield OK, I gave it a try (my code for reference is below) and no printing seems to take place while the drawings are loading false. It will print when they are loading true. I tried it both with a physical printer as well as PDF (ultimately, I will be using PDF with this). I wonder if there is another attribute that needs to be set in the Drawing Printer Manager that will allow false loaded drawings to be printed. Let me know what you think. thanks.
Sub Main()
Dim oAssyDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oDrawDoc As DrawingDocument
Dim ParentItemNumber As String = "0"
Dim DrawingPath As String = "C:\Vault\Master Models\Clarifier\Drawings\"
'[Gets drawing file name from assembly/part filename
AssyFullFileName = oAssyDoc.FullFileName
'strips path
AssyFileName = Right(AssyFullFileName, Len(AssyFullFileName) -InStrRev(AssyFullFileName, "\"))
'strips extension
AssyName = Left(AssyFileName, Len(AssyFileName) -4)
'adds drawing path and extension
AssyDrawingFileName = DrawingPath & AssyName & ".idw"
']
'Prints Top Level Assembly Drawing
'Opens prints and closes drawing with filename that matches the assembly that this rule is run from.
Try
oDrawDoc = ThisApplication.Documents.Open(AssyDrawingFileName, True)
PrintBG(oDrawDoc, ParentItemNumber)
If InStr(oDrawDoc.PropertySets.Item("Inventor User Defined Properties").Item("Drawing Type").Value, "Assembly") > 0 Then
MsgBox("Running child from main level")
Child(oAssyDoc, ParentItemNumber, DrawingPath)
End If
oDrawDoc.Close(True)
Catch
End Try
End Sub
Sub Child(oAssyDoc As AssemblyDocument, ParentItemNumber As String, DrawingPath As String)
Dim oBOM As BOM = oAssyDoc.ComponentDefinition.BOM
Dim oBOMView As BOMView = oBOM.BOMViews.Item("Structured")
Dim oBOMRow As BOMRow
'Prints Fabrication Drawings and additional assembly drawings that exist in the BOM.
'Checks each item in BOM with greater than 0 qty for drawing with matching filename in the given directory, opens, prints, and closes.
For Each oBOMRow In oBOMView.BOMRows
If oBOMRow.ItemQuantity > 0 Then
'[Gets drawing file name from assembly/part filename
FullFileName = oBOMRow.ComponentOccurrences.Item(1).Definition.Document.FullFileName
'strips path
FileName = Right(FullFileName, Len(FullFileName) -InStrRev(FullFileName, "\"))
'strips extension
Name = Left(FileName, Len(FileName) -4)
'adds drawing path and extension
DrawingFileName = DrawingPath & Name & ".idw"
']
'If a drawing with the same filename from the BOM is found, it is opened and printed
'Determines if drawing is an assembly drawing that may have children drawings
Try
oDrawDoc = ThisApplication.Documents.Open(DrawingFileName, True)
ItemNumber = ParentItemNumber & "." & oBOMRow.ItemNumber
PrintBG(oDrawDoc, ItemNumber)
If InStr(oDrawDoc.PropertySets.Item("Inventor User Defined Properties").Item("Drawing Type").Value, "Assembly") > 0 Then
MsgBox("Running child from child" & vbNewLine & oBOMRow.ItemNumber)
Child(oBOMRow.ComponentOccurrences.Item(1).Definition.Document, ParentItemNumber & "." & oBOMRow.ItemNumber, DrawingPath)
End If
oDrawDoc.Close(True)
Catch
'If nothing is found, nothing is done
End Try
End If
Next
End Sub
Sub PrintBG(oDrawDoc As DrawingDocument, ItemNumber As String)
'Print all sheets in drawing document
'Get the active document and check whether it's drawing document
'If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
'Dim oDrgDoc As DrawingDocument
'oDrgDoc = ThisApplication.ActiveDocument
' Set reference to drawing print manager
' DrawingPrintManager has more options than PrintManager
' as it's specific to drawing document
Dim oDrgPrintMgr As DrawingPrintManager
oDrgPrintMgr = oDrawDoc.PrintManager
' Set the printer name
' comment this line to use default printer or assign another one
oDrgPrintMgr.Printer = "PDF-XChange Standard"
'oDrgPrintMgr.Printer = "\\minnie\MyQ Black & White"
'Set the paper size , scale and orientation
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
oDrgPrintMgr.PaperSize = kPaperSizeA4
oDrgPrintMgr.PrintRange = kPrintAllSheets
oDrgPrintMgr.Orientation = kLandscapeOrientation
oDrgPrintMgr.SubmitPrint
'End If
End Sub