新人发帖 统计块的数量并绘制成表格 各位大佬看看我的源码 可以的话请给出建议!谢谢- (defun c:tt()
- (acad-activex-base)
- (setq old_err *error*)
- (setq os (getvar "osmode"))
- (setvar "osmode" 0)
- (setq blkobj (vla-get-blocks dwgobj))
- (setq blklist nil blknum_list nil)
- (setq pt1 (getpoint "\n表格左上角点"))
- (setq pt2 (polar pt1 0 60))
- (setq pt3 (polar pt2 (* pi 1.5) 10))
- (setq pt4 (polar pt3 pi 60))
- (setq ww (distance pt1 pt2))
- (setq hh (distance pt1 pt4))
- (command "pline" pt1 pt2 pt3 pt4 "c")
- (setq pa (polar pt1 0 (/ ww 2)))
- (setq pb (polar pa (* pi 1.5) hh))
- (command "line" pa pb "")
- (command "text" "m" (inters pt1 pb pt4 pa) (/ hh 2) "0" "图块名称")
- (command "text" "m" (inters pa pt3 pb pt2) (/ hh 2) "0" "数量")
- (vlax-for sobj blkobj
- (setq blkn (vla-get-name sobj))
- (if (/= (substr blkn 1 1) "*")
- (progn
- (setq ss (ssget "X" (list '(0 . "insert") (cons 2 blkn))))
- (if ss
- (setq nns (sslength ss))
- )
- (setq pt1 pt4 pt2 pt3 pa pb)
- (setq pt3 (polar pt2 (* pi 1.5) hh))
- (setq pt4 (polar pt1 (* pi 1.5) hh))
- (setq pb (polar pa (* pi 1.5) hh))
- (command "pline" pt1 pt2 pt3 pt4 "c")
- (command "line" pa pb "")
- (command "text" "m" (inters pt1 pb pt4 pa) (/ hh 2) "0" blkn)
- (command "text" "m" (inters pa pt3 pb pt2) (/ hh 2) "0" (rtos nns))
- )
- )
- )
- (acad-activex-exit)
- (setvar "osmode" os)
- (prin1)
- )
- (defun acad-activex-base()
- (vl-load-com)
- (setq acadobj (vlax-get-acad-object))
- (setq dwgobj (vla-get-ActiveDocument acadobj))
- (setq mspace (vla-get-ModelSpace dwgobj))
- )
- (defun acad-activex-exit()
- (vlax-release-object acadobj)
- )
- (defun *error*(st)
- (if (and (/= st "Function cancelled")
- (/= st "quit / exit abort"))
- (princ (strcat "错误!" st))
- )
- (setq *error* old_err)
- (setvar "osmode" os)
- )
|