Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I have this rule for batch printing, it checks the sheet sizes and sends different size sheets to different printers. It works great except for one thing.. It doesn't print in numerical order. Is there a way in iLogic to sort the components of an assembly and then print them in that order?
'THIS RULE WILL PRINT THE .idw OF ALL COMPONENTS IN THE ACTIVE ASSEMBLY Dim Bldg1_Asize = "\\server3.eac.local\Design-CM" Dim Bldg1_Bsize = "\\server3.eac.local\Design-CM" Dim Bldg1_Dsize = "\\server3.eac.local\DESIGN-D2" Dim Bldg2_Asize = "\\server3.eac.local\BUILDING2-CM" Dim Bldg2_Bsize = "\\server3.eac.local\BUILDING2-CM" Dim Bldg2_Dsize = "\\server3.eac.local\BUILDING2-D1" '---PICK LOCATION OF PRINTERS--- PrintLocation = InputRadioBox("Where would you like to print?", "Bldg.1", "Bldg.2", booleanParam, Title := "Printer location") Dim Aprinter As String If PrintLocation = True Then Aprinter = Bldg1_Asize Else Aprinter = Bldg2_Asize End If Dim Bprinter As String If PrintLocation = True Then Bprinter = Bldg1_Bsize Else Bprinter = Bldg2_Bsize End If 'Dim Cprinter = Dim Dprinter As String If PrintLocation = True Then Dprinter = Bldg1_Dsize Else Dprinter = Bldg2_Dsize End If Dim Asize = 9987 Dim Bsize = 9988 Dim Csize = 9989 Dim Dsize = 9990 '---CHECK THAT THE ACTIVE DOCUMENT IS AN ASSEMBLY--- If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If '---DEACTIVATE VAULT--- Dim oVault As ApplicationAddIn For Each oVault In ThisApplication.ApplicationAddIns If oVault.DisplayName = "Inventor Vault" Then Exit For Next If oVault IsNot Nothing Then oVault.Deactivate '---DEFINE THE ACTIVE DOCUMENT AS AN ASSEMBLY--- Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) '---NOTICE REQUIRING USER INPUT--- If PrintLocation = True Then RUsure = MessageBox.Show ( _ "You will be printing to Building 1." _ & vbLf & " This could take a while. Do you want to continue? " _ & vbLf & "", "Notice", MessageBoxButtons.YesNo) Else RUsure = MessageBox.Show ( _ "You will be printing to Building 2." _ & vbLf & " This could take a while. Do you want to continue? " _ & vbLf & "", "Notice", MessageBoxButtons.YesNo) End If If RUsure = vbNo Then oVault.Activate Return Else End If '---DETERMINE IF PRINTS SHOULD BE IN COLOR--- oColorAsBlack="False" 'RUsure = MessageBox.Show ( "Do you want to print this in COLOR?"& vbLf & "", "Color or B/W Prints",MessageBoxButtons.YesNo) 'If RUsure = vbNo Then 'oColorAsBlack="True" 'Return 'Else 'End If Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document numFiles = 0 '---COMPONENT DRAWINGS--- For Each oRefDoc In oRefDocs idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" If (System.IO.File.Exists(idwPathName)) Then numFiles = numFiles + 1 'If numFiles = 10 Then Exit Sub Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) oDrawDoc.Activate oDrawDoc = ThisApplication.ActiveDocument oDrgPrintMgr = oDrawDoc.PrintManager oDrgPrintMgr.AllColorsAsBlack = oColorAsBlack If oDrawDoc.ActiveSheet.Size = Asize Then oDrawDoc.PrintManager.Printer = Aprinter oDrgPrintMgr.PaperSize = kPaperSizeLetter oDrgPrintMgr.Orientation = kLandscapeOrientation oDrgPrintMgr.ScaleMode = kPrintFullScale Else If oDrawDoc.ActiveSheet.Size = Bsize Then oDrawDoc.PrintManager.Printer = Bprinter oDrgPrintMgr.PaperSize = kPaperSize11x17 oDrgPrintMgr.Orientation = kLandscapeOrientation oDrgPrintMgr.ScaleMode = kPrintFullScale 'Else If oDrawDoc.ActiveSheet.Size = Csize Then ' oDrawDoc.PrintManager.Printer = Cprinter ' oDrgPrintMgr.PaperSize = kPaperSize17x22 ' oDrgPrintMgr.Orientation = kLandscapeOrientation ' oDrgPrintMgr.ScaleMode = kPrintFullScale Else If oDrawDoc.ActiveSheet.Size = Dsize Then oDrawDoc.PrintManager.Printer = Dprinter oDrgPrintMgr.PaperSize = kPaperSize22x34 oDrgPrintMgr.Orientation = kLandscapeOrientation oDrgPrintMgr.ScaleMode = kPrintFullScale Else MessageBox.Show("Sheet size not supported. Print will be scaled to fit on A size.", "Error") oDrawDoc.PrintManager.Printer = Aprinter oDrgPrintMgr.PaperSize = kPaperSizeLetter oDrgPrintMgr.Orientation = kLandscapeOrientation oDrgPrintMgr.ScaleMode = kPrintBestFitScale End If oDrgPrintMgr.PrintRange = kPrintAllSheets'Prints all sheets in the idw. oDrgPrintMgr.NumberOfCopies = 1 ' Set to print one copies. oDrgPrintMgr.SubmitPrint ' Submit the print. oDrawDoc.Close (True) End If Next 'MsgBox ("There are " & numFiles & " sent to printer.") '---TOP LEVEL DRAWING--- oAsmDrawing = ThisDoc.ChangeExtension(".idw") If (System.IO.File.Exists(oAsmDrawing)) Then oAsmDrawingDoc = ThisApplication.Documents.Open(oAsmDrawing, True) oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -3) oAsmDrawDoc = ThisApplication.Documents.Open(oAsmDrawing, True) oAsmDrawDoc.Activate oDrgPrintMgr = oAsmDrawDoc.PrintManager oDrgPrintMgr.AllColorsAsBlack = oColorAsBlack If oAsmDrawDoc.ActiveSheet.Size = Asize Then oAsmDrawDoc.PrintManager.Printer = Aprinter oDrgPrintMgr.PaperSize = kPaperSizeLetter oDrgPrintMgr.Orientation = kLandscapeOrientation oDrgPrintMgr.ScaleMode = kPrintFullScale Else If oAsmDrawDoc.ActiveSheet.Size = Bsize Then oAsmDrawDoc.PrintManager.Printer = Bprinter oDrgPrintMgr.PaperSize = kPaperSize11x17 oDrgPrintMgr.Orientation = kLandscapeOrientation oDrgPrintMgr.ScaleMode = kPrintFullScale 'Else If oDrawDoc.ActiveSheet.Size = Csize Then ' oDrawDoc.PrintManager.Printer = Cprinter ' oDrgPrintMgr.PaperSize = kPaperSize17x22 ' oDrgPrintMgr.Orientation = kLandscapeOrientation ' oDrgPrintMgr.ScaleMode = kPrintFullScale Else If oAsmDrawDoc.ActiveSheet.Size = Dsize Then oAsmDrawDoc.PrintManager.Printer = Dprinter oDrgPrintMgr.PaperSize = kPaperSize22x34 oDrgPrintMgr.Orientation = kLandscapeOrientation oDrgPrintMgr.ScaleMode = kPrintFullScale Else MessageBox.Show("Sheet size not supported. Print will be scaled to fit on A size.", "Error") oAsmDrawDoc.PrintManager.Printer = Aprinter oDrgPrintMgr.PaperSize = kPaperSizeLetter oDrgPrintMgr.Orientation = kLandscapeOrientation oDrgPrintMgr.ScaleMode = kPrintBestFitScale End If oDrgPrintMgr.PrintRange = kPrintAllSheets'Prints all sheets in the idw. oDrgPrintMgr.NumberOfCopies = 1 ' Set to print one copies. oDrgPrintMgr.SubmitPrint ' Submit the print. oAsmDrawDoc.Close (True) numFiles = numFiles + 1 Else MessageBox.Show (" No IDW of the Top level file found!" _ & vbLf & " " _ & vbLf & "There were " & numFiles & " files sent to the printer."," Job Complete ") Return End If '---REACTIVATE VAULT--- oVault.Activate MessageBox.Show ("There were " & numFiles & " files sent to the printer."," Job Complete ") 'MessageBox.Show("New Files Created in: " & vbLf & idwpathname, "iLogic")'open the folder where the new ffiles are saved'Shell("explorer.exe " & oFolder,vbNormalFocus)
Solved! Go to Solution.