Automated print setup Ilogic

Automated print setup Ilogic

HassanLaamiri
Participant Participant
242 Views
3 Replies
Message 1 of 4

Automated print setup Ilogic

HassanLaamiri
Participant
Participant

I try to automate the print setup with some Ilogic code. Selecting the printer and paper size works fine on the  \\DC01\Kyocera Engineering", except on the "HP Designjet T770 44in HPGL2" the paper size stays on letter.

 

Does anyone have a solution for this?

 

HassanLaamiri_0-1668507820700.png

 

Code:

Dim oDoc As DrawingDocument = ThisDoc.Document

For Each oSheet As Sheet In oDoc.Sheets
	If oSheet.Width = 21.0 Then'A4
		oDoc.PrintManager.Printer = "\\DC01\Kyocera Engineering"
		oDoc.PrintManager.PaperSize = kPaperSizeA4
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A4")
	ElseIf oSheet.Width = 42.0 Then 'A3
		oDoc.PrintManager.Printer = "\\DC01\Kyocera Engineering"
		oDoc.PrintManager.PaperSize = kPaperSizeA3
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A3")
	ElseIf oSheet.Width = 59.4 Then 'A2
		oDoc.PrintManager.Printer = "HP Designjet T770 44in HPGL2"
		oDoc.PrintManager.PaperSize = kPaperSizeA2
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A2")
	ElseIf oSheet.Width = 84.1 Then 'A1
		oDoc.PrintManager.Printer = "HP Designjet T770 44in HPGL2"
		oDoc.PrintManager.PaperSize = kPaperSizeA1
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A1")
	End If
	
	Next

 

0 Likes
243 Views
3 Replies
Replies (3)
Message 2 of 4

Darkforce_the_ilogic_guy
Advisor
Advisor

Why not fix that by create a new printer driver on the computer. that are setup to A1. So you do not have to change papir size but simple select the printer ?

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor

Hi @HassanLaamiri.  I may be wrong, but I don't think that those print settings are being 'saved' individually for each sheet, so I'm guessing whichever sheet is the last one to be checked in that loop, that is likely how the print settings are going to remain when the rule has finished.  And if the last sheet in the loop did not match one of the 4 specific sheet widths, it may not have been set up as expected, since there is no final Else condition.  But if any of them matched the sheet width, I'm not sure why one of those specified paper sizes would not be visible in the dialog afterwards.  Seems a bit odd that different sheets in the same drawing document may be different sheet sizes.  That must make for some pretty interesting printing & publishing routines...like this one.😉

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

HassanLaamiri
Participant
Participant

Thanks for the replies, found that the printer only  have available paper ''letter'' in the settings. Looking for a way now to add more paper sizes. 

 

HassanLaamiri_0-1669024925792.png

 

Updated the code..

 

Dim oDoc As DrawingDocument = ThisDoc.Document

For Each oSheet As Sheet In oDoc.Sheets
	If oSheet.Width = 29.7 And oSheet.Height = 21.0 Then'A4
		oDoc.PrintManager.Printer = "\\DC01\Kyocera Engineering"
		oDoc.PrintManager.PaperSize = kPaperSizeA4
		oDoc.PrintManager.Orientation = kLandscapeOrientation
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A4 Landscape")
	ElseIf oSheet.Width = 21.0 And oSheet.Height = 29.7 Then'A4
		oDoc.PrintManager.Printer = "\\DC01\Kyocera Engineering"
		oDoc.PrintManager.PaperSize = kPaperSizeA4
		oDoc.PrintManager.Orientation = kPortraitOrientation
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A4 Portrait")	
	ElseIf oSheet.Width = 42.0 And oSheet.Height = 29.7 Then 'A3
		oDoc.PrintManager.Printer = "\\DC01\Kyocera Engineering"
		oDoc.PrintManager.PaperSize = kPaperSizeA3
		oDoc.PrintManager.Orientation = kLandscapeOrientation
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A3 Landscape")
	ElseIf oSheet.Width = 29.7 And oSheet.Height = 42.0 Then 'A3
		oDoc.PrintManager.Printer = "\\DC01\Kyocera Engineering"
		oDoc.PrintManager.PaperSize = kPaperSizeA3
		oDoc.PrintManager.Orientation = kPortraitOrientation
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A3 Portrait")
	ElseIf oSheet.Width = 59.4 And oSheet.Height = 42.0 Then 'A2
		oDoc.PrintManager.Printer = "HP Designjet T770 44in HPGL2"
		oDoc.PrintManager.PaperSize = kPaperSizeA2
		oDoc.PrintManager.Orientation = kLandscapeOrientation
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A2 Landscape")
	ElseIf oSheet.Width = 42.0 And oSheet.Height = 59.4 Then 'A2
		oDoc.PrintManager.Printer = "HP Designjet T770 44in HPGL2"
		oDoc.PrintManager.PaperSize = kPaperSizeA2
		oDoc.PrintManager.Orientation = kPortraitOrientation
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A2 Portrait")
	ElseIf oSheet.Width = 84.1 And oSheet.Height = 59.4 Then 'A1
		oDoc.PrintManager.Printer = "HP Designjet T770 44in HPGL2"
		oDoc.PrintManager.PaperSize = kPaperSizeA1
		oDoc.PrintManager.Orientation = kLandscapeOrientation
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A1 Landscape")
	ElseIf oSheet.Width = 59.4 And oSheet.Height = 84.1 Then 'A1
		oDoc.PrintManager.Printer = "HP Designjet T770 44in HPGL2"
		oDoc.PrintManager.PaperSize = kPaperSizeA1
		oDoc.PrintManager.Orientation = kPortraitOrientation
		MessageBox.Show(oDoc.PrintManager.Printer & " -> Sheet A1 Portrait")
	End If
	
	Next

	

 

 

0 Likes