Author Topic: Specify plotter paper size?  (Read 7444 times)

0 Members and 1 Guest are viewing this topic.

scottcd

  • Newt
  • Posts: 52
Specify plotter paper size?
« on: January 29, 2009, 11:04:46 AM »
With the following code I can create my layout plot settings, apart from my paper size.
Can someone point me in the right direction to set the paper size?

Note that scl is set elsewhere... it is a real number eg 0.1

Thanks

Scott

Code: [Select]
(defun nortec_setplotter ()
  (setq AcadObj (vlax-get-Acad-Object))
  (setq FilesObj (vla-get-Files (vla-get-Preferences AcadObj)))
  (setq ActLo (vla-get-ActiveLayout (vla-get-ActiveDocument AcadObj)))
  (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (vlax-put ActLo 'ConfigName "HP DesignJet 500 42 by HP.pc3")     ; Plotter Name
  (vlax-put ActLo 'PlotType acExtents)     ; Plot Extents
  (vlax-put Actlo 'PlotRotation ac0degrees)     ; Plot Landscape
  (vlax-put Actlo 'PaperUnits acMillimeters)     ; Plot Millimeters
  (vlax-put ActLo 'StandardScale acVpCustomScale)     ; Use Custom Linetype Scale
  (vlax-put Actlo 'CenterPlot -1)             ; Centre Plotting
  (vlax-invoke ActLo 'SetCustomScale 1.0 scl)     ; Set Custom Scale set elsewhere
  ;;;(vlax-invoke Actlo 'LocalMediaName "ISO A1 (landscape)")             ; Set Paper Size ;????
  (vlax-invoke ActDoc 'Regen acActiveViewport)     ; Regen Viewport
)
AutoCAD Dos R9 - 2018 and BricCAD 18.2

dustinthiesse

  • Guest
Re: Specify plotter paper size?
« Reply #1 on: January 29, 2009, 11:11:29 AM »
I believe the setting for paper size is canonicalmedianames.
I got this selectplotter code (I think from JeffreyPSanders.com) and added to it to incorporate paper sizes.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Specify plotter paper size?
« Reply #2 on: January 29, 2009, 11:12:16 AM »
I think you have to set the ' CanonicalMediaName '.  To get that name if you have the locale media name, you will have to get the list of canonical names, and the change them to locale names, and then when you find the one you want, assign that to the aforementioned property of the layout.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

scottcd

  • Newt
  • Posts: 52
Re: Specify plotter paper size?
« Reply #3 on: January 29, 2009, 11:46:19 AM »
Thanks for that, I think I am getting closer..

I have the list - but still can't set the paper size - error of member not found?

What else can I try?

Cheers
Scott


Code: [Select]
(defun nortec_setplotter ()
  (setq AcadObj (vlax-get-Acad-Object))
  (setq FilesObj (vla-get-Files (vla-get-Preferences AcadObj)))
  (setq ActLo (vla-get-ActiveLayout (vla-get-ActiveDocument AcadObj)))
  (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (vlax-put ActLo 'ConfigName "HP DesignJet 500 42 by HP.pc3")     ; Plotter Name
  (vlax-put ActLo 'PlotType acExtents)     ; Plot Extents
  (vlax-put Actlo 'PlotRotation ac0degrees)     ; Plot Landscape
  (vlax-put Actlo 'PaperUnits acMillimeters)     ; Plot Millimeters
  (vlax-put ActLo 'StandardScale acVpCustomScale)     ; Use Custom Linetype Scale
  (vlax-put Actlo 'CenterPlot -1)     ; Centre Plotting
  (vlax-invoke ActLo 'SetCustomScale 1.0 scl)     ; Set Custom Scale set elsewhere
  (setq paperList
(mapcar '(lambda (x) (vlax-invoke ActLo 'GetLocaleMediaName x))
(vlax-invoke ActLo 'GetCanonicalMediaNames)
)
  )
  (vlax-invoke Actlo 'RefreshPlotDeviceInfo)
  (vlax-invoke Actlo 'canonicalmedianame (nth 72 paperlist))     ; Set Paper Size
  (vlax-invoke ActDoc 'Regen acActiveViewport)     ; Regen Viewport
)
AutoCAD Dos R9 - 2018 and BricCAD 18.2

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Specify plotter paper size?
« Reply #4 on: January 29, 2009, 11:56:59 AM »
You're still setting the Locale name instead of the Canonical name.  The Locale name is human readable, and the Canonical is the machine readable, so you need to set the one the machine can read.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

scottcd

  • Newt
  • Posts: 52
Re: Specify plotter paper size?
« Reply #5 on: January 29, 2009, 12:03:53 PM »
Sorry Tim,

You've lost me there.. :oops:

How do I set the machine readable?  :ugly:


AutoCAD Dos R9 - 2018 and BricCAD 18.2

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Specify plotter paper size?
« Reply #6 on: January 29, 2009, 12:15:51 PM »
Sorry about that Scott.  This code will get you a list of both names

Code: [Select]
(setq paperList
(mapcar '(lambda (x) (cons (vlax-invoke ActLo 'GetLocaleMediaName x) x))
(vlax-invoke ActLo 'GetCanonicalMediaNames)
)
  )

Here is a quote to show what I'm talking about.  The first is the human readable, and the second is the machine readable.

Quote
(
    ("F (40.00 x 28.00 Inches)" . "UserDefinedImperial (40.00 x 28.00Inches)")
    ("ISO A0 (1189.00 x 841.00 MM)" . "ISO_A0_(1189.00_x_841.00_MM)")
)

So if you wanted to set the paper to the first item in the list, you would go

Code: [Select]
(vla-put-CanonicalMediaName ActLo (cdr (car paperList)))

Hope that makes sense now.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

scottcd

  • Newt
  • Posts: 52
Re: Specify plotter paper size?
« Reply #7 on: January 29, 2009, 01:11:16 PM »
Thanks Tim, I will look at this further tomorrow....

Suffering some serious brain fade this afternoon!

Cheers
Scott

AutoCAD Dos R9 - 2018 and BricCAD 18.2

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Specify plotter paper size?
« Reply #8 on: January 29, 2009, 01:16:07 PM »
You're welcome Scott.  I know how the brain goes.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

scottcd

  • Newt
  • Posts: 52
Re: Specify plotter paper size?
« Reply #9 on: January 30, 2009, 03:45:16 AM »
I am getting the following error:

Error: bad argument type: consp "Previous paper size  (593.98 x 1099.95 mm)"

using the code below as suggested.

Code: [Select]
(defun nortec_setplotter ()
  (setq AcadObj (vlax-get-Acad-Object))
  (setq FilesObj (vla-get-Files (vla-get-Preferences AcadObj)))
  (setq ActLo (vla-get-ActiveLayout (vla-get-ActiveDocument AcadObj)))
  (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (vlax-put ActLo 'ConfigName "HP DesignJet 500 42 by HP.pc3")     ; Plotter Name
  (vlax-put ActLo 'PlotType acExtents)     ; Plot Extents
  (vlax-put Actlo 'PlotRotation ac0degrees)     ; Plot Landscape
  (vlax-put Actlo 'PaperUnits acMillimeters)     ; Plot Millimeters
  (vlax-put ActLo 'StandardScale acVpCustomScale)     ; Use Custom Linetype Scale
  (vlax-put Actlo 'CenterPlot -1)     ; Centre Plotting
  (vlax-invoke ActLo 'SetCustomScale 1.0 scl)     ; Set Custom Scale set elsewhere
  (setq paperList
(mapcar '(lambda (x) (vlax-invoke ActLo 'GetLocaleMediaName x))
(vlax-invoke ActLo 'GetCanonicalMediaNames)
)
  )
  (vla-put-CanonicalMediaName ActLo (cdr(car paperList)))

  (vlax-invoke Actlo 'RefreshPlotDeviceInfo)
  (vlax-invoke ActDoc 'Regen acActiveViewport)     ; Regen Viewport
)

Command: !paperlist
("Previous paper size  (593.98 x 1099.95 mm)" "Oversize: US Executive
(landscape)" "Oversize: JIS B5  (landscape)" "Oversize: US Legal  (landscape)"
"Oversize: ISO Super A3 (landscape)" ...............


I have also attached an image showing the error generated in vlide

Any suggestions as to what I am missing in trying to set the plotter page size?

Cheers
Scott

AutoCAD Dos R9 - 2018 and BricCAD 18.2

dustinthiesse

  • Guest
Re: Specify plotter paper size?
« Reply #10 on: January 30, 2009, 08:26:55 AM »
Code: [Select]
(setq paperList
(mapcar '(lambda (x) [color=red](cons [/color] (vlax-invoke ActLo 'GetLocaleMediaName x) [color=red]x)[/color])
(vlax-invoke ActLo 'GetCanonicalMediaNames)
)
)

Those parts in red are kind of important.  Otherwise when you do "(cdr(car(paperlist)))" it will error on the "cdr" because you have no dotted pairs. 

scottcd

  • Newt
  • Posts: 52
Re: Specify plotter paper size?
« Reply #11 on: January 30, 2009, 03:52:35 PM »
Ahhhh! amazing the difference a few letters make!

That seems to have sorted the page size, but now for some reason the units are not being set to mm?

Ah well, something to think about over the weekend...

Thanks for all the help.

Have a good weekend everybody.

Time for a beer :-)
AutoCAD Dos R9 - 2018 and BricCAD 18.2

scottcd

  • Newt
  • Posts: 52
Re: Specify plotter paper size?
« Reply #12 on: February 02, 2009, 10:56:25 AM »
Right, back to the grind..

for some reason the paper units are not being set to mm

Code: [Select]
(vlax-put ActLo 'paperunits 1)
Seems to keep defaulting to inches?

Is there a trick to the order I am setting everything?

Cheers
Scott

AutoCAD Dos R9 - 2018 and BricCAD 18.2

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Specify plotter paper size?
« Reply #13 on: February 02, 2009, 11:07:12 AM »
Looks like I used to ' RefreshPlotDeviceInfo ' before I set any of the properties.  Hopefully that will fix the issue.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

scottcd

  • Newt
  • Posts: 52
Re: Specify plotter paper size?
« Reply #14 on: February 02, 2009, 11:14:55 AM »
Hurrah!

Thanks very much for the much needed nudge!

If anyone else is interested here is the working code.

Code: [Select]
(defun nortec_setplotter ()
  (prompt "\nSetting Layout Plotting Parameters....")
  (setq AcadObj (vlax-get-Acad-Object))
  (setq FilesObj (vla-get-Files (vla-get-Preferences AcadObj)))
  (setq ActLo (vla-get-ActiveLayout (vla-get-ActiveDocument AcadObj)))
  (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (vlax-put ActLo 'ConfigName "HP DesignJet 500 42 by HP.pc3")     ; Plotter Name
  (setq paperList
(mapcar '(lambda (x) (cons (vlax-invoke ActLo 'GetLocaleMediaName x) x))
(vlax-invoke ActLo 'GetCanonicalMediaNames)
)
  )
    (vlax-invoke Actlo 'RefreshPlotDeviceInfo)
  (vla-put-CanonicalMediaName ActLo (cdr (nth 72 paperlist)))
  (vlax-put ActLo 'paperunits 1)     ; Plot Millimeters
  (vlax-put ActLo 'PlotType acExtents)     ; Plot Extents
  (vlax-put Actlo 'PlotRotation ac0degrees)     ; Plot Landscape
  (vlax-put ActLo 'StandardScale acVpCustomScale)     ; Use Custom Linetype Scale
  (vlax-put Actlo 'CenterPlot -1)     ; Centre Plotting
  (vlax-invoke ActLo 'SetCustomScale 1.0 scl)     ; Set Custom Scale set elsewhere
  (vlax-invoke ActDoc 'Regen acActiveViewport)     ; Regen Viewport
;;;  (vlax-dump-object Actlo)
)
AutoCAD Dos R9 - 2018 and BricCAD 18.2