COPYBASE w/ 0,0
I wrote 2 lisp routines, but they do not work well.One is to do a copybase at 0,0 and the other is to paste at 0,0.; ==================================================================================================(defun c:cpz ()(command "_copybase" "0,0" "")(princ));_defun; ==================================================================================================(defun c:pcz ()(command "pasteclip" "0,0" "")(princ));_defun; ==================================================================================================How can I improve the code?
Greg Here are some minor improvements:
(defun c:cpz ( / s ) (if (setq s (ssget)) (command "_.copybase" "_non" '(0 0) s "")) (princ))(defun c:pcz ( ) (command "_.pasteclip" "_non" '(0 0)) (princ))
Beautiful!Thank you, Sir!
Greg
I think I understand everything but the "_non".What function does that do?
Greg This is what I use:
;; Copy items to clip board @ 0,0,0(defun c:cb (/ ss) (setvar 'cmdecho 0) (if (setq ss (ssget ":L")) (progn (if (= 1.0 (car (getvar 'ucsxdir))) (command "_.copybase" '(0 0 0) ss "") (progn (command "_.ucs" "world") (command "_.copybase" '(0 0 0) ss "") (command "_.ucs" "view") ) ) (princ (strcat "\n" (itoa (sslength ss)) " items copied to clip board...")) ) ) (setvar 'cmdecho 1) (princ));; Paste items copied to clip board @ 0,0,0(defun c:cv nil (setvar 'cmdecho 0) (if (= 1.0 (car (getvar 'ucsxdir))) (command "_.pasteclip" '(0 0 0)) (progn (command "_.ucs" "world") (command "_.pasteclip" '(0 0 0)) (command "_.ucs" "view")) ) (setvar 'cmdecho 1) (princ)) Its to ignore all your OSNAP settings.
Ahhhhh.Ok, thank you.It makes sense.
Greg I was just about to post something very similar so forgive me if I post in here.
My problem is that I would like to sssetfirst the pasted objects to select them after I paste, should I need to change then straight away in the new drawing or whatnot.
(setq ent (entlast))(sssetfirst nil ent)
Doesn't work in the below code.
; Created by 3dwannab; INFO; 2018.03.27 - First release; USAGE; Copies preselected objects or asks user to select and copies at location 0,0.; Pastes as clip at 0,0.; Pastes as block at 0,0.; COMMANDS; C0 Copies at 0,0; P0 Paste as clip at 0,0; B0 Paste as block at 0,0; Copies at 0,0(defun c:C0 ( / ss )(setq *error* SS:error)(SS:startundo)(setq cmde (getvar "cmdecho"))(setq os (getvar "osmode"))(setvar 'cmdecho 0)(setvar 'osmode 0)(progn (setq ss (last (ssgetfirst))) (if (not ss) (setq ss (ssget)) ) (if ss (progn (command "._COPYBASE" "0,0" ss "") (princ ":: Copied selected objects @ 0,0 ::") ) (princ "\nUser Cancelled Command") ) )(*error* nil)(princ)); Paste clip at 0,0(defun c:P0 ( / ent )(command "._PASTECLIP" "0,0");; Won't select newly created objects. Is there a way round this?(setq ent (entlast))(sssetfirst nil ent)(princ (strcat "\n::" (itoa (sslength ss)) " Pasted copied objects @ 0,0 ::"))); Paste block at 0,0(defun c:B0 ( / )(command "._PASTEBLOCK" "0,0")(princ)(princ (strcat "\n::" (itoa (sslength ss)) " Pasted copied objects to block definition @ 0,0 ::")))(defun SS:error (errmsg)(and acDoc (vla-EndUndoMark acDoc))(and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n>")) )(setvar 'cmdecho cmde)(setvar 'osmode os))(defun SS:startundo ()(setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))(or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)))(princ(strcat "\n:: 3dwannab_Copy_0_Paste_0.lsp Loaded ::" "\n:: Invoke by typing 'C0' 'P0' 'B0' ::" ))(princ);;----------------------------------------------------------------------;;;; End of File ;;;;----------------------------------------------------------------------;; ; Paste clip at 0,0(defun c:P0 ( / ent )(command "._PASTECLIP" "0,0") ;; Won't select newly created objects. Is there a way round this?(setq ent (entlast))
Flanders, before 'pasteclipping' into the new drawing you have to store initially the last created entity(if theres one).
Then you must iterate from it using entnext, and store these enames into your customly created selection set.
And in the end just grip it with sssetfirst. lol.
I think I'm close, but struggling now. Tried everything. I'm sure with these two fns by CAB I can achieve what I'm after.
Just lost ATM.
; Paste clip at 0,0(defun c:P0 ( / LastEntInDatabase)(command "._COPYBASE" "0,0" pause "")(command "._PASTECLIP" "0,0")(setq LastEntInDatabase (GetLastEnt))(sssetfirst nil (GetNewEntities LastEntInDatabase));;CAB - get last entity in datatbase(defun GetLastEnt ( / ename result ) (if (setq result (entlast)) (while (setq ename (entnext result)) (setq result ename) ) ) result );;===================================;;CAB - return a list of new enames(defun GetNewEntities (ename / new) (cond ((null ename) (alert "Ename nil")) ((eq 'ENAME (type ename)) (while (setq ename (entnext ename)) (if (entget ename) (setq new (cons ename new))) ) ) ((alert "Ename wrong type.")) ) new ))
页:
[1]
2