maahee Posted April 4 Posted April 4 (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 April 4 by maahee Quote
Saxlle Posted April 4 Posted April 4 (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 April 4 by Saxlle 1 Quote
GLAVCVS Posted April 4 Posted April 4 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 April 4 Author Posted April 4 (edited) 6 hours ago, 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. 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 April 4 by maahee Quote
maahee Posted April 4 Author Posted April 4 6 hours ago, 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>") ) ) Hiiii GLAVCVS Select only the pline that passes through the given co-ordinary, Thank you for the additional knowledge, Quote
Saxlle Posted April 4 Posted April 4 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 April 4 Posted April 4 24 minutes ago, 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 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 April 4 Posted April 4 (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 April 4 by GLAVCVS 1 Quote
GLAVCVS Posted April 4 Posted April 4 (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 April 4 by GLAVCVS 1 Quote
GLAVCVS Posted April 4 Posted April 4 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 April 4 Posted April 4 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.