Author Topic: ssget filtering  (Read 11532 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ssget filtering
« Reply #15 on: October 25, 2010, 09:15:14 AM »
You're a excellent student, keep up the good work. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Robert98

  • Guest
Re: ssget filtering
« Reply #16 on: October 25, 2010, 01:46:41 PM »
You're a excellent student, keep up the good work. 8-)

Thank you, Mr. CAB and I would try .! :-)

johnson

  • Guest
Re: ssget filtering
« Reply #17 on: February 15, 2011, 10:11:20 AM »
Maybe this?
Code: [Select]
(defun c:comp (/ ELST EN ENAME I LST N3_FILTER SS filter)
  (setq filter "")
  (if (and
        (setq en (entsel "\n Please select a number for filtering :"))
        (setq elst (entget (car en)))
        (or (equal '(0 . "TEXT") (assoc 0 elst))
            (prompt "\nObject was not text."))
        (or (not(repeat (strlen (cdr(assoc 1 elst)))(setq filter (strcat filter "#"))))
            (wcmatch (cdr (assoc 1 elst)) filter)
            (prompt "\nText did not contain correct number of digets."))
      )
    (progn

      ;; =================================================

      (setq N3_filter
             (list
               (cons 0 "TEXT")
               (cons 1 filter)          ; text to match
               (assoc 7 elst)           ; style of digit text
               (assoc 8 elst)           ; selected layer name
               (assoc 40 elst)          ; selected text height
               (assoc 410 elst)
             )
      )

      (setq ss (ssget "X" N3_filter))   ; select all number in up filter
      (setq i -1)
      (while (setq ename (ssname ss (setq i (1+ i))))
        (setq elst (entget ename))
        (setq lst (cons (cdr (assoc 1 elst)) lst))
      )
      (princ lst)   ;print  list of 3 digit numbers that found on drawing
    )
   
  )
  (princ)
)                                       ;end defun     


cab how to filter the text(Mtext)depending upon the height.qselect method...more text area how to filter 40 height text(Mtext)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ssget filtering
« Reply #18 on: February 15, 2011, 10:22:42 AM »
If you are just trying to include MTEXT just change "TEXT" to "TEXT,MTEXT" in both places.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

johnson

  • Guest
Re: ssget filtering
« Reply #19 on: February 15, 2011, 08:01:27 PM »
If you are just trying to include MTEXT just change "TEXT" to "TEXT,MTEXT" in both places.


i want to select some height of text...as per my spec 75 height only allowed.so <>75 i want to select........

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ssget filtering
« Reply #20 on: February 15, 2011, 08:45:40 PM »
Try this:
Code: [Select]
       (setq ss
            (ssget "x"
               '( (0 . "TEXT,MTEXT")
                  (-4 . "!=")  
                  (40 . 75)
                )
            )
        )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

johnson

  • Guest
Re: ssget filtering
« Reply #21 on: February 16, 2011, 09:53:36 AM »
Try this:
Code: [Select]
       (setq ss
            (ssget "x"
               '( (0 . "TEXT,MTEXT")
                  (-4 . "!=")  
                  (40 . 75)
                )
            )
        )


tried.but no reflection...no selection.......

chlh_jd

  • Guest
Re: ssget filtering
« Reply #22 on: February 22, 2011, 08:05:02 AM »
Hi ,
Here's my way to quickly select objects .
You can add the other conditions , such as color , angle ...  and so on.
Code: [Select]
;;;Layer Select Filiter
;;;Support the transparent use
;;;by GSLS(SS)
(defun C:SS (/ ss1 i lst s1 layer_fili ss2 filiter pt)
  (if ss-filiter-old-ss ;_(setq ss-filiter-old-ss nil)
    (progn
      (prompt "Existing layer filters, if need to be rebuilt type 'N':")
      (ss-sel-grread)
    )
    (progn
      (prompt "Select characteristical Entities :")
      (setq ss1 (ssget))
    )
  )
  (if ss1
    (progn
      (setq
i   -1
lst '()
      )
      (while (setq s1 (ssname ss1 (setq i (1+ i))))
(setq lst (append lst (list (cdr (assoc 8 (entget s1))))))
      )
      (setq
layer_fili
 (vl-string-right-trim
   ","
   (apply 'strcat
  (mapcar '(lambda (x) (strcat x ",")) lst)
   )
 )
filiter  (list (cons 8 layer_fili))
ss-filiter-old-ss filiter
      );_ss-filiter-old-ss the Global variables
    )
    (setq filiter ss-filiter-old-ss)
  )
  (if filiter
    (progn
      (setq pt (cadr pt))
      (if (and pt (listp pt))
(SendKeys (ss-pt->str pt))
      )
      (setq ss2 (ssget filiter))
    )
    (c:ss)
  )
  (princ
    (strcat "Total Selected " (rtos (sslength ss2) 2 0) " Entities.")
  )
  ss2
)
;;;Layer & Entity-type Select Filiter
;;;Support the transparent use
;;;by GSLS(SS)
(defun C:S1 (/ ss1 i lst lst1 s1 ent layer_fili TYPE_fili filiter ss2 pt)
  (if ss-filiter-old-s1
    (progn
      (prompt "Existing layer & entity-type filters, if need to be rebuilt type 'N':")
      (ss-sel-grread)
    )
    (progn
      (prompt "Select characteristical Entities :")
      (setq ss1 (ssget))
    )
  )
  (if ss1
    (progn
      (setq
i    -1
lst  '()
lst1 '()
      )
      (while (setq s1 (ssname ss1 (setq i (1+ i))))
(setq ent  (entget s1)
     lst  (append lst (list (cdr (assoc 8 ent))))
     lst1 (append lst1 (list (cdr (assoc 0 ent))))
)
      )
      (setq lst (vl-remove-doubles lst)
   lst1 (vl-remove-doubles lst1)
      )
      (setq
layer_fili
 (vl-string-right-trim
   ","
   (apply 'strcat
  (mapcar '(lambda (x) (strcat x ",")) lst)
   )
 )
TYPE_fili
 (vl-string-right-trim
   ","
   (apply 'strcat
  (mapcar '(lambda (x) (strcat x ",")) lst1)
   )
 )
filiter  (list (cons 0 TYPE_fili)
(cons 8 layer_fili)
 )
ss-filiter-old-s1 filiter
      );_ss-filiter-old-s1 the Global variables
    )
    (setq filiter ss-filiter-old-s1)
  )
  (if filiter
    (progn
      (setq pt (cadr pt))
      (if (and pt (listp pt))
(SendKeys (ss-pt->str pt))
      )
      (setq ss2 (ssget filiter))
    )
    (c:s1)
  )
  (princ
    (strcat "Total Selected " (rtos (sslength ss2) 2 0) " Entities.")
  )
  ss2
)
(defun ss-sel-grread ()
     (setq is_go_on T)
      (while (and
      is_go_on
      (setq pt (grread t 4 2))
      (/= 3 (car pt))
      (/= 25 (car pt))
    )
(cond
 ((and (= 2 (car pt))
(or (eq (strcase (chr (cadr pt))) "N")
   (eq (strcase (chr (cadr pt)) T) "n")
)
  )
  (prompt "Select characteristical Entities :")
  (setq ss1 (ssget))
  (setq is_go_on nil)
 )
 (t
  (if (= (car PT) 5)
    (setq id_go_on nil)
  )
 )
)
      )
  )
(defun SendKeys (keys / ws)
  (setq ws (vlax-create-object "WScript.Shell"))
  (vlax-invoke-method ws 'sendkeys keys)
  (vlax-release-object ws)
  (princ)
)
(defun ss-pt->str (pts / str)
  (if (numberp (car pts))
    (progn
      (setq str "")
      (foreach a pts
(setq str (strcat str (strcat (rtos a 2 6) ",")))
)
      (setq str (vl-string-right-trim "," str))
      (strcat str " ")
      )    
    (mapcar 'ss-pt->str pts)
    )
  )
(defun vl-remove-doubles (lst)
  (if lst
    (cons (car lst)
 (vl-remove-doubles (vl-remove (car lst) lst))
    )
  )
)

johnson

  • Guest
Re: ssget filtering
« Reply #23 on: February 22, 2011, 10:21:33 AM »
Hi ,
Here's my way to quickly select objects .
You can add the other conditions , such as color , angle ...  and so on.
Code: [Select]
;;;Layer Select Filiter
;;;Support the transparent use
;;;by GSLS(SS)
(defun C:SS (/ ss1 i lst s1 layer_fili ss2 filiter pt)
  (if ss-filiter-old-ss ;_(setq ss-filiter-old-ss nil)
    (progn
      (prompt "Existing layer filters, if need to be rebuilt type 'N':")
      (ss-sel-grread)
    )
    (progn
      (prompt "Select characteristical Entities :")
      (setq ss1 (ssget))
    )
  )
  (if ss1
    (progn
      (setq
i   -1
lst '()
      )
      (while (setq s1 (ssname ss1 (setq i (1+ i))))
(setq lst (append lst (list (cdr (assoc 8 (entget s1))))))
      )
      (setq
layer_fili
 (vl-string-right-trim
   ","
   (apply 'strcat
  (mapcar '(lambda (x) (strcat x ",")) lst)
   )
 )
filiter  (list (cons 8 layer_fili))
ss-filiter-old-ss filiter
      );_ss-filiter-old-ss the Global variables
    )
    (setq filiter ss-filiter-old-ss)
  )
  (if filiter
    (progn
      (setq pt (cadr pt))
      (if (and pt (listp pt))
(SendKeys (ss-pt->str pt))
      )
      (setq ss2 (ssget filiter))
    )
    (c:ss)
  )
  (princ
    (strcat "Total Selected " (rtos (sslength ss2) 2 0) " Entities.")
  )
  ss2
)
;;;Layer & Entity-type Select Filiter
;;;Support the transparent use
;;;by GSLS(SS)
(defun C:S1 (/ ss1 i lst lst1 s1 ent layer_fili TYPE_fili filiter ss2 pt)
  (if ss-filiter-old-s1
    (progn
      (prompt "Existing layer & entity-type filters, if need to be rebuilt type 'N':")
      (ss-sel-grread)
    )
    (progn
      (prompt "Select characteristical Entities :")
      (setq ss1 (ssget))
    )
  )
  (if ss1
    (progn
      (setq
i    -1
lst  '()
lst1 '()
      )
      (while (setq s1 (ssname ss1 (setq i (1+ i))))
(setq ent  (entget s1)
     lst  (append lst (list (cdr (assoc 8 ent))))
     lst1 (append lst1 (list (cdr (assoc 0 ent))))
)
      )
      (setq lst (vl-remove-doubles lst)
   lst1 (vl-remove-doubles lst1)
      )
      (setq
layer_fili
 (vl-string-right-trim
   ","
   (apply 'strcat
  (mapcar '(lambda (x) (strcat x ",")) lst)
   )
 )
TYPE_fili
 (vl-string-right-trim
   ","
   (apply 'strcat
  (mapcar '(lambda (x) (strcat x ",")) lst1)
   )
 )
filiter  (list (cons 0 TYPE_fili)
(cons 8 layer_fili)
 )
ss-filiter-old-s1 filiter
      );_ss-filiter-old-s1 the Global variables
    )
    (setq filiter ss-filiter-old-s1)
  )
  (if filiter
    (progn
      (setq pt (cadr pt))
      (if (and pt (listp pt))
(SendKeys (ss-pt->str pt))
      )
      (setq ss2 (ssget filiter))
    )
    (c:s1)
  )
  (princ
    (strcat "Total Selected " (rtos (sslength ss2) 2 0) " Entities.")
  )
  ss2
)
(defun ss-sel-grread ()
     (setq is_go_on T)
      (while (and
      is_go_on
      (setq pt (grread t 4 2))
      (/= 3 (car pt))
      (/= 25 (car pt))
    )
(cond
 ((and (= 2 (car pt))
(or (eq (strcase (chr (cadr pt))) "N")
   (eq (strcase (chr (cadr pt)) T) "n")
)
  )
  (prompt "Select characteristical Entities :")
  (setq ss1 (ssget))
  (setq is_go_on nil)
 )
 (t
  (if (= (car PT) 5)
    (setq id_go_on nil)
  )
 )
)
      )
  )
(defun SendKeys (keys / ws)
  (setq ws (vlax-create-object "WScript.Shell"))
  (vlax-invoke-method ws 'sendkeys keys)
  (vlax-release-object ws)
  (princ)
)
(defun ss-pt->str (pts / str)
  (if (numberp (car pts))
    (progn
      (setq str "")
      (foreach a pts
(setq str (strcat str (strcat (rtos a 2 6) ",")))
)
      (setq str (vl-string-right-trim "," str))
      (strcat str " ")
      )    
    (mapcar 'ss-pt->str pts)
    )
  )
(defun vl-remove-doubles (lst)
  (if lst
    (cons (car lst)
 (vl-remove-doubles (vl-remove (car lst) lst))
    )
  )
)



i have tried.how to use this chlh_jd

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ssget filtering
« Reply #24 on: February 22, 2011, 11:04:54 AM »
tried.but no reflection...no selection.......

Was ss nil?

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

chlh_jd

  • Guest
Re: ssget filtering
« Reply #25 on: February 23, 2011, 06:39:53 AM »
Hi, johnson
It just be used by this way :
type the command into command-line ,when need to select object , then type 'ss or 's1 to run the routine .
if you want to select before command , it must add (sssetfirst nil ss2) .
hi Alan, my windows system is XP-SP3 , I have test in ACAD2004 2006 2009 2011 , it run well .
the before codes use the vlax funs (vlax-invoke-method  ...) , is it call the problem .
« Last Edit: February 23, 2011, 06:43:01 AM by chlh_jd »