iLogic Print to Active Sheet Size

iLogic Print to Active Sheet Size

Anonymous
Not applicable
2,368 Views
5 Replies
Message 1 of 6

iLogic Print to Active Sheet Size

Anonymous
Not applicable

How can I print with the Active Document Sheet size using iLogic? The code below works just fine for printing to a specified sheet size (in this case 11x17). But I would like to be able to change the sheet size and have one rule that will print to the appropriate size. All the help I have found online seems to be only for printing to one size.

 

Dim oDrgDoc As DrawingDocument
oDrgDoc = ThisApplication.ActiveDocument

' Set reference to drawing print manager' DrawingPrintManager has more options than PrintManager' as it's specific to drawing document
Dim oDrgPrintMgr As DrawingPrintManager
oDrgPrintMgr = oDrgDoc.PrintManager
' Set the printer name' comment this line to use default printer or assign another one
oDrgPrintMgr.Printer = "\\bflprn01\BFLPRT01"

'Set the paper size , scale and orientation
oDrgPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
oDrgPrintMgr.PaperSize = PaperSizeEnum.kPaperSize11x17
oDrgPrintMgr.PrintRange = kPrintAllSheets
oDrgPrintMgr.Orientation = kLandscapeOrientation
oDrgPrintMgr.AllColorsAsBlack = False
oDrgPrintMgr.SubmitPrint

 

 

I tried using something like this:

 

oPaperSize = kPaperSize & ActiveSheet.Size

...

...

oDrgPrintMgr.PaperSize = oPaperSize

 

But the problem seems to be that the Inventor print manager uses a string value for the sheet size, and the printer API uses an integer value so I get this error:

 

Error in rule: Print_Only, in document: My Standard.idw

Conversion from string "B" to type 'Integer' is not valid.

 

 

Anyone got any Ideas?

0 Likes
2,369 Views
5 Replies
Replies (5)
Message 2 of 6

MechMachineMan
Advisor
Advisor

Just use a Select Case Loop to grab the sheet size from inventor, check what it is, and convert it to a form that is appropriate for print manager.

 

Also, check your Programming help within inventor for more information on valid sheet sizes that can be used.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 6

rjay75
Collaborator
Collaborator

 

Make a utility function that maps the Inventor Sheet sizes to the Papersize sizes. Put the function on the bottom of your rule. Make sure the existing code of your rule is wrapped in a Main sub.

 

Sub Main()

***** Your Code Here *****

End Sub

 

 

SyntaxEditor Code Snippet

Function GetPaperSize(shtSize As DrawingSheetSizeEnum) As PaperSizeEnum
    'Add a line for each sheet and papersize combination
    If shtSize = DrawingSheetSizeEnum.kA0DrawingSheetSize Then Return PaperSizeEnum.kPaperSizeA0
End Function

 Call like so

 

oDrgPrintMgr.PaperSize = GetPaperSize(ActiveSheet.Size)

 

Very tedious but will give you the size combinations you need.

Message 4 of 6

RoyWickrama_RWEI
Advisor
Advisor

I am trying to print 22x34 drawings in 11x17 papers. It prints on the 11x17 paper but the drawing does not scaled to best fit. It always limits to 1/2 of the paper (like letter size). Could you help me.

Sub Main()
Dim oDrgDoc As DrawingDocument
oDrgDoc = ThisApplication.ActiveDocument

' Set reference to drawing print manager' DrawingPrintManager has more options than PrintManager' as it's specific to drawing document
Dim oDrgPrintMgr As DrawingPrintManager
oDrgPrintMgr = oDrgDoc.PrintManager
' Set the printer name' comment this line to use default printer or assign another one
'oDrgPrintMgr.Printer = "\\PRINTSERV\Upstairs Copier"

 oDrgPrintMgr.Printer = "MFC-J5720DW"
 

 
'Set the paper size , scale and orientation
'oDrgPrintMgr.Scalemode = kCustomScale
oDrgPrintMgr.PaperSize = PaperSizeEnum.kPaperSize11x17	
oDrgPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
	'A3
oDrgPrintMgr.PrintRange = kPrintCurrentSheet
oDrgPrintMgr.Orientation = kLandscapeOrientation
oDrgPrintMgr.Rotate90Degrees = True		'True
oDrgPrintMgr.AllColorsAsBlack = False


oDrgPrintMgr.SubmitPrint

'oDrgPrintMgr.PaperSize = kcustomsize'oDrgPrintMgr.PaperHeight = 16.54'oDrgPrintMgr.PaperWidth = 23.39
'oDrgPrintMgr.PrintRange = kPrintCurrentSheet
'oDrgPrintMgr.PrintRange = kPrintAllSheets
'oPrintMgr.PaperHeight = 15
'oPrintMgr.PaperWidth = 10


oDrgDoc.Save

'oDrgDoc.Close
End Sub

Function GetPaperSize(shtSize As DrawingSheetSizeEnum) As PaperSizeEnum
    'Add a line for each sheet and papersize combination
    If shtSize = "D" Then Return PaperSizeEnum.kPaperSize11x17
End Function

Thanks.

0 Likes
Message 5 of 6

MechMachineMan
Advisor
Advisor

Try changing the sheet orientation?


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 6

rjay75
Collaborator
Collaborator

Document the process of printing manually carefully first. You are selecting the paper size, setting the it to Landscape, setting the rotation, and customizing the paper size.

 

One of these are conflicting. When doing this through code I discovered that certain printer drivers and settings conflicted. Meaning there were some paper settings (particularly for Legal and Tabloid [11 x 17]) there was a Landscape and Portrait paper selection. So I would select one and override it with custom setting thus resulting on printing on half the page similar to what you described.

0 Likes