maahee Posted Friday at 06:34 AM Posted Friday at 06:34 AM (edited) (setq ln (ssget "f" pts '((0 . "LINE") (62 . 1)(62 . 5)))) where pts is a list of points that can not select red and blue lines within the selection set (setq ln (ssget "_X" (list '(0 . "LWP*") '(-4 . "=,=,*") (list 10 (car p1) (cadr p1) 0.0)))) cant select the line that passes through the coordinate x ordinate 5 and y x ordinate 12 Edited Friday at 07:41 AM by maahee Quote
Saxlle Posted Friday at 06:57 AM Posted Friday at 06:57 AM (edited) Hi @maahee, Try with this: (setq ln (ssget "_F" pts '((0 . "LINE") (-4 . "<NOT") (-4 . "<OR") (62 . 1) (62 . 5) (62 . 256) (-4 . "OR>") (-4 . "NOT>")))) This will reject selecting "LINE" entities which are colored in red, blue and bylayer (62 . 256) (bylayer present that LINE which cross over the red and blue LINE's). Use this reference to all "ssget" function reference: ssget. Edited Friday at 07:20 AM by Saxlle 1 Quote
GLAVCVS Posted Friday at 07:24 AM Posted Friday at 07:24 AM Hi Maahee If what you're looking for is a mix of the two, maybe this is what you're looking for? (ssget "_X" (list (cons 0 "LWP*") '(-4 . "<and") '(-4 . "<not") '(-4 . "=,=,*") (list 10 (car p1) (cadr p1)) '(-4 . "not>") '(-4 . "<or") '(62 . 1) '(62 . 2) '(-4 . "or>") '(-4 . "and>") ) ) 1 Quote
maahee Posted Friday at 01:53 PM Author Posted Friday at 01:53 PM (edited) On 4/4/2025 at 6:57 AM, Saxlle said: Hi @maahee, Try with this: (setq ln (ssget "_F" pts '((0 . "LINE") (-4 . "<NOT") (-4 . "<OR") (62 . 1) (62 . 5) (62 . 256) (-4 . "OR>") (-4 . "NOT>")))) This will reject selecting "LINE" entities which are colored in red, blue and bylayer (62 . 256) (bylayer present that LINE which cross over the red and blue LINE's). Use this reference to all "ssget" function reference: ssget. Expand hi Saxlle (setq ln (ssget '((0 . "LINE") (-4 . "<OR") (62 . 5) (62 . 1) (-4 . "OR>") ))) this line selects red and blue color lines, but it does not pick a red or blue layer object Edited Friday at 01:54 PM by maahee Quote
maahee Posted Friday at 01:59 PM Author Posted Friday at 01:59 PM On 4/4/2025 at 7:24 AM, GLAVCVS said: Hi Maahee If what you're looking for is a mix of the two, maybe this is what you're looking for? (ssget "_X" (list (cons 0 "LWP*") '(-4 . "<and") '(-4 . "<not") '(-4 . "=,=,*") (list 10 (car p1) (cadr p1)) '(-4 . "not>") '(-4 . "<or") '(62 . 1) '(62 . 2) '(-4 . "or>") '(-4 . "and>") ) ) Expand Hiiii GLAVCVS Select only the pline that passes through the given co-ordinary, Thank you for the additional knowledge, Quote
Saxlle Posted Friday at 02:09 PM Posted Friday at 02:09 PM You didn't mention that you want a polylines. Just susbtitue (0 . "LINE") with (0 . "LWP*"). (setq ln (ssget '((0 . "LWP*") (-4 . "<OR") (62 . 5) (62 . 1) (-4 . "OR>") ))) 1 Quote
Lee Mac Posted Friday at 02:18 PM Posted Friday at 02:18 PM On 4/4/2025 at 1:53 PM, maahee said: (setq ln (ssget '((0 . "LINE") (-4 . "<OR") (62 . 5) (62 . 1) (-4 . "OR>") ))) this line selects red and blue color lines, but it does not pick a red or blue layer object Expand To include the layer colour, you'll need to iterate over the layer table first and construct an appropriate filter (or check the layer colour for each object within the selection and prune the selection). Here's an example - (defun c:test ( / def lay lst ) (setq lst '(1 5)) ;; Target colours (while (setq def (tblnext "layer" (null def))) (if (member (abs (cdr (assoc 62 def))) lst) (setq lay (cons (cons 8 (LM:escapewildcards (cdr (assoc 2 def)))) lay)) ) ) (sssetfirst nil (ssget "_X" (append '( (000 . "LINE") (-04 . "<OR") ) (mapcar '(lambda ( x ) (cons 62 x)) lst) (if lay (append '( (-04 . "<AND") (062 . 256) (-04 . "<OR") ) lay '( (-04 . "OR>") (-04 . "AND>") (-04 . "OR>") ) ) '( (-04 . "OR>") ) ) ) ) ) (princ) ) ;; Escape Wildcards - Lee Mac ;; Escapes wildcard special characters in a supplied string (defun LM:escapewildcards ( str ) (vl-list->string (apply 'append (mapcar '(lambda ( c ) (if (member c '(35 64 46 42 63 126 91 93 45 44)) (list 96 c) (list c) ) ) (vl-string->list str) ) ) ) ) (princ) 1 Quote
GLAVCVS Posted Friday at 06:13 PM Posted Friday at 06:13 PM (edited) I had a hard time understanding you. Let's see if I can get it this time: (setq c nil) (ssget "_X" (list '(0 . "LWP*") (cons 8 (while (setq c (tblnext "LAYER" (if c nil (not (setq r nil))))) (setq r (if (member (cdr (assoc 62 c)) '(1 5)) (if r (strcat r "," (cdr (assoc 2 c))) (cdr (assoc 2 c))) r)) ) ) '(-4 . "=,=,*") (list 10 (car p1) (cadr p1)) ) ) Edited Friday at 06:42 PM by GLAVCVS 1 Quote
GLAVCVS Posted Friday at 06:20 PM Posted Friday at 06:20 PM (edited) A brief explanation: 1) The line of code '(setq c nil)' is for if you have variable 'c' assigned because the 'while' clause of 'ssget' requires it to be initially 'nil'. 2) I've kept the filter to select only polylines that pass through point 'p1'. If you want to disable this filter, just disable the last two lines in the 'ssget' list. I hope I made myself clear. Edited Friday at 06:44 PM by GLAVCVS 1 Quote
GLAVCVS Posted Friday at 07:49 PM Posted Friday at 07:49 PM If, in addition, the selection must take into account the objects on those layers and that have their color set to "bylayer", then... (ssget "_X" (list '(0 . "LWP*") (cons 8 (while (setq c (tblnext "LAYER" (if c nil T))) (setq r (if (member (cdr (assoc 62 c)) '(1 5)) (if r (strcat r "," (cdr (assoc 2 c))) (cdr (assoc 2 c))) r)) ) ) '(-4 . "=,=,*") (list 10 (car p1) (cadr p1)) '(62 . 256) ) ) 1 Quote
GLAVCVS Posted Friday at 07:52 PM Posted Friday at 07:52 PM But remember: 'c' and 'r' must be 'nil' before running this 'ssget' 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.