Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Printing with VB .Net

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
GeorgK
1892 Views, 4 Replies

Printing with VB .Net

Hello together,

 

is there a complete sample for printing on different printers, paper size, scale mode, sheets, orientation, color, line weights, preview and paper source?

 

Thank you very much

 


Georg

4 REPLIES 4
Message 2 of 5
skyngu
in reply to: GeorgK

no, there is not a complete sample.

Autodesk Inventor Professional 2019
Message 3 of 5
GeorgK
in reply to: GeorgK

Do you have some examples?

Message 4 of 5
saseendrankombath
in reply to: GeorgK

This code is used for printing to 3 different printers, please note that the identification of paper size and oreintation is done by checking the boarder size which I am using. change it accordingly.

 Private Sub oButtonAutoPrint_OnExecute(Context As Inventor.NameValueMap) Handles oButtonAutoPrint.OnExecute
            Try
                Dim oDoc As Inventor.DrawingDocument
                oDoc = m_inventorApplication.ActiveDocument

                Dim oSheet As Inventor.Sheet
                oSheet = oDoc.ActiveSheet

                Dim oPM As Inventor.PrintManager
                oPM = oDoc.PrintManager

                Dim strPrinter As String = Nothing

                If oSheet.Border.Name = "IP-A4R" Then
                    oPM.Printer = "HP LaserJet 1022"
                    oPM.ColorMode = PrintColorModeEnum.kPrintGrayScale
                    oPM.PaperSize = PaperSizeEnum.kPaperSizeA4
                    oPM.Orientation = PrintOrientationEnum.kLandscapeOrientation
                    oPM.NumberOfCopies = 1
                    oPM.scalemode = Inventor.PrintScaleModeEnum.kPrintBestFitScale
                    oPM.printrange = Inventor.PrintRangeEnum.kPrintCurrentSheet
                    oPM.RemoveLineWeights = True
                ElseIf oSheet.Border.Name = "IP-A4" Then
                    oPM.Printer = "HP LaserJet 1022"
                    oPM.ColorMode = PrintColorModeEnum.kPrintGrayScale
                    oPM.PaperSize = PaperSizeEnum.kPaperSizeA4
                    oPM.Orientation = PrintOrientationEnum.kPortraitOrientation
                    oPM.NumberOfCopies = 1
                    oPM.scalemode = Inventor.PrintScaleModeEnum.kPrintBestFitScale
                    oPM.printrange = Inventor.PrintRangeEnum.kPrintCurrentSheet
                    oPM.RemoveLineWeights = True
                ElseIf oSheet.Border.Name = "IP-A3" Then
                    oPM.Printer = "HP Officejet Pro K850 Series"
                    oPM.ColorMode = PrintColorModeEnum.kPrintColorPalette
                    oPM.PaperSize = PaperSizeEnum.kPaperSizeA3
                    oPM.Orientation = PrintOrientationEnum.kLandscapeOrientation
                    oPM.NumberOfCopies = 1
                    oPM.scalemode = Inventor.PrintScaleModeEnum.kPrintBestFitScale
                    oPM.printrange = Inventor.PrintRangeEnum.kPrintCurrentSheet
                    oPM.RemoveLineWeights = True
                ElseIf oSheet.Border.Name = "IP-A2" Then
                    oPM.Printer = "HP Designjet 500 42+HPGL2 Card"
                    oPM.ColorMode = PrintColorModeEnum.kPrintColorPalette
                    oPM.PaperSize = PaperSizeEnum.kPaperSizeA2
                    oPM.Rotate90Degrees = True
                    oPM.Orientation = PrintOrientationEnum.kPortraitOrientation
                    oPM.NumberOfCopies = 1
                    oPM.scalemode = Inventor.PrintScaleModeEnum.kPrintBestFitScale
                    oPM.printrange = Inventor.PrintRangeEnum.kPrintCurrentSheet
                    oPM.RemoveLineWeights = True
                ElseIf oSheet.Border.Name = "IP-A1" Then
                    oPM.Printer = "HP Designjet 500 42+HPGL2 Card"
                    oPM.ColorMode = PrintColorModeEnum.kPrintColorPalette
                    oPM.PaperSize = PaperSizeEnum.kPaperSizeA1
                    oPM.Rotate90Degrees = True
                    oPM.Orientation = PrintOrientationEnum.kPortraitOrientation
                    oPM.NumberOfCopies = 1
                    oPM.scalemode = Inventor.PrintScaleModeEnum.kPrintBestFitScale
                    oPM.printrange = Inventor.PrintRangeEnum.kPrintCurrentSheet
                    oPM.RemoveLineWeights = True
                ElseIf oSheet.Border.Name = "IP-A0" Then
                    oPM.Printer = "HP Designjet 500 42+HPGL2 Card"
                    oPM.ColorMode = PrintColorModeEnum.kPrintColorPalette
                    oPM.PaperSize = PaperSizeEnum.kPaperSizeA0
                    oPM.Rotate90Degrees = True
                    oPM.Orientation = PrintOrientationEnum.kPortraitOrientation
                    oPM.NumberOfCopies = 1
                    oPM.scalemode = Inventor.PrintScaleModeEnum.kPrintBestFitScale
                    oPM.printrange = Inventor.PrintRangeEnum.kPrintCurrentSheet
                    oPM.RemoveLineWeights = True
                End If

                oPM.SubmitPrint()

                If oSheet.Border.Name = "IP-A2" Then
                    MsgBox("Please Load A2 Paper (Portrait) on " & strPrinter, MsgBoxStyle.Information, " Automated Printing")
                ElseIf oSheet.Border.Name = "IP-A1" Then
                    MsgBox("Please Load A1 Paper (Portrait) on " & strPrinter, MsgBoxStyle.Information, " Automated Printing")
                ElseIf oSheet.Border.Name = "IP-A0" Then
                    MsgBox("Please Load A0 Paper (Roll) on " & strPrinter, MsgBoxStyle.Information, " Automated Printing")
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

 

Message 5 of 5
GeorgK
in reply to: GeorgK

Thank you very much for your example.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report