MfgEng Posted December 13, 2022 Posted December 13, 2022 This lisp works great in AutoCAD, but it fails to prompt for the initial "Base Point" and "Select objects" when run in DraftSight. I see those prompts bracketed within "(if (and" logic. Can anyone show me the necessary modifications to force it to display those two initial prompts (Base point & Select objects) when run in DraftSight? ;;; CopyRotate.lsp by Charles Alan Butler ;;; by Precision Drafting & Design All Rights Reserved. ;;; Contact at ab2draft[at]TampaBay.rr.com ;;; ;;; Version 4.0 Beta Feb 07,2005 ;;; ;;; DESCRIPTION ;;; User pick base point then selects object(s) ;;; Paste mode until Escape is pressed ;;; Once pasted user selects rotation angle ;;; ;;; Command Line Usage ;;; Command: copyr ;; Copy objects, then paste & rotate new copy ;; does not show the objects during paste (defun c:crot (/ pt ss elast ssnew) ; ; ;; Rune Wold and Michael Puckett - modified ale_lastent ale_ss-after (defun ale_lastent (/ entnam outval) (and (setq outval (entlast)) (while (setq entnam (entnext outval)) (setq outval entnam) ) ) outval ) (defun ale_ss-after (entnam / entnxt selset) (cond ((not entnam) (ssget "_X")) ((setq entnxt (entnext entnam)) (setq selset (ssadd entnxt)) (while (setq entnxt (entnext entnxt)) (if (entget entnxt) (ssadd entnxt selset) ) ) selset ) ) ) (if (and (setq pt (getpoint "\nPick base point of object to copy:")) (null (prompt "\nSelect objects to copy:")) (setq ss (ssget)) ) (progn (command "._copybase" pt ss "") (while (setq pt (getpoint "\nPick insertion point.")) ;; get last item in database (setq elast (ale_lastent)) (command "._pasteclip" pt) ;; get new items pasted. (setq ssnew (ale_ss-after elast)) ;; allow user to rotate (command "._rotate" ssnew "" pt pause) ) ; while ) ; progn ) ; endif ; ; ; (princ) ) (princ) Quote
mhupp Posted December 14, 2022 Posted December 14, 2022 (edited) Might have to do with the null in the prompt not sure. Personal preference but I like to call ssget first thing. This allows you to have things already selected if you run the command. If the getpoint was called first everything is deselected. Try this updated code Its a little more straight forward. and doesn't need subroutines. ;;----------------------------------------------------------------------------;; ;; Copy and Rotate Selected Objects (defun C:foo (/ LastEnt SS pt SScopy ent) (setq LastEnt (entlast)) (prompt "\nSelect Objects to Copy: ") (if (and (setq SS (ssget)) (setq pt (getpoint "\nBase Point: "))) (progn (command "_.Copybase" pt SS "") (while (setq pt (getpoint "\nInsertion Point: ")) (setq SScopy (ssadd)) (command "_.Pasteclip" pt) (while (setq LastEnt (entnext LastEnt)) (ssadd LastEnt SScopy) (setq LastEnt (entnext LastEnt)) ) (command "_.Rotate" SScopy "" pt pause) (setq SScopy nil) ) ; while ) ; progn ) ; endif (princ) ) Edited December 14, 2022 by mhupp Quote
MfgEng Posted December 14, 2022 Author Posted December 14, 2022 I tried your code in DraftSight, and like my original post, it does not display the prompts. It also crashes before it rotates the copied objects. This is not a criticism, as I recognize it could be further debugged and/or developed. I decided to open a different lisp that in use does show prompts in DraftSight, and noticed this line just before the prompts: (command "undo" "be"). Just for kicks I added it to my original lisp and it works now! Obviously I'm not a lisp guru, so I'm not exactly sure why that command makes the difference, but there it is. Here is my working lisp with the additions separated with this note: ;;;;; Addition : ;;; CopyRotate.lsp by Charles Alan Butler ;;; by Precision Drafting & Design All Rights Reserved. ;;; Contact at ab2draft[at]TampaBay.rr.com ;;; ;;; Version 4.0 Beta Feb 07,2005 ;;; ;;; DESCRIPTION ;;; User pick base point then selects object(s) ;;; Paste mode until Escape is pressed ;;; Once pasted user selects rotation angle ;;; ;;; Command Line Usage ;;; Command: copyr ;; Copy objects, then paste & rotate new copy ;; does not show the objects during paste (defun c:crot (/ pt ss elast ssnew) ; ; ;; Rune Wold and Michael Puckett - modified ale_lastent ale_ss-after (defun ale_lastent (/ entnam outval) (and (setq outval (entlast)) (while (setq entnam (entnext outval)) (setq outval entnam) ) ) outval ) (defun ale_ss-after (entnam / entnxt selset) (cond ((not entnam) (ssget "_X")) ((setq entnxt (entnext entnam)) (setq selset (ssadd entnxt)) (while (setq entnxt (entnext entnxt)) (if (entget entnxt) (ssadd entnxt selset) ) ) selset ) ) ) ; ;;;;; Addition (command "undo" "be") ;;;;; Addition end ; (if (and (setq pt (getpoint "\nPick base point of object to copy:")) (null (prompt "\nSelect objects to copy:")) (setq ss (ssget)) ) (progn (command "._copybase" pt ss "") (while (setq pt (getpoint "\nPick insertion point.")) ;; get last item in database (setq elast (ale_lastent)) (command "._pasteclip" pt) ;; get new items pasted. (setq ssnew (ale_ss-after elast)) ;; allow user to rotate (command "._rotate" ssnew "" pt pause) ) ; while ) ; progn ) ; endif ; ; ; ;;;;; Addition (command "undo" "e") ;;;;; Addition end ;; (princ) ) (princ) Please consider this request as Solved. -MfgEng 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.