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 :
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
Modified:
Works for me now.
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
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
Thnx,
This doesn't quite solve the problem (IMO) but downgrades the feature so that the issues are impossible.
Regards
Is it possible that the issues comes from how the user has their printer options set? I.E. they have the printer set to default to double sided printing so that's what they get... or they manually printed something double sided and it's using the last printer settings?
Can't find what you're looking for? Ask the community or share your knowledge.