明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3354|回复: 10

[求助]如何实现快速打印一个窗口内的多份图纸!-有LSP

[复制链接]
发表于 2010-1-4 16:20:00 | 显示全部楼层 |阅读模式

我的自动打印命令换了打印机后就不能用了!先谢谢大家帮助我解决问题!我是新手!直接弄好后我学习就可以了!以前命令行输入,XXX 或者00和33都可以自动打印同个绘图区内的多份图纸的,我的图框是块的,只是最近换了台打印机!是否还有写相关文件要改呀!


(defun c:xxx( / str)

  (setq colorall 105)
  (N002 colorall)
  (if (not str) (exit))

   (setvar "cmdecho" 0)
   (setq n 0)
   (princ "\n请选择为要列印的图框:") 
   (setq ss (ssget))
   (setq i (sslength ss))
   (setq j 0)
   (repeat i
     (setq n(+ 1 n))
     (setq en (ssname ss j))
     (setq j (+ j 1))
     (setq form (entget en))
     (if(and (= (cdr(assoc 0 form)) "INSERT") (= (strcase(cdr(assoc 2 form))) "A3"))
       (progn
  (command "ucs" "")
         (setq pick_point(trans(cdr(assoc 10 form)) 0 1))
         (setq form_scale(cdr(assoc 41 form)))
         (setq p1(list (- (car pick_point) (* 205 form_scale)) (- (cadr pick_point) (* 144.5 form_scale))))
         (setq p2(list (+ (car pick_point) (* 205 form_scale)) (+ (cadr pick_point) (* 144.5 form_scale))))
         (setq p3(list (- (car pick_point) (* 191 form_scale)) (+ (cadr pick_point) (* 138.5 form_scale))))
  (setq p1 (trans p1 2 0))
         (setq p2 (trans p2 2 0))
  (setq p3 (trans p3 2 0))
         (setq nfeosmode (getvar "osmode"))
         (setvar "osmode" 0)
  (command "layer" "t" "MARK" "")
  (setq dwgprefix-name (strcat "图档路径>>> " (getvar "dwgprefix")))
  (setq p30 (polar p3 (* 1.75 pi) (* 6 form_scale)))
  (command "text" "s" "chinese"  p30 (* 2.5 form_scale) 0.0 dwgprefix-name)
  (command "layer" "t" "0" "")
  (setq lastobject (entlast))
  (setq acadver (getvar"acadver"))
  (if(= acadver "15.0")
    (progn
      (if(= str "5004")
        (command "-plot" "Y" "" "HP_5004.pc3" "A3" "M" "L" "n" "W" p1 p2 "F" "C" "Y" "acad.ctb" "Y" "N" "N" "y" "Y"))
      (if(= str "XDC5")
        (command "-plot" "Y" "" "X-DC5.pc3" "A3 (297x420mm)" "M" "L" "n" "W" p1 p2 "F" "C" "Y" "acad.ctb" "Y" "N" "N" "Y" "Y"))
            )
    )
  (if(= acadver "14.0")
    (progn
             (if(= str "5004")
        (progn
   (setvar "plotid" "HP_5004")
   (command "plot" "w" p1 p2 "5" "" "" "" "M" "0,0" "408,282" "0" "" "F" "0")
               )
      )
      (if(= str "XDC5")
        (progn
   (setvar "plotid" "X-DC5")
   (command "plot" "w" p1 p2 "5" "" "" "" "M" "0,0" "408,282" "0" "" "F" "0")
               )
      )
      )
    )
      (command "erase" lastobject "")
         (setvar "osmode" nfeosmode)  
         (princ)
       )
      )
     (if(and (= (cdr(assoc 0 form)) "INSERT") (= (strcase(cdr(assoc 2 form))) "A4"))
       (progn
  (command "ucs" "")
         (setq pick_point(trans (cdr(assoc 10 form)) 0 1))
         (setq form_scale(cdr(assoc 41 form)))
         (setq p1(list (- (car pick_point) (* 99.0 form_scale)) (- (cadr pick_point) (* 144.5 form_scale))))
         (setq p2(list (+ (car pick_point) (* 101.0 form_scale)) (+ (cadr pick_point) (* 144.5 form_scale))))
  (setq p3(list (- (car pick_point) (* 85.0 form_scale)) (+ (cadr pick_point) (* 138.5 form_scale))))
         (setq p1 (trans p1 2 0))
         (setq p2 (trans p2 2 0))
  (setq p3 (trans p3 2 0))
         (setq nfeosmode (getvar "osmode"))
         (setvar "osmode" 0)
  (command "layer" "t" "MARK" "")
  (setq dwgprefix-name (strcat "图档路径>>> " (getvar "dwgprefix")))
  (setq p30 (polar p3 (* 1.75 pi) (* 6 form_scale)))
  (command "text" "s" "chinese"  p30 (* 3.0 form_scale) 0.0 dwgprefix-name)
  (command "layer" "t" "0" "")
  (setq lastobject (entlast))
  (setq acadver (getvar"acadver"))
  (if(= acadver "15.0")
    (progn
      (if(= str "5004")
     (command "-plot" "Y" "" "HP_5004.pc3" "A4" "M" "P" "n" "W" p1 p2 "F" "C" "Y" "acad.ctb" "Y" "N" "N" "y" "Y"))
      (if(= str "XDC5")
      (command "-plot" "Y" "" "X-DC5.pc3" "A4 (210x297mm)" "M" "P" "n" "W" p1 p2 "F" "C" "Y" "acad.ctb" "Y" "N" "N" "Y" "Y"))
            )
    )
  (if(= acadver "14.0")
    (progn
             (if(= str "5004")
        (progn
   (setvar "plotid" "HP_5004")
   (command "plot" "w" p1 p2 "5" "" "" "" "M" "" "A4" "90" "" "F" "0")
               )
      )
      (if(= str "XDC5")
        (progn
   (setvar "plotid" "X-DC5")
   (command "plot" "w" p1 p2 "5" "" "" "" "M" "" "A4" "90" "" "F" "0")
               )
      )
      )
    )
 
  (command "erase" lastobject "")
         (setvar "osmode" nfeosmode)  
         (princ)
       )
    )
  )
     (princ(strcat "******* 列印完毕,共" (rtos n 2 0) ".*******"))
     (princ)
)
    (princ "\nn002.lsp <快速列印> loaded!")
    (princ)


(defun N002( color / dcl_id x y dx dy)
  (setq dcl_id (load_dialog "N002"))
  (if(> dcl_id 0)(new_dialog "N002" dcl_id)(prompt "Unable to open the dialog box!"))
  (start_image "a1")
  (setq x (dimx_tile "a1"))
  (setq y (dimy_tile "a1"))
  (setq dx (/ x 2) dy (/ y 1))
  (dlg_recf 1 1 dx (- dy 2) color)
  (slide_image 0 -1 (- x 1) (- y 1) "N002.sld")
  (end_image)
  (action_tile "a1" "(setq fname (N002A $key colorall 1))")
  (action_tile "accept" "(if(= str nil)(progn(done_dialog dcl_id)(setq str \"5004\"))(done_dialog dcl_id))")
  (action_tile "cancel" "(setq str nil)")
  (if(/= str nil)(done_dialog dcl_id))
  (start_dialog)
)


(defun dlg_recf(x0 y0 w0 h0 colorf)
  (fill_image x0 y0 w0 h0 colorf)
)
 
(defun N002A(key color color1 / w h dx dy)
  (setq w (dimx_tile key))
  (setq h (dimy_tile key))
  (setq dx (/ w 2) dy (/ h 1))
  (start_image key)
  (dlg_recf 1 1 dx (- dy 2) -2)
  (dlg_recf dx 1 (- dx 2) (- dy 2) -2)
  (if(and (> $x 0)(< $x dx))
      (if(< $y dy)(progn
      (setq str "5004")
      (dlg_recf 1 1 dx (- dy 2) color)))
  )
  (if(and (> $x dx)(< $x (* dx 2)))
      (if(< $y dy)(progn
      (setq str "XDC5")
      (dlg_recf dx 1 (- dx 2) (- dy 2) color)))
  )
  (slide_image 0 -1 (- x 1) (- y 1) "N002.sld")
  (end_image)
  )

以上第一个命令

(defun c:00 (/ s a n m lname li p0 p1 p2 x y xx yy)
(setq a (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq kk (getvar "osmode"))
(setvar "osmode" 0)
(prompt "\n此程序用来打印图面上所有a3和a4图框里的图形!")
(prompt "\n请在命令行里输入00即可!")

(setq s (ssget "x" ))  
(setq n (sslength s))
(setq m 0) 
(setq l 0)
(setq j 0)
(while (< m n)
    (setq lname (ssname s m))
    (setq li (entget lname))
    (if  (=(cdr  (assoc '2  li)) "a3")
          (progn    
            (setq pa  (assoc '10 li))  
            (setq p0 ( list (nth 1 pa) (nth 2 pa))) 
            (setq xx (cdr (assoc '41 li)))
            (setq yy (cdr (assoc '42 li)))
            (setq x (* xx 410))  
            (setq y (* yy 289))
     (setq pp (polar p0 0 (/ x 2)))
     (setq p1 (polar pp (/ pi 2) (/ y 2)))  
            (setq ppp (polar p0 pi (/ x 2)))
            (setq p2 (polar ppp (* pi 1.5) (/ y 2) ))            
            (command "-plot" "yes" "" "EPSON EPL-1220 Advanced.pc3" "a3 297 x 420 mm" "m" "l" "yes" "w" p2 p1 "" "" "yes" "acad.ctb" "yes" "no" "no" "yes" "yes" )
            (setq l (+ l 1))
            
          )
       )
    
      (if  (=(cdr  (assoc '2  li)) "a4")
          (progn    
            (setq pa  (assoc '10 li))  
            (setq p0 ( list (nth 1 pa) (nth 2 pa))) 
            (setq xx (cdr (assoc '41 li)))
            (setq yy (cdr (assoc '42 li)))
            (setq x (* xx 200))  
            (setq y (* yy 289)) 
            (setq pp (polar p0 0 (/ x 2)))
     (setq p1 (polar pp (/ pi 2) (/ y 2)))  
            (setq ppp (polar p0 pi (/ x 2)))
            (setq p2 (polar ppp (* pi 1.5) (/ y 2) ))   
            (command "-plot" "yes" "" "EPSON EPL-1220 Advanced.pc3" "a4 210 x 297 mm" "m" "p" "yes" "w" p2 p1 "" "" "yes" "acad.ctb" "yes" "no" "no" "yes" "yes" )
            (setq j (+ j 1))
          
          )
       )
    
   
     
    (setq m (+ m 1 ))
)
(setvar "osmode" kk)
(setvar "cmdecho" a)
(prompt "\注意只能在ap100-01上打印啊!!!")
(princ)
)

以上第2个命令

N002:dialog {
      label="请选择印表机类型:";
      alignment=centered;
      spacer_1;

      :image_button{
           key="a1";
           allow_accept=true;
           width=60;
           aspect_ratio=0.5;
           color=-2;
           }
    spacer_1;
       ok_cancel;
       }
           以上第3个命令

(DEFUN C:33 (/ p1 p2 a b)
  (setq old (getvar "osmode"))
  (setvar "osmode" 37)
 
  (SETQ P1 (GETPOINT "\n选择打印框选第一点:"))
  (setq p2 (getcorner p1 "\n选择打印框选第二点:"))
  (setq p11 (car p2))
  (setq p22 (cadr p1))
  (setq p3 (list p11 p22))
  (setq p111 (car p1))
  (setq p222 (cadr p2))
  (setq p4 (list p111 p222))
  (setq a (distance p1 p3))
  (setq b (distance p1 p4))
  (if (> a b)
      (command "-plot" "yes" "" "EPSON EPL-1220 Advanced.pc3" "a3 297 x 420 mm" "m" "l" "yes" "w" p1 p2 "" "" "yes" "acad.ctb" "yes" "no" "no" "yes" "yes" )
      (command "-plot" "yes" "" "EPSON EPL-1220 Advanced.pc3" "a4 210 x 297 mm" "m" "p" "yes" "w" p1 p2 "" "" "yes" "acad.ctb" "yes" "no" "no" "yes" "yes" )
  )
  (setvar "osmode" old)
  (prompt "\n打印在AP100-01彭泽胜电脑上请取图")
  (princ)
  )

以上第4个命令

 楼主| 发表于 2010-1-4 16:29:00 | 显示全部楼层
 楼主| 发表于 2010-1-4 16:30:00 | 显示全部楼层
一共6个附件,明天继续上传!
发表于 2012-7-10 12:26:09 | 显示全部楼层
后面怎么没有啊 !!!
发表于 2013-1-21 21:22:33 | 显示全部楼层
这几个月都没有信了?
 楼主| 发表于 2013-8-16 03:39:51 | 显示全部楼层
野狼谷/〈M〉 发表于 2013-1-21 21:22
这几个月都没有信了?

(DEFUN C:111 (/ p1 p2 a b)
  (setq old (getvar "osmode"))
  (setvar "osmode" 37)
  
  (SETQ P1 (GETPOINT "\n选择打印框选第一点:"))
  (setq p2 (getcorner p1 "\n选择打印框选第二点:"))
  (setq p11 (car p2))
  (setq p22 (cadr p1))
  (setq p3 (list p11 p22))
  (setq p111 (car p1))
  (setq p222 (cadr p2))
  (setq p4 (list p111 p222))
  (setq a (distance p1 p3))
  (setq b (distance p1 p4))
  (if (> a b)
      (command "-plot" "yes" "" "\\\\192.168.1.48\\HP Universal Printing PCL 6" "a4" "m" "l" "yes" "w" p2 p1 "f" "c" "yes" "acad.ctb" "yes" "a" "no" "yes" "yes" )
      (command "-plot" "yes" "" "\\\\192.168.1.48\\HP Universal Printing PCL 6" "a4" "m" "p" "yes" "w" p2 p1 "f" "c" "yes" "acad.ctb" "yes" "a" "no" "yes" "yes" )
  )
  (setvar "osmode" old)
  (prompt "\n请在打印服务器上取图!!!")
  (princ)
  )


 楼主| 发表于 2013-8-16 03:40:34 | 显示全部楼层
以上单独打印
 楼主| 发表于 2013-8-16 03:41:12 | 显示全部楼层
(defun *error* (ERROR)
     (princ "钣金开发事业群 群QQ 49400228:")
     (setvar "osmode" 703)
)
(defun c:222 ( / a j k kk l li lname m n p0 p0x p0y p1 p1x p1y p2 p2x p2y pa pp ppp s x xx y yy)
(setq a (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq kk (getvar "osmode"))
(setvar "osmode" 0)
(command "ucs" "")
(prompt "\n此程序用来打印框选中所有a3和a4图框里的图形及工艺流程卡!")
(prompt "\nby:yutianweidi!")

(setq s (ssget))   
(setq n (sslength s))
(setq m 0)  
(setq l 0)
(setq j 0)
(setq k 0)
(while (< m n)
    (setq lname (ssname s m))
    (setq li (entget lname))
    (if  (=(cdr  (assoc '2  li)) "a3")
          (progn     
            (setq pa  (assoc '10 li))   
            (setq p0 ( list (nth 1 pa) (nth 2 pa)))  
            (setq xx (cdr (assoc '41 li)))
            (setq yy (cdr (assoc '42 li)))
            (setq x (* xx 410))   
            (setq y (* yy 289))
            (setq pp (polar p0 0 (/ x 2)))
            (setq p1 (polar pp (/ pi 2) (/ y 2)))          
            (setq ppp (polar p0 pi (/ x 2)))
            (setq p2 (polar ppp (* pi 1.5) (/ y 2) ))            
            (command "-plot" "yes" "" "\\\\192.168.1.48\\HP Universal Printing PCL 6" "a3" "m" "l" "yes" "w" p2 p1 "f" "c" "yes" "acad.ctb" "yes" "a" "no" "yes" "yes" )
            (setq l (+ l 1))
            
          )
       )
     
      (if  (=(cdr  (assoc '2  li)) "a4")
          (progn     
            (setq pa  (assoc '10 li))   
            (setq p0 ( list (nth 1 pa) (nth 2 pa)))  
            (setq xx (cdr (assoc '41 li)))
            (setq yy (cdr (assoc '42 li)))
            (setq x (* xx 200))   
            (setq y (* yy 289))  
            (setq pp (polar p0 0 (/ x 2)))
            (setq p1 (polar pp (/ pi 2) (/ y 2)))          
            (setq ppp (polar p0 pi (/ x 2)))
            (setq p2 (polar ppp (* pi 1.5) (/ y 2) ))   
            (command "-plot" "yes" "" "\\\\192.168.1.48\\HP Universal Printing PCL 6" "a4" "m" "p" "yes" "w" p2 p1 "f" "c" "yes" "acad.ctb" "yes" "a" "no" "yes" "yes" )
            (setq j (+ j 1))
           
          )
       )
     (if  (=(cdr  (assoc '2  li)) "a5")
          (progn     
            (setq pa(assoc '10 li))   
            (setq p0x (nth 1 pa))
            (setq p0y (nth 2 pa))
            (setq xx (cdr (assoc '41 li)))
            (setq yy (cdr (assoc '42 li)))
            (setq p1x(+ p0x (* xx 200)))
            (setq p1y(- p0y (* yy 289)))
            (setq p1 (list p1x p1y))
            (setq p2x(+ p0x (* xx 2)))
            (setq p2y(- p0y (* yy 2)))
            (setq p2 (list p2x p2y))
            (command "-plot" "yes" "" "\\\\192.168.1.48\\HP Universal Printing PCL 6" "a5" "m" "l" "yes" "w" p2 p1 "f" "c" "yes" "acad.ctb" "yes" "a" "no" "yes" "yes" )
            (setq k (+ k 1))
           
          )
       )
   
      
    (setq m (+ m 1 ))
)
(setvar "osmode" kk)
(setvar "cmdecho" a)
(prompt "\仅供彭氏工创使用!!!")
(princ)
)
 楼主| 发表于 2013-8-16 03:41:46 | 显示全部楼层
以上批量打印,终于修复问题了!
发表于 2013-9-1 11:43:16 | 显示全部楼层
楼主你的批量打印占线很长啊
非常感谢您的源代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-26 07:45 , Processed in 0.209478 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表