2010年8月2日 星期一

Autolisp 排除選集中特定物件 Exclude Entites from selection set

;;************************************************************************************;;
;;***********          排除選集中特定物件       **************************************;;
;;************************************************************************************;;
(defun SSEntTypExclude (SSrex entype / i n endata enNamen ssExcluded result)
  (if (/= SSrex nil)
    (progn
      (setq ssExcluded (ssadd))
      (setq n 0)
      (repeat (sslength SSrex)
    (setq enNamen (ssname SSrex n))
    (setq endata (entget enNamen))
    (if (= (cdr (assoc 0 endata)) entype)
      (progn 
       (print entype)
       (print (cdr (assoc 0 endata)))
           (setq ssExcluded (ssadd enNamen ssExcluded))
      );;progn
    );;if
    (setq n (+ n 1))
      ) ;;repeat
    );;progn
  );;if

  (if (/= ssExcluded nil)
    (progn
      (setq i 0)
      (if (> (sslength ssExcluded) 0)
    (progn 
      (repeat (sslength ssExcluded)
    (setq enNameI (ssname ssExcluded i))
    (setq ssresult (ssdel enNameI SSrex))
    (setq i (+ 1 i))
      );;repeat
      (setq result ssresult)
      );;progn
    (setq result SSrex)
    );;if
    )
    ;;progn
  )
) 


您只要反向操作,這個程式也可以選中特定型態....



範例1
(defun c:Tt (/ ss)
  (setq ss (ssget))
  (setq ss (SSEntTyp ss "DIMENSION"))
  (command "erase" ss "")
)
範例1.不管選中什麼 TT 只幫你刪掉標註



範例2
(defun c:Tt2 (/ ss Dss Lss)
  (setq ss (ssget))
  (setq Dss (SSEntTyp ss "DIMENSION"))
  (setq Lss (SSEntTyp ss "LEADER"))
  (command "erase" Dss "")
  (command "erase" Lss "")
)
範例2.不管選中什麼 TT 只幫你刪掉標註及引線


(defun SSEntTyp (SSrex entype /  n endata enNamen ssExcluded result)
   (if (/= SSrex nil)
     (progn
       (setq ssExcluded (ssadd))
       (setq n 0)
       (repeat (sslength SSrex)
     (setq enNamen (ssname SSrex n))
     (setq endata (entget enNamen))
     (if (= (cdr (assoc 0 endata)) entype)
       (progn
        (print entype)
        (print (cdr (assoc 0 endata)))
            (setq ssExcluded (ssadd enNamen ssExcluded))
       );;progn
     );;if
     (setq n (+ n 1))
       ) ;;repeat
     );;progn
   );;if
          (setq result ssExcluded)
   )

沒有留言:

張貼留言