Croftyno1 发表于 2022-7-6 09:59:28

选择多层过滤器

我目前正在使用ssget选择要包含在lisp程序中的层,但正如您在下面看到的,我必须在图形上拖动窗口4次,才能将每个层保存到一个集合中。我想知道是否有办法在对象周围选择一个窗口(而不是重复四次),然后过滤掉我想要的层,并将它们保存到四个不同的SETQ。
下面是我目前在程序中写的内容
 
(提示“\n选择要添加到一起的行:”)
(setq ss1(ssget(列表(cons 8“layer1”)))
(setq ss2(ssget(列表(cons 8“layer2”)))
(setq ss3(ssget(列表(cons 8“layer3”)))
(setq ss4(ssget(列表(cons 8“layer4”)))
 
正如你们所看到的,我需要四次ssget,只是想知道我是否可以使用它一次,并且它存储在SS1、SS2、SS3、SS4中
 
谢谢
 
安得烈

Tharwat 发表于 2022-7-6 10:08:26

您可以在每个ssget之后使用“_x”自动获取它们。
 
实例
 
将上述示例应用于所有代码。
 
塔瓦特

pBe 发表于 2022-7-6 10:13:51

试试这个:
 

(defun c:test ()
(setq
      ss_set '("ss1" "ss2" "ss3")cnt -1)
(foreach
         layername (list "Layer1" "Layer2" "Layer3")
          (set (setq tempo (read (nth (setq cnt (1+ cnt)) ss_set)))
                     (ssget "_x" (list (cons 8 layername))))
         )
   )

 
当然,您需要根据需要更新图层列表和变量名
 
 
祝大家圣诞快乐!!!

David Bethel 发表于 2022-7-6 10:19:51

或者可能:

(setq i 1)
(repeat 4
   (set (read (strcat "SS" (itoa i)))
      (ssget "X" (list (cons 8 (strcat "LAYER" (itoa i))))))
   (setq i (1+ i)))

 
 
-大卫

pBe 发表于 2022-7-6 10:32:02

 
是的。我同意。这将消除对列表的需要。但话说回来。如果您有不同名称的不同层。。您可能仍然需要为图层制作一个列表
 
说得好David

David Bethel 发表于 2022-7-6 10:37:25

我经常使用类似的方法来详细描述部件:

;;;GET LAYER NUMBERS
(while
   (progn
       (and il (princ "\n") (prin1 il))
       (setq in (getint "\nLayer Number To Select:   ")))
   (if (and in (not (member in il)))
       (setq il (cons in il))))

;;;GET PICK SETS
(foreach i il
   (setq dxs (strcat "SS" (if (< i 10) "0" "") (itoa i)))
   (set (read dxs) (ssget "X" (list (cons 8(strcat "LAYER" (itoa i)))))))


 
-大卫

alanjt 发表于 2022-7-6 10:46:03

(ssget '((8 . "pizza,beer,cheese,fun")))

Lee Mac 发表于 2022-7-6 10:50:54

我认为OP要求选择一个窗口,因此我会选择Alan的演示。
 
我不会用我的代码演示的方式来处理它,但是它确实显示了一种按照OP最初请求分配变量的方法:
 
5
 
它比其他任何东西都更适合学术界-它提醒我为每个列表项设置变量。。。

David Bethel 发表于 2022-7-6 10:54:25

李,
 
有时我想你一定中了一张括号彩票,你的奖品是一个人一生中可以使用的无限数量。筑巢直到你掉下去!观看很有趣,解码也很有趣-大卫

Lee Mac 发表于 2022-7-6 11:00:10

 
让事情变得有趣一点
页: [1]
查看完整版本: 选择多层过滤器