Offset, then erase (entlast)

Discussion in 'AutoCAD' started by Fatfreek, Nov 15, 2004.

  1. Fatfreek

    Fatfreek Guest

    At times OFFSETing a closed poly creates more than one entity especially if
    the amount is drastic. Program code for Erasing one is easy (entlast) but
    if more than one, not easy (for me -- since I don't know how).

    Any tips?
    Len Miller
     
    Fatfreek, Nov 15, 2004
    #1
  2. I'm not sure this Tablet/Screen/Pop-down item is exactly what you want, but
    maybe at least it's a starting point:

    [EraseLast#]^C^C^P(setq eraseno (getint "Erase Last How Many? ")) \+
    (while (>= eraseno 1) (command "ERASE" "L" "") +
    (setq eraseno (1- eraseno))) ^P

    It asks how many items you want to erase, then does Erase Last that many
    times. The potential difficulty in relation to what you describe is that
    the excess entities may not be the last however-many, but the one you want
    to KEEP may be "between" (in sequence) some that you want to erase, in which
    case this wouldn't work -- you'd need to select them manually.
     
    Kent Cooper, AIA, Nov 15, 2004
    #2
  3. Fatfreek

    dblaha Guest

    Try an SSGET using "prev" instead of entlast.


    Dave
     
    dblaha, Nov 15, 2004
    #3
  4. why not set an undo mark?
    (command "undo" "begin")
    do offset
    don't like it, undo

    If you want to erase those at a later time, you need to group them.
    Here is some handy dandy code to do what you want.
    Note that this all started with Frank Ouendo's code at the bottom.
    Hence the reason I feel obligated to give something back.

    To use it, do something like this:

    (defun c:I-love-things-for-free-routine ()
    (c:MARK-POINT)
    do lots of fun stuff that adds entities to the drawing....
    do more fun stuff....
    do even more really fun stuff like inserting blocks
    (c:MAKE-GROUP-LAST "anything-here")
    (princ)
    )

    You will find anything added to be grouped. (turn on group selection if its not)
    Think about that a little. This applies to EVERY situation, inserting blocks, grouping stuff drawn by a lisp, you name
    it.
    This is one of my better tricks for creating groups. This is way better than any undo mark could do.


    ; MAKE-GROUP.LSP BY JAMES MAEDING 10-20-01
    ; USED FOR PURPOSE OF GROUPING OBJECTS BETWEEN
    ; TWO POINTS IN TIME
    ; USE (c:MARK-POINT) TO MARK STARTING ENTITY
    ; USE (c:MAKE-GROUP-LAST "<PROG>") TO MAKE GROUP OF ENTS AFTER MARKED ENTITY

    (VL-LOAD-COM)

    (DEFUN C:MARK-POINT ()
    (SETQ MARKED-ENT-NAME (COUNTBACK 1)) ;GLOBAL VARIABLE MARKED-ENT-NAME !
    (PRINC)
    )

    (DEFUN C:MAKE-GROUP-LAST (PROG / )
    (IF (NOT MARKED-ENT-NAME)
    (PROGN
    (PRINC "\nUse (C:MARK-POINT) before this function to mark last entity.")
    (EXIT)
    )
    )
    (SETQ ENT-LIST NIL
    INDEX 1
    )
    ;START AT END AND LOOP BACKWARD LOOKING FOR MARKED ENTITY
    (IF (SETQ ENT-NAME (COUNTBACK 1)) ;CHECK FOR BLANK DWG
    (PROGN
    (WHILE (NOT (EQ ENT-NAME MARKED-ENT-NAME))
    (SETQ ENT-LIST (CONS ENT-NAME ENT-LIST)
    INDEX (+ 1 INDEX)
    ENT-NAME (COUNTBACK INDEX)
    )
    )
    (IF (> (LENGTH ENT-LIST) 1) ;IF MORE THAN ONE ENTITY
    (MAKE-GROUP-OF ENT-LIST PROG)
    )
    )
    )
    (SETQ MARKED-ENT-NAME NIL)
    (PRINC)
    )


    ;------MAKE-GROUP-OF.LSP------

    ;SUPPLY:
    ;ENT-LIST LIST OF ENTITY NAMES
    ;GRP-USER WHAT IS USING THE GROUP
    ;RETURN:
    ;NOTHING

    (DEFUN MAKE-GROUP-OF (ENT-LIST GRP-USER
    / ENT-START INDEX ENT-NEXT GRP-STRING)
    (IF (> (LENGTH ENT-LIST) 0)
    (PROGN
    (SETQ ENT-START (NTH 0 ENT-LIST))
    (SETQ INDEX 1)
    (SETQ GRP-STRING (STRCAT "In use by " GRP-USER))
    (COMMAND "_.-group" "_create" "*" GRP-STRING ENT-START)
    (WHILE (< INDEX (LENGTH ENT-LIST))
    (SETQ ENT-NEXT (NTH INDEX ENT-LIST))
    (COMMAND ENT-NEXT)
    (SETQ INDEX (+ INDEX 1))
    )
    (COMMAND "")
    )
    )
    (PRINC)
    )

    ;-------COUNTBACK.LSP-------
    ;BY FRANK OQUENDO
    ;USED TO GET NTH ENT IN DWG, 1 IS LAST ENTITY, 2 is 2nd to last
    ;returns entity name

    (defun COUNTBACK (steps / ms)
    (IF (= (GETVAR "CVPORT") 1) ;CVPORT = 1, THEN CURSOR IS IN PAPERSPACE
    (PROGN
    (setq ms (vla-get-paperspace (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-vla-object->ename (vla-item ms (- (vla-get-count ms) steps)))
    )
    (PROGN
    (setq ms (vla-get-modelspace (vla-get-activedocument(vlax-get-acad-object))))
    (vlax-vla-object->ename (vla-item ms (- (vla-get-count ms) steps)))
    )
    )
    )

    "Fatfreek" <>
    |>At times OFFSETing a closed poly creates more than one entity especially if
    |>the amount is drastic. Program code for Erasing one is easy (entlast) but
    |>if more than one, not easy (for me -- since I don't know how).
    |>
    |>Any tips?
    |>Len Miller

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Nov 15, 2004
    #4
  5. Of course, the situation as you originally described it (erasing one entity
    with entlast) could also be a problem, since the offset entity you want to
    keep (I assume you're talking about keeping one) might be the "last" one.
    Maybe what you would have to do is change the one you want to keep to a
    Layer that's turned off. Then you could run erase last however many times
    you want, regardless of where that entity falls in the sequence, and all the
    ones that are showing and available will be erased in reverse order.
    --
    Kent Cooper, AIA


     
    Kent Cooper, AIA, Nov 15, 2004
    #5
  6. Fatfreek

    dblaha Guest

    Upon further review, (ssget "_P") doesn't work at all in this situation, although it does work very nicely for grabbing the all the debris of an object that was just exploded.

    Here's something else to try. It notes the current entlast before you offset and then creates a selection set of everything created after that point.

    (defun c:eek:ffset_grab ()
    (setq last_ent (entlast)
    ent_set (ssadd)
    )
    ;<your offset code goes here>
    (while (setq last_ent (entnext last_ent))
    (setq ent_set (ssadd last_ent ent_set))
    )
    )

    The ent_set selection set contains all of the offset entities.


    Dave
     
    dblaha, Nov 15, 2004
    #6
  7. Fatfreek

    Fatfreek Guest

    Dave,

    I believe this is what I'm looking for. I never understood how entnext
    could be used and am looking forward to trying it.

    Len

    although it does work very nicely for grabbing the all the debris of an
    object that was just exploded.
    offset and then creates a selection set of everything created after that
    point.
     
    Fatfreek, Nov 16, 2004
    #7
  8. Fatfreek

    dblaha Guest

    Glad I could help. :)

    Dave
     
    dblaha, Nov 16, 2004
    #8
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.