Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I'm having an issue trying to get a working version of a code I came across here on the forums. My coding experience is very limited, but what I'm looking for: put all .dwgs for all .ipts into an array, display the missing parts before continuing, sort the array by file name or part number, then finally, print all the .dwgs. Currently, the missing parts portion works fine, but I can't get it over the finish line.
Here is my latest attempt to fit snippets I found here:
Sub Main '---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 '---CREATE LIST OF DWGs & MISSING DWGs--- Dim dwgList As New ArrayList Dim MissingList As New ArrayList Dim oAsm As AssemblyDocument = ThisDoc.Document numFiles = 0 For Each oRefDoc As Document In oAsm.AllReferencedDocuments dwgPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) -3) & "dwg" dwgName = oRefDoc.DisplayName If (System.IO.File.Exists(dwgPathName)) Then numFiles = numFiles + 1 dwgList.Add(dwgPathName) Else MissingList.Add(dwgName) End If Next dwgList.Sort MissingList.Sort Dim oText As String 'Added For i As Integer = 0 To MissingList.Count - 1 If i = 0 Then oText = MissingList(i) Else oText = oText & vbLf & MissingList(i) End If Next '---SHOW MISSING DWG LIST--- If oText = "" Then Else RUsure = MessageBox.Show( _ "No .dwg found for.." _ & vbLf & "" _ & vbLf & oText _ & vbLf & "" _ & vbLf & "Continue?", "Notice", MessageBoxButtons.YesNo) If RUsure = vbNo Then Return Else End If End If For Each dwgName In dwgList Call PrintDocument(DwgPath) Next End Sub Function PrintDocument(DwgPath As String) Dim OpenVisible As Boolean = True Dim oDrawDoc As DrawingDocument = ThisApplication.Documents.Open(DwgPath, OpenVisible) Dim oPrintMgr As PrintManager = oDrawDoc.PrintManager With oPrintMgr .Printer = "\\lse-cep-data\Copier Office" .AllColorsAsBlack = True .ScaleMode = kPrintBestFitScale .ColorMode = kPrintDefaultColorMode .PrintRange = kPrintAllSheets .NumberOfCopies = 1 .Orientation = kLandscapeOrientation ' .PaperSize = oPaperSize .SubmitPrint End With oDrawDoc.Close End Function
Any help appreciated!
Solved! Go to Solution.