Ilogic to print drawings that rescales to the drawing format size
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Trying to make an Ilogic that looks for the drawing of every individual part in an assembly and the assembly drawing even if the drawing is located outside of the main folder and prints the drawing at a different size depending on what format its on. So if the printer is set to "Adobe PDF" by default and the drawing it opens has a format labeled "A-SIZE" print to pdf in letter scale or 8.5 x 11 and if its "B-size" to be ansi B or 11 x 17 and so on up to "D-SIZE". I have a bunch of variations all either doing a fraction of what i need it to do all together. I want to be able to hit run, drawing open, drawing print to scale defined, then drawing closes and opens the next one to repeat. here's what I have so far that really only prints to PDF but for some strange reason it changes my default print to microsoft print to pdf :
Sub Main() ' Rev 1 Try Dim oDoc As Document = ThisApplication.ActiveDocument Dim oDocName As String = oDoc.DisplayName Dim sFileName As String = System.IO.Path.GetFileNameWithoutExtension(oDocName) Dim sDrawingName As String = sFileName & ".idw" ' Search for the drawing in all subfolders Dim allFiles As String() = System.IO.Directory.GetFiles(System.IO.Path.GetDirectoryName(oDoc.FullFileName), "*.idw", System.IO.SearchOption.AllDirectories) For Each file In allFiles If System.IO.Path.GetFileName(File).ToLower() = sDrawingName.ToLower() Then ' Open the found drawing file ThisApplication.Documents.Open(File, True) ' Check the sheet size Dim activeSheet As Sheet = ThisApplication.ActiveDocument.ActiveSheet Dim sheetSize As String = activeSheet.Size.ToString() ' Display the sheet size MsgBox("Sheet size: " & sheetSize, MsgBoxStyle.Information, "Sheet Size") ' Save the drawing as a PDF Dim pdfPath As String = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(File), sFileName & ".pdf") ThisApplication.ActiveDocument.SaveAs(pdfPath, True) ' Print the PDF using the default system printer Dim shellCommand As String = "rundll32.exe printui.dll,PrintUIEntry /y /n " & Chr(34) & "Microsoft Print to PDF" & Chr(34) & " " & Chr(34) & pdfPath & Chr(34) Shell(shellCommand, AppWinStyle.Hide, True) Exit Sub End If Next ' If still not found, show an error message MsgBox("Couldn't find the associated drawing.", MsgBoxStyle.Exclamation, "Error") Catch ex As Exception ' Handle any exceptions MsgBox("Error: " & ex.Message, MsgBoxStyle.Critical, "Error") End Try End Sub
I was thinking calling out SheetSize and for all 4 sizes just say If "A-SIZE.idw" then print to letter If "B-SIZE.idw" Print to 11 x 17 paper