Delete all polyline between 1-9 feet?

Discussion in 'AutoCAD' started by Sage Cowsert, Feb 27, 2004.

  1. Sage Cowsert

    Sage Cowsert Guest

    I thought I posted this last night but don't see it. My appologizes if I
    just missed it. Anyhow...

    I've got a topography drawing with polylines at every 2ft. So 2 4 6 8 10 12
    14 16 18 20 22...

    I'd like to search and delete all of these polylines but keep the ones at
    the 10's example 0 10 20 30.

    I know (ssget "x" '((0 . "LWPOLYLINE")(38 . 72.0))) will get everything at
    the 6ft level. I would like suggestions on how to rewrite the (38. ??) to
    loop thru the other elevations while missing the 10's. Thoughts?

    Sage
     
    Sage Cowsert, Feb 27, 2004
    #1
  2. Sage Cowsert

    Sage Cowsert Guest

    So I've come up with this code to get the elevations I'm looking for, I need
    to filter out the 10ft locations.

    (SETQ CNT 0)
    (WHILE (< CNT 10000)
    (SETQ CNTLIST (append CNTLIST (list CNT)))
    (SETQ CNT (+ 24 CNT))
    )

    Spits out

    (0 24 48 72 96....)
     
    Sage Cowsert, Feb 27, 2004
    #2
  3. Sage Cowsert

    Devin Guest

    How about this...

    (setq
    max_el 100.0
    min_el 0.0
    el (1- min_el)
    )
    (while
    (< (setq el (1+ el)) max_el)
    (if
    (zerop (rem el 10.0))
    (command "ERASE" (ssget "x" (list (cons 0 "LWPOLYLINE")(cons 38 el))))
    "")
    )
    )
     
    Devin, Feb 27, 2004
    #3
  4. Sage Cowsert

    Devin Guest

    Sorry forgot you're working in inches, then it would be...
    (setq
    max_el (* 100.0 12.0)
    min_el 0.0
    el (1- min_el)
    )
    (while
    (< (setq el (1+ el)) max_el)
    (if
    (zerop (rem el 120.0))
    (command "ERASE" (ssget "x" (list (cons 0 "LWPOLYLINE")(cons 38 el))))
    "")
    )
    )
     
    Devin, Feb 27, 2004
    #4
  5. Sage Cowsert

    Devin Guest

    OK one more time for good luck, I reversed the logic...
    (setq
    max_el (* 100.0 12.0)
    min_el 0.0
    el (1- min_el)
    )
    (while
    (< (setq el (1+ el)) max_el)
    (if
    (not (zerop (rem el 120.0)))
    (command "ERASE" (ssget "x" (list (cons 0 "LWPOLYLINE")(cons 38 el))))
    "")
    )
    )
     
    Devin, Feb 27, 2004
    #5
  6. Sage Cowsert

    Jeff Mishler Guest

    How about this?

    (defun c:rem-cont (/ factor ss idx ent entlist)
    (if (setq ss (ssget "x" '((0 . "LWPOLYLINE"))))
    (progn
    (if (< 2 (getvar "lunits") 5)
    (setq factor 120);archy units
    (setq factor 10);other units
    )
    (setq idx 0)
    (while (< idx (sslength ss))
    (setq ent (ssname ss idx))
    (setq entlist (entget ent))
    (if (/= (rem (cdr (assoc 38 entlist)) factor) 0)
    (progn
    (ssdel ent ss)
    (entdel ent)
    )
    (setq idx (1+ idx))
    )
    )
    )
    )
    (princ)
    )

    HTH,
    Jeff
     
    Jeff Mishler, Feb 27, 2004
    #6
  7. Sage Cowsert

    Sage Cowsert Guest

    Man you guys are fast. :)

    ; Gets elevations
    (SETQ CNT 0)
    (WHILE (< CNT 10000)
    (SETQ CNTLIST (append CNTLIST (list CNT)))
    (SETQ CNT (+ 24 CNT))
    )
    ; removes elevations at 10' mark
    (SETQ CNT 0)
    (WHILE (< CNT 10000)
    (SETQ CNTLIST (remove CNT cntlist))
    (SETQ CNT (+ 120 CNT))
    )

    ;;; REMOVE - Removes an item from a list (double elements allowed)
    ;;; (remove 0 '(0 1 2 3 0)) -> (1 2 3)
    (defun remove (expr lst) ; (c) by Serge Volkov
    (apply 'append (subst nil (list expr) (mapcar 'list lst)))
    )

    Cntlist is the list of elevations to be deleted. I'll have to take a look
    at your guy's code. I really appreciate this.



     
    Sage Cowsert, Feb 27, 2004
    #7
  8. Sage Cowsert

    Sage Cowsert Guest

    Thanks I like your usage of

    (if (< 2 (getvar "lunits") 5)
    (setq factor 120);archy units
    (setq factor 10);other units
    )

    I haven't seen that before. I'd perfer to do this via selection sets as
    there are tons of lines and I think it would be quicker then looking at each
    line.

    I'm amazed by how quick you guys are.

    Thanks Sage


     
    Sage Cowsert, Feb 27, 2004
    #8
  9. Sage Cowsert

    Jeff Mishler Guest

    So how about this?

    (defun c:rem-cont (/ factor ss idx ent entlist)
    (if (< 2 (getvar "lunits") 5)
    (setq factor 120)
    (setq factor 10)
    )
    (setq count -1)
    (setq elList (list (cons -4 "<NOT")))
    (setq elList (cons (cons -4 "<OR") ellist))
    (while (< (setq count (1+ count)) 1001)
    (setq elList (cons (cons 38 (* count factor)) elList))
    )
    (setq elList (cons (cons -4 "OR>") ellist))
    (setq elList (reverse (cons (cons -4 "NOT>") elList)))
    (if (setq ss (ssget "x" (cons (cons 0 "LWPOLYLINE") elList )))
    (command "_.erase" ss "")
    )
    (princ)
    )

    Jeff

     
    Jeff Mishler, Feb 27, 2004
    #9
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.