Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Printing a drawing in the right size by default

18 REPLIES 18
Reply
Message 1 of 19
SophieSmith
2720 Views, 18 Replies

Printing a drawing in the right size by default

Hi everyone,

I am using Inventor professional 2014.

I heard that in this version,

a drawing printing can now be saved so that each time I have a format A to print, it prints format A by default.

Each time I have a format B to print, it prints format B by default.

Where and how do I do that?

Now, if i have a drawing format A and another drawing format B to print, i have to change the format prining page each time.

 

Thanks a lot,

Sophie

18 REPLIES 18
Message 2 of 19
yannick3
in reply to: SophieSmith

Hi

For 5$ it exist a add-in who will make the job, if i remembe,r i think you can add icon for each printer configuration

 

http://apps.exchange.autodesk.com/INVNTOR/2014/en/Detail/Index?id=appstore.exchange.autodesk.com%3as...

Yannick Verreault
INV PRO 2015
MS Office 2007
Win 7 pro, core i7 950, asus P6T WS
nvidia Gforce GTX 295
WD caviar black 500Go
WD caviar black 1To

Message 3 of 19
SophieSmith
in reply to: SophieSmith

Hi Yannick,

Have you tried the program?

I was told that Swift Prints had to many bugs in them.

I this true?  And is the program easy to install ?  No bugs?

 

Thanks,

Sophie

Message 4 of 19
mrattray
in reply to: SophieSmith

I wrote my own macro for this. If you're interested I'll post the code.
Mike (not Matt) Rattray

Message 5 of 19
yannick3
in reply to: SophieSmith

Hi Sophie

I never use this program recently, but i think you can try it before bought it

you can try kwikprint32 too (25$) this come from a very good developper with a lot of good stuf on his web site

 

http://apps.exchange.autodesk.com/INVNTOR/2014/en/Detail/Index?id=appstore.exchange.autodesk.com%3ak...

 

Yannick Verreault
INV PRO 2015
MS Office 2007
Win 7 pro, core i7 950, asus P6T WS
nvidia Gforce GTX 295
WD caviar black 500Go
WD caviar black 1To

Message 6 of 19
SophieSmith
in reply to: yannick3

Yannick,
Next week I will be posting the demand to have kwikprint32 in our office.. if it works i won't forget to get back to you!
Thanks alot!
(sorry againg for the late answer)

Sophie
Message 7 of 19
david.fletcher
in reply to: mrattray

Hello Mike,

 

Please post the macro code.  I was just about to try to figure it out myself, but if you don't mind sharing, I'll sing your praises.

 

Sincerely,

David Fletcher

Message 8 of 19
mrattray
in reply to: david.fletcher

Swift prints for me was never an acceptable solution, I still had to tell it wether I was looking at an A or B size sheet. Inventor already knows what size the sheet is!

 

I wrote this almost three years ago when I was just learning VBA, so it's not pretty but it does work flawlessly for our whole office:

 

Public Sub printMacro(ByVal printAll As Boolean, ByVal copies As Long, ByVal plotFullScale As Boolean)

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim sheetNum As Integer
Dim totSheets As Integer
Dim curSheet As Object
Dim sheetSize As String
Dim doc As DrawingDocument
Dim box As Long

On Error GoTo notadwg:
Set doc = ThisApplication.ActiveDocument
On Error GoTo 0

If printAll = True Then

Set oSheets = doc.Sheets

sheetNum = 0
totSheets = oSheets.count

For Each oSheet In oSheets
    
    sheetNum = sheetNum + 1
    
    If sheetNum > totSheets Then Exit For
    
    Set curSheet = doc.Sheets.Item(sheetNum)
    
    If curSheet.ExcludeFromPrinting = True Then GoTo code:
    
    curSheet.Activate
    
    If curSheet.Orientation = kPortraitPageOrientation Then
        doc.PrintManager.Orientation = kPortraitOrientation
    Else
        doc.PrintManager.Orientation = kLandscapeOrientation
    End If
    
    If curSheet.Size = kBDrawingSheetSize Then
        doc.PrintManager.PaperSize = kPaperSize11x17
    ElseIf curSheet.Size = kADrawingSheetSize Then
        doc.PrintManager.PaperSize = kPaperSizeLetter
    Else
code2:
        sheetSize = InputBox("The current sheet is not formated in a way that I can easily read. Please enter an " & Chr(34) & "A" _
        & Chr(34) & " if this is an 8.5x11 sheet or " & Chr(34) & "B" & Chr(34) & " if this is an 11x17 sheet.", _
        "Sheet size?", "A")
        If sheetSize = "A" Or sheetSize = "a" Then
            curSheet.Size = kADrawingSheetSize
            doc.PrintManager.PaperSize = kPaperSizeLetter
        ElseIf sheetSize = "B" Or sheetSize = "b" Then
            curSheet.Size = kBDrawingSheetSize
            doc.PrintManager.PaperSize = kPaperSize11x17
        ElseIf sheetSize = "" Then
            Exit Sub
        Else
            sheetSize = MsgBox("Invalid entry! Follow the directions!!!", vbOKOnly, "Invalid entry")
            GoTo code2:
        End If
    End If
    
    If plotFullScale = True Then
        doc.PrintManager.ScaleMode = kPrintFullScale
    Else
        doc.PrintManager.ScaleMode = kPrintBestFitScale
    End If
    doc.PrintManager.AllColorsAsBlack = True
    doc.PrintManager.PrintRange = kPrintCurrentSheet
    doc.PrintManager.NumberOfCopies = copies
    doc.PrintManager.SubmitPrint
code:
    
Next

Else

Set curSheet = doc.ActiveSheet

If curSheet.Orientation = kPortraitPageOrientation Then
        doc.PrintManager.Orientation = kPortraitOrientation
    ElseIf curSheet.Orientation = kLandscapePageOrientation Then
        doc.PrintManager.Orientation = kLandscapeOrientation
    Else
        doc.PrintManager.Orientation = kDefaultOrientation
    End If
    
    If curSheet.Size = kBDrawingSheetSize Then
        doc.PrintManager.PaperSize = kPaperSize11x17
    ElseIf curSheet.Size = kADrawingSheetSize Then
        doc.PrintManager.PaperSize = kPaperSizeLetter
    Else
code3:
        sheetSize = InputBox("The current sheet is not formated in a way that I can easily read. Please enter an " & Chr(34) & "A" _
        & Chr(34) & " if this is an 8.5x11 sheet or " & Chr(34) & "B" & Chr(34) & " if this is an 11x17 sheet.", _
        "Sheet size?", "A")
        If sheetSize = "A" Or sheetSize = "a" Then
            curSheet.Size = kADrawingSheetSize
            doc.PrintManager.PaperSize = kPaperSizeLetter
        ElseIf sheetSize = "B" Or sheetSize = "b" Then
            curSheet.Size = kBDrawingSheetSize
            doc.PrintManager.PaperSize = kPaperSize11x17
        ElseIf sheetSize = "" Then
            Exit Sub
        Else
            sheetSize = MsgBox("Invalid entry! Follow the directions!!!", vbOKOnly, "Invalid entry")
            GoTo code3:
        End If
    End If

    If plotFullScale = True Then
        doc.PrintManager.ScaleMode = kPrintFullScale
    Else
        doc.PrintManager.ScaleMode = kPrintBestFitScale
    End If
    doc.PrintManager.AllColorsAsBlack = True
    doc.PrintManager.PrintRange = kPrintCurrentSheet
    doc.PrintManager.NumberOfCopies = copies
    doc.PrintManager.SubmitPrint
End If

Exit Sub

notadwg:
box = MsgBox("Please have a drawing active when using the print macro.", vbOKOnly, "Not a drawing")
Exit Sub

cancel:
End Sub

Sub printOptions()

printDialog.Show

End Sub

 

You'll also want the form (attahced).

Mike (not Matt) Rattray

Message 9 of 19
david.fletcher
in reply to: mrattray

Mike,

 

Sweeeeet!  That is really what I've been needing to stop the profuse bleeding from the center of my forehead for the last 2 years!  I can't believe that Autodesk didn't implement something simple like this a long, long time ago.

 

For other users who sometimes use C and D size drawings, but print them to a run-of-the-mill copy/print machine that doesn't have paper that big, I've added a bit of capability to this code, Mike.  It now detects C and D size sheets, then temporarily changes the "full scale" boolean to false so that they will fit on 11x17 (B) size paper. 

 

Nice work!  You rock!  You are the man.

 

Sincerely,

David Fletcher

 

 

>>> updated code:

 

Sub printMacro(ByVal printAll As Boolean, ByVal copies As Long, ByVal plotFullScale As Boolean)

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim sheetNum As Integer
Dim totSheets As Integer
Dim curSheet As Object
Dim sheetSize As String
Dim doc As DrawingDocument
Dim box As Long

On Error GoTo notadwg:
Set doc = ThisApplication.ActiveDocument
On Error GoTo 0

If printAll = True Then

Set oSheets = doc.Sheets

sheetNum = 0
totSheets = oSheets.Count

For Each oSheet In oSheets
   
    sheetNum = sheetNum + 1
   
    If sheetNum > totSheets Then Exit For
   
    Set curSheet = doc.Sheets.Item(sheetNum)
   
    If curSheet.ExcludeFromPrinting = True Then GoTo code:
   
    curSheet.Activate
    Call SetSheetSize(curSheet, doc, printAll, copies, plotFullScale)
code:
    'Do nothing, we're excluding this sheet.
Next

Else


'We are just printing the current sheet
Set curSheet = doc.ActiveSheet
Call SetSheetSize(curSheet, doc, printAll, copies, plotFullScale)

End If

Exit Sub

notadwg:
box = MsgBox("Please have a drawing active when using the print macro.", vbOKOnly, "Not a drawing")
Exit Sub

cancel:
End Sub

Sub printOptions()

printDialog.Show

End Sub

 

 

Private Sub SetSheetSize(ByRef curSheet As Sheet, ByRef doc As Document, ByVal printAll As Boolean, _
    ByVal copies As Long, ByVal plotFullScale As Boolean)

    Dim originalsetting_plotfullscale As Boolean
    originalsetting_plotfullscale = plotFullScale

    If curSheet.Orientation = kPortraitPageOrientation Then
        doc.PrintManager.Orientation = kPortraitOrientation
    Else
        doc.PrintManager.Orientation = kLandscapeOrientation
    End If
   
    If curSheet.Size = kBDrawingSheetSize Then
        doc.PrintManager.PaperSize = kPaperSize11x17
    ElseIf curSheet.Size = kADrawingSheetSize Then
        doc.PrintManager.PaperSize = kPaperSizeLetter
    ElseIf curSheet.Size = kCDrawingSheetSize Then
        doc.PrintManager.PaperSize = kPaperSize11x17   'kPaperSizeCSheet
        plotFullScale = False
    ElseIf curSheet.Size = kDDrawingSheetSize Then
        doc.PrintManager.PaperSize = kPaperSize11x17        'kPaperSizeDSheet
        plotFullScale = False
    Else
code2:
        sheetSize = InputBox("The current sheet is not formated in a way that I can easily read. Please enter an " & Chr(34) & "A" _
        & Chr(34) & " if this is an 8.5x11 sheet or " & Chr(34) & "B" & Chr(34) & " if this is an 11x17 sheet.", _
        "Sheet size?", "A")
        If sheetSize = "A" Or sheetSize = "a" Then
            'curSheet.Size = kADrawingSheetSize
            doc.PrintManager.PaperSize = kPaperSizeLetter
            plotFullScale = False
        ElseIf sheetSize = "B" Or sheetSize = "b" Then
            'curSheet.Size = kBDrawingSheetSize
            doc.PrintManager.PaperSize = kPaperSize11x17
            plotFullScale = False
        ElseIf sheetSize = "" Then
            Exit Sub
        Else
            sheetSize = MsgBox("Invalid entry! Follow the directions!!!", vbOKOnly, "Invalid entry")
            GoTo code2:
        End If
    End If
   
    If plotFullScale = True Then
        doc.PrintManager.ScaleMode = kPrintFullScale
    Else
        doc.PrintManager.ScaleMode = kPrintBestFitScale
    End If
    doc.PrintManager.AllColorsAsBlack = False
    doc.PrintManager.PrintRange = kPrintCurrentSheet
    doc.PrintManager.NumberOfCopies = copies
    doc.PrintManager.SubmitPrint
    plotFullScale = originalsetting_plotfullscale
End Sub

 

Message 10 of 19
mrattray
in reply to: david.fletcher

Glad to see it worked for you, that was a scenario that wasn't ever going to occur at our shop as we simply scale the views to whatever we want to and keep our sheet sizes to actual printable sizes.
I agree that Inventors handling of this situation is insane. When I started here I think I did one or two small jobs before I yelled "No more! This needs fixing immediately!"
Mike (not Matt) Rattray

Message 11 of 19
Callesson
in reply to: mrattray


@mrattray wrote:
Glad to see it worked for you, that was a scenario that wasn't ever going to occur at our shop as we simply scale the views to whatever we want to and keep our sheet sizes to actual printable sizes.
I agree that Inventors handling of this situation is insane. When I started here I think I did one or two small jobs before I yelled "No more! This needs fixing immediately!"

 

 

Hi!

 

I was looking for this function aswell so I found this on google.

 

But I don't know how I can put this code into work in Inventor? Could you help me? (I've never used macros and stuff)

 

Also, I only use A4 and A3 in my work. How can we change the code so it will work for that?

 

Cause I tried the code and it wont print cause the printer says I dont have the right format. I tried via Microsoft visual basic.

 

And, can I decide if I want color or B&W?

 

I hope you can answer this and help me!

 

Kind regards

 

calle

Autodesk Inventor 2015 User
Message 12 of 19
JJ_aabo
in reply to: Callesson

First of all let me state: "I am not a clever man..." Then: How do I impelment these apparantly very usefull tool in Inventor? It does not appear to be iLogic or...? Could anyone direct me in the right direction?
Message 13 of 19
mrattray
in reply to: SophieSmith

@Callesson I'm sorry, but I don't have the free time right now to customize this for you.
@Callesson & @JJ_aabo This code is written as a VBA macro. If I was to write it from scratch today I would write it as iLogic, but with the poor documentation for it I had to use VBA instead. It should be implemented the same as any other VBA macro. There should be plenty of information around on the various means of doing so. For me, I have several utilities written that are all integrated on an iLogic form.
Mike (not Matt) Rattray

Message 14 of 19
david.fletcher
in reply to: JJ_aabo


@JJ_aabo wrote:
First of all let me state: "I am not a clever man..." Then: How do I impelment these apparantly very usefull tool in Inventor? It does not appear to be iLogic or...? Could anyone direct me in the right direction?

Hello JJ,

 

Well, if you want to get this to work, you're going to have to become a cleverer man than you were!

 

So, to start, find the VBA editor in Inventor.  Go to Tools ribbon, Options group, and click on VBA Editor icon.

 

You have to paste Mike's code or the updated code I posted into one of the "modules" in your vba environment.  You also have to get the VBA form that Mike posted.  This provides the options for Setting All colors As black, or not, or to print all sheets.  I included a button on my version of the form that says "Send large sheets to the Plotter" in case I want to print C and D size sheets full scale.  (If I am just testing out a drawing, I default them to scale down to 11X17" paper size.)

 

Expect to spend a few hours tinkering if you don't know what you are doing.  But once you are done, you will not have to fiddle faddle with Inventor's print dialog or your printer's options.  I have it set up now so that when I am in Inventor, i hit one keystroke, check the print options, and hit <Enter> and my drawing prints... no matter what size it was created on!

 

Good luck,

David Fletcher

Message 15 of 19

Here is my Print Dialog Box. (see attached). in the VBA environment, under Application Project (In the project browser on the left of your screen), expand the "Forms" folder.  There should be nothing there.  Right-click on the Forms folder and select "Import File..."  Then select the attachments (from wherever you saved them).

 

Make sure you copy and paste the code below into a VBA module.

 

Then you can select a hotkey in Inventor, or add a button to the ribbon to call up the PrintDialog macro that starts off the whole shebang.

 

And then Bob's your uncle!

 

David Fletcher

 

Below is the code that appears in the VBA "module"

 

'''''

 

Sub printMacro(ByVal printAll As Boolean, ByVal copies As Long, ByVal UsePlotter_forLarge As Boolean, ByVal All_Colours_As_Black As Boolean)

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim sheetNum As Integer
Dim totSheets As Integer
Dim curSheet As Object
Dim SheetSize As String
Dim doc As DrawingDocument
Dim box As Long

On Error GoTo notadwg:
Set doc = ThisApplication.ActiveDocument
On Error GoTo 0

If printAll = True Then

Set oSheets = doc.Sheets

sheetNum = 0
totSheets = oSheets.Count

For Each oSheet In oSheets
   
    sheetNum = sheetNum + 1
   
    If sheetNum > totSheets Then Exit For
   
    Set curSheet = doc.Sheets.Item(sheetNum)
   
    If curSheet.ExcludeFromPrinting = True Then GoTo code:
   
    curSheet.Activate
    Call SetSheetSize(curSheet, doc, printAll, copies, UsePlotter_forLarge, All_Colours_As_Black)
code:
    'Do nothing, we're excluding this sheet.
Next

Else


'We are just printing the current sheet
Set curSheet = doc.ActiveSheet
Call SetSheetSize(curSheet, doc, printAll, copies, UsePlotter_forLarge, All_Colours_As_Black)

End If

Exit Sub

notadwg:
box = MsgBox("Please have a drawing active when using the print macro.", vbOKOnly, "Not a drawing")
Exit Sub

cancel:
End Sub

Sub printOptions()

printDialog.Show

End Sub

 

Private Sub SetSheetSize(ByRef curSheet As Sheet, ByRef doc As Document, ByVal printAll As Boolean, _
    ByVal copies As Long, ByRef UsePlotter_forLarge As Boolean, ByRef All_Colours_As_Black As Boolean)
   
    Dim oprtmgr As PrintManager
    Dim plotFullScale As Boolean
    plotFullScale = True
   

    Dim defaultPrinter, oPlotter As String
    oPlotter = "HP Designjet T2300 HPGL2"

   
    Set oprtmgr = ThisApplication.ActiveDocument.PrintManager
    defaultPrinter = oprtmgr.Printer
   
    If curSheet.Orientation = kPortraitPageOrientation Then
        oprtmgr.Orientation = kPortraitOrientation
    Else
        oprtmgr.Orientation = kLandscapeOrientation
    End If
   
    If curSheet.Size = kBDrawingSheetSize Then
        oprtmgr.PaperSize = kPaperSize11x17
    ElseIf curSheet.Size = kADrawingSheetSize Then
        oprtmgr.PaperSize = kPaperSizeLetter
    ElseIf curSheet.Size = kCDrawingSheetSize Then
        Call Decide_Plotter(UsePlotter_forLarge, oprtmgr, oPlotter, plotFullScale, "C")
    ElseIf curSheet.Size = kDDrawingSheetSize Then
        Call Decide_Plotter(UsePlotter_forLarge, oprtmgr, oPlotter, plotFullScale, "D")
    Else
code2:
        SheetSize = InputBox("The current sheet is not formated in a way that I can easily read. Please enter an " _
        & Chr(34) & "A" & Chr(34) & " if this is close to 8.5x11 sheet," & vbNewLine _
        & Chr(34) & "B" & Chr(34) & " if this is close to 11x17 sheet," & vbNewLine _
        & Chr(34) & "C" & Chr(34) & " if this is close to 17x22 sheet,  OR" & vbNewLine _
        & Chr(34) & "D" & Chr(34) & " if this is close to 22x34 sheet,", _
        "Sheet size?", "A")
       
        If SheetSize = "A" Or SheetSize = "a" Then
            oprtmgr.PaperSize = kPaperSizeLetter
            plotFullScale = False
        ElseIf SheetSize = "B" Or SheetSize = "b" Then
            oprtmgr.PaperSize = kPaperSize11x17
            plotFullScale = False
        ElseIf SheetSize = "C" Or SheetSize = "c" Then
            Call Decide_Plotter(UsePlotter_forLarge, oprtmgr, oPlotter, plotFullScale, "C")
        ElseIf SheetSize = "D" Or SheetSize = "d" Then
            Call Decide_Plotter(UsePlotter_forLarge, oprtmgr, oPlotter, plotFullScale, "D")
        ElseIf SheetSize = "" Then
            Exit Sub
        Else
            SheetSize = MsgBox("Invalid entry! Follow the directions!!!", vbOKOnly, "Invalid entry")
            GoTo code2:
        End If
    End If
   
    If plotFullScale = True Then
        oprtmgr.ScaleMode = kPrintFullScale
    Else
        oprtmgr.ScaleMode = kPrintBestFitScale
    End If
    oprtmgr.AllColorsAsBlack = All_Colours_As_Black
    oprtmgr.PrintRange = kPrintCurrentSheet
    oprtmgr.NumberOfCopies = copies
    oprtmgr.SubmitPrint
    plotFullScale = originalsetting_plotfullscale
    oprtmgr.Printer = defaultPrinter
End Sub

Public Sub Decide_Plotter(ByRef WeWantPlotter As Boolean, ByRef oprtmgr As PrintManager, ByRef oPlotter As String, _
            ByRef plotFullScale As Boolean, ByVal SheetSize As String)
If WeWantPlotter Then
    oprtmgr.Printer = oPlotter
    If SheetSize = "C" Then
        oprtmgr.PaperSize = kPaperSizeCSheet
    ElseIf SheetSize = "D" Then
    oprtmgr.PaperSize = kPaperSizeDSheet
    End If
Else
     plotFullScale = False
     oprtmgr.PaperSize = kPaperSize11x17
End If
End Sub

Message 16 of 19
JJ_aabo
in reply to: david.fletcher

Thanks for the noob guide! I seems to be working, and I will need to be more clever soon since I have to modify the code to fit european paper sizes. I will post my result here for others to benefit from should I ever get it to work 🙂
Tags (1)
Message 17 of 19
david.fletcher
in reply to: JJ_aabo

There is documentation within inventor to help you solve your problem.

Every variable has a name, and once you know its name (and how to call it) you can do with it whatever you want.

So Click the drop-down next to the question mark, hover over "Help", and Go to Programming/API help. Don't get scared. You're just looking for the name of the paper size you want.


[cid:image001.png@01D0737A.599D74C0]

I just did a quick search for "paper size" and this is what I got:
[cid:image006.png@01D0737A.707F7530]

Good Luck!

David Fletcher, P. Eng.
Design Engineer

[smtklogo]

Timken Gears & Services - Canada
868 60th St E., Saskatoon, SK., CAN., S7K 8G8
Phone: 306.931.3343
Direct: 306.659.9000
Fax: 306.249.9484
www.standardmachine.ca


This message and any attachments are intended for the individual or entity named above. If you are not the intended recipient, please do not forward, copy, print, use or disclose this communication to others; also please notify the sender by replying to this message, and then delete it from your system. The Timken Company / The Timken Corporation
Message 18 of 19
JJ_aabo
in reply to: david.fletcher

Thanks! It's all very helpfull. A4 and A3 are printing perfect on the standard printer, but the plotter is giving me troubles.

 

Printing A4 and A3 size on the plotter is ok, but setting the paper size to A2 (oprtmgr.PaperSize = kPaperSizeA2) or higher gives following error:

"method 'papersize' of object 'drawingprintmanager' failed"

 

But kPaperSizeA2 should be a part of the API.

 

Sub printMacro(ByVal printAll As Boolean, ByVal copies As Long, ByVal UsePlotter_forLarge As Boolean, ByVal All_Colours_As_Black As Boolean)
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim sheetNum As Integer
Dim totSheets As Integer
Dim curSheet As Object
Dim SheetSize As String
Dim doc As DrawingDocument
Dim box As Long
On Error GoTo notadwg:
Set doc = ThisApplication.ActiveDocument
On Error GoTo 0
If printAll = True Then
Set oSheets = doc.Sheets
sheetNum = 0
totSheets = oSheets.Count
For Each oSheet In oSheets
  
    sheetNum = sheetNum + 1
  
    If sheetNum > totSheets Then Exit For
  
    Set curSheet = doc.Sheets.Item(sheetNum)
  
    If curSheet.ExcludeFromPrinting = True Then GoTo code:
  
    curSheet.Activate
    Call SetSheetSize(curSheet, doc, printAll, copies, UsePlotter_forLarge, All_Colours_As_Black)
code:
    'Do nothing, we're excluding this sheet.
Next
Else

'We are just printing the current sheet
Set curSheet = doc.ActiveSheet
Call SetSheetSize(curSheet, doc, printAll, copies, UsePlotter_forLarge, All_Colours_As_Black)
End If
Exit Sub
notadwg:
box = MsgBox("Please have a drawing active when using the print macro.", vbOKOnly, "Not a drawing")
Exit Sub
cancel:
End Sub
Sub printOptions()
printDialog.Show
End Sub
 
Private Sub SetSheetSize(ByRef curSheet As Sheet, ByRef doc As Document, ByVal printAll As Boolean, _
    ByVal copies As Long, ByRef UsePlotter_forLarge As Boolean, ByRef All_Colours_As_Black As Boolean)
  
    Dim oprtmgr As PrintManager
    Dim plotFullScale As Boolean
    plotFullScale = True
  
    Dim defaultPrinter, oPlotter As String
    oPlotter = "\\192.168.100.8\HP Designjet 500 42+HPGL2 Card"
  
    Set oprtmgr = ThisApplication.ActiveDocument.PrintManager
    defaultPrinter = oprtmgr.Printer
  
    If curSheet.Orientation = kPortraitPageOrientation Then
        oprtmgr.Orientation = kPortraitOrientation
    Else
        oprtmgr.Orientation = kLandscapeOrientation
    End If
  
 
    If curSheet.Size = kA4DrawingSheetSize Then
        oprtmgr.PaperSize = kPaperSizeA4
    ElseIf curSheet.Size = kA3DrawingSheetSize Then
        oprtmgr.PaperSize = kPaperSizeA3
    ElseIf curSheet.Size = kA2DrawingSheetSize Then
        Call Decide_Plotter(UsePlotter_forLarge, oprtmgr, oPlotter, plotFullScale, "A2")
    ElseIf curSheet.Size = kA1DrawingSheetSize Then
        Call Decide_Plotter(UsePlotter_forLarge, oprtmgr, oPlotter, plotFullScale, "A1")
    Else
code2:
        SheetSize = InputBox("Jeg kan ikke genkende den valgte papir størrelse. Vælg venligst:" _
        & Chr(34) & "A4" & Chr(34) & " hvis det minder om A4," & vbNewLine _
        & Chr(34) & "A3" & Chr(34) & " hvis det minder om A3," & vbNewLine _
        & Chr(34) & "A2" & Chr(34) & " hvis det minder om A2, Eller" & vbNewLine _
        & Chr(34) & "A1" & Chr(34) & " hvis det minder om A1,", _
        "Str.?", "A4")
      
        If SheetSize = "A4" Or SheetSize = "a4" Then
            oprtmgr.PaperSize = kPaperSizeA4
            plotFullScale = False
        ElseIf SheetSize = "A3" Or SheetSize = "a3" Then
            oprtmgr.PaperSize = kPaperSizeA3
            plotFullScale = False
        ElseIf SheetSize = "A2" Or SheetSize = "a2" Then
            Call Decide_Plotter(UsePlotter_forLarge, oprtmgr, oPlotter, plotFullScale, "A2")
        ElseIf SheetSize = "A1" Or SheetSize = "a1" Then
            Call Decide_Plotter(UsePlotter_forLarge, oprtmgr, oPlotter, plotFullScale, "A1")
        ElseIf SheetSize = "A0" Or SheetSize = "a0" Then
            Call Decide_Plotter(UsePlotter_forLarge, oprtmgr, oPlotter, plotFullScale, "A0")
        ElseIf SheetSize = "" Then
            Exit Sub
        Else
            SheetSize = MsgBox("Den går ikke! Læs vejledningen igen!!!", vbOKOnly, "Forkert indtastning")
            GoTo code2:
        End If
    End If
  
    If plotFullScale = True Then
        oprtmgr.ScaleMode = kPrintFullScale
    Else
        oprtmgr.ScaleMode = kPrintBestFitScale
    End If
    oprtmgr.AllColorsAsBlack = All_Colours_As_Black
    oprtmgr.PrintRange = kPrintCurrentSheet
    oprtmgr.NumberOfCopies = copies
    oprtmgr.SubmitPrint
    plotFullScale = originalsetting_plotfullscale
    oprtmgr.Printer = defaultPrinter
End Sub
Public Sub Decide_Plotter(ByRef WeWantPlotter As Boolean, ByRef oprtmgr As PrintManager, ByRef oPlotter As String, _
            ByRef plotFullScale As Boolean, ByVal SheetSize As String)

' Ved plotter størrelser skal der vælges "custom size"
'      ' Change the paper size to a custom size.  The units are in centimeters.
 '   oPrintMgr.PaperSize = kPaperSizeCustom
'    oPrintMgr.PaperHeight = 59.4
'    oPrintMgr.PaperWidth = 84.1

If WeWantPlotter Then
    oprtmgr.Printer = oPlotter
    If SheetSize = "A2" Then
        oprtmgr.PaperSize = kPaperSizeA2 'Custom
        'oprtmgr.PaperHeight = 29.94
        'oprtmgr.PaperWidth = 21.59
    ElseIf SheetSize = "A1" Then
        oprtmgr.PaperSize = kPaperSizeCustom
        oprtmgr.PaperHeight = 59.4
        oprtmgr.PaperWidth = 84.1
    ElseIf SheetSize = "A0" Then
        oprtmgr.PaperSize = kPaperSizeCustom
        oprtmgr.PaperHeight = 84.1
        oprtmgr.PaperWidth = 118.9
    End If
Else
     plotFullScale = False
     oprtmgr.PaperSize = kPaperSizeA4
End If
End Sub

 

Message 19 of 19
david.fletcher
in reply to: JJ_aabo


Hi
@JJ_aabo wrote:

Thanks! It's all very helpfull. A4 and A3 are printing perfect on the standard printer, but the plotter is giving me troubles.

 

Printing A4 and A3 size on the plotter is ok, but setting the paper size to A2 (oprtmgr.PaperSize = kPaperSizeA2) or higher gives following error:

"method 'papersize' of object 'drawingprintmanager' failed"

 

But kPaperSizeA2 should be a part of the API.

 

   oPlotter = "\\192.168.100.8\HP Designjet 500 42+HPGL2 Card"
 

If WeWantPlotter Then
    oprtmgr.Printer = oPlotter
    If SheetSize = "A2" Then
        oprtmgr.PaperSize = kPaperSizeA2 'Custom

 

Hi JJ,

 

I think the problem is with your name for oplotter.  When I wrote me code, there was no network path in the name for oplotter.  It looked like this:

  
    oPlotter = "HP Designjet T2300 HPGL2"

 

So if you have anything that is not EXACTLY the right name for that printer, as soon as you call oprtmgr.PaperSize (you are actually accessing the printmanager object now) it fails because it can't find a printer with that EXACT name.  There is probably nothing wrong with the paper size.  You could try using the numerical equivalent (14339) to see if that changes anything.  But I expect it is the name of the printer that is wrong.

 

You are almost there!  Or you have already figured this out, and have gone on your way, happy to be done with this silly issue!

 

Good luck,

David Fletcher

 

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

Post to forums  

Autodesk Design & Make Report