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: 

oPrintMgr.GetSheetRange is not working

3 REPLIES 3
Reply
Message 1 of 4
saeplY470
447 Views, 3 Replies

oPrintMgr.GetSheetRange is not working

I have written a script that will convert a drawing to XPS format and it's working well.  The problem is that if I have a drawing with 2 or more sheets only the first sheet is converted to XPS as if it's the only sheet in the drawing.  Here is my code, any help would be appreciated

Sub Main()
'Creates a DXF copy of the drawing in the same directory
'as the drawing


   ' Set a reference to the print manager object of the active document.
   ' This will fail if a drawing document is not active.
    Dim oPrintMgr As DrawingPrintManager
    oPrintMgr = ThisApplication.ActiveDocument.PrintManager
    
    oPrintMgr.Printer = "Microsoft XPS Document Writer"
    
    ' Set to print in gray
    oPrintMgr.ColorMode = kPrintGrayScale
    
    ' Set to print using portrait orientation.
    oPrintMgr.Orientation = kLandscapeOrientation
    
    ' Set the paper size.
    oPrintMgr.PaperSize = kPaperSizeA3
    
    ' Set to print full scale.
    oPrintMgr.ScaleMode = kPrintBestFitScale
    
    ' Change the number of copies to 1.
    oPrintMgr.NumberOfCopies = 1
	
    ' Get and set the current sheet range.
    Dim iFromSheet As Long
    Dim iToSheet As Long
    Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)
        
    ' Change the print range to print all sheets.
    oPrintMgr.PrintRange = kPrintSheetRange
    Call oPrintMgr.SetSheetRange(iFromSheet,iToSheet)
    
    'Set File Name and Path
    path_and_name = ThisDoc.PathAndFileName(False) ' without extension
	
    ' Submit the print.
    oPrintMgr.PrintToFile(path_and_name & ".xps")
End Sub

 

3 REPLIES 3
Message 2 of 4
Mike.Wohletz
in reply to: saeplY470

try this out and see if it works for you:

 

Sub Main()
'Creates a DXF copy of the drawing in the same directory
'as the drawing


   ' Set a reference to the print manager object of the active document.
   ' This will fail if a drawing document is not active.
    Dim oPrintMgr As DrawingPrintManager
    oPrintMgr = ThisApplication.ActiveDocument.PrintManager
    
    oPrintMgr.Printer = "Microsoft XPS Document Writer"
    
    ' Set to print in gray
    oPrintMgr.ColorMode = kPrintGrayScale
    
    ' Set to print using portrait orientation.
    oPrintMgr.Orientation = kLandscapeOrientation
    
    ' Set the paper size.
    oPrintMgr.PaperSize = kPaperSizeA3
    
    ' Set to print full scale.
    oPrintMgr.ScaleMode = kPrintBestFitScale
    
    ' Change the number of copies to 1.
    oPrintMgr.NumberOfCopies = 1
	
    ' Get and set the current sheet range.
    ' Dim iFromSheet As Long
    ' Dim iToSheet As Long
    ' Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)
        
    ' Change the print range to print all sheets.
    oPrintMgr.PrintRange = kPrintAllSheets
    ' Call oPrintMgr.SetSheetRange(iFromSheet,iToSheet)
    
    'Set File Name and Path
    path_and_name = ThisDoc.PathAndFileName(False) ' without extension
	
    ' Submit the print.
    oPrintMgr.PrintToFile(path_and_name & ".xps")
End Sub

 

Message 3 of 4
saeplY470
in reply to: saeplY470

Is the only difference the use of kPrintAllSheets?

 

I have tried that and it didn't work, but i'll try again.

Message 4 of 4
Mike.Wohletz
in reply to: saeplY470

Commenting out the getting range items and changing it to printallsheets is all I have done and it worked for me.  If you want to go by the sheet range you can use something like the following;

 

Dim oDrawDoc as DrawingDocument 
oDrawDoc = ThisApplication.ActiveDocument

Call oPrintMgr.SetSheetRange(1,oDrawDoc.Sheets.Count)

 it is my understanding that the GetSheetRange is not going to give you the number of sheets, but rather what the current values are for the sheet range. 

 

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

Post to forums