列表写出指定范围内块个数
本帖最后由 弥勒 于 2024-3-2 14:20 编辑;20211105学习20220324修改20240120
;QQ:11414516
(defun c:ktj();只列出有的
(setvar"cmdecho" 0)
(setq os ( getvar "osmode"))
(setvar "osmode" 0)
(setq apt1(getpoint "\n 块统计表格基点:"))
(setq ww 60)
;(if ( null ww) (setq ww 40.0))
(setq hh 8)
;(if (null hh) (setq hh 8.0) )
(setq blknnzw "种类")
(setq apt2 (polar apt1 0 ww))
(setq apt3 (polar apt2 (* pi 1.5) hh))
(setq apt4 (polar apt1 (* pi 1.5) hh))
(command"pline" apt1 apt2 apt3 apt4"c" )
(setq apt5 (polar apt1 0 (/ ww 2)))
(setq apt6 (polar apt5 (* pi 1.5) hh))
(command "line" apt5apt6 "" )
(command "text" "m" (inters apt1 apt6 apt4 apt5) ( / hh 2) 0 "块名称")
(command "text" "m" (inters apt5 apt3 apt2 apt6) ( / hh 2) 0 "数量" )
(prompt "提示: 选择多段线范围,多段线为闭合。右键确认")
(setq s1 (ssname (ssget) 0))
;(setq ss (ssget "_CP" ( plgetlsts1)))
(setq blk (tblnext "block" t));重复使用 tblnext 时,它每次通常会返回指定表中的下一个条目
(while blk
(setq blkn (assoc 2 blk));取表的第2个点对
;(0 . "BLOCK") 符号类型
;(2 . "BOX") 符号名
;(70 . 0) 标志
;(10 9.0 2.0 0.0) 原点坐标 X,Y,Z
;(-2 . <图元名: 1dca370>) 第一个图元
(setq blk_key (substr (cdr blkn) 1 1));取块名
(if (/= blk_key "*")
(progn
(setq ss (ssget "_CP" ( plgetlsts1) (list blkn)));依据块名的表,选择块的集合 list(2 . "BOX")
(if ( null ss)
(setq ssn 0)
(progn
(setq ssn (sslength ss));测表的长度,即统计个数
; 开始写表
(setq blknn (cdr blkn))
(setq apt1 apt4 apt5 apt6 apt2 apt3)
(setq apt4 (polar apt1 (* pi 1.5) hh))
(setq apt8 (polar apt1 (* pi 1) 30))
(setq apt9 (polar apt4 (* pi 1) 30))
(setq apt6 (polar apt5 (* pi 1.5) hh))
(setq apt3 (polar apt2 (* pi 1.5) hh))
(setq slst '( ("GC200" "高程点" )
("gc063" "摄像头")
("gc042" "上水井" )
("gc053" "雨水井" )
("gc143" "独立树" )
("gc144" "独立松" )
("gc144" "独立果" )
("gc135" "水龙头" )
("gc041" "雨篦子" )
("gc203" "路灯单" )
("gc097" "路灯双" )
("gc110" "单坟" )
("gc048" "通讯井" )
("gc129" "变电箱" )
("gc146" "机井" )
("gc234" "电缆桩" )
("gc052" "路标" )
("gc043" "污水井" )
("gc046" "燃气井" )
("gc050" "电力井" )
("gc047" "热力井" )
("GCBJ0305" "垃圾箱" )
("gc133" "消防井" )
("GCBJ0407" "公园椅子" )
("gc188" "无名井" )
)
)
(setqsdata (car (assoc blknn slst)))
(if (= blknn sdata)
(setq blknnzw (car (cdr (assoc blknn slst))))
(setq blknnzw blknn)
)
(setq apt7 (polar (inters apt1 apt6 apt4 apt5) (* pi 1) 30))
(command "pline" apt2 apt3 apt4 apt1 "")
(command "pline" apt1 apt8 apt9 apt4 "")
(command "line" apt5 apt6 "")
(command "text" "m" (inters apt1 apt6 apt4 apt5) (/ hh 2) 0 blknn)
(command "text" "m" apt7 (/ hh 2) 0 blknnzw)
(command "text" "m" (inters apt5 apt3 apt2 apt6) (/ hh 2) 0 (itoa ssn))
)
)
)
)
(setq blk (tblnext "block" ));返回指定表中的下一个条目
)
(setvar "osmode" os)
)
(defun plgetlst(ent)
(mapcar 'cdr (vl-remove-if-not (FUNCTION (LAMBDA (x) (= 10 (car x)))) (entget ent)))
)
哈哈,随便看。 是怎么用的大神 菜鸟一个,ktj 就可以。
页:
[1]