Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Send to Printer issue

3 REPLIES 3
Reply
Message 1 of 4
benjamin.herinckx
267 Views, 3 Replies

Send to Printer issue

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  

 

Tags (2)
3 REPLIES 3
Message 2 of 4

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 !

Message 3 of 4

Thnx,

 

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

 

Regards

Message 4 of 4
clutsa
in reply to: benjamin.herinckx

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report