块到层
有人能帮忙吗。。。绘制一个包含多个块的图形,所有块都位于零层。我需要一个lisp例程,使他们成为基于邮政编码的个人层(见附图)。
你能寄一张样图吗? 没有问题。见附件。这只是我正在处理的文件的一个样本。
Southwark邮编。图纸 已测试,并在您发布的示例图形中工作。如果你遇到任何问题,请告诉我。
;;;
;;; CheSyn 2013
;;; BLK2LAYER - change layer of block to tag value
;;;
(defun c:blk2layer ( / oe ss no e x at ax ln)
(command "_.undo" "BEgin")
(setq oe (getvar 'CMDEcho) )
(setvar 'CMDEcho 0)
(setq ss (ssget "_x" '( (0 . "INSERT")(2 . "BLK*")(8 . "0") ))
no 0 )
(while
(< no (sslength ss) )
(setq e (ssname ss no)
x (entget e)
at (entnext e)
ax (entget at) )
(while
(/= "SEQEND" (cdr (assoc 0 ax)) )
(if
(= "Postcode" (cdr (assoc 2 ax)) )
(setq ln (cdr (assoc 1 ax)) )
)
(setq at (entnext at)
ax (entget at) )
)
(entmod
(subst
(cons 8 ln)
(assoc 8 x)
x
)
)
(entupd e)
(setq no (1+ no) )
)
(setvar 'CMDEcho oe)
(command "_.undo" "End")
(princ)
)
谢谢,效果很好,谢谢。 编写代码的另一种方法
(defun c:b2l (/ ss i lay e et enx)
(if (setq ss (ssget "_X"
'((0 . "INSERT") (66 . 1))
)
)
(repeat (setq i (sslength ss))
(setq lay nil e(ssname ss (Setq i (1- i)))
l(assoc -1 (entget e))
et e
)
(while
(and
(null lay)
(= (cdr (assoc 0 (setq enx (entget (setq et (entnext et))))))
"ATTRIB"
)
)
(if (= "POSTCODDE" (strcase (cdr (assoc 2 enx))))
(setq lay (cdr (assoc 1 enx)))
)
)
(if lay (entmod (list (cons 8 lay) l)))
)
)
(princ)
)
不客气。
非常干净,pBe!
如果程序处理的属性块不包含邮政编码标签,该怎么办?
把我带到那里,LM,(除其他外)
干杯 ..........
页:
[1]