Entnext and Error with LSELSETP

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

  1. Fatfreek

    Fatfreek Guest

    I'm trying to use the following routine to create a virgin set of closed
    polylines. I can't figure out the error I'm getting, "Error, bad argument
    type: LSELSETP nil".
    Len Miller

    (defun CreateNewBounds (OldBounds );;/ LastEnt EntSS)
    (setq LastEnt (entlast)
    EntSS (ssadd)
    )
    (command "._-boundary" MidX "")
    (while (setq LastEnt (entnext LastEnt))
    (setq EntSS (ssadd LastEnt EntSS))
    )
    (command "_.erase"
    OldBounds
    ""
    )
    (setq PolysWithin EntSS)
    )

    ;;;First, Create one polyline rectangle, then offset
    ;;;it some arbitrary distance, outside or inside, to
    ;;;make the second one.
    ;;;Pick them both as OldSet
    (setq MidX (getpoint "Pick inside, between the rectangles"))
    (setq OldSet (ssget))
    (CreateNewBounds OldSet)
     
    Fatfreek, Nov 29, 2004
    #1
  2. Fatfreek

    ECCAD Guest

    When you do:
    (setq LastEnt (entlast) EntSS (ssadd))
    ..you get only (1) entity, the 'last' in var LastEnt.
    Then, when doing:
    (while (setq LastEnt (entnext LastEnt))
    (setq EntSS (ssadd LastEnt EntSS))
    )
    .......
    you get nil in var LastEnt..no entnext exists 'after'
    LastEnt..
    Hence, downhill from there.

    Bob
     
    ECCAD, Nov 29, 2004
    #2
  3. Fatfreek

    Fatfreek Guest

    Thanks to a snippet I borrowed from a Joe Burke post, replace the following
    three lines with what follows:
    (while (setq LastEnt (entnext LastEnt))
    (setq EntList (entget LastEnt))
    (if
    (and
    (not
    (wcmatch (cdr (assoc 0 EntList))
    "ATTRIB,VERTEX,SEQEND"
    )
    )
    (eq (cdr (assoc 410 EntList)) (getvar "ctab"))
    )
    (ssadd LastEnt EntSS)
    )
    )
     
    Fatfreek, Nov 30, 2004
    #3
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.