Send to Printer issue

Send to Printer issue

benjamin.herinckx
Contributor Contributor
347 Views
3 Replies
Message 1 of 4

Send to Printer issue

benjamin.herinckx
Contributor
Contributor

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  

 

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

bradeneuropeArthur
Mentor
Mentor

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 & 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 4

benjamin.herinckx
Contributor
Contributor

Thnx,

 

This doesn't quite solve the problem (IMO) but downgrades the feature so that the issues are impossible.

 

Regards

0 Likes
Message 4 of 4

clutsa
Collaborator
Collaborator

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? 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes