Jump to content

Recommended Posts

Posted

Let's say i use copy or mirror command, and i create 25 new objects after using one of these commands. How can i select quickly these 25 new objects created? Any lisp for something like this?

Posted

Please check the routine from second post of this thread. If you will call the offset/copy command in an AutoLISP routine then just adjust that to your case; if the edit is done manually on prompter then should split it in two routines, one to retain the reference entity (last entity - ENTLAST) and a second one to gather new items.

Posted

Please have a look at this code:

;;*****************************************************************************
;                     LASTN.LSP V1.0 by Zoltan Toth
;    ZOTO Technologies,
;    23 Greenhills Dve,
;    Melton, 3337.
;    E-MAIL: zoltan.toth@ains.net.au
;       WWW: http://www.ains.net.au/zoto/
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This program will select the last n objects created in a drawing where n
; is an integer input by the user. This is most useful when you create a
; number of objects with the COPY, MIRROR or ARRAY commands and you wish to
; work with the ones just created. LASTN has been written so that it can be
; used in three different ways for maximum flexibility. First, it can be
; called by itself at the "Command:" prompt and the objects so selected can
; be accessed by a later command with the "Previous" option. Second, it can
; be called transparently (with a preceding apostrophe) at a "Select
; objects:" prompt and the objects selected will be passed back to the
; waiting command. Since it can be tedious to type in the preceding
; apostrophe, it is best to incorporate this command in the menu with the
; apostrophe included to make it a quick "single pick" invokation. Thirdly,
; as the (LASTN) function is not nested within (C:LASTN), it can be called
; (with an integer argument) by other programs. As an example, to set symbol
; SS1 to a selection set containing the last 5 objects created, use:
;
; (setq SS1(lastn 5))
;
;      Any program that utilizes the (LASTN) function should, of course, check
; to see if it is already loaded and if not, load it. The following AutoLISP
; code would be satisfactory in most cases:
;
; (if(not LASTN)(load "LASTN"))
;
;      Note that although AutoCAD's "Last" option selects the last drawn
; object visible, at least partially, on screen, LASTN always selects the
; last n drawn objects, whether visible on screen or not. This includes
; objects on layers that are OFF or FROZEN. Objects on LOCKed layers are
; also selected but cannot be edited whereas objects on FROZEN or OFF layers
; can be edited. Caution: don't specify a value higher than the number of
; objects you have created in the current space (Paper or Model) since you
; last entered that space ie. changed TILEMODE - the results won't be what
; you want.
;;*****************************************************************************
(defun lastn (INT2 / SS2 SSL2)             ;define function to take 1 argument
(setq SS2 (ssadd))                         ;set SS2 to an empty selection set
(repeat INT2                                               ;repeat INT2 times
 (if (entlast)
  (progn
   (ssadd (entlast) SS2)          ;add last undeleted object to selection set
   (entdel (entlast))                           ;delete last undeleted object
  )
 )
)
(setq SSL2 (1- (sslength SS2)));set SSL2 to 1 less than size of selection set
 (while (>= SSL2 0)              ;while SSL2 is greater than or equal to zero
 (entdel (ssname SS2 SSL2))         ;undelete SSL2'th object in selection set 
 (setq SSL2 (1- SSL2))                                         ;decrement SL2
)
SS2                                 ;return selection set to calling function
)                                                        ;end (lastn) function
(defun C:loo (/ COUNT2)                                     ;define function
;set COUNT2 to number of objects
(setq COUNT2 (getint "\nEnter number of objects: "))
(if (= 0 (getvar "CMDACTIVE"))                 ;if no other command is active
 (progn                                                                 ;else
  (command "._SELECT" (lastn COUNT2) "")       ;run SELECT command and (lastn)
  (princ)                                                       ;exit quietly
 )
 (lastn COUNT2)                          ;call (lastn) function with argument
)
)

 

 

Using this, i have to insert the number of object created; i want to use something like this , but to insert somethig like... lc - last created, not a number.... when i use select command from autocad, and i say L -last, i will select only the last created object, using somethig like LC- last created, i want to select all 10...or 25 obect created with the last command used.How??

Posted

You can start from this:

(setq lastItem (entlast))
;; do your processing
(setq ssetItems (ssadd))
(while (setq lastItem (entnext lastItem))
(ssadd lastItem ssetItems)
)
(sssetfirst nil ssetItems)

Posted

One comment, that will gather all identical entities from drawing, not only the ones added at last action.

Posted

i just want to select entities created with the last command...this is the idea...

Posted

Fell free to modify it to suit your needs:

(defun c:CopyMWithSelect( / lastItem ssetItems )
(setq lastItem (entlast))
(command "_COPY" pause "" "_M")
(while (> (getvar "CMDACTIVE") 0)
 (command pause)
)
(setq ssetItems (ssadd))
(while (setq lastItem (entnext lastItem))
 (ssadd lastItem ssetItems)
)
(sssetfirst nil ssetItems)
(princ)
)

Posted

Wow, that's perfect! Thanks, irneb!

Posted

Sorry, should explain how to use this lisp shouldn't I?:oops:

 

You need to have it loaded automatically as it's using reactors. Easiest way would be to save it to a folder on your support paths, then add a line like this to your ACadDoc.LSP file:

(load "selresult")

This then allows you to select any batch of new entities created - through the 'Result command. A running list of the last 5 batches of entities. See this example extract of my command line:

Command: l
LINE Specify first point:
Specify next point or [undo]:
Specify next point or [undo]:
Specify next point or [Close/Undo]:
Specify next point or [Close/Undo]: c

Command: c
COPY
Select objects: 'result

Which one of these do you want to select? 0-LINE <0>:
 4 found

Select objects:
Select objects:
Current settings:  Copy mode = Multiple
Specify base point or [Displacement/mOde] <Displacement>:
Specify second point or [Array] <use first point as displacement>:
Specify second point or [Array/Exit/Undo] <Exit>:
Specify second point or [Array/Exit/Undo] <Exit>: *Cancel*

Command: m
MOVE
Select objects: 'result

Which one of these do you want to select? 0-COPY 1-COPY 2-LINE <0>: 1
 4 found

Select objects:
Select objects:
Specify base point or [Displacement] <Displacement>:
Specify second point or <use first point as displacement>:
Command:  'RESULT
Which one of these do you want to select? 0-COPY 1-COPY 2-LINE <0>: *Cancel*
; error: Function cancelled

Command:
Command: RESULT

Which one of these do you want to select? 0-COPY 1-COPY 2-LINE <0>:

Command:
Command: m
MOVE 4 found

Specify base point or [Displacement] <Displacement>:
Specify second point or <use first point as displacement>:

And the video screen capture.

SelResult.gif.Zip

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