求帮助单独选择改批量选择如何修改??????
以下为明经源码,感谢原作者,有个问题,执行命令需要一个个点选多段线框才能打印,能否改为 一次性批量框选多段线框直接打印尝试改了下: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)
)
(defun c:ksdy ()
(vl-load-com)
(setvar "cmdecho" 0)
(princ "\n请选取矩形图框: ")
(if (setq ss (ssget (list '(0 . "LWPOLYLINE") '(90 . 4))))
(progn
(xyp-MkLaCo "fzx" 1)
(setq lst (xyp-Sort-Plist (xyp-Sort ss "1" "Y-max") 1)
i 1
s0 (entlast)
ptn (mapcar '(lambda (x)
(setq p1 (xyp-9pt x 1)
p9 (xyp-9pt x 9)
s1 (xyp-Line p1 p9)
s2 (xyp-Line (xyp-9pt x 3) (xyp-9pt x 7))
s3 (xyp-Text 5 (xyp-9pt x 5) (itoa i))
s3 (xyp-SubUpd s3 40 6000)
i(1+ i)
fx (if (> (- (car p9) (car p1)) (- (cadr p9) (cadr p1)))
"L"
"P"
)
)
(list p1 p9 fx)
)
(mapcar 'cdr lst)
)
sstk (xyp-SsEntnext s0)
i -1
kw (Ukword 1 "Y N" "[批量打印: 确认(Y)/退出(N)]" kw)
)
(if (= kw "Y")
(progn
(command "erase" sstk "")
(foreach aa ptn
(setq p1 (car aa)
p9 (cadr aa)
fx (last aa)
)
(command "_.PLOT" "Y" "" "pdfFactory Pro" "A3" "M" fx "N" "W" p1 p9 "F" "C" "Y" "monochrome.ctb" "Y" "N" "N" "N" "Y")
(princ (strcat "\n 程序正在打印第"
(itoa (- (length ptn) i))
"张>>>>>>>> "
)
)
)
)
(command "erase" sstk "")
)
)
)
(setvar "osmode" os)
(princ)
) 有木有人帮忙解答下 本帖最后由 xyp1964 于 2023-10-14 10:59 编辑
;; 快速打印程序,选一堆矩图框,再批量打印
;; ksdy(快速打印)
(defun c:ksdy (/ s1 fx i maxx0 maxy0 minx0 miny0 os p1 p9 ptn ss sstk)
(vl-load-com)
(setvar "cmdecho" 0)
(princ "\n请选取矩形图框: ")
(if (setq ss (ssget (list '(0 . "LWPOLYLINE") '(90 . 4))))
(progn
(setq os(getvar "osmode")
sstk (ssadd)
ptn'()
i-1
)
(while (setq s1 (ssname ss (setq i (1+ i))))
(vla-getboundingbox (vlax-ename->vla-object s1) 'p1 'p9)
(setq p9 (vlax-safearray->list p9)
p1 (vlax-safearray->list p1)
minx0 (car p1)
miny0 (cadr p1)
maxx0 (car p9)
maxy0 (cadr p9)
fx (if (>= (- maxx0 minx0) (- maxy0 miny0)) "L" "P")
ptn (cons (list p1 p9 fx) ptn)
)
(entmake (list '(0 . "LINE")(cons 62 6)(cons 10 p1)(cons 11 p9)))
(ssadd (entlast) sstk)
(entmake (list '(0 . "LINE")(cons 62 6)(cons 10 (list minx0 maxy0 0))(cons 11 (list maxx0 miny0 0))))
(ssadd (entlast) sstk)
)
(initget "Y N ")
(if (= (getpoint (strcat "\n 确定批量打印?[确认(Y)/退出(N)]:<Y> ")) "Y" )
(progn
(command "erase" sstk "")
(repeat (setq i (length ptn))
(setq aa (nth (setq i (1- i)) ptn)
p1 (car aa)
p9 (cadr aa)
fx (last aa)
)
(command "_.PLOT" "Y" "" "pdfFactory Pro" "A3" "M" fx "N" "W" p1 p9 "F" "C" "Y" "monochrome.ctb" "Y" "N" "N" "N" "Y")
(princ (strcat "\n 程序正在打印第" (itoa (- (length ptn) i)) "张>>>>>>>> "))
)
)
(command "erase" sstk "")
)
)
)
(setvar "osmode" os)
(princ)
)
xyp1964 发表于 2023-10-14 10:48
;; 快速打印程序,选一堆矩图框,再批量打印
;; ksdy(快速打印)
(defun c:ksdy (/ s1 fx i maxx0 maxy0 mi ...
感谢院长,还有个小小问题,看能不能帮忙解决下
1、图纸打印出来顺序能加个判断么,因为是框选,所以无论那种选择方式能保证打印图纸大致是左到右,上到下方式呢
xyp1964 发表于 2023-10-14 10:48
;; 快速打印程序,选一堆矩图框,再批量打印
;; ksdy(快速打印)
(defun c:ksdy (/ s1 fx i maxx0 maxy0 mi ...
不太懂代码,看里面好像是有方向判断,但是目前打印出来顺序是乱的,我琢磨了下没搞出来,:'( xyp1964 发表于 2023-10-14 14:40
(defun c:ksdy ()
(vl-load-com)
(setvar "cmdecho" 0)
院长是不是缺少函数啊,提示no function definition: XYP-MKLACO xyp1964 发表于 2023-10-14 14:40
(defun c:ksdy ()
(vl-load-com)
(setvar "cmdecho" 0)
后面这个没法使用了,是不是有问题呢,缺少函数,麻烦有空看下哈
页:
[1]