Lee Mac 发表于 2022-7-6 09:47:11

也许我说的是显而易见的,但你不能只搜索“M2”吗,或者这也有多次出现吗?

Lee Mac 发表于 2022-7-6 09:51:37

快速修改David的例程以搜索属性值:
 
(defun c:findkatt (/ i tl en ed an ad ss)

(setq tl '("VAV" "M2"))
(princ "\nSearching For Tagnames: ")
(prin1 tl)

(and (setq ss (ssget "X" '((0 . "INSERT")(66 . 1))))
      (while (setq en (ssname ss 0))
             (setq ed (entget en)
                   an (entnext en)
                   ad (entget an)
                   i 0)
             (while (/= "SEQEND" (cdr (assoc 0 ad)))
                  (if (member (strcase (cdr (assoc 1 ad))) tl)
                        (setq i (1+ i)))
                  (setq an (entnext an)
                        ad (entget an)))
             (if (= i (length tl))
               (progn
                   (command "_.ZOOM" "_C" (trans (cdr (assoc 10 ed)) en 1) "")
                   (redraw en 3)
                   (getstring (strcat "\n" (cdr (assoc 2 ed))
                                    " Press Enter To Continue..."))))
             (ssdel en ss)))
(princ "\nSearch Complete   ")
(redraw)
(prin1))

ketongin 发表于 2022-7-6 09:55:14

是的,李,这一个也有多次出现。
 

ketongin 发表于 2022-7-6 09:58:23

你几乎在那里,但VAV和M2不是静态的。这两个属性都有任何值。VAV为设备类型,M2为设备编号。VAv可以是RTU、CEF、SP等,M2可以是A1、B2、C3等。
 
 
 
 
我试过这个,但也没用
 
(defun c:findkatt (/ i tl en ed an ad ss unit unitno)

(setq unit (getstring "\n Enter unit type:"))
(setq unitno (getstring "\n Enter unit type:"))

(setq tl '(unit unitno))
(princ "\nSearching For Tagnames: ")
(prin1 tl)

(and (setq ss (ssget "X" '((0 . "INSERT")(66 . 1))))
      (while (setq en (ssname ss 0))
             (setq ed (entget en)
                   an (entnext en)
                   ad (entget an)
                   i 0)
             (while (/= "SEQEND" (cdr (assoc 0 ad)))
                  (if (member (strcase (cdr (assoc 1 ad))) tl)
                        (setq i (1+ i)))
                  (setq an (entnext an)
                        ad (entget an)))
             (if (= i (length tl))
               (progn
                   (command "_.ZOOM" "_C" (trans (cdr (assoc 10 ed)) en 1) "")
                   (redraw en 3)
                   (getstring (strcat "\n" (cdr (assoc 2 ed))
                                    " Press Enter To Continue..."))))
             (ssdel en ss)))
(princ "\nSearch Complete   ")
(redraw)
(prin1))

David Bethel 发表于 2022-7-6 10:05:32

看起来您在搜索属性值,而不是标记名:
 

(defun c:findmatv (/ fl tl en ed an ad av ss)

(setq tl '("VAV" "M2"))
(princ "\nSearching For Attrib Values: ")
(prin1 tl)

(and (setq ss (ssget "X" '((0 . "INSERT")(66 . 1))))
      (while (setq en (ssname ss 0))
             (setq ed (entget en)
                   an (entnext en)
                   ad (entget an)
                   fl nil)
             (while (/= "SEQEND" (cdr (assoc 0 ad)))
                  (setq av (cdr (assoc 1 ad)))
                  (and (member av tl)
                         (not (member av fl))
                         (setq fl (cons av fl)))
                  (setq an (entnext an)
                        ad (entget an)))
             (if (= (length fl) (length tl))
               (progn
                   (command "_.ZOOM" "_C" (trans (cdr (assoc 10 ed)) en 1) "")
                   (redraw en 3)
                   (getstring (strcat "\n" (cdr (assoc 2 ed))
                                    " Press Enter To Continue..."))))
             (ssdel en ss)))
(princ "\nSearch Complete   ")
(redraw)
(prin1))

 
-大卫

ketongin 发表于 2022-7-6 10:08:12

谢谢大卫和李。谢谢你的帮助。这就是我一直在找的。我学到了很多。再次感谢。。。
页: 1 [2]
查看完整版本: 查找块中的属性