- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
Credit for this code as far as I know to Joe Burke, it was archived but still very useful so I thought I'd share and also request for help 🙂
You have no idea how this lisp is making my life easier, however if it does what it does I thought on some improvements that honestly I do not know how to add.
- It is helping me select lines with a certain length range and this is awesome but I often need to apply the same length range to poly lines which it does not do.
- Also it would be awesome to add the area filter to this code for poly lines for example:Enter minimum area value/ Enter Max area value and select entities and retrieve result.
If some can help with the updates to this file I will be very grateful and any guidance will be very much appreciated
Joe Burke
;select lines by fixed length or within range
(defun c:SSLineLen ( / *Error* cnt ent fixlen len stpt enpt maxlen minlen
mode ss)
(defun *Error* (Msg)
(cond
((or (not Msg)
(member Msg '("console break"
"Function cancelled"
"quit / exit abort"
)
) ;close member
) ;close or
) ;close condition, no message to display
((princ (strcat "\nError: " Msg))) ;else display message
) ;close cond
(princ)
) ;close defun *Error*
(initget 1 "R F ")
(setq MODE
(getkword "Select lines within (R)ange or (F)ixed length : "))
(if (or (= MODE "") (= MODE "F"))
(setq MODE "F")
) ;end if
(if (= MODE "F")
(setq FIXLEN (getdist "\nEnter fixed line length: "))
(progn
(setq MINLEN (getdist "\nEnter minimum length: "))
(setq MAXLEN (getdist "\nEnter maximum length: "))
) ;end progn else
) ;end if
(if (ssget "I")
(setq SS (ssget "I" (list (cons 0 "LINE"))))
(setq SS (ssget (list (cons 0 "LINE"))))) ;end if
(setq CNT 0)
(repeat (sslength SS)
(setq ENT (ssname SS CNT)
STPT (cdr (assoc 10 (entget ENT)))
ENPT (cdr (assoc 11 (entget ENT)))
LEN (distance STPT ENPT)
) ;end setq
(cond
((= MODE "F")
(if (equal FIXLEN LEN 0.00001)
(setq CNT (1+ CNT)) ;then next
(ssdel ENT SS) ;else delete
) ;end if
) ;end cond F
((= MODE "R")
(if
(or
(and (<= MINLEN LEN) (>= MAXLEN LEN))
(equal MINLEN LEN 0.00001)
(equal MAXLEN LEN 0.00001)
) ;end or
(setq CNT (1+ CNT))
(ssdel ENT SS)
) ;end if
) ;end cond R
) ;end conditions
) ;end repeat
(if (> (sslength SS) 0)
(progn
(princ (strcat "Number of objects selected = "(itoa (sslength SS))))
(sssetfirst nil SS)
) ;progn
(princ "No objects met the criteria ") ;else
) ;end if
(*Error* nil)
(princ)
) ;end defun
Solved! Go to Solution.