How to set PLT/PRN Output from Inventor drawingPrintManager to come out in different orientation

How to set PLT/PRN Output from Inventor drawingPrintManager to come out in different orientation

BrianDP-ABCPackaging
Participant Participant
1,671 Views
12 Replies
Message 1 of 13

How to set PLT/PRN Output from Inventor drawingPrintManager to come out in different orientation

BrianDP-ABCPackaging
Participant
Participant

I've been trying to get Inventor to output to a PLT (PRN) file in the orientation that works best with out printer - A Xerox 6279.  This is the code I've been using, but try as I might, I can't seem to get the options of the drawingPrintManager object to do what I want.  This is the code I've been using, I took out the references to other drawing sizes since I'm hoping to get this to work with a B size first, then I can adapt it to other sizes.

 

Public Sub PlotAllSheets()

Dim OInvdrawdoc As DrawingDocument
Dim oDrawDoc As DrawingDocument
Dim oSheet As Sheet
Dim oDrawPrintMgr As DrawingPrintManager

Dim sFullFileName As String
Dim f2Partno As String

Set OInvdrawdoc = ThisApplication.ActiveDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Set oSheet = oDrawDoc.ActiveSheet

If ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then

Set oDrawPrintMgr = OInvdrawdoc.PrintManager

oDrawPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
oDrawPrintMgr.AllColorsAsBlack = True

Select Case oSheet.Size

Case 9988:
oDrawPrintMgr.Printer = "Xerox 6279 Print to Plot"

oDrawPrintMgr.PaperSize = kPaperSize11x17

' If I set rotate90Degress = true, it DOES come out
' Horizontal, but it's upside down!
'oDrawPrintMgr.Rotate90Degrees = True
oDrawPrintMgr.Rotate90Degrees = False
oDrawPrintMgr.PaperHeight = 11
oDrawPrintMgr.PaperWidth = 17


' No Matter WHICH of these I choose, it has no effect
' on what the PLT comes out as - It's always Portrait.
'oDrawPrintMgr.Orientation = kPortraitOrientation
oDrawPrintMgr.Orientation = kLandscapeOrientation
'oDrawPrintMgr.Orientation = kDefaultOrientation


End Select

End If

' Save FileName
sFullFileName = "H:\dp\templot\" & Left(OInvdrawdoc.DisplayName, Len(OInvdrawdoc.DisplayName) - 4) & ".PLT"
Debug.Print sFullPDFName

' Export to a PLT..
oDrawPrintMgr.PrintToFile (sFullFileName)


End Sub

 

This is the output I get from modifying these options:

 

turningprints.JPG

0 Likes
Accepted solutions (1)
1,672 Views
12 Replies
Replies (12)
Message 2 of 13

WCrihfield
Mentor
Mentor

Have you tried reversing the page size specification?

For instance, instead of oDrawPrintMgr.PaperHeight = 11 and oDrawPrintMgr.PaperWidth = 17, switch it around to say oDrawPrintMgr.PaperHeight = 17 and oDrawPrintMgr.PaperWidth = 11.  See if that helps with the upside down thing.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 13

BrianDP-ABCPackaging
Participant
Participant

Yeah, It seems like that was one of the things I checked - But because you ask - I'll go re-double my efforts on that front.  Back with an answer in a jiffy.......  And No.  No difference with either way set to 17 / 11.

 

I saw an earlier post that you helped someone with, and they had been using the printMgr instead of the drawingprintmanager so I tried a little bit of that code with no luck either.

 

Could the print driver be causing this somehow?


-Brian

 

0 Likes
Message 4 of 13

WCrihfield
Mentor
Mentor

This is just a condensed version of your original code, with a few small tweaks.  Since we have already specified a PaperSize by the PaperSizeEnum, and it was not equivalent to kPaperSizeCustom, so we don't really need to specify PaperWidth & PaperHeight.  And since you only posted one possible drawing sheet size, I eliminated the Select Case block, and replaced it with a If...Then block.  Also you were defining two different drawing documents, but only using one of them.  And there was a variable that was declared, but no value was set for it, so I deleted it too.

And I moved the document type check to the top of the code, and handled it in a more direct way, so that the entire rest of the code didn't have to be enclosed within it's block.

 

Sub PrintToFile()
    If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
        Call MsgBox("This macro only works on Drawing documents. Exiting.", vbOKOnly + vbCritical, " ")
        Exit Sub
    End If
    Dim oDDoc As DrawingDocument
    Set oDDoc = ThisApplication.ActiveDocument
    Dim oSheet As Inventor.Sheet
    Set oSheet = oDDoc.ActiveSheet
    Dim oDrawPrintMgr As DrawingPrintManager
    Set oDrawPrintMgr = oDDoc.PrintManager
    oDrawPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
    oDrawPrintMgr.AllColorsAsBlack = True
    oDrawPrintMgr.Orientation = kLandscapeOrientation
    If oSheet.Size = kBDrawingSheetSize Then 'easier to read and understand than 9988
        oDrawPrintMgr.Printer = "Xerox 6279 Print to Plot"
        oDrawPrintMgr.PaperSize = kPaperSize11x17
        oDrawPrintMgr.Rotate90Degrees = False
    End If
    Dim sFullFileName As String
    sFullFileName = "H:\dp\templot\" & Left(OInvdrawdoc.DisplayName, Len(OInvdrawdoc.DisplayName) - 4) & ".PLT"
    Debug.Print sFullPDFName
    oDrawPrintMgr.PrintToFile (sFullFileName)
End Sub

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 13

BrianDP-ABCPackaging
Participant
Participant

Thanks.  I found a couple of places where you hadn't changed the long form of odrawingdoc to oddoc.  changed those.

 

But I'm still not sure what to do about this orientation problem.  If I can get it to work at all, I can expand it to work with the other various sizes of paper.   The rest of this was because I had inherited this from someone else, and I hadn't finished getting rid of the extraneous parts of the code.  I agree though it's easier to get down to the brass tacks if there isn't a bunch of other fluff to distract from what is going on.

 

I don't understand why it doesn't respond to

oDrawPrintMgr.Orientation = kLandscapeOrientation   -or- 

oDrawPrintMgr.Orientation = kPortraitOrientation

 

Why have the option if it ignores it??

 

-Brian

 

 

0 Likes
Message 6 of 13

WCrihfield
Mentor
Mentor

Yes. It is very possible that something could be happening with the Printer you specified simply understanding the data being supplied to it in a different way than we would expect.  The DrawingPrintManager has a property called PrinterDeviceContext, that seems to let you either Get or Set this value, which is a Long (a long integer), but I have no idea how to make use of it.  I believe there used to be more options within the PrintColorModeEnum (used by the ColorMode property), which used to have an option that was printer specific, and therefore unstable, but I'm not seeing it anymore.  Any time you're dealing with either printer specific settings or a simulated 'digital printer application', it's possible for something to be misinterpreted.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 13

BrianDP-ABCPackaging
Participant
Participant

It seems like I tried this with an HPGL driver to see if it would make any difference, but I dropped that idea earlier on because it wouldn't let you specify paper sizes larger than 22 inches (We'll need 34 to deal with D & E) but maybe I give that other driver a test again, and see if any of the options we've talked about here have any change on output of drawing.

 

Some people have posed that orientation isn't something that is set in a PLT file - that somehow the print driver, or the program that opens and views it somehow takes care of that.  I'm not so sure though.  This ViewCompanion application I have been using is able to open the PLT, rotate it, and save it.  When you open it again, it's in a landscape format (or portrait if you saved it like that) so it seems to me like that information is somehow stored in there.

 

I'm about ready to break out the HPGL manual and see if I can stick a RO90, or RO0 in the first line of the file and get it to take that way!

 

0 Likes
Message 8 of 13

WCrihfield
Mentor
Mentor

😂I used to mess around with HPGL coding too, back in the day.  Similar to coding for other CNC machines.  I haven't heard anyone talk about it in many years.

I'm sure there is some level of orientation information stored within the print file, but how that information is stored, and how some other printer may interpret that information is another thing.  Frankly, whatever the orientation may look in one viewer or another, most often the specified paper size can only fit through the printer one way, and most printers today do have enough (optional) smart settings to be able to figure out that is has to be printed in the one possible orientation.  I would imagine there are also settings on the target printer side for how to handle printing from a print file too.  But I digress.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 9 of 13

BrianDP-ABCPackaging
Participant
Participant
Accepted solution

In the end, I used our trusty "ViewCompanion" which I cannot sing the praises of highly enough.  I consider it sort of the Swiss army knife for PLT files.  

I use the regular script that we discussed yesterday, which outputs the file in a form - that isn't what I'm looking for - Then I right away, run this command:

 

Shell “Viewcompanion /ro90 /PLT H:\Holding\plot\” & drawing & “.PLT h:\holding\plot” & drawing & “.PLT”

 

of course subbing in the drawing name for drawing.  So right away after the file is plotted by Inventor, it gets instantly turned to the correct orientation for our production department to run prints from that plot.

 

-Brian

 

0 Likes
Message 10 of 13

Kreshnik.HASANI
Contributor
Contributor

Hi,

 

I have the same issue (the rotation is not important for me)

 

I'm trying to implement this solution but I have some issues : I installed an HPGL Printer (hpi16gex) but when I export HPGL file, the texts are not presents in the file.

 

I don't know if this comes from driver or Inventor code.

 

Any Idea?

0 Likes
Message 11 of 13

BrianDP-ABCPackaging
Participant
Participant

Is this the ViewCompanion Solution you're trying to implement?

 

I don't know if it will help, but I've always used the generic HPGL Driver - "HP Universal Print Driver" I'm sorry there are all kinds of files in there called all sorts of names so I don't know an individual filename like you called it - but who knows if this generic driver would even help you.

0 Likes
Message 12 of 13

Kreshnik.HASANI
Contributor
Contributor

Hi Brian,

 

Thanks for the answer.

 

I installed aslo an HP Generic HPGL Drive. BUt I don't know why the texts are not printed. I also tried from AutoCAD and I have the same issue.

 

So the problem comes for sure from the driver and not the Inventor API code.

 

May I ask you the url where you dowloaded the driver (I hope you remember) ?

0 Likes
Message 13 of 13

BrianDP-ABCPackaging
Participant
Participant

You can get the driver off of HP's website.
HP Universal Print Driver for Windows Software and Driver Downloads | HP® Customer Support

If you're trying to overlay stamps and such in Autocad, I'm not going to be much help.  Like I said in my original posts to this topic, I used VIEWCOMPANION to accomplish this.

 

I don't think the driver mattered that much.  The heavy lifting was accomplished by the ViewCompanion program.

 

-Brian

 

0 Likes