Print only A4 Sheets in a Drawing

Print only A4 Sheets in a Drawing

CCarreiras
Mentor Mentor
1,088 Views
9 Replies
Message 1 of 10

Print only A4 Sheets in a Drawing

CCarreiras
Mentor
Mentor

Hi!

 

The goal:

is to print only the A4 size sheets in a multisheet drawing (Portrait and landscape).

Im using the code below to select only the A4 size sheets and print them.

 

Problem:

When i print, it select well the number, size and orientation for the A4 sheets in the document, but only print the content (views, border, Titleblock) of the active sheet.

 

i.e

If i have 4 sheets in the drawing,

Sheet 1 is not A4 and is active

Sheet 2 is A4 Portrait

Sheet3 is A4 Landscape

Sheet4 is not A4

 

then, it will print two paper sheets(correct): one size A4 and Portrait (from sheet2 specifications), other size A4 Landscape (from sheet 3 specifications), but both have the content of the sheet1 (active sheet)

 

Any help to correct this?

Thanks.

 

SyntaxEditor Code Snippet

'Define the drawing
Dim oDrawing As DrawingDocument
oDrawing = ThisApplication.ActiveDocument
Dim oSheet As Sheet

For Each oSheet In oDrawing.Sheets

		If oSheet.Size = kA4DrawingSheetSize And oSheet.Orientation = kPortraitPageOrientation Then
  			
			oPrintMgr = ThisApplication.ActiveDocument.PrintManager
			'oPrintMgr.ColorMode = kPrintGrayScale
			oPrintMgr.ColorMode = kPrintColorPalette
			oPrintMgr.NumberOfCopies = 1
			oPrintMgr.ScaleMode = kPrintFullScale
			oPrintMgr.Orientation = kPortraitOrientation
			'oPrintMgr.Orientation = kLandscapeOrientation
			oPrintMgr.PaperSize = kPaperSizeA4
			oPrintMgr.PaperHeight = 210 mm
			oPrintMgr.PaperWidth = 297 mm
			oPrintMgr.SubmitPrint
		End If 

		If oSheet.Size = kA4DrawingSheetSize And oSheet.Orientation = kLandscapePageOrientation Then 		
			oPrintMgr = ThisApplication.ActiveDocument.PrintManager
			'oPrintMgr.ColorMode = kPrintGrayScale
			oPrintMgr.ColorMode = kPrintColorPalette
			oPrintMgr.NumberOfCopies = 1
			oPrintMgr.ScaleMode = kPrintFullScale
			'oPrintMgr.Orientation = kPortraitOrientation
			oPrintMgr.Orientation = kLandscapeOrientation
			oPrintMgr.PaperSize =  kPaperSizeA4
			oPrintMgr.PaperHeight = 297 mm
			oPrintMgr.PaperWidth = 210 mm
			oPrintMgr.SubmitPrint			        
		End If
Next

 

CCarreiras

EESignature

0 Likes
Accepted solutions (2)
1,089 Views
9 Replies
Replies (9)
Message 2 of 10

bradeneuropeArthur
Mentor
Mentor

Code is a little modified.

Please use the correct declarations!!

You need to do this also with the printermanager declarations.

I assume you know how to do this now!

Dim oDrawing As Inventor.DrawingDocument
oDrawing = ThisApplication.ActiveDocument
Dim oSheet As Inventor.Sheet

For Each oSheet In oDrawing.Sheets

		If oSheet.Size =  Inventor.DrawingSheetSizeEnum.kA4DrawingSheetSize And oSheet.Orientation = Inventor.PageOrientationTypeEnum.kPortraitPageOrientation Then
  			
			oPrintMgr = ThisApplication.ActiveDocument.PrintManager
			'oPrintMgr.ColorMode = kPrintGrayScale
			oPrintMgr.ColorMode = kPrintColorPalette
			oPrintMgr.NumberOfCopies = 1
			oPrintMgr.ScaleMode = kPrintFullScale
			oPrintMgr.Orientation = kPortraitOrientation
			'oPrintMgr.Orientation = kLandscapeOrientation
			oPrintMgr.PaperSize = kPaperSizeA4
			oPrintMgr.PaperHeight = 210 mm
			oPrintMgr.PaperWidth = 297 mm
			oPrintMgr.SubmitPrint
		End If 

		If oSheet.Size = Inventor.DrawingSheetSizeEnum.kA4DrawingSheetSize And oSheet.Orientation = Inventor.PageOrientationTypeEnum.kLandscapePageOrientation Then 		
			oPrintMgr = ThisApplication.ActiveDocument.PrintManager
			'oPrintMgr.ColorMode = kPrintGrayScale
			oPrintMgr.ColorMode = kPrintColorPalette
			oPrintMgr.NumberOfCopies = 1
			oPrintMgr.ScaleMode = kPrintFullScale
			'oPrintMgr.Orientation = kPortraitOrientation
			oPrintMgr.Orientation = kLandscapeOrientation
			oPrintMgr.PaperSize =  kPaperSizeA4
			oPrintMgr.PaperHeight = 297 mm
			oPrintMgr.PaperWidth = 210 mm
			oPrintMgr.SubmitPrint			        
		End If
Next

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 10

CCarreiras
Mentor
Mentor

HI!

 

Thank you for your reply.

 

With your code i got the same result.

 

The question isnt about size or orientation, is about to activate the proper sheet to print.

It choose the size and orientation based in the rules, but print in every paper only the content of the active sheet in the moment i push the rule. 

CCarreiras

EESignature

0 Likes
Message 4 of 10

bradeneuropeArthur
Mentor
Mentor

For me this works:

Vba:

Public Sub main()

Dim oDrawing As Inventor.DrawingDocument
Set oDrawing = ThisApplication.ActiveDocument
Dim oSheet As Inventor.Sheet
Dim oPrintMgr As Inventor.PrintManager
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
For Each oSheet In oDrawing.Sheets
'MsgBox oSheet.Orientation

        If oSheet.Size = kA4DrawingSheetSize And oSheet.Orientation = kPortraitPageOrientation Then

            MsgBox "P"
            oPrintMgr.ColorMode = kPrintColorPalette
            oPrintMgr.NumberOfCopies = 1
            oPrintMgr.ScaleMode = kPrintFullScale
            oPrintMgr.Orientation = kPortraitOrientation

            oPrintMgr.PaperSize = kPaperSizeA4
            oPrintMgr.PaperHeight = 210
            oPrintMgr.PaperWidth = 297
            oPrintMgr.SubmitPrint
        End If

        If oSheet.Size = kA4DrawingSheetSize And oSheet.Orientation = kLandscapePageOrientation Then
            MsgBox "L"
            'oPrintMgr = ThisApplication.ActiveDocument.PrintManager

            oPrintMgr.ColorMode = kPrintColorPalette
            oPrintMgr.NumberOfCopies = 1
            oPrintMgr.ScaleMode = kPrintFullScale

            oPrintMgr.Orientation = kLandscapeOrientation
            oPrintMgr.PaperSize = kPaperSizeA4
            oPrintMgr.PaperHeight = 297
            oPrintMgr.PaperWidth = 210
            oPrintMgr.SubmitPrint
        End If
Next
End Sub

I Logic

Public Sub main()

Dim oDrawing As Inventor.DrawingDocument
oDrawing = ThisApplication.ActiveDocument
Dim oSheet As Inventor.Sheet
Dim oPrintMgr As Inventor.PrintManager
oPrintMgr = ThisApplication.ActiveDocument.PrintManager
For Each oSheet In oDrawing.Sheets
'MsgBox oSheet.Orientation

        If oSheet.Size = kA4DrawingSheetSize And oSheet.Orientation = kPortraitPageOrientation Then

            MsgBox "P"
            oPrintMgr.ColorMode = kPrintColorPalette
            oPrintMgr.NumberOfCopies = 1
            oPrintMgr.ScaleMode = kPrintFullScale
            oPrintMgr.Orientation = kPortraitOrientation

            oPrintMgr.PaperSize = kPaperSizeA4
            oPrintMgr.PaperHeight = 210
            oPrintMgr.PaperWidth = 297
            oPrintMgr.SubmitPrint
        End If

        If oSheet.Size = kA4DrawingSheetSize And oSheet.Orientation = kLandscapePageOrientation Then
            MsgBox "L"
            'oPrintMgr = ThisApplication.ActiveDocument.PrintManager

            oPrintMgr.ColorMode = kPrintColorPalette
            oPrintMgr.NumberOfCopies = 1
            oPrintMgr.ScaleMode = kPrintFullScale

            oPrintMgr.Orientation = kLandscapeOrientation
            oPrintMgr.PaperSize = kPaperSizeA4
            oPrintMgr.PaperHeight = 297
            oPrintMgr.PaperWidth = 210
            oPrintMgr.SubmitPrint
        End If
Next
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 10

CCarreiras
Mentor
Mentor

Hi!

 

Are you sure it work for you? Did you test it?

For me, i had the same behavior of the original code, no changes using both of your codes.

 

I'm using Inventor 2019.0.1

Tested in a  Drawing with 4 sheets, conditions explained in the first post.

 

Ps: didnt test the vb version, only iLogic.

 

Thank you.

CCarreiras

EESignature

0 Likes
Message 6 of 10

bradeneuropeArthur
Mentor
Mentor

Hi,

 

The problem you have has to do with the printer selves.

you need to let recognize the printer what sheet format is printed.

the printer manager of inventor has nothing to do with that.

so landscape or portrait has to be read and set in the printer...

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@CCarreiras,

 

Try below iLogic code to print A4 sheets in a drawing. To print A4 sheet, it is advised to activate and print the same.

Dim oDrawing As Inventor.DrawingDocument
oDrawing = ThisApplication.ActiveDocument
Dim oSheet As Inventor.Sheet

For Each oSheet In oDrawing.Sheets

		If oSheet.Size =  Inventor.DrawingSheetSizeEnum.kA4DrawingSheetSize And oSheet.Orientation = Inventor.PageOrientationTypeEnum.kPortraitPageOrientation Then
  			 ActiveSheet = ThisDrawing.Sheet(oSheet.Name)
 

			oPrintMgr = ThisApplication.ActiveDocument.PrintManager
			'oPrintMgr.ColorMode = kPrintGrayScale
			oPrintMgr.ColorMode = kPrintColorPalette
			oPrintMgr.NumberOfCopies = 1
			oPrintMgr.ScaleMode = kPrintFullScale
			oPrintMgr.Orientation = kPortraitOrientation
			'oPrintMgr.Orientation = kLandscapeOrientation
			oPrintMgr.PaperSize = kPaperSizeA4
			oPrintMgr.PaperHeight = 210 mm
			oPrintMgr.PaperWidth = 297 mm
			oPrintMgr.SubmitPrint
		End If 

		If oSheet.Size = Inventor.DrawingSheetSizeEnum.kA4DrawingSheetSize And oSheet.Orientation = Inventor.PageOrientationTypeEnum.kLandscapePageOrientation Then 		
			 ActiveSheet = ThisDrawing.Sheet(oSheet.Name)
			oPrintMgr = ThisApplication.ActiveDocument.PrintManager
			'oPrintMgr.ColorMode = kPrintGrayScale
			oPrintMgr.ColorMode = kPrintColorPalette
			oPrintMgr.NumberOfCopies = 1
			oPrintMgr.ScaleMode = kPrintFullScale
			'oPrintMgr.Orientation = kPortraitOrientation
			oPrintMgr.Orientation = kLandscapeOrientation
			oPrintMgr.PaperSize =  kPaperSizeA4
			oPrintMgr.PaperHeight = 297 mm
			oPrintMgr.PaperWidth = 210 mm
			oPrintMgr.SubmitPrint			        
		End If
Next

Please feel free to contact if there is any queries.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 8 of 10

bradeneuropeArthur
Mentor
Mentor
Accepted solution

with the Comments of @chandra.shekar.g this will do the job:

 

Public Sub main()

Dim oDrawing As Inventor.DrawingDocument
oDrawing = ThisApplication.ActiveDocument
Dim oSheet As Inventor.Sheet
Dim oPrintMgr As Inventor.PrintManager
oPrintMgr = ThisApplication.ActiveDocument.PrintManager
For Each oSheet In oDrawing.Sheets
'MsgBox oSheet.Orientation
Dim ActiveSheet As Sheet
        If oSheet.Size = kA4DrawingSheetSize And oSheet.Orientation = kPortraitPageOrientation Then
        oSheet.Activate

            MsgBox "P"
            oPrintMgr.ColorMode = kPrintColorPalette
            oPrintMgr.NumberOfCopies = 1
            oPrintMgr.ScaleMode = kPrintFullScale
            oPrintMgr.Orientation = kPortraitOrientation

            oPrintMgr.PaperSize = kPaperSizeA4
            oPrintMgr.PaperHeight = 210
            oPrintMgr.PaperWidth = 297
            oPrintMgr.SubmitPrint
        End If

        If oSheet.Size = kA4DrawingSheetSize And oSheet.Orientation = kLandscapePageOrientation Then
       
        oSheet.Activate

            MsgBox "L"
            'oPrintMgr = ThisApplication.ActiveDocument.PrintManager

            oPrintMgr.ColorMode = kPrintColorPalette
            oPrintMgr.NumberOfCopies = 1
            oPrintMgr.ScaleMode = kPrintFullScale

            oPrintMgr.Orientation = kLandscapeOrientation
            oPrintMgr.PaperSize = kPaperSizeA4
            oPrintMgr.PaperHeight = 297
            oPrintMgr.PaperWidth = 210
            oPrintMgr.SubmitPrint
        End If
Next
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 9 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

@bradeneuropeArthur,

 

 

As the user is familiar with iLogic functions. Intentionally, I included ActivateSheet = ThisDrawing.Sheet(oSheet.Name) function in iLogic code.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 10 of 10

CCarreiras
Mentor
Mentor

@chandra.shekar.g, thank you very much, activating the sheet in each step did the trick, it's working.

@bradeneuropeArthur, was not a question of orientation, that, has i told you worked good, was a question of printing the right content. Thank you anyway.

CCarreiras

EESignature

0 Likes