Author Topic: Copy & Paste to All Layouts  (Read 1925 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10365
Copy & Paste to All Layouts
« on: June 19, 2004, 11:27:02 AM »
If anyone is interested here is a routine to copy objects from one layout tab to
all other layout tabs.

Code: [Select]
;;;  Copy2Tabs.lsp by Charles Alan Butler
;;;         Copyright 2004
;;;  by Precision Drafting & Design All Rights Reserved.
;;;  Contact at ab2draft@TampaBay.rr.com
;;;
;;;   Version 1.0 Beta  June 19,2004
;;;
;;; DESCRIPTION
;;;  Copy objects in one layout to all layouts
;;;   keeping the same insertion point
;;;
;;;  Limitations
;;;  Can not use in Model Space
;;;
;;; Command Line Usage
;;; Command: c2t
;;;
;;;  Options: none
;;;
;;;  This software is provided "as is" without express or implied      ;
;;;  warranty.  All implied warranties of fitness for any particular   ;
;;;  purpose and of merchantability are hereby disclaimed.             ;
;;;  You are hereby granted permission to use, copy and modify this    ;
;;;  software without charge, provided you do so exclusively for       ;
;;;  your own use or for use by others in your organization in the     ;
;;;  performance of their normal duties, and provided further that     ;
;;;  the above copyright notice appears in all copies and both that    ;
;;;  copyright notice and the limited warranty and restricted rights   ;
;;;  notice appear in all supporting documentation.                    ;
(defun c:c2t (/ cnt ss ctab omited sslen sscnt elst newent tab)
  ;;  Returns T if Locked
  ;;        nil if Unlocked or not found
  ;;        nil if lname is not a string
  (defun islayerlocked (lname / entlst)
    (and (= 'str (type lname))
         (setq entlst (tblsearch "LAYER" lname))
         (= 4 (logand 4 (cdr (assoc 70 entlst))))
    )
  ); defun
  (defun count ()
    (if (= cnt 0) ; count only once
      ;;  count the omitted from copy
      (setq omited (1+ omited))
    )
  ); defun
  (if (= (getvar "tilemode") 1)
    (alert "\nYou must be in Paper Space to run this routine.\t")
    (progn ; else you are in paper space, ok to proceed
      (if (/= (getvar "cvport") 1) ; a view port is active
        (command "_pspace") ; close the view port
      )
      (prompt "\nSelect objects to copy")
      (if (setq ss (ssget))
        (progn
          (setq ctab (getvar "ctab"))
          (setq cnt    0
                omited 0
                sslen  (sslength ss)
          )
          (foreach tab (layoutlist)
            (if (not (member tab (list "Model" ctab)))
              (progn
                (setq sscnt (sslength ss))
                (while (>= (setq sscnt (1- sscnt)) 0)
                  (setq elst (entget (ssname ss sscnt)))
                  (if (assoc 410 elst)
                    (progn
                      (if (null (islayerlocked (cdr (assoc 8 elst))))
                        (progn ; do not copy is layer is locked
                          (setq newent (subst (cons 410 tab) (assoc 410 elst) elst))
                          (if (null(entmake newent))
                            (count) ; rejected entity
                          )
                        )
                        (count) ; locked layer
                      )
                    )
                    (count) ; no 410 code
                  )
                )
                (setq cnt (1+ cnt))
              )
            )
          )
          (prompt
            (strcat "\n"(itoa cnt)" Layouts Updated with "(itoa sslen)
                         " items selected and "(itoa omited)" items not copied.")
          )
        )
      )
    )
  )
  (princ)
)
(prompt "\ncopy2tabs loaded, enter c2t to run.")
(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.