Author Topic: page setup routine  (Read 6712 times)

0 Members and 1 Guest are viewing this topic.

MvdP

  • Guest
Re: page setup routine
« Reply #15 on: September 13, 2005, 01:06:36 PM »
It must be tough nut to crack.!!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: page setup routine
« Reply #16 on: September 13, 2005, 01:44:56 PM »
I thought don was going to take a look. If not I'll look at it tonight.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: page setup routine
« Reply #17 on: September 14, 2005, 09:31:42 PM »
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.

Code: [Select]
;;  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")
      )
    )
  )
)

« Last Edit: September 14, 2005, 11:19:44 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: page setup routine
« Reply #18 on: September 14, 2005, 11:37:56 PM »
I found the source for the routines & looks like he corrected errors I found
when trying to use the old code so here is the link to the new code.
http://www.jtbworld.com/lisp/GetPlotDevices.htm

I modified the "ListAllLocalMediaNames" routine as I got an error because the
driver was missing for one of my plot devices. I also modified the return list.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MvdP

  • Guest
Re: page setup routine
« Reply #19 on: September 15, 2005, 01:52:33 AM »
CAB
I wanna thank you for your time.

MvdP

I can't get it to work i am giving this thing up..
« Last Edit: September 15, 2005, 02:15:11 AM by MvdP »

Andrea

  • Water Moccasin
  • Posts: 2372
Re: page setup routine
« Reply #20 on: September 18, 2005, 07:02:24 PM »
why complicate programming...

Just make your page setup default in a blank drawing...and than insert-it !!
Keep smile...