以下为明经源码,感谢原作者,有个问题,执行命令需要一个个点选多段线框才能打印,能否改为 一次性批量框选多段线框直接打印
尝试改了下:S不行,应该不是单纯改这里就行的,实际情况是不能用的,请大神帮忙看看如何改
- ;;; 快速打印程序,选一堆矩图框,再批量打印
- (defun c:ksdy (/ ent fx i maxpoint maxx0 maxy0 minpoint minx0 miny0 os pmax pmin ptlist ss sstk)
- (vl-load-com)
- (setvar "cmdecho" 0) (setq os (getvar "osmode") ss (ssadd) sstk (ssadd) )
- (princ "\n 请选取矩形图框:")
- (while (setq ss (ssget ":S" (list '(0 . "LWPOLYLINE") '(90 . 4))))
- ;(while (setq ss (ssget (list '(0 . "LWPOLYLINE") '(90 . 4))))
- (setq ent (ssname ss 0))
- (vla-getboundingbox (vlax-ename->vla-object ent) 'minpoint 'maxpoint)
- (setq pmax (vlax-safearray->list maxpoint) pmin (vlax-safearray->list minpoint)
- minx0 (car pmin) miny0 (cadr pmin) maxx0 (car pmax) maxy0 (cadr pmax))
- (if (>= (- maxx0 minx0) (- maxy0 miny0)) (setq fx "L") (setq fx "P") )
- ;;;生成矩形的对角线并将对角线加入选择集sstk
- (entmake (list '(0 . "LINE") (cons 62 6) (cons 10 (list minx0 miny0 0)) (cons 11 (list maxx0 maxy0 0))))
- (setq sstk (ssadd (entlast) sstk))
- (entmake (list '(0 . "LINE") (cons 62 6) (cons 10 (list minx0 maxy0 0)) (cons 11 (list maxx0 miny0 0))))
- (setq sstk (ssadd (entlast) sstk))
- ;;;生成矩形的对角线并将对角线加入选择集sstk结束
- (setq ptlist (cons (list pmin pmax fx) ptlist))
- )
- (initget "Y N ")
- (if (/= (getpoint (strcat "\n 确定批量打印?[确认(Y)/退出(N)]:<Y> ")) "N")
- (progn
- (command "erase" sstk "")
- (repeat (setq i (length ptlist))
- (setq ent (nth (setq i (1- i)) ptlist ) pmin (car ent) pmax (cadr ent) fx (last ent))
- (command "_.PLOT" "Y" "" "pdfFactory Pro" "A3" "M" fx "N" "W" pmin pmax "F" "C" "Y" "monochrome.ctb" "Y" "N" "N" "N" "Y")
- (princ (strcat "\n 程序正在打印第" (itoa (- (length ptlist) i)) "张>>>>>>>> "))
- )
- )
- (command "erase" sstk "")
- )
- (setvar "osmode" os) ; 恢复捕捉模式
- (princ)
- )
|