egjg1234 Posted December 9, 2020 Posted December 9, 2020 (edited) Hello Everyone, Been looking through lee mac's website for helpful lisp routines for work and found this copy2layouts lisp routine he created. When I start the command, it doesn't seem to select any objects I have within the layout for me to copy. Instead, it only selects object in the model space. Can anyone help me with this? And if Lee Mac see this, BIG FAN! Copy2LayoutsV1-1.lsp © 2020 Lee Mac DarkLightVLIDE ;;-----------------------=={ Copy to Layouts }==------------------------;; ;; ;; ;; This program enables a user to quickly copy a selection of objects ;; ;; to all or selected layouts in a drawing. ;; ;; ;; ;; Upon calling the program with 'C2L' at the command line, the user ;; ;; is prompted to make a selection of objects in the active layout to ;; ;; copy. Following selection, the user is prompted, via a dialog ;; ;; interface, to choose one or more layouts to which the objects will ;; ;; be copied. ;; ;; ;; ;; If the program is called with 'C2AL' at the command line, every ;; ;; object in the selection is automatically copied to all layouts ;; ;; in the drawing, without the use of the dialog interface. ;; ;; ;; ;;----------------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2013 - www.lee-mac.com ;; ;;----------------------------------------------------------------------;; ;; Version 1.0 - 10-02-2011 ;; ;; ;; ;; First Release. ;; ;;----------------------------------------------------------------------;; ;; Version 1.1 - 08-07-2013 ;; ;; ;; ;; Entire program rewritten. ;; ;;----------------------------------------------------------------------;; (defun c:c2l nil (copy2layouts nil)) ;; Copy to selected layouts (defun c:c2al nil (copy2layouts t)) ;; Copy to all layouts (defun copy2layouts ( all / lst obl sel tab ) (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (if (= 1 (getvar 'cvport)) (setq tab (strcase (getvar 'ctab))) (setq tab "MODEL") ) (if (ssget (list (cons 410 tab))) (progn (vlax-for lay (vla-get-layouts (LM:acdoc)) (if (/= tab (strcase (vla-get-name lay))) (setq lst (cons (cons (vla-get-name lay) lay) lst)) ) ) (if (or (and all (setq lst (mapcar 'cdr lst))) (setq lst (mapcar '(lambda ( x ) (cdr (assoc x lst))) (LM:listbox "Choose Layouts to Copy to" (mapcar 'car (vl-sort lst '(lambda ( a b ) (< (vla-get-taborder (cdr a)) (vla-get-taborder (cdr b)))))) t ) ) ) ) (progn (vlax-for obj (setq sel (vla-get-activeselectionset (LM:acdoc))) (setq obl (cons obj obl)) ) (vla-delete sel) (LM:startundo (LM:acdoc)) (foreach lay lst (vlax-invoke (LM:acdoc) 'copyobjects obl (vla-get-block lay))) (LM:endundo (LM:acdoc)) ) ) ) ) (princ) ) ;;-----------------------=={ List Box }==---------------------;; ;; ;; ;; Displays a List Box allowing the user to make a selection ;; ;; from the supplied data. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2012 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; title - List Box Dialog title ;; ;; lst - List of Strings to display in the List Box ;; ;; multiple - Boolean flag to determine whether the user ;; ;; may select multiple items (T=Allow Multiple) ;; ;;------------------------------------------------------------;; ;; Returns: List of selected items, else nil. ;; ;;------------------------------------------------------------;; (defun LM:ListBox ( title lst multiple / dch des tmp res ) (cond ( (not (and (setq tmp (vl-filename-mktemp nil nil ".dcl")) (setq des (open tmp "w")) (write-line (strcat "listbox : dialog { label = \"" title "\"; spacer; : list_box { key = \"list\"; multiple_select = " (if multiple "true" "false") "; } spacer; ok_cancel; }" ) des ) (not (close des)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "listbox" dch) ) ) (prompt "\nError Loading List Box Dialog.") ) ( t (start_list "list") (foreach item lst (add_list item)) (end_list) (setq res (set_tile "list" "0")) (action_tile "list" "(setq res $value)") (setq res (if (= 1 (start_dialog)) (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" res ")"))) ) ) ) ) (if (< 0 dch) (unload_dialog dch) ) (if (and tmp (setq tmp (findfile tmp))) (vl-file-delete tmp) ) res ) ;; Start Undo - Lee Mac ;; Opens an Undo Group. (defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc) ) ;; End Undo - Lee Mac ;; Closes an Undo Group. (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc) ) ;;----------------------------------------------------------------------;; (vl-load-com) (princ (strcat "\n:: Copy2Layouts.lsp | Version 1.1 | \\U+00A9 Lee Mac " (menucmd "m=$(edtime,$(getvar,date),YYYY)") "\n:: Available Commands:" "\n:: \"C2L\" - Copy to selected layouts." "\n:: \"C2AL\" - Copy to all layouts." ) ) (princ) ;;----------------------------------------------------------------------;; ;; End of File ;; ;;----------------------------------------------------------------------;; Edited December 10, 2020 by SLW210 Added Code Tags Quote
Lee Mac Posted December 12, 2020 Posted December 12, 2020 Do you perhaps have an active Modelspace viewport when running the command within a Paperspace layout? Quote
egjg1234 Posted December 14, 2020 Author Posted December 14, 2020 On 13/12/2020 at 02:49, Lee Mac said: Do you perhaps have an active Modelspace viewport when running the command within a Paperspace layout? Not at all from the tests ive been doing, its only does seem to work only in the model space. Whenever i try to select a block or object in paperspace it doesnt highlight it Quote
Magnum Z Posted December 15, 2020 Posted December 15, 2020 From what I understand, you need to copy stuff from one layout to another. If so, I know this won't be as efficient as the lisp is intended to be, but it may at least help out until you can get it working properly. I've attached a couple actions I made for this purpose a while ago. If you're not familiar with them, think of them as macros that you can call like a regular command or lisp routine. Place them in your actions folder and you're off to races. You may need to restart your AutoCAD or at the very least close and reopen your drawing. The Actions folder can be located via Options under the Files tab labeled Action Recorder Settings. Usage: Select what you want to copy on a layout (paper space), enter PSCOPY, navigate to another layout, PSPASTE, navigate to another layout, PSPASTE, etc... Hope that helps. Even temporarily. PSCOPY.actm PSPASTE.actm Quote
vuxvix Posted August 24, 2023 Posted August 24, 2023 Hi! I recently used this lisp to copy viewport and block from one layout and paste the same position in other layouts. however, the C2AL: command works but on some layouts. I checked the newly pasted viewports and it shows nothing. I check the properties the viewports are not showing Misc: On: No. I changed it back to Yes. So how do I edit this lisp. To make sure it displays properly as the original viewport. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.