Croftyno1 发表于 2022-7-6 09:17:57

过滤层(包含n个

下午的Cadders,
 
我想在过滤层时忽略字母,只过滤包含某些数字的层,即层名称:grid510,只按数字510过滤,而不是按整个层名称过滤。欢迎任何建议!!
这是我目前用来过滤我的图层的代码,这是Lee Mack从之前发布的问题中提供的。
 
(defun test ( / ss ) (vl-load-com)

(if (setq ss (ssget (setq l '((8 . "ti grid re510,ti grid re520,ti grid re540,ti grid re560,ti grid re570,ti grid re580,ti grid tx150,ti grid type 1,ti grid type 2,ti grid type 3,ti grid type 4")))))
   (
   (lambda ( l / i e sym )
       (repeat (setq i (sslength ss))
         (ssadd (setq e (ssname ss (setq i (1- i))))
         (cond
             (
               (eval
               (setq sym
                   (read
                     (strcat "ss"
                     (
                         (lambda ( j )
                           (vl-some
                           (function
                               (lambda ( x ) (setq j (1+ j))
                                 (if (wcmatch (strcase (cdr (assoc 8 (entget e)))) (strcase x))
                                 (itoa j)
                                 )
                               )
                           )
                           l
                           )
                         )
                         0
                     )
                     )
                   )
               )
               )
             )
             ( (set sym (ssadd)) )
         )
         )
       )
   )
   (LM:str->lst (cdar l) ",")
   )
)
)

BlackBox 发表于 2022-7-6 09:44:04

???
 

...
(if (setq ss (ssget '((8 . "*510*,*520*"))))
...

alanjt 发表于 2022-7-6 09:54:56

您应该阅读一下wcmatch函数。它将为您提供ssget选择筛选所需的信息。

Croftyno1 发表于 2022-7-6 10:16:34

现在感觉自己像一个成年累月的人,*510*起作用了!真不敢相信,看在上帝的份上,这就是我所需要做的一切。
谢谢大家

irneb 发表于 2022-7-6 10:24:18

wild-Cards的奇迹8)!只有当你开始使用它们时,你才开始注意到ACad的wcmatch函数的缺点:o。然后你开始考虑使用正则表达式——但这是一个完全不同的游戏!
页: [1]
查看完整版本: 过滤层(包含n个