CAD线号自动编号与排序[源码]
[*](defun c:chn ()
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq ss (ssget '((0 . "TEXT,MTEXT"))))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq ll (acet-ss-to-list ss))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(initget "LD LU RD RU DL DR UL UR")
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq tw (getkword "\n<DL>:"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(if tw nil (setq tw "DL"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(cond
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif ((or (= tw "DL")(= tw "DR"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq ll (sorty+ ll))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (if (= tw "DL")(setq ll (sortx+ ll))(setq ll (sortx- ll)) )
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif )
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif ((or (= tw "LD")(= tw "LU"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq ll (sortx+ ll))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (if (= tw "LD")(setq ll (sorty+ ll))(setq ll (sorty- ll)) )
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif )
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif ((or (= tw "RD")(= tw "RU"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq ll (sortx- ll))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (if (= tw "RD")(setq ll (sorty+ ll))(setq ll (sorty- ll)) )
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif )
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif ((or (= tw "UL")(= tw "UR"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq ll (sorty- ll))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (if (= tw "UL")(setq ll (sortx+ ll))(setq ll (sortx- ll)) )
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif )
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq qz (getstring "\n请输入前缀相同的部分: "))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq sn (getint "\n输入开始编号 <1>:"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq in (getint "\n输入增量 <1>:"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq cr (getint "\n输入颜色 1:红 2:黄 3:绿 5:蓝 7:白 <7>:"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq zt (getstring "\n输入字体 /宋体 /ROMANS /工程字 /WD /Standard <宋体>: "))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(if sn nil (setq sn 1))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(if in nil (setq in 1))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(if cr nil (setq cr 7))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(if (= zt "") (setq zt "宋体"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(foreach i ll
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq obj (vlax-ename->vla-object i))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (vla-put-textstring obj (strcat qz (itoa sn)))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (vla-put-stylename obj zt)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif;设置字体
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (vla-put-color obj cr)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif;设置字体颜色,1:红色2:黄色3:绿色5:蓝 7:白
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq sn (+ sn in))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif;
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(defun sortx+ (lst)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq lst (vl-sort lst '(lambda (p1 p2)(< (car (cdr (assoc 10 (entget p1))))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (car (cdr (assoc 10 (entget p2))))))))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(defun sortx- (lst)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq lst (vl-sort lst '(lambda (p1 p2)(> (car (cdr (assoc 10 (entget p1))))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (car (cdr (assoc 10 (entget p2))))))))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(defun sorty+ (lst)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq lst (vl-sort lst '(lambda (p1 p2)(< (cadr (cdr (assoc 10 (entget p1))))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (cadr (cdr (assoc 10 (entget p2))))))))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(defun sorty- (lst)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif(setq lst (vl-sort lst '(lambda (p1 p2)(> (cadr (cdr (assoc 10 (entget p1))))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (cadr (cdr (assoc 10 (entget p2))))))))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif)
CAD批量打印_单排等距.lsp
[*](defun c:mdy()
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setvar "osmode" 0)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setvar "osmode" 1)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq fx (getstring "\n 输入图形方向 [纵向(P)/横向(L)] <横向>: "))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (if(= fx "P")(setq fx "P")(setq fx "L"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq PN (getstring "\n 输入打印机名称<Adobe PDF>: "))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (if(= PN "")(setq PN "Adobe PDF"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq zz (getstring "\n 输入打印偏移 (x,y) <0.00,0.00>或 [居中打印(C)] <C>: "))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (if(= zz "")(setq zz "C"))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq AS (getint "\n输入需要打印圖紙數量<1>: "))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (if AS nil (setq AS 1))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq VDI (getdist "\n輸入||||間距<500.00>: "))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (if VDI nil (setq VDI 500.00))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq P1 (getpoint "\n***框選零件圖的左下點: "))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq P2 (getcorner p1 "\n***框選零件圖的右上點: "))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq sn 0)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (while (/= sn AS)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq PP (polar p1 0 (* VDI sn)))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq MP (polar p2 0 (* VDI sn)))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setq sn (+ sn 1))
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (command "-plot" "y" "model" PN "a4" "m" fx "n" "w" PP MP "f" zz "y" "monochrome.ctb" "y" "n" "n" "n" "y" )
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif )
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif (setvar "osmode" 33)
[*]http://www.cad8.net/source/plugin/imc_colorcode/images/jssc_none.gif)
pengl86 发表于 2019-2-1 11:40
CAD批量打印_单排等距.lsp
最好给个动态演示,这样看不清楚效果 谢谢楼主分享 我也想学编程 如果有动画演示就更好 谢谢楼主分享源码,支持你 一起来看下吧 可以进行特定文字编号排序吗? 分感谢楼主的大公无私 多谢大神的分享,谢谢 非常不错的代码,谢谢楼主分享
页:
[1]
2