dhl Posted November 9, 2009 Posted November 9, 2009 As the title suggest i'm trying to select the copies of multiple object, probably an easy task... eg I copy a number of object from place A to place B. Now I want to select these objects. when I use (ssget "L") it only selects one object, same as (entlast) I guess Using (ssget "P") selects the objects I've copied from, not the copies themself Quote
NBC Posted November 9, 2009 Posted November 9, 2009 Prior to copying the objects, make them into either a group or a block Quote
jammie Posted November 9, 2009 Posted November 9, 2009 Maybe something like this to start off with ;Store the last database entity before copying objects (setq Marker (entlast)) ;Create a temporary selection set (setq TempSelectionSet (ssadd)) ;Preform commands (command "copy" ...) ;Add all entities created after copy to the TempSelectionSet (while (setq Marker (entnext Marker)) (ssadd Marker TempSelectionSet )) Quote
alanjt Posted November 9, 2009 Posted November 9, 2009 Try something like this: ;;; Copy Command and return selectionset ;;; Requires Express Tools' ACET-SS-Drag-Move subroutine ;;; Alan J. Thompson, 11.09.09 (defun AT:Copy (/ #SS #Pnt1 #Pnt2 #Pnts #SSAdd #Copy) (vl-load-com) (cond ((and (setq #SS (ssget "_:L")) (setq #Pnt1 (getpoint "\nSpecify base point: ")) (setq #Pnt2 (acet-ss-drag-move #SS #Pnt1 "\nSpecify placement point: " T)) ) ;_ and (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) (setq #Pnts (mapcar '(lambda (x) (vlax-3d-point (trans x 1 0))) (list #Pnt1 #Pnt2) ) ;_ mapcar ) ;_ setq (setq #SSAdd (ssadd)) (vlax-for x (setq #SS (vla-get-activeselectionset *AcadDoc*)) (ssadd (vlax-vla-object->ename (setq #Copy (vla-copy x))) #SSAdd) (vla-move #Copy (car #Pnts) (cadr #Pnts)) ) ;_ vlax-for (vl-catch-all-apply 'vla-delete (list #SS)) ) ;_ cond ) ;_ cond #SSAdd ) ;_ defun It will mimic Copy, but return a selection set. You could do something simple like: (defun c:Test (/ ss) (and (setq ss (AT:Copy)) (command "_.change" ss "" "_p" "_c" 3 "") ) ;_ and ) ;_ defun This isn't the best example, but I'm sure you get the idea. Quote
VVA Posted November 9, 2009 Posted November 9, 2009 Almost as shown by jammie (defun C:TEST ( / ss ) (setvar "CMDECHO" 1) ;;;Creat Marker (mip:mark) ;;;Preform commands (princ "\nSelect objects for copying... ") (setq ss (ssget "_:L")) (command "_COPY" ss "" "_M") (while (> (getvar "CMDACTIVE") 0)(command pause)) ;;; Select all entities created after copy (setq ss (mip:get-last-ss)) ;;; Change color new objects to red (if ss (command "_CHPROP" ss "" "_Color" 1 "") ) (setq ss nil) (princ) ) (defun mip:mark ( ) ;;;* Mark data base to allow KB:catch. ;;;* http://www.theswamp.org/index.php?topic=15863.0 (if (setq *mip:mark (entlast)) nil (progn (entmake '((0 . "point") (10 0.0 0.0 0.0))) (setq *mip:mark (entlast))(entdel *mip:mark)))(princ)) ;;;* returns selection set of entities since last mip:mark. (defun mip:get-last-ss (/ ss tmp val) (setq val (getvar "cmdecho"))(setvar "cmdecho" 0) (if *mip:mark (progn (setq ss (ssadd)) (while (setq *mip:mark (entnext *mip:mark))(ssadd *mip:mark ss)) (command "._select" ss "")(setq tmp ss ss nil));_progn (alert "*mip:mark not set. \n run (mip:mark) before mip:get-last-ss."));_if (setvar "cmdecho" val) tmp) Quote
alanjt Posted November 9, 2009 Posted November 9, 2009 Almost as shown by jammie (defun C:TEST ( / ss ) (setvar "CMDECHO" 1) ;;;Creat Marker (mip:mark) ;;;Preform commands (princ "\nSelect objects for copying... ") (setq ss (ssget "_:L")) (command "_COPY" ss "" "_M") (while (> (getvar "CMDACTIVE") 0)(command pause)) ;;; Select all entities created after copy (setq ss (mip:get-last-ss)) ;;; Change color new objects to red (if ss (command "_CHPROP" ss "" "_Color" 1 "") ) (setq ss nil) (princ) ) (defun mip:mark ( ) ;;;* Mark data base to allow KB:catch. ;;;* http://www.theswamp.org/index.php?topic=15863.0 (if (setq *mip:mark (entlast)) nil (progn (entmake '((0 . "point") (10 0.0 0.0 0.0))) (setq *mip:mark (entlast))(entdel *mip:mark)))(princ)) ;;;* returns selection set of entities since last mip:mark. (defun mip:get-last-ss (/ ss tmp val) (setq val (getvar "cmdecho"))(setvar "cmdecho" 0) (if *mip:mark (progn (setq ss (ssadd)) (while (setq *mip:mark (entnext *mip:mark))(ssadd *mip:mark ss)) (command "._select" ss "")(setq tmp ss ss nil));_progn (alert "*mip:mark not set. \n run (mip:mark) before mip:get-last-ss."));_if (setvar "cmdecho" val) tmp) Now that is creative! Very nice. Quote
dhl Posted November 12, 2009 Author Posted November 12, 2009 thanks a lot guys! I would have thought this to be a simple task, but apparently it is not so.. Quote
alanjt Posted November 12, 2009 Posted November 12, 2009 thanks a lot guys! I would have thought this to be a simple task, but apparently it is not so.. Psh! The only easy thing, is coming up with stuff to program. Glad it helped. Quote
gilsoto13 Posted November 13, 2009 Posted November 13, 2009 thanks a lot guys! I would have thought this to be a simple task, but apparently it is not so.. What I do is to check how many objects were selected when I copied them... then I use this lisp to select last "n" number of objects created, So I type the lisp, then I need to write down the number of previously selected objects (previously used for copy) and done, I can use them with the "previous" option. Loo.lsp Quote
CAB Posted November 16, 2009 Posted November 16, 2009 My way. ;; CAB 09.17.08 - get last entity of a type in datatbase ;; An entity name, or nil, if there are no entities in the current drawing. (defun GetLastEnt ( / ename result ) (if (setq result (entlast)) (while (setq ename (entnext result)) (setq result ename) ) ) result ) ;; CAB 09.17.08 - return a list of new enames ;; if ename is nil then return all objects in DWG (defun GetNewEntities (ename / new) (cond ((or (null ename) (null (setq new (list (entnext)))))) ((eq 'ENAME (type ename)) (while (setq ename (entnext ename)) (if (entget ename) (setq new (cons ename new))) ) ) ;((alert "Ename wrong type.")) ) new ) Quote
Balão Posted July 15, 2022 Posted July 15, 2022 I copy to de same position and use the original to move leave the copy in his place... not elegant... but works... Sorry my lame english. Quote
tombu Posted July 15, 2022 Posted July 15, 2022 irneb posted SelectResults.lsp at https://forums.augi.com/showthread.php?81175-select-result-lisp-modification#5 which creates selection sets of objects produced by commands with a reactor so you can select them easily. Lisp needs to be loaded when you open a drawing. In the lisp set $Result-Length to how many previous sets you want to keep. 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.