AutoLISP Program to select the newly created objects!

Discussion in 'AutoCAD' started by pradeep_hebbar, May 22, 2004.

  1. Hi,

    Will somebody help me in writing a customized AutoLISP program to select the newly created objects? (those objects which are created afetr using Array, copy, mirror, offset.... commands) The command should be transparent & should be able to run under any "Select objects" prompt.

    The option "Last " will be useful only for single object.

    Rgds,
    H P Hebbar
     
    pradeep_hebbar, May 22, 2004
    #1
  2. pradeep_hebbar

    Paul Turvill Guest

    Depending on how your code is written, you could just add the new objects to
    a selection set as each is created with (settq ss (ssadd (entlast) ss)) ...
    or

    Before creating the new objects, set a variable to the last existing object:
    (setq lastobj (entlast))
    Then after the objects are created, step through them with (entnext ...)
    starting with
    (entnext lastobj)
    and go from there.

    Once the selection set is created, there are several ways to assign it to
    the "Previous" selection option [e.g., (command "_.select" ss "")] for use
    from the keyboard, if that's what you want.
    ___

    the newly created objects? (those objects which are created afetr using
    Array, copy, mirror, offset.... commands) The command should be transparent
    & should be able to run under any "Select objects" prompt.
     
    Paul Turvill, May 22, 2004
    #2
  3. pradeep_hebbar

    Paul Turvill Guest

    .... that's (setq ...) obviously.
    ___

    ....
     
    Paul Turvill, May 22, 2004
    #3
  4. pradeep_hebbar

    ECCAD Guest

    Looks like you need a reactor to gather a selection set ---
    Bob
     
    ECCAD, May 22, 2004
    #4
  5. pradeep_hebbar

    Jamie Duncan Guest

    or redefine a slew of commands to reset a global pointer before the command,
    and then reset the selection set after the command.


    Jamie Duncan
     
    Jamie Duncan, May 22, 2004
    #5
  6. Here is something I wrote to start you on your way. This is NOT a
    transparent command, but it may give you something to think about. The SL
    command is used to set a point as the last entity in the drawing. The GL
    command is used to save all entities after the point to a selection set !SS,
    then erase the point.

    To test -
    type SL at the command prompt
    type Copy, Array, Mirror, etc. command at perform command
    type GL at the command prompt
    type COPY !SS to copy new last entities


    (defun C:SL (/ CURLAY)
    (command "POINT" (getvar "viewctr"))
    (setq EL1 (entget (entlast)))
    (princ)
    )
    (defun C:GL (/ EL2 EN)
    (setq EL2 (entget (entlast)))
    (entdel (cdr (assoc -1 EL1)))
    (setq SS (ssadd))
    (if (not (equal EL1 EL2))
    (progn
    (setq EN (entget (entnext (cdr (assoc -1 EL1)))))
    (while (and EN (not (equal EN EL2)))
    (ssadd (cdr (assoc -1 EN)) SS)
    (setq EN (entget (entnext (cdr (assoc -1 EN)))))
    )
    (ssadd (cdr (assoc -1 EN)) SS)
    )
    )
    (princ)
    )
     
    Alan Henderson @ A'cad Solutions, May 23, 2004
    #6
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.