Lisp to select Last items

Discussion in 'AutoCAD' started by kevinmukbel, Nov 23, 2004.

  1. kevinmukbel

    kevinmukbel Guest

    I am looking for a lisp or a script that selects the last itemS copied and moved if they had to be all selected again to be relocated or rotated or whatever again. The “last†command only selects ONE of the selected copied items, and the “previous†command only selects the items originally copied. How can I accoplish this?
     
    kevinmukbel, Nov 23, 2004
    #1
  2. One method is save the "last" entity in the drawing prior to starting the
    copy & move command.
    Then starting at the "last" entity, create a selection set of the new
    entities.

    moved if they had to be all selected again to be relocated or rotated or
    whatever again. The "last" command only selects ONE of the selected copied
    items, and the "previous" command only selects the items originally copied.
    How can I accoplish this?
     
    Alan Henderson @ A'cad Solutions, Nov 24, 2004
    #2
  3. kevinmukbel

    LUCAS Guest

    ; Easy way but slow

    (setq SS_START (ssget "x"))
    ;;
    ;;do something----copy
    ;;
    (setq SS_END (ssget "x"))
    (command "_.select" SS_END "r" SS_START "")
    (setq SS (ssget "p"))

    moved if they had to be all selected again to be relocated or rotated or
    whatever again. The ¡§last¡¨ command only selects ONE of the selected
    copied items, and the ¡§previous¡¨ command only selects the items originally
    copied. How can I accoplish this?
     
    LUCAS, Nov 24, 2004
    #3
  4. You could do what I do for a "copy and rotate" routine (sorry about what the
    system does with the double backslash):

    [Copy&Rot]*^C^CSELECT \COPY P 0,0 0,0 MOVE P \\ROTATE P ;

    After the selection, it copies the selection set IN PLACE, then MOVEs the
    Previous set. What's actually being moved is the original selection set,
    and the new one(s) -- the copy -- is/are left in the original location. It
    comes out "backwards" in a way, but it means that the Rotate command can
    then simply use the Previous selection set again.
     
    Kent Cooper, AIA, Nov 24, 2004
    #4
  5. ; Marc'Antonio Alessi - http://xoomer.virgilio.it/alessi
    ; Function: ALE_LastEnt
    ;
    ; Description:
    ; get the absolute last entity in the database,
    ; for problems in >=r15 in blocks with attrib, and polylines
    ;
    ; Arguments: none
    ;
    ; Example: (setq marker (ALE_LASTENT))
    ;
    ; Return Values:
    ; An entity name;
    ; otherwise nil, if there are no entities in the current drawing
    ;
    (defun ALE_LastEnt ( / EntNam OutVal)
    (and
    (setq OutVal (entlast))
    (while (setq EntNam (entnext OutVal))
    (setq OutVal EntNam)
    )
    )
    OutVal
    )

    ; Marc'Antonio Alessi - http://xoomer.virgilio.it/alessi
    ; Function: ALE_Ss-After
    ;
    ; Description:
    ; get a selection set of items after EntNam in the database
    ;
    ; Arguments: An entity name
    ;
    ; Example:
    ; (setq marker (ALE_LASTENT)) ...create new entities...
    ; to include reference entity:
    ; (command "_.MOVE" (ALE_SS-AFTER marker) marker "" ...)
    ; not include reference entity:
    ; (command "_.MOVE" (ALE_SS-AFTER marker) "" ...)
    ;
    ; Return Values:
    ; A selection set;
    ; otherwise nil, if there are no entities after EntNam
    ;
    (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
    )
    )
    )
    ;
    ; Marc'Antonio Alessi - http://xoomer.virgilio.it/alessi
    ;
    (defun C:ALE_COPROT ( / SelSet Pnt001 CurOrt)
    (setvar "CMDECHO" 0)
    (princ "\nSelezionare oggetto(i) da copiare e ruotare: ")
    (if (setq SelSet (ssget))
    (progn
    (princ "\nSpecificare punto base: ")
    (vl-cmdf "_.COPY" SelSet "" "_NONE" "0.0,0.0,0.0" "")
    (vl-cmdf "_.MOVE" SelSet "" pause)
    (princ "\nPunto di posizionamento: ")
    (command pause)
    (setq Pnt001 (getvar "LASTPOINT"))
    (princ "\nAngolo di rotazione: ")
    (vl-cmdf "_.ROTATE" SelSet "" "_NONE" Pnt001 pause)
    )
    (alert "Nessun oggetto selezionato, comando annullato. ")
    )
    (redraw)
    (princ)
    )

    --
     
    Marc'Antonio Alessi, Nov 24, 2004
    #5
  6. kevinmukbel

    alex Guest

    How about the PREVIOUS command? eg. move p
     
    alex, Nov 24, 2004
    #6
  7. I believe that was noted in the original post.

    Try doing this... Copy a set of objects... and then enter the move command
    and use 'p'.... this selects the objects that were copied... not the copied
    objects (which is what is desired)
     
    Casey Roberts, Nov 24, 2004
    #7
  8. [Exactly what I said, but you left out the fact that you have to Copy them
    with zero displacement in order for the copy-then-move operation to have the
    same result as a plain copy operation, with the things in the new location
    now being the Previous selection set.]
     
    Kent Cooper, AIA, Nov 24, 2004
    #8
  9. kevinmukbel

    LUCAS Guest

    Hi Kent,

    Handle is different!draworder is different!.......



     
    LUCAS, Nov 25, 2004
    #9
  10. Yes, they are. I don't see anything in the original post that would suggest
    that there's any problem with that.

    But the problem with all suggestions so far (including mine and yours) is
    that you have to know you're going to need to use them before you do the
    copying. I assume from the original post that Kevin sometimes finds that
    he's copied some set of things to not quite the right place (don't we
    all?!). So he then wants to reposition them (or rotate them or something).
    As he says, selecting P or L won't do it (except when it's only one entity,
    in which case L works), and he has to reselect the selection set. But
    unless you often want to copy some things and then fine-tune their position
    or rotation, you probably don't want the overhead of doing any of these
    things every time you use the Copy command. But I can't imagine any way to
    do what he wants except to establish the items in the new location as a
    selection set and use P.
    --
    Kent Cooper, AIA


    ...
    ....
    ....
     
    Kent Cooper, AIA, Nov 29, 2004
    #10
  11. kevinmukbel

    kevinmukbel Guest

    Thank you guys. I guess so far no solution yet and the scripts and the lisps you've listed don't do the job. I know someone wrote a lisp that does what I want. Once I find it, I will post it here....It might take a couple of weeks though...The lisp is somewhere in Hawaii.....
     
    kevinmukbel, Nov 30, 2004
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.