Author Topic: page setup routine  (Read 6747 times)

0 Members and 1 Guest are viewing this topic.

MvdP

  • Guest
page setup routine
« on: September 05, 2005, 10:52:16 AM »
I have written a pagesetup routine.
In here in can choose scale and papersize and its makes layers, dimstyles and text styles and inserts a stamp if wanted.
But....... this only works in modelspace.
So now i am in the proces of trying to improve this routine by adding  a toggle in my dcl (This part is already working)that when activated it will show 4 popuplists (not activated greyed-out)in which i can choose all availabele plotters,its papersizes,all availabele plotstyles and scale.I know this can be done with visual  lisp but it much more difficult than lisp.So can somebody help me in the right direction how to make the 4  listings and show me how to assign the selected items to the new layout.

I know i am asking a lot but in advance thanks for your collaboration.

MvdP

Some pieces of code i found on the net...


; Return a list of all Plotter configurations
(defun PlotDeviceNamesList ()
  (vla-RefreshPlotDeviceInfo (ActLay))
  (vlax-safearray->list
    (vlax-variant-value
      (vla-GetPlotDeviceNames
   (ActLay)
      )
    )
  )
)


; Return a list of all Plot style tables
(defun PlotStyleTableNamesList ()
  (vla-RefreshPlotDeviceInfo (ActLay))
  (vlax-safearray->list
    (vlax-variant-value
      (vla-GetPlotStyleTableNames
   (ActLay)
      )
    )
  )
)





« Last Edit: September 05, 2005, 11:08:57 AM by MvdP »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: page setup routine
« Reply #1 on: September 05, 2005, 12:47:00 PM »
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 #2 on: September 05, 2005, 12:51:09 PM »
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 #3 on: September 05, 2005, 12:54:09 PM »
Here ia another that may be of interest.
http://www.theswamp.org/forum/index.php?topic=1916.0
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 #4 on: September 05, 2005, 02:00:28 PM »
That is indeed "some" reading.....and doing it right now.
Thanks CAB

MvdP

  • Guest
Re: page setup routine
« Reply #5 on: September 06, 2005, 08:50:24 AM »
This is some of what i got sofar,but i can't get it to work what am i missing here.?
When i type (princ device-list) on the command line a can see all the plotters but they aint show up in my dropdownlist.


;;===============================================
(defun plotall_device_list (/ curdwg pslayout)
  (vl-load-com)
  (setq
    curdwg (vla-get-ActiveDocument (vlax-get-Acad-Object))
    pslayout (vla-get-Layout (vla-get-PaperSpace curdwg))
  )
  ; Call RefreshPlotDeviceInfo before GetPlotDeviceNames
  (vla-RefreshPlotDeviceInfo pslayout)
  (vlax-safearray->list (vlax-variant-value (vla-GetPlotDeviceNames pslayout)))
) ; End plotall_device_list

;;===============================================
  (defun init_vars ()
    (if (not PLOTALL-DEVICE) (setq PLOTALL-DEVICE "None"))
         (setq  device-list (plotall_device_list))
          (if (and PLOTALL-DEVICE (member PLOTALL-DEVICE device-list))
      (setq
        device#
         (- (length device-list) (length (member PLOTALL-DEVICE device-list)))
      )
      (setq device# 0)
    )
  ) ; End init_vars

;;===============================================



the lisp starts with
  (init_vars)
  (plotall_device_list)
 

(action_tile "tilemode" "(mode_tile \"list_plotter\" (- 1 (atoi $value)))
(mode_tile \"list_plotstyle\" (- 1 (atoi $value)))
(mode_tile \"list_papierformaat\" (- 1 (atoi $value)))
(mode_tile \"list_plotschaal\" (- 1 (atoi $value)))")
   
(action_tile "list_plottter" "(setq plt (nth (atoi $value) device-list))"  )
(action_tile "list_plotstyle" "(setq pls (nth (atoi $value) plotstyle-list))"  ) 
(action_tile "list_papierformaat" "(setq pf (nth (atoi $value) papierformaat-list))"  )
(action_tile "list_plotschaal" "(setq posch (nth (atoi $value) plotschaal-list))" )




V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: page setup routine
« Reply #6 on: September 06, 2005, 08:56:56 AM »

Code: [Select]
   (start_list "list_plottter" )
   (mapcar 'add_list device-list)
   (end_list)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

MvdP

  • Guest
Re: page setup routine
« Reply #7 on: September 06, 2005, 09:19:18 AM »

Code: [Select]
   (start_list "list_plottter" )
   (mapcar 'add_list device-list)
   (end_list)

That didn't do the trick..

It did the trick typo

Thanks
« Last Edit: September 06, 2005, 09:50:18 AM by MvdP »

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: page setup routine
« Reply #8 on: September 06, 2005, 12:11:31 PM »

Please post all code so that I can help.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

MvdP

  • Guest
Re: page setup routine
« Reply #9 on: September 06, 2005, 12:16:25 PM »
What makes more sense.
To make 3 more init_vars and defuns (for plotstyle,papersize and scale) or add it to this one
;;===============================================
(defun plotall_device_list (/ curdwg pslayout)
  (vl-load-com)
  (setq
    curdwg (vla-get-ActiveDocument (vlax-get-Acad-Object))
    pslayout (vla-get-Layout (vla-get-PaperSpace curdwg))
  )
  ; Call RefreshPlotDeviceInfo before GetPlotDeviceNames
  (vla-RefreshPlotDeviceInfo pslayout)
  (vlax-safearray->list (vlax-variant-value (vla-GetPlotDeviceNames pslayout)))
) ; End plotall_device_list

;;===============================================
  (defun init_vars ()
    (if (not PLOTALL-DEVICE) (setq PLOTALL-DEVICE "None"))
         (setq  device-list (plotall_device_list))
          (if (and PLOTALL-DEVICE (member PLOTALL-DEVICE device-list))
      (setq
        device#
         (- (length device-list) (length (member PLOTALL-DEVICE device-list)))
      )
      (setq device# 0)
    )
  ) ; End init_vars

;;===============================================

If possible of course.

MvdP

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: page setup routine
« Reply #10 on: September 06, 2005, 02:05:02 PM »
Food for thought..

Code: [Select]
(defun init_vars ()
  (or PLOTALL-DEVICE (setq PLOTALL-DEVICE "None"))
  (setq device-list (plotall_device_list))
  (or (setq device# (vl-position  PLOTALL-DEVICE device-list))
      (setq device# 0)
  )
  device#
)
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 #11 on: September 07, 2005, 01:46:07 AM »
Food for thought..

Code: [Select]
(defun init_vars ()
  (or PLOTALL-DEVICE (setq PLOTALL-DEVICE "None"))
  (setq device-list (plotall_device_list))
  (or (setq device# (vl-position  PLOTALL-DEVICE device-list))
      (setq device# 0)
  )
  device#
)


CAB
I don't understand.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: page setup routine
« Reply #12 on: September 07, 2005, 08:22:05 AM »
I was just showing you another way to write the subroutine.
Here it is with comments.

Code: [Select]
(defun init_vars ()
  ;;  'or' elvaluates expressions until one returns a non nil value
  ;;  so if PLOTALL-DEVICE is nil, it is set to "None"
  (or PLOTALL-DEVICE (setq PLOTALL-DEVICE "None"))

  ;;  same as yours, get the list
  (setq device-list (plotall_device_list))

  ;;  'or' again, sets device# to the position number OR to zero
  ;;  zero in this case being "None"
  (or (setq device# (vl-position  PLOTALL-DEVICE device-list))
      (setq device# 0)
  )

  ;;  return the device number
  device#
)
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 #13 on: September 07, 2005, 08:30:12 AM »
Why don't you take dvarino up on his offer to help you with the code.
Just attach the lisp & dcl file to your post & he can at least test it for you
on another machine. Another pair of eyes is always helpful.
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 #14 on: September 07, 2005, 09:10:20 AM »
When i select a device in my popup-list the paper sizes arent updated so i guess i am doing something wrong.!!

So here is the huge code.
Not al that is necessary is attached in this post (stamp, fonts and external layer routines)
Remember it is my first attempt and any help is appreciated.

MvdP

Something a forgot to ask is it possible to make a default device and plotstyle.?
« Last Edit: September 07, 2005, 09:12:18 AM by MvdP »

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...