if then for a set of polylines

Discussion in 'AutoCAD' started by mnash, Feb 21, 2005.

  1. mnash

    Tom Smith Guest

    Okay, okay, okay. You know, you can skip the whole loop-de-loop business here by just filtering the selection set. Eliminates some programming overhead and runs many times faster than doing entgets on multiple entities.

    (set sset (ssget))
    (if (ssget "p" '((0 . "lwpolyline,polyline")))
    (do-the-pline-command)
    (do-the-nopline-command)
    )

    That eliminates the nopoly flag variable, the index variable, and the entire looping process. And it's way faster.

    Any time you find yourself setting a "flag" variable in lisp, just to keep track of what has previously been decided, it should be a warning that there's probably a cleaner way to do things.
     
    Tom Smith, Feb 24, 2005
    #21
  2. mnash

    Jeff Mishler Guest

    Okay back at ya. Now this makes a whole lot more sense.
    I'll only defend my original code with my original statement of "I don't
    recall if this is something I wrote or if I got from this group" and if it
    IS something I wrote, it was from the time when I was just starting to learn
    lisp.....and to be honest, I don't think I had investigated the use of ss
    filters yet.

    And even more honestly, even now I don't know if I wouldv'e thought to use
    the dual ssget's as you did. Thanks for sharing that.
     
    Jeff Mishler, Feb 24, 2005
    #22
  3. mnash

    Tom Smith Guest

    And even more honestly, even now I don't know if I wouldv'e thought to use
    The docs aren't real clear on when ssget filtering can be used -- it doesn't
    work on all selection methods. But in this case filtering the "previous" set
    accomplishes your test in a simple way. Long ago, as I recall, there wasn't
    such a thing, so you had to do the filtering manually, and that could be
    very slow on a big sset.
     
    Tom Smith, Feb 24, 2005
    #23
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.