TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: aswin on June 07, 2017, 01:07:14 AM

Title: LISP HELP - Combine functions into single COMMAND
Post by: aswin on June 07, 2017, 01:07:14 AM
Hi friends .. I am posting a lisp here... this lisp functions are  'CURRENT LAYOUT SETUP TO ALL LAYOUT TABS' and 'PRINT ALL LAYOUTS TABS' .
but i have to enter two comments ,

CPS='CURRENT LAYOUT SETUP TO ALL LAYOUT TABS'
PT  ='PRINT ALL LAYOUTS TABS'

can we make this into a single command for both functions?

-----------------------------------------------------------------------------------------------------------------------------------------------------------
Code - Auto/Visual Lisp: [Select]
  1.  
  2. ;; Copy current layout page setup to all layout tabs
  3. (defun c:CPS (/ Adoc Layts clyt)
  4.         Layts (vla-get-layouts aDoc)
  5.         clyt  (vla-get-activelayout aDoc)
  6.   )
  7.             itm
  8.                (vl-remove (vla-get-name clyt) (layoutlist))
  9.     (vla-copyfrom (vla-item Layts itm) clyt)
  10.   )
  11.   (princ)
  12. )
  13.  
  14.  
  15.  
  16. (Defun C:PT
  17.             (/ PLO_LAYOUTS PLO_CNTR PLO_LIST PLO_LAYOUTTAB)
  18.   (setvar "FILEDIA" 0)
  19.   (setvar "CMDDIA" 0)
  20.   (initget 6) ; disallow 0 or <0
  21.   (setq nofs (getint "Enter number of sets: <1>"))
  22.   (setq nofs (if (or nofs (= nofs 0)) nofs  1))
  23.   (setq PLO_LAYOUTS
  24.          (vla-get-layouts
  25.          )
  26.   )
  27.   (vlax-for PLO_LAYOUT PLO_LAYOUTS
  28.     (setq plo_list (cons (vla-get-name PLO_LAYOUT) plo_list))
  29.   )
  30.   (setq PLO_LIST (reverse PLO_LIST))
  31.   (while (>= nofs 1)
  32.     (setq plo_cntr 0)
  33.     (repeat (1- (length plo_list)) ; plot all but MODEL
  34.       (setq PLO_LAYOUTTAB (nth PLO_CNTR PLO_LIST))
  35.       (command "-PLOT" "n" PLO_LAYOUTTAB "" "" "" "" "" "")
  36.       (setq PLO_CNTR (1+ PLO_CNTR))
  37.     )
  38.     (prompt "\nPlot Set Complete")
  39.     (setq nofs (1- nofs))
  40.   )
  41.  
  42.   (setvar "FILEDIA" 1)
  43.   (setvar "CMDDIA" 1)
  44.   (princ)
  45. )
  46.  

Edit kdub : changed Subject title to be descriptive.
                   add code tags
Title: Re: LISP HELP - Combine functions into single COMMAND
Post by: kdub_nz on June 07, 2017, 04:54:52 AM

You could try something like :
Code - Auto/Visual Lisp: [Select]
  1. (defun c:CPS-PT ()
  2.  
  3.         (c:CPS)
  4.         (c:PT)
  5.  
  6.         (princ)
  7. )
Title: Re: LISP HELP - Combine functions into single COMMAND
Post by: aswin on June 07, 2017, 05:02:16 AM
@kdub
thank you soo much...