Print Sheets with Different Orientation

Print Sheets with Different Orientation

donaldleigh
Advocate Advocate
1,045 Views
4 Replies
Message 1 of 5

Print Sheets with Different Orientation

donaldleigh
Advocate
Advocate

Evening all

 

I have the following rule that prints all the drawings that are open to my printer. This works great but if you have a drawing with 2 or more sheets that are in different Orientation all the sheets in that drawing print in the Orientation that the 1st sheet is.

 

Can anyone please let me know where I am going wrong. As you see I can get the rule to recognize the correct orientation of each sheet but still prints all of them the same as the 1st sheet.

 

Donald

'NumberCopies = InputBox("Enter Number of Copies", "Print Manager", "1")
Dim oDrawDoc As Inventor.Document

Dim SheetOrientation As String

For Each oDrawDoc In ThisApplication.Documents.VisibleDocuments

    If (oDrawDoc.documenttype = kDrawingDocumentObject) Then 'Found a drawing
        Dim oSheet As Sheet 
        For Each oSheet In oDrawDoc.Sheets 
            oSheet.Activate 
            
            SheetOrientation = ThisApplication.ActiveDocument.ActiveSheet.Orientation
            
            Dim oPrintMgr As PrintManager
            oPrintMgr = oDrawDoc.PrintManager

            Dim sMyPrinter As String
            sMyPrinter = "\\AWE-SVR-01\KONICA MINOLTA C284 PCL"

            oPrintMgr.Printer = sMyPrinter
            oPrintMgr.ColorMode = kPrintDefaultColorMode
            oPrintMgr.PrintRange = kPrintAllSheets
            
            If SheetOrientation = "10242" Then ' Sheet is Landscape
                oPrintMgr.Orientation = kLandscapeOrientation
                MessageBox.Show("Landscape", "Title")
            Else If SheetOrientation = "10243" Then ' Sheet is Portrait
                oPrintMgr.Orientation = kPortraitOrientation
                MessageBox.Show("Portrait", "Title")
            End If
            
            'oPrintMgr.Orientation = kOrientation
            oPrintMgr.Scale = kPrintBestFitScale
            oPrintMgr.PaperSize = kPaperSizeB
            'oPrintMgr.NumberOfCopies = NumberCopies
            'MessageBox.Show("Printed " & NumberCopies, "Title")
            'oPrintMgr.SubmitPrint
        Next
    End If
Next

ActiveSheet = ThisDrawing.Sheet("Sheet:1")

 

0 Likes
1,046 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

I see a couple of things that may be causing trouble. If you're going to Activate & Submit your print per sheet, then you definately don't want to tell it to send all pages to the printer for each sheet loop.  Also, if you define the document you're working with as a drawing document, not just by eliminating other types, then you can use the DrawingPrintManager, which has more options specific to drawing documents.  Also, as you'll notice in my code below, there is a difference between PrintOrientationTypeEnum settings and PageOrientationTypeEnum. Try this.

For Each oIDW As DrawingDocument In ThisApplication.Documents.VisibleDocuments
	Dim oPrintMgr As DrawingPrintManager = oIDW.PrintManager
	oPrintMgr.Printer = "\\AWE-SVR-01\KONICA MINOLTA C284 PCL"
	oPrintMgr.AllColorsAsBlack = False
	oPrintMgr.ColorMode = PrintColorModeEnum.kPrintDefaultColorMode
	oPrintMgr.NumberOfCopies = InputBox("Enter Number of Copies.", "Drawing Print Manager", "1")
	oPrintMgr.PrintRange = PrintRangeEnum.kPrintCurrentSheet
	oPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
	oPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeB0
	oPrintMgr.PrintExcludedSheets = False
	oPrintMgr.RemoveLineWeights = False
	'oPrintMgr.Rotate90Degrees = False
	
	For Each oSheet As Sheet In oIDW.Sheets
		oSheet.Activate
		If oSheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation Then
			oPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation
		ElseIf oSheet.Orientation = PageOrientationTypeEnum.kPortraitPageOrientation Then
			oPrintMgr.Orientation = PrintOrientationEnum.kPortraitOrientation
		ElseIf oSheet.Orientation = PageOrientationTypeEnum.kDefaultPageOrientation Then
			oPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation
		End If
		oPrintMgr.SubmitPrint
	Next
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

donaldleigh
Advocate
Advocate

Hi @WCrihfield 

 

I have finally got back to this issue now we have upgraded from 2014 to 2021

 

When I tried your code I get an error at the very 1st line of the rule. (see attached)

 

Also in my original code since upgrading to Inventor 2021 every time we use this rule if the current drawing open has 2 or more sheets it printed them twice (each sheet) but all the other drawings that are open in the background print once even if multiple sheets.

 

Donald  

0 Likes
Message 4 of 5

donaldleigh
Advocate
Advocate

Error Attached

0 Likes
Message 5 of 5

JhoelForshav
Mentor
Mentor

@donaldleigh 

That problem occurs because you have documents open that are not drawing documents.

Just make sure that the code only runs for drawing documents like this.

 

For Each oIDW As Document In ThisApplication.Documents.VisibleDocuments
	If oIDW.DocumentType = DocumentTypeEnum.kDrawingDocumentObject
		Dim oPrintMgr As DrawingPrintManager = oIDW.PrintManager
		oPrintMgr.Printer = "\\AWE-SVR-01\KONICA MINOLTA C284 PCL"
		oPrintMgr.AllColorsAsBlack = False
		oPrintMgr.ColorMode = PrintColorModeEnum.kPrintDefaultColorMode
		oPrintMgr.NumberOfCopies = InputBox("Enter Number of Copies.", "Drawing Print Manager", "1")
		oPrintMgr.PrintRange = PrintRangeEnum.kPrintCurrentSheet
		oPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
		oPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeB0
		oPrintMgr.PrintExcludedSheets = False
		oPrintMgr.RemoveLineWeights = False
		'oPrintMgr.Rotate90Degrees = False

		For Each oSheet As Sheet In oIDW.Sheets
			oSheet.Activate
			If oSheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation Then
				oPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation
			ElseIf oSheet.Orientation = PageOrientationTypeEnum.kPortraitPageOrientation Then
				oPrintMgr.Orientation = PrintOrientationEnum.kPortraitOrientation
			ElseIf oSheet.Orientation = PageOrientationTypeEnum.kDefaultPageOrientation Then
				oPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation
			End If
			oPrintMgr.SubmitPrint
		Next
	End If
Next
0 Likes