Jump to content

Recommended Posts

Posted

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

Posted

Prior to copying the objects, make them into either a group or a block

Posted

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 ))

Posted

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.

Posted

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)

Posted
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. :)

Posted

thanks a lot guys!

 

I would have thought this to be a simple task, but apparently it is not so.. :)

Posted
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. :)

Posted
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

Posted

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
)

  • 12 years later...
Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...