Author Topic: pagesetup lisp  (Read 15001 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
pagesetup lisp
« on: November 04, 2004, 01:27:57 PM »
i have copied somebody elses's stuff but i modified it. tell me what you think. im a total noOb, please bear with me. this a lisp routine that will import pagesetups from a file. if i new more i would make it so that it doesnt have to reference files and rather make pagesetups through variables. it works for me but is this common practice in lisp?

Quote

;loads pagesetups for 1"=1'-0"
(defun C:123624(/ Save_Expert)
  (setq Save_Expert (getvar "EXPERT"))
  (setvar "EXPERT" 2)
  (command "_.-PSETUPIN" "S:/WYNN-CAD/pagesetups/12_36x24.dwg" "*")
  (setvar "EXPERT" Save_Expert)
  (princ)
)

;loads pagesetups for 3/4"=1'-0"
(defun C:163624(/ Save_Expert)
  (setq Save_Expert (getvar "EXPERT"))
  (setvar "EXPERT" 2)
  (command "_.-PSETUPIN" "S:/WYNN-CAD/pagesetups/16_36x24.dwg" "*")
  (setvar "EXPERT" Save_Expert)
  (princ)
)

;loads pagesetups for 1/4"=1'-0"
(defun C:483624(/ Save_Expert)
  (setq Save_Expert (getvar "EXPERT"))
  (setvar "EXPERT" 2)
  (command "_.-PSETUPIN" "S:/WYNN-CAD/pagesetups/48_36x24.dwg" "*")
  (setvar "EXPERT" Save_Expert)
  (princ)
)

;loads pagesetups for 1/4"=1'-0"
(defun C:483624(/ Save_Expert)
  (setq Save_Expert (getvar "EXPERT"))
  (setvar "EXPERT" 2)
  (command "_.-PSETUPIN" "S:/WYNN-CAD/pagesetups/48_36x24.dwg" "*")
  (setvar "EXPERT" Save_Expert)
  (princ)
)

;loads pagesetups for paperspace 36x24
(defun C:ps3624(/ Save_Expert)
  (setq Save_Expert (getvar "EXPERT"))
  (setvar "EXPERT" 2)
  (command "_.-PSETUPIN" "S:/WYNN-CAD/pagesetups/PS_36x24.dwg" "*")
  (setvar "EXPERT" Save_Expert)
  (princ)
)

ronjonp

  • Needs a day job
  • Posts: 7527
pagesetup lisp
« Reply #1 on: November 04, 2004, 01:40:20 PM »
Why don't you save all pagesetups in one file so you don't have to have a lisp for each one? They are easily accessible in the pulldown.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

M-dub

  • Guest
pagesetup lisp
« Reply #2 on: November 04, 2004, 01:50:13 PM »
Quote from: ronjonp
Why don't you save all pagesetups in one file so you don't have to have a lisp for each one? They are easily accessible in the pulldown.

Ron


I'll second that notion....That's what I use and it is SuWEEEET!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
pagesetup lisp
« Reply #3 on: November 04, 2004, 01:56:43 PM »
Then load them with the click of a button
^C^CDel_Pagesetups;^C^C.-PSETUPIN "PageSetups.dwg" "*"
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.

M-dub

  • Guest

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
pagesetup lisp
« Reply #5 on: November 04, 2004, 02:21:16 PM »
This subject goes way back. :)
PageSetup
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.

M-dub

  • Guest
pagesetup lisp
« Reply #6 on: November 04, 2004, 02:27:00 PM »
...and still growing!  :)

dubb

  • Swamp Rat
  • Posts: 1105
pagesetup lisp
« Reply #7 on: November 04, 2004, 02:36:00 PM »
THANK YOU GUYS....a menu bar would be nicer. the reason why i have it this because i want just the setups that i need for each drawing.

when i use
Code: [Select]

^C^CDel_Pagesetups;^C^C.-PSETUPIN "PageSetups.dwg" "*"


i get
Quote

Command: .-PSETUPIN Enter file name: "S:/WYNN-CAD/pagesetups/12_36x24.dwg"
Enter user defined page setup(s) to import or [?]: "*"
Page setup "11x17" already exists. Redefine it? [Yes/No] <N>: *Cancel*

Page setup "12_36x24" already exists. Redefine it? [Yes/No] <N>: *Cancel*


so i use hotkeys. and later i will make a pull down menu and a toolbar

M-dub

  • Guest
pagesetup lisp
« Reply #8 on: November 04, 2004, 02:37:47 PM »
Did you load Del_Pagesetups first?

M-dub

  • Guest
pagesetup lisp
« Reply #9 on: November 04, 2004, 02:38:41 PM »
Here's what I use in my button macro:
Code: [Select]
^C^C(load"O:/Drawings/Menus-Blocks/LISP/Del_Pagesetups.lsp") Del_Pagesetups;^C^C.-PSETUPIN "O:/Drawings/SupportforCAD/AutoCAD-2004-Support/PageSetups.dwg" "*" PLOT;

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
pagesetup lisp
« Reply #10 on: November 04, 2004, 02:47:43 PM »
In cas you did not get the link by m-dub
Code: [Select]
;;  Function to delete all user plot set ups
(defun c:Del_Pagesetups (/ curdwg pslayout x)
  (vl-load-com)
  (setq
    curdwg   (vla-get-ActiveDocument (vlax-get-Acad-Object))
    pslayout (vla-get-Layout (vla-get-PaperSpace curdwg))
  ) ;_ end of setq
  ;; Call RefreshPlotDeviceInfo before GetPlotDeviceNames
  (vla-RefreshPlotDeviceInfo pslayout)
  (vlax-for x (vla-get-Plotconfigurations curdwg)
    (vla-delete x)
  ) ;_ end of vlax-for
)               ; End Plot_config_list



PS this thread doesn't belong in this forum.
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.

M-dub

  • Guest
pagesetup lisp
« Reply #11 on: November 04, 2004, 02:51:03 PM »
>PS this thread doesn't belong in this forum.
*Oh yeah, forgot to mention that...*

I should also stop being lazy and paste the code in here instead of posting the link instead.  :roll:
Thanks CAB ;)

hyposmurf

  • Guest
pagesetup lisp
« Reply #12 on: March 28, 2005, 12:24:23 PM »
Im trying to sort my page setups out.I have the following macro asociated with a menu button.

^C^CDel_Pagesetups;^C^C.-PSETUPIN "A0PSETUP.dwg" "A0"

This imports the A0 page setup but it wont set it as current.Is there a way to do this?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
pagesetup lisp
« Reply #13 on: March 28, 2005, 12:32:50 PM »
Code: [Select]
; Jason Piercey . May 16th, 2003
; assign a pagesetup to a layout
; [layout] - string, layout name
; [setup] - string, pagesetup to assign
; return: T or nil
(defun putPagesetup (layout setup / layouts plots)
 (defun item-p (collection item)
  (if
   (not
    (vl-catch-all-error-p
     (vl-catch-all-apply
      '(lambda () (setq item (vla-item collection item))))))
   item
   )
  )
 (and
  (or *acad* (setq *acad* (vlax-get-acad-object)))
  (or *doc* (setq *doc* (vla-get-activedocument *acad*)))
  (setq layouts (vla-get-layouts *doc*))
  (setq plots (vla-get-plotconfigurations *doc*))
  (setq layout (item-p layouts layout))
  (setq setup (item-p plots setup))
  (not (vla-copyfrom layout setup))
  )
 )
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.

daron

  • Guest
pagesetup lisp
« Reply #14 on: March 28, 2005, 12:40:25 PM »
Quote from: CAB
...
PS this thread doesn't belong in this forum.


I was thinking the same thing.

daron

  • Guest
pagesetup lisp
« Reply #15 on: March 28, 2005, 02:49:29 PM »
I moved it to the lisp forum, away from the show your stuff forum.

hyposmurf

  • Guest
pagesetup lisp
« Reply #16 on: March 28, 2005, 03:13:55 PM »
Quote from: CAB
Code: [Select]
; Jason Piercey . May 16th, 2003
; assign a pagesetup to a layout
; [layout] - string, layout name
; [setup] - string, pagesetup to assign
; return: T or nil
(defun putPagesetup (layout setup / layouts plots)
 (defun item-p (collection item)
  (if
   (not
    (vl-catch-all-error-p
     (vl-catch-all-apply
      '(lambda () (setq item (vla-item collection item))))))
   item
   )
  )
 (and
  (or *acad* (setq *acad* (vlax-get-acad-object)))
  (or *doc* (setq *doc* (vla-get-activedocument *acad*)))
  (setq layouts (vla-get-layouts *doc*))
  (setq plots (vla-get-plotconfigurations *doc*))
  (setq layout (item-p layouts layout))
  (setq setup (item-p plots setup))
  (not (vla-copyfrom layout setup))
  )
 )



Thanks for that CAB Ive got the lisp apploaded and cant seem to get it to run.What do I need to initiate it?
psetup
putPagesetup
item-p
Probably none of these and I need to assign the name of my page setup in there somewhere. :?

daron

  • Guest
pagesetup lisp
« Reply #17 on: March 28, 2005, 03:28:14 PM »
putPagesetup requires two arguments: layout & setup. I would assume those to be your layout to set to and the setup name.

hyposmurf

  • Guest
pagesetup lisp
« Reply #18 on: March 28, 2005, 05:23:50 PM »
Im still scratching my head over where to put in my Layout 1 & A0 (which is my pagesetup name).

This next bit your going to find a bit of a mess but it works! :)

^C^CDel_Pagesetups;^C^C.-PSETUPIN "A0PSETUP.dwg" "A0" ^C^C.-INSERT "A0SML.dwg" 0,0 1 1 0 ;;;;;;;;;;;;;;;;;;

Thats the macro to insert a A0 pagesetup and my A0 titleblock.Im hoping to have this set for each titleblock and accompanying page setup.Everything is fine(well not the cleanest macro),but Im still miffed over that lisp for setting the current page setup.

daron

  • Guest
pagesetup lisp
« Reply #19 on: March 29, 2005, 07:45:18 AM »
(putPagesetup "Layout 1" "A0")

Try that.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
pagesetup lisp
« Reply #20 on: March 29, 2005, 08:44:51 AM »
To take it one step farther.
Code: [Select]
(defun c:DansHelper(/ lay)
  (foreach lay (layoutlist)
    (putPagesetup lay "A0")
  )
  (princ)
)


Dan,
Are you taking Stig's Lisp Course?
If so you will understand the 'foreach' function.
Look up the 'layoutlist' function.
I haven't been following the course but you probably have covered
passing variables between lisp routines. I am talking about
'lay' and '"A0"' here. Can you figure out what each of the four lines of
code is doing?
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.

hyposmurf

  • Guest
pagesetup lisp
« Reply #21 on: March 29, 2005, 01:02:03 PM »
Nice defun! :) As far as Stig,s lisp course has gone ...... :oops: .My workload has almost doubled at work now another employee has left and Im also trying to get myself prepared for a departure to, which leaves me hardly any spare time.I even stayed in the whole easter weekend :roll: .Sad git that I am :)  it will pay off eventually.Thanks for the lisp I'll go and have a go and come back with some feedback.The need for me to learn how to lisp is becoming more apparent everyday!

hyposmurf

  • Guest
pagesetup lisp
« Reply #22 on: August 24, 2005, 08:05:13 AM »
Quote from: CAB
To take it one step farther.
Code: [Select]
(defun c:DansHelper(/ lay)
  (foreach lay (layoutlist)
    (putPagesetup lay "A0")
  )
  (princ)
)


Dan,
Are you taking Stig's Lisp Course?


Just got back on this one and hoping to sort it before I start work tomorrow :shock: .I havent seen Stigs course since cant even find it on the swamp any more. Im going to take a guess at what each layer means.
(defun c:DansHelper(/ lay) Defines the function
  (foreach lay (layoutlist) Attains a list of layouts
    (putPagesetup lay "A0") Sets the current layout to A0
  )
  (princ)
)        Exits the lisp quietly


When I run the lisp I get:
Command: DansHelper
; error: no function definition: PUTPAGESETUP


So the last line of code needs to finished,a functioned defined?Is it not possible to add to the macro I already have to set it current that way the whole sequence of events can be set from one button?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
pagesetup lisp
« Reply #23 on: August 24, 2005, 08:17:48 AM »
Look here: http://www.theswamp.org/phpBB2/viewtopic.php?p=55224#55224

Load it with the other lisp or add it to it like
Code: [Select]
(defun c:DansHelper(/ lay)

<put it here>

  (foreach lay (layoutlist)
    (putPagesetup lay "A0")
  )
  (princ)
)
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.

hyposmurf

  • Guest
pagesetup lisp
« Reply #24 on: August 24, 2005, 09:07:31 AM »
Thanks.That is almost there it sets the pagesetup I want to be current,but I still have to reopen the page setup dialogue and hit enter before any changes to the setup in the drawing are set.