- (defun c:P185()
- (setvar "cmdecho" 0)
- (setq os (getvar "osmode"))
- (setvar "osmode" 0)
- (setq pt1 (getpoint "\n左上角: "));getpoint 让用户点选一个点
- (setq ww (getdist pt1 "\n宽度 <50>: "));等待用户输入一个距离值或用鼠标点选
- (if (null ww) (setq ww 40.0));判断用户输入的距离是否为空,为空则默认为40.0
- (setq hh (getdist pt1 "\n每格高度 <8>: "));等待用户输入每格的高度
- (if (null hh) (setq hh 8.0));判断用户输入的值是否为空,为空则默认为8.0
- (setq pt2 (polar pt1 0 ww));
- (setq pt3 (polar pt2 (* pi 1.5) hh))
- (setq pt4 (polar pt1 (* pi 1.5) hh))
- (command "pline" pt1 pt2 pt3 pt4 "c")
- (setq pt5 (polar pt1 0 (/ ww 2)))
- (setq pt6 (polar pt5 (* pi 1.5) hh))
- (command "line" pt5 pt6 "")
- (command "text" "m" (inters pt1 pt6 pt4 pt5) (/ hh 2) 0 "图块名称")
- (command "text" "m" (inters pt5 pt3 pt2 pt6) (/ hh 2) 0 "数量")
- (setq blk (tblnext "block" t))
- (while blk
- (setq blkn (assoc 2 blk))
- (setq blk_key (substr (cdr blkn) 1 1))
- (if (/= blk_key "*")
- (progn
- (setq ss (ssget "X" (list blkn)))
- (if (null ss)
- (setq ssn 0)
- (setq ssn (sslength ss))
- )
- (setq blknn (cdr blkn))
- (setq pt1 pt4 pt5 pt6 pt2 pt3)
- (setq pt4 (polar pt1 (* pi 1.5) hh))
- (setq pt6 (polar pt5 (* pi 1.5) hh))
- (setq pt3 (polar pt2 (* pi 1.5) hh))
- (command "pline" pt2 pt3 pt4 pt1 "")
- (command "line" pt5 pt6 "")
- (command "text" "m" (inters pt1 pt6 pt4 pt5) (/ hh 2) 0 blknn)
- (command "text" "m" (inters pt5 pt3 pt2 pt6) (/ hh 2) 0 (itoa
- ssn))
- )
- )
- (setq blk (tblnext "block"))
- )
- (setvar "osmode" os)
- (prin1)
- )
求高手帮忙把此程序改一下,希望统计的块是让用户自己选取一个范围内的!上面的这程序是统计了整个图上所有的图块了! |