明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2949|回复: 10

[分享]批量打印

[复制链接]
发表于 2007-9-12 13:49:00 | 显示全部楼层 |阅读模式
;bplotone 批量打印
;creprint 定义打印区
;(delprint) 删除打印区
;bplotlin 图框打印
;;; 保存原有系统变量,设置程序运行时的系统变量
(Defun cmd1 ()
(Setq cho (Getvar "Cmdecho")
osm (Getvar "Osmode")
)
(Setvar "Cmdecho" 0)
(Setvar "osmode" 0)
)



;;; 恢复原有系统变量
(Defun cmd2 ()
(Setvar "Cmdecho" cho)
(Setvar "Osmode" osm)
(Terpri)
(Princ)
)

(vl-load-com)

(defun getbound1( / ent i obj plist pta ptb ss)
(setq ss (ssget "x" (list (cons 8 "print") )))
(setq i  -1)
(setq plist (LIST) )
 (while (setq ent (ssname ss (setq i (1+ i))))
     (setq obj (vlax-ename->vla-object ent))
      (vla-GetBoundingBox obj 'pta 'ptb)
      (setq plist (append plist (LIST (list (vlax-safearray->list pta) (vlax-safearray->list ptb)))))
 );end while
 plist
);end defun
 
;取得图元的外形最小点与最大点
(defun getbound( / ent obj pta ptb)
(setvar "osmode" 0)
  (if (setq ent (car (entsel "\n选择图框:")))
    (progn
      (setq obj (vlax-ename->vla-object ent))
      (vla-GetBoundingBox obj 'pta 'ptb)
      (list (vlax-safearray->list pta) (vlax-safearray->list ptb) )
    )
  );end if
);end defun

;批量打印
(defun c:bplotlin( / a an n p1 p2 plist px py)
(cmd1)
(setq n (getint "\n请输入份数[1]:"))
(if (= n nil)
   (setq n 1)
)
(setq plist (getbound))
(setq p1 (nth 0 plist))
(setq p2 (nth 1 plist))
(setq px  (- (car p2) (car p1)) )
(setq py (-(cadr p2) (cadr p1)))
(if (> px py)
  (setq an "L")
  (setq an "P")
  )
;(setq p1 (getpoint "\n左下点:"))
;(setq p2 (getpoint "\n右上点:"))
(setq a (strcase (getstring "\nA4/A3[A3]:")))
(if (= a nil)
   (setq a "A3")
)
(repeat n
(command "-plot" "y" "模型" "\\\\JH-05\\HP LaserJet 5100 PCL 6" a "M" an "N" "W" p1 p2 "F" "1.75,0.00" "y" "monochrome.ctb" "y" "w" "N" "n" "Y")
)
(cmd2)
(princ)
)

;批量打印,可为矩形,可为图块
(defun c:bplotone( / a an n p1 p2 plist px py)
(cmd1)
(setq n (getint "\n请输入份数[1]:"))
(if (= n nil)
   (setq n 1)
)
(setq a (strcase (getstring "\nA4/A3[A3]:")))
(if (= a nil)
   (setq a "A3")
)
(setq plist (getbound1))
(setq i 0)
(repeat (length plist)
  (setq plotlist (nth i plist))
  (setq p1 (nth 0 plotlist))
  (setq p2 (nth 1 plotlist))
  (setq px  (- (car p2) (car p1)) )
  (setq py (-(cadr p2) (cadr p1)))
  (if (> px py)
    (setq an "L")
    (setq an "P")
   )
   (repeat n
     (command "-plot" "y" "模型" "\\\\JH-05\\HP LaserJet 5100 PCL 6" a "M" an "N" "W" p1 p2 "F" "1.75,0.00" "y" "monochrome.ctb" "y" "w" "N" "n" "Y")
    );end repeat
   (setq i (1+ i))
 );end repeat
(cmd2)
(princ)
)
;定义打印矩形
(defun C:creprint( / p1 p2 )
(cmd1)
(setq p1 (polar (getpoint "\n左上点:") (* pi 0.75) 50))
(setq p2 (polar (getcorner p1 "\n右下点:")(* pi -0.25) 50) )
(command "-layer" "m" "print" "p" "n" "print" "" )
(command "rectang" p1 p2)
(cmd2)
)
;删除打印矩形
(defun delprint()
(command ".erase" (ssget "x" (list (cons 8 "print"))))
)
取之于"明",用之于"明"
欢迎到我的BLOG里看看哟?
http://dgwintai.b.co.163.com
发表于 2007-9-29 19:28:00 | 显示全部楼层
不错不错,留起来备用,呵
发表于 2007-10-4 12:14:00 | 显示全部楼层

正需要,楼主辛苦了

发表于 2007-10-6 10:52:00 | 显示全部楼层
大哥我不知怎么下载,有直接下载装机的吗?
发表于 2011-11-19 11:08:05 | 显示全部楼层
沒人頂了。我正好用到了。對樓主說聲謝謝啦
就是要這樣提供源碼才可造福更多人學習呢
发表于 2011-11-20 00:05:47 | 显示全部楼层
测试一下,真的还不错啊 谢谢啊
发表于 2023-8-18 08:14:37 | 显示全部楼层
不錯不錯,留起來備用,呵
发表于 2023-8-18 19:40:08 | 显示全部楼层
谢谢楼主! 分享学习!
发表于 2023-10-26 16:54:37 | 显示全部楼层
謝謝樓主! 分享學習!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 16:01 , Processed in 0.201858 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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