Send to Printer issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
version: Inventor Professional 2019
I have the following code :
Sub Main() Dim oDoc As Document = ThisApplication.ActiveDocument Do oSheet = ThisApplication.CommandManager.Pick _ (SelectionFilterEnum.kDrawingSheetFilter, _ "Selectionner une feuille, press Esc to finish") If Not oSheet Is Nothing Then PrintSheetA4(oSheet,oDoc) End If Loop While Not oSheet Is Nothing End Sub Function PrintSheetA3(oItem As Sheet, oDoc As DrawingDocument) Dim oPrintMgr As PrintManager oPrintMgr = oDoc.PrintManager 'specify your printer name oPrintMgr.Printer = "\\srvdc\Kyocera TASKalfa 4551ci KX - BE (PCL XL)" oPrintMgr.PrintRange= kPrintCurrentPage oPrintMgr.ColorMode = kPrintDefaultColorMode oPrintMgr.Orientation = GetOrientation(oItem) oPrintMgr.RemoveLineWeights = True oPrintMgr.PaperSize = kPaperSizeA3 oPrintMgr.ScaleMode = kPrintBestFitScale oPrintMgr.SubmitPrint End Function Function PrintSheetA4(oItem As Sheet, oDoc As DrawingDocument) Dim oPrintMgr As PrintManager oPrintMgr = oDoc.PrintManager 'specify your printer name oPrintMgr.Printer = "\\srvdc\Kyocera TASKalfa 4551ci KX - BE (PCL XL)" oPrintMgr.PrintRange= kPrintCurrentPage oPrintMgr.ColorMode = kPrintDefaultColorMode oPrintMgr.Orientation = GetOrientation(oItem) oPrintMgr.RemoveLineWeights = True oPrintMgr.PaperSize = kPaperSizeA4 oPrintMgr.ScaleMode = kPrintBestFitScale oPrintMgr.SubmitPrint End Function Function GetOrientation(oItem As Sheet) As PrintOrientationEnum oItem.Activate Dim oOrientation As PageOrientationTypeEnum = oItem.Orientation If oOrientation = kLandscapePageOrientation Then Return kLandscapeOrientation Else Return kPortraitOrientation End If End Function
I use this code snippet as a ilogic quick print option (a much needed inventor feature).
As you can see, there's a function to adapt the printing to the sheet orientation (amazing).
It all works amazing when there's only 1 sheet in the .idw.
When there are multiple sheets it sometimes ( about 5% of the time ) yields the following issues :
- prints all .idw sheets (even unselected ones)
- prints the selected sheets in two-sided (very interesting behaviour since I have been looking for that one for an other application but I can't seem to pinpoint the exploit)
I have a feeling these issues have something to do with the code robustness vs user-experience.
Mainly the issues have come about when colleagues used the snippet.
I'm thinking maybe the click speed is a factor and/or the printer reaction time ?
Anyhow, if someone could help me turn this ilogic snippet into a dumbproof ilogic rule this could be a usefull tool for y'all.
Regards