使用创建新的相同层
大家好,我遇到了另一个我自己无法解决的挑战。
比如说我画了一幅画
-“B-LINELAYER”层上有20行
-“B-BLOCKLAYER”层上有6个块
-还有一个以“B”开头的图层。
现在我想运行我的命令。能够选择对象。(所有内容都允许删除锁定层)。然后键入“V”。
假设我在“B-LINELAYER”层上选择了10条线。我想把它们移到“V-LINELAYER”层。如果该层不存在,则需要使用原始层“B-LINELAYER”的精确属性进行制作。
这样,我可以给某些行/块一个特定的“状态”。Tho,它们在屏幕上显示相同。
到目前为止,我自己做到了:
-选择对象(除锁定层外的所有层)
-选择:B V或T(我使用的3种状态)
-如果没有选择,什么都不会发生。
-如果选择,则获取对象的数量并为每个对象运行循环。
但是现在。。。变化的部分。。。有什么想法吗?
(defun C:ChangeStatus(/ objecten nieuwestatus n index)
(setq objecten (ssget ":L"))
(initget "B V T")
(setq nieuwestatus (getkword "\nChange to status : "))
(if (= nieuwestatus nil)
(progn
(princ "\nNothing changed.")
)
(progn
(princ "\nChange status...")
(setq n (sslength objecten))
(setq index 0)
(repeat n
<something here>
(setq index (1+ index))
)
)
)
(princ)
)
嗨,这里有一些提示:
更改某些实体的层(在本例中,所选实体位于“VLD\U AnnotateLINES”层,我们将其更改为“VLD\U TEXT”层):
_$ (setq e (car (entsel))) ; get some ename
<Entity name: 7ff70ce073a0>
_$ (setq enx (entget e)) ; get entity's data
((-1 . <Entity name: 7ff70ce073a0>) (0 . "CIRCLE") (330 . <Entity name: 7ff70ce039f0>) (5 . "2B2") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "VLD_AnnotateLINES") (100 . "AcDbCircle") (10 177.098 166.179 0.0) (40 . 13.7554) (210 0.0 0.0 1.0))
_$ (setq enx (subst (cons 8 "VLD_TEXT") (assoc 8 enx) enx)) ; change (substitute) the layer association of its data
((-1 . <Entity name: 7ff70ce073a0>) (0 . "CIRCLE") (330 . <Entity name: 7ff70ce039f0>) (5 . "2B2") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "VLD_TEXT") (100 . "AcDbCircle") (10 177.098 166.179 0.0) (40 . 13.7554) (210 0.0 0.0 1.0))
_$ (entmod enx) ; modify the entity
((-1 . <Entity name: 7ff70ce073a0>) (0 . "CIRCLE") (330 . <Entity name: 7ff70ce039f0>) (5 . "2B2") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "VLD_TEXT") (100 . "AcDbCircle") (10 177.098 166.179 0.0) (40 . 13.7554) (210 0.0 0.0 1.0))
_$
迭代选择集(最常见的方法):
(if
(setq SS
(ssget "_:L" ; exclude locked layers
(list (cons 8 "B-LINELAYER,B-BLOCKLAYER")) ; filter the selection by these layers
)
); setq
(repeat (setq i (sslength SS)) ; iterate thru the selection set
(setq e (ssname SS (setq i (1- i)))) ; get an ename
; < do stuff with that ename >
); repeat
); if SS
希望你能学到一些东西。
页:
[1]