Jump to content

Recommended Posts

Posted (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 by maahee
  • maahee changed the title to Selection set filter
Posted (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 by Saxlle
  • Thanks 1
Posted

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>")
       )
)

 

  • Thanks 1
Posted (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 by maahee
Posted
  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, 

 

 

Posted

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>") )))

 

  • Thanks 1
Posted
  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)

 

  • Thanks 1
Posted (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 by GLAVCVS
  • Thanks 1
Posted (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 by GLAVCVS
  • Agree 1
Posted

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) 
       )
)

 

  • Thanks 1
Posted

But remember: 'c' and 'r' must be 'nil' before running this 'ssget'

  • Agree 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...