MvdP
Looking at you routine I had two problems. First was the language and the other was
the size of the routine. It is a bigger job than I am willing to tackle.
I did go through and change some of the code to show you other methods of doing
a particular task. I marked the code changes with ; CAB modified so you can look
at the changes. see the attachment.
Also here is some code that will get all the plot devices and there paper sizes.
I did not add it to your code. I think you can do that. Because the accusation of the
data is slow (very slow) I suggest you get all the data & hold it in a variable and
not try to get the paper size each time the user picks a new device. You could pop up
an alert box to ask the user to WAIT while the data is being colected.
But that is up to you to decide.
;; test to get all paper Sizes for all devices
(defun c:gps (/ ad )
(setq AD (vla-get-activedocument (vlax-get-acad-object)))
;;(setq pdlist (GetPlotDevices ad)) ; get all plot devices
;;(setq tmp (GetLocaleMediaName ad)) ; get current
(setq tmp (ListAllLocalMediaNames ad))
;; returns a list of all devices & list of there paper sizes
;; (( "device name1" ("papersize1" "papersize2" etc))
;; ( "device name2" ("papersize1" "papersize2" etc))
;; )
)
;; The source of the sub routines with minor modifications by CAB
;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2003 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com / http://jtbworld.vze.com
;;; E-mail: info@jtbworld.com / jtbworld@hotmail.com
(defun GetCanonicalMediaNames (ad)
(vla-refreshplotdeviceinfo (vla-get-activelayout ad))
(vlax-safearray->list
(vlax-variant-value
(vla-getcanonicalmedianames
(vla-item (vla-get-layouts ad) "Model")
)
)
)
)
(defun GetLocaleMediaName (ad / mn mnl)
(setq la (vla-item (vla-get-layouts ad) "Model"))
(foreach mn (GetCanonicalMediaNames ad)
(setq mnl (cons (vla-getlocalemedianame la mn) mnl))
)
(reverse mnl)
)
(defun ListAllMediaNames (ad / al cn pd apmn)
(setq al (vla-get-activelayout ad))
(setq cn (vla-get-configname al))
(foreach pd (GetPlotDevices)
(if (/= pd "None")
(progn
(vla-put-configname al pd)
(setq apmn (cons pd apmn))
(setq apmn (cons (GetCanonicalMediaNames ad) apmn))
)
)
)
(if (/= cn "None")
(vla-put-configname al cn)
)
(reverse apmn)
)
(defun ListAllLocalMediaNames (ad / al cn pd apmn err)
(setq al (vla-get-activelayout ad))
(setq cn (vla-get-configname al))
(foreach pd (GetPlotDevices ad)
(if (/= pd "None")
(progn
(setq err
(vl-catch-all-apply
'vla-put-configname
(list al pd)
)
)
(if (vl-catch-all-error-p err)
(setq apmn (cons (list pd (vl-catch-all-error-message err)) apmn))
;; else proceed to get names
(setq apmn (cons (list pd (GetLocaleMediaName ad)) apmn))
)
)
)
)
(if (/= cn "None")
(vla-put-configname al cn)
)
(reverse apmn)
)
(defun GetPlotDevices (ad)
(vla-refreshplotdeviceinfo (vla-get-activelayout ad))
(vlax-safearray->list
(vlax-variant-value
(vla-getplotdevicenames
(vla-item (vla-get-layouts ad) "Model")
)
)
)
)