明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4505|回复: 9

[源码] 编号程序

[复制链接]
发表于 2013-9-16 19:59 | 显示全部楼层 |阅读模式
本帖最后由 boylovecfy 于 2013-9-16 20:01 编辑

1、本程序不是本人所写,也不知是哪位高人的作品,

2、程序原来明经上有的,但是后来不知为何原因帐号被封,后看到很多人找就再次发出来

3、求改进该程序  (1、加循环,2、将该程序封装成单独函数,以便其他程序可以直接调用编号,3、加详细注释,让我们这些小菜能好好学习。)在此谢谢程序的作者和修改程序的作者。



  1. ;参数初始化
  2. (defun chushihua()
  3.   ;(setvar "cmdecho" 0)
  4.   (setq bhlx 0)
  5.   (write-line "编号类型:0")
  6.   (setq bh0 0)
  7.   (write-line "编号初值:1")
  8.   (setq bh1 64)
  9.   (setq bh2 0)
  10.   (setq bh3 64)
  11.   (setq yx "Y")
  12.   (write-line "引线:Y")
  13.   (setq bklx "Y")
  14.   (write-line "边框:Y")
  15.   (setq r 2.5)
  16.   (setq zidong_r t)
  17.   (write-line "边框圆半径:自动")
  18.   (setq th 3.5)
  19.   (write-line "文字高度:3.5")
  20.   (setq ta 0)
  21.   (write-line "文字旋转角度:0")
  22.   (setq jl 1)
  23.   (write-line "编号到引线距离:1")
  24.   (setq jiantou 2.5)
  25.   (write-line "箭头大小:2.5")
  26.   (setq chang 5)
  27.   (setq zidong_chang t)
  28.   (write-line "水平段引线长度:自动")
  29.   (setq qianzhui2 "")
  30.   (write-line "自然数前缀:无")
  31.   (setq houzhui2 "")
  32.   (write-line "自然数后缀:无")
  33.   (setq qianzhui3 "")
  34.   (write-line "字母前缀:无")
  35.   (setq houzhui3 "")
  36.   (write-line "字母后缀:无")
  37.   (setq pianyi 7)
  38.   (write-line "边框自动处理时,文字到边框的偏移系数:7")



  39. )


  40. (chushihua)

  41. ;主函数*********************************************************************


  42. (defun c:sb(/ o ob)
  43.   (defun er(str)
  44.     (setvar "osmode" dx)   
  45.     (princ "\nSB已取消")   
  46.   )
  47.   (setq erod *error* *error* er)


  48.   (if (= yx "N")
  49.     (progn
  50.       (initget "C Y K W H T")
  51.       (setq ob (getpoint "\n指定编号位置[编号初值(C)/引线(Y)/边框(K)/文字(W)/还原为默认设置(H)/退出(T)]:<编号之前请先将当前文字样式的文字高度项设为0>"))
  52.       (if (or (= ob "C") (= ob "Y") (= ob "T") (= ob "K") (= ob "W") (= ob "H") (= ob nil))
  53.         (progn
  54.           (if (= ob "C") (chuzhi))           
  55.           (if (= ob "Y") (yinxian))
  56.           (if (= ob "K") (bkshezhi))
  57.           (if (= ob "W") (wenzi))
  58.           (if (= ob "H") (chushihua))
  59.           (if (= ob nil) (gaodu0))


  60.           (if (= ob "T") (exit))
  61.         )
  62.         (progn
  63.           (huitu o ob)
  64.         )
  65.       )
  66.     )
  67.     (progn
  68.       (initget "C Y K W H T")
  69.       (setq o (getpoint "\n指定标注位置[编号初值(C)/引线(Y)/边框(K)/文字(W)/还原为默认设置(H)/退出(T)]:<编号之前请先将当前文字样式的文字高度项设为0>"))
  70.       (if (or (= o "C") (= o "Y") (= o "T") (= o "K") (= o "W") (= o "H") (= o nil))
  71.         (progn
  72.           (if (= o "C") (chuzhi))           
  73.           (if (= o "Y") (yinxian))
  74.           (if (= o "K") (bkshezhi))
  75.           (if (= o "W") (wenzi))
  76.           (if (= o "H") (chushihua))
  77.           (if (= o nil) (gaodu0))


  78.           (if (= o "T") (exit))
  79.         )
  80.         (progn
  81.           (initget 1)
  82.           (setq ob (getpoint o "\n指定编号位置:"))         
  83.           (huitu o ob)
  84.         )
  85.       )
  86.     )   
  87.   )

  88. )


  89. ;绘制过程*********************************************************************************

  90. (defun huitu(o ob / dian1 dian2 dianx diany jiantou0 chang0)
  91.   (graphscr)

  92.   (setq jiantou0 jiantou)
  93.   (command "text" '(0 0) th ta "编号速写" "erase" (entlast) "")




  94.   ;编号升序
  95.   ;0 (1 2 3...) 1 (a b c.../A B C...) 2 (a1 a2.../B1 B2...) 3 (aa ab ac.../Ma Mb Mc...)
  96.   (if (= bhlx 0)
  97.     (progn
  98.       (setq bh0 (+ bh0 1))
  99.       (setq bh (itoa bh0))
  100.     )
  101.   )
  102.   (if (= bhlx 1)
  103.     (progn
  104.       (setq bh1 (+ 1 bh1))
  105.       (if (> bh1 122) (setq bh1 97))
  106.       (if (and (> bh1 90) (< bh1 97)) (setq bh1 65))
  107.       (if (< bh1 65) (setq bh1 65))
  108.       (if (and (< bh1 97) (> bh1 90)) (setq bh1 97))
  109.       (setq bh (chr bh1))
  110.     )
  111.   )

  112.   (if (= bhlx 2)
  113.     (setq bh (strcat qianzhui2 (itoa (setq  bh2 (+ 1 bh2))) houzhui2))
  114.   )

  115.   (if (= bhlx 3)
  116.     (progn
  117.       (setq bh3 (+ 1 bh3))
  118.       (if (> bh3 122) (setq bh3 97))
  119.       (if (and (> bh3 90) (< bh3 97)) (setq bh3 65))
  120.       (if (< bh3 65) (setq bh3 65))
  121.       (if (and (< bh3 97) (> bh3 90)) (setq bh3 97))
  122.       (setq bh (strcat qianzhui3 (chr bh3) houzhui3))
  123.     )

  124.   )

  125.   (if (= bklx "Y")       ;边框半径是否自动处理及r0值
  126.     (progn
  127.       (if (= zidong_r t)
  128.         (setq r0 (/ (tdaxiao 3) 2))
  129.         (setq r0 r)
  130.       )
  131.     )
  132.     (setq r0 (/ (tdaxiao 2) 2))
  133.   )
  134.   (if (= bklx "J")       ;边框为矩形时r0值
  135.     (if (= zidong_j t)
  136.       (setq r0 (/ (tdaxiao 2) 2))
  137.       (setq r0 (/ jgao 2))
  138.     )
  139.   )

  140.   (if (= zidong_chang t) ;引线长度是否自动处理及chang0值
  141.     (progn
  142.       (if (= bklx "Y")
  143.         (setq chang0 (* r0 2))
  144.         (progn
  145.           (if (= bklx "J")
  146.             (if (= zidong_j t)
  147.               (setq chang0 (tdaxiao 1))
  148.               (setq chang0 jkuan)           
  149.             )
  150.             (if (= bklx "W")
  151.               (setq chang0 (tdaxiao 1))
  152.             )
  153.           )
  154.         )
  155.         
  156.       )
  157.     )
  158.     (setq chang0 chang)
  159.   )

  160.   ;对象捕捉
  161.   (setq dx (getvar "osmode"))
  162.   (setvar "osmode" 0)  




  163.   (biankuangy r0 ob bh)
  164.   (if (and (/= yx "N") (/= yx "n"))
  165.     (progn
  166.       (if (>= (car o) (car ob))
  167.         (progn
  168.           (setq dian1 (list(+ (car ob) (/ chang0 2)) (- (cadr ob) r0 jl)))
  169.           (setq dian2 (list(- (car ob) (/ chang0 2)) (- (cadr ob) r0 jl)))
  170.           (if (> jiantou0 (distance o dian1)) (setq jiantou0 0))
  171.           (setq dianx (+ (car o) (* (/ jiantou0 (distance o dian1)) (- (car dian1) (car o)))))
  172.           (setq diany (+ (cadr o) (* (/ jiantou0 (distance o dian1)) (- (cadr dian1) (cadr o)))))
  173.           (command "pline" o "w" 0 (/ jiantou0 3) (list dianx diany) "w" 0 0 dian1 dian2 "")

  174.          
  175.         )
  176.         (progn
  177.           (setq dian1 (list(- (car ob) (/ chang0 2)) (- (cadr ob) r0 jl)))
  178.           (setq dian2 (list(+ (car ob) (/ chang0 2)) (- (cadr ob) r0 jl)))
  179.           (if (> jiantou0 (distance o dian1)) (setq jiantou0 0))
  180.           (setq dianx (+ (car o) (* (/ jiantou0 (distance o dian1)) (- (car dian1) (car o)))))
  181.           (setq diany (+ (cadr o) (* (/ jiantou0 (distance o dian1)) (- (cadr dian1) (cadr o)))))
  182.           (command "pline" o "w" 0 (/ jiantou0 3) (list dianx diany) "w" 0 0 dian1 dian2 "")

  183.          
  184.         )
  185.       )
  186.     )
  187.   )
  188.   ;对象捕捉
  189.   (setvar "osmode" dx)
  190.   (setq *error* erod erod nil)

  191. (eval bh)

  192. )



  193. ;参数设置********************************************************************************

  194. ;初值设置
  195. (defun chuzhi(/ qianzhui20 houzhui20 qianzhui30 houzhui30)


  196.       (initget 1 "0 1 2 3")
  197.       (setq bhlx (atoi (getkword "选择一种编号类型:\n<0>  自然数序列(1 2 3...)  <1>  字母序列(a b c.../A B C...)  <2>  带前/后缀自然数序列(a1 a2.../B1 B2.../(1)...)  <3>  带前/后缀字母序列(aa ab ac.../Ma Mb Mc.../(a)...)  选择其中一种0/1/2/3:")))
  198.       (if (= bhlx 0)
  199.         (progn
  200.           (setq bh0 (getint "\n输入起始数值:<1>"))
  201.           (if (= bh0 nil) (setq bh0 1))
  202.           (setq bh0 (1- bh0))
  203.         )
  204.       )
  205.       (if (= bhlx 1)
  206.         (progn         
  207.           (setq bh1 (1- (ascii (getstring "\n输入起始字母:<A>"))))
  208.         )
  209.       )
  210.       (if (= bhlx 2)
  211.         (progn
  212.           (setq qianzhui20 (getstring (strcat "输入前缀:<" qianzhui2 ">")))
  213.           (if (/= qianzhui20 "") (setq qianzhui2 qianzhui20))
  214.           (setq bh2 (getint "\n输入起始数值:<1>"))
  215.           (if (= bh2 nil) (setq bh2 1))
  216.           (setq bh2 (1- bh2))
  217.           (setq houzhui20 (getstring (strcat "输入后缀:<" houzhui2 ">")))
  218.           (if (/= houzhui20 "") (setq houzhui2 houzhui20))
  219.         )
  220.       )
  221.       (if (= bhlx 3)
  222.         (progn
  223.           (setq qianzhui30 (getstring (strcat "输入前缀:<" qianzhui3 ">")))
  224.           (if (/= qianzhui30 "") (setq qianzhui3 qianzhui30))
  225.           (setq bh3 (1- (ascii (getstring "\n输入起始字母:<A>"))))
  226.           (setq houzhui30 (getstring (strcat "输入后缀:<" houzhui3 ">")))
  227.           (if (/= houzhui30 "") (setq houzhui3 houzhui30))
  228.         )
  229.       )



  230.   (c:sb)
  231. )

  232. ;引线设置
  233. (defun yinxian(/ yx0 yxf jl0 chang0 jiantou0)
  234.   (initget "Y N")
  235.   (if (= yx "Y") (setq yxf "N") (setq yxf "Y"))
  236.   (setq yx0 (getkword (strcat "\n" "编号是否带引线?<Y>/<N>:<" yxf ">")))
  237.   (if (= yx0 nil) (setq yx yxf) (setq yx yx0))
  238.   (if (= yx "Y")
  239.     (progn
  240.       (setq jl0 (getdist (strcat "输入编号到引线的距离:<" (rtos jl) ">")))
  241.       (if (/= jl0 nil) (setq jl jl0))
  242.       (setq chang0 (getdist "输入水平段引线的长度:<自动>"))
  243.       (if (/= chang0 nil) (setq chang chang0 zidong_chang nil) (setq zidong_chang t))
  244.       (setq jiantou0 (getdist (strcat "输入箭头大小:<" (rtos jiantou) ">")))
  245.       (if (/= jiantou0 nil) (setq jiantou jiantou0))



  246.     )
  247.   )
  248.   (c:sb)
  249. )

  250. ;边框设置
  251. (defun bkshezhi(/ r0)
  252.   (initget 1 "Y W J")
  253.   (setq bklx (getkword "\n选择边框类型[圆(Y)/矩形(J)/无(W)]:"))

  254.   (if (= bklx "Y")
  255.     (progn

  256.       (setq r0 (getdist (strcat "输入圆半径:<" "自动" ">")))
  257.       (if (/= r0 nil) (setq r r0 zidong_r nil) (setq zidong_r t))
  258.     )
  259.   )
  260.   (if (= bklx "J")
  261.     (progn
  262.       (setq jkuan (getdist "\n输入矩形宽:<自动>"))
  263.       (if (= jkuan nil)
  264.         (setq zidong_j t)
  265.         (progn
  266.           (setq zidong_j nil)
  267.           (setq jgao (getdist "\n输入矩形高度:"))
  268.         )
  269.       )
  270.     )
  271.   )







  272. (c:sb)
  273. )
  274. ;文字设置
  275. (defun wenzi(/ th0 ta0)
  276. (setq th0 (getdist (strcat "输入文字高度:<" (rtos th) ">")))
  277.   (if (/= th0 nil)
  278.     (progn
  279.       (setq th th0)

  280.     )

  281.   )


  282.   (setq ta0 (getangle (strcat "输入文字角度:<" (rtos ta) ">")))
  283.   (if (/= ta0 nil)
  284.     (progn
  285.       (setq ta ta0)
  286.       (setq ta (* (/ ta pi) 180))
  287.     )
  288.   )

  289. (c:sb)
  290. )  

  291. ;绘边框  
  292. (defun biankuangy(banjing yuanxin bianhao)
  293.   (if (= bklx "Y")
  294.     (command "circle" yuanxin banjing)
  295.   )
  296.   (if (= bklx "J")
  297.     (progn
  298.       (if (= zidong_j t)
  299.         (setq jkuan0 (tdaxiao 1) jgao0 (tdaxiao 2))
  300.         (setq jkuan0 jkuan jgao0 jgao)
  301.       )
  302.       (command "pline")
  303.       (command (list (- (car yuanxin) (/ jkuan0 2)) (- (cadr yuanxin) (/ jgao0 2))))
  304.       (command "w" 0 0)
  305.       (command (list (+ (car yuanxin) (/ jkuan0 2)) (- (cadr yuanxin) (/ jgao0 2))))
  306.       (command (list (+ (car yuanxin) (/ jkuan0 2)) (+ (cadr yuanxin) (/ jgao0 2))))
  307.       (command (list (- (car yuanxin) (/ jkuan0 2)) (+ (cadr yuanxin) (/ jgao0 2))))
  308.       (command "c")
  309.     )
  310.   )




  311.   (command "text" "J" "MC" yuanxin th ta bianhao)

  312. )  
  313. ;将当前文字样式的文字高度项设置为0
  314. (defun gaodu0()
  315.   (command "style" "" "" 0 "" "" "" "" "")
  316.   (c:sb)
  317. )


  318. ;编号文字宽与高
  319. (defun tdaxiao(x / a b c)  ;x=t则b=宽.x=nil则b=高
  320.   (setq a (textbox (list (cons 1 bh))))
  321.   (setq c (/ (- (cadar a) (cadadr a)) pianyi))
  322.   (if (= x 1)
  323.     (setq b (- (caadr a) (caar a) c))
  324.     (if (= x 2)
  325.       (setq b (- (cadadr a) (cadar a) c))
  326.       (setq b (- (distance (car a) (cadr a)) c))
  327.     )
  328.   )
  329.   (eval b)
  330. )






本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2016-8-4 16:27 | 显示全部楼层
求一个自动编号闭合面的插件
回复 支持 1 反对 0

使用道具 举报

发表于 2013-9-16 20:07 | 显示全部楼层
下面算做你说的循环吗:


;参数初始化
(defun chushihua()
  ;(setvar "cmdecho" 0)
  (setq bhlx 0)
  (write-line "编号类型:0")
  (setq bh0 0)
  (write-line "编号初值:1")
  (setq bh1 64)
  (setq bh2 0)
  (setq bh3 64)
  (setq yx "Y")
  (write-line "引线:Y")
  (setq bklx "Y")
  (write-line "边框:Y")
  (setq r 2.5)
  (setq zidong_r t)
  (write-line "边框圆半径:自动")
  (setq th 3.5)
  (write-line "文字高度:3.5")
  (setq ta 0)
  (write-line "文字旋转角度:0")
  (setq jl 1)
  (write-line "编号到引线距离:1")
  (setq jiantou 2.5)
  (write-line "箭头大小:2.5")
  (setq chang 5)
  (setq zidong_chang t)
  (write-line "水平段引线长度:自动")
  (setq qianzhui2 "")
  (write-line "自然数前缀:无")
  (setq houzhui2 "")
  (write-line "自然数后缀:无")
  (setq qianzhui3 "")
  (write-line "字母前缀:无")
  (setq houzhui3 "")
  (write-line "字母后缀:无")
  (setq pianyi 7)
  (write-line "边框自动处理时,文字到边框的偏移系数:7")



)


(chushihua)

;主函数*********************************************************************


(defun c:sb(/ o ob)
  (defun er(str)
    (setvar "osmode" dx)   
    (princ "\nSB已取消")   
  )
  (setq erod *error* *error* er)

(while
  (if (= yx "N")
    (progn
      (initget "C Y K W H T")
      (setq ob (getpoint "\n指定编号位置[编号初值(C)/引线(Y)/边框(K)/文字(W)/还原为默认设置(H)/退出(T)]:<编号之前请先将当前文字样式的文字高度项设为0>"))
      (if (or (= ob "C") (= ob "Y") (= ob "T") (= ob "K") (= ob "W") (= ob "H") (= ob nil))
        (progn
          (if (= ob "C") (chuzhi))           
          (if (= ob "Y") (yinxian))
          (if (= ob "K") (bkshezhi))
          (if (= ob "W") (wenzi))
          (if (= ob "H") (chushihua))
          (if (= ob nil) (gaodu0))


          (if (= ob "T") (exit))
        )
        (progn
          (huitu o ob)
        )
      )
    )
    (progn
      (initget "C Y K W H T")
      (setq o (getpoint "\n指定标注位置[编号初值(C)/引线(Y)/边框(K)/文字(W)/还原为默认设置(H)/退出(T)]:<编号之前请先将当前文字样式的文字高度项设为0>"))
      (if (or (= o "C") (= o "Y") (= o "T") (= o "K") (= o "W") (= o "H") (= o nil))
        (progn
          (if (= o "C") (chuzhi))           
          (if (= o "Y") (yinxian))
          (if (= o "K") (bkshezhi))
          (if (= o "W") (wenzi))
          (if (= o "H") (chushihua))
          (if (= o nil) (gaodu0))


          (if (= o "T") (exit))
        )
        (progn
          (initget 1)
          (setq ob (getpoint o "\n指定编号位置:"))         
          (huitu o ob)
        )
      )
    )   
  )

))


;绘制过程*********************************************************************************

(defun huitu(o ob / dian1 dian2 dianx diany jiantou0 chang0)
  (graphscr)

  (setq jiantou0 jiantou)
  (command "text" '(0 0) th ta "编号速写" "erase" (entlast) "")




  ;编号升序
  ;0 (1 2 3...) 1 (a b c.../A B C...) 2 (a1 a2.../B1 B2...) 3 (aa ab ac.../Ma Mb Mc...)
  (if (= bhlx 0)
    (progn
      (setq bh0 (+ bh0 1))
      (setq bh (itoa bh0))
    )
  )
  (if (= bhlx 1)
    (progn
      (setq bh1 (+ 1 bh1))
      (if (> bh1 122) (setq bh1 97))
      (if (and (> bh1 90) (< bh1 97)) (setq bh1 65))
      (if (< bh1 65) (setq bh1 65))
      (if (and (< bh1 97) (> bh1 90)) (setq bh1 97))
      (setq bh (chr bh1))
    )
  )

  (if (= bhlx 2)
    (setq bh (strcat qianzhui2 (itoa (setq  bh2 (+ 1 bh2))) houzhui2))
  )

  (if (= bhlx 3)
    (progn
      (setq bh3 (+ 1 bh3))
      (if (> bh3 122) (setq bh3 97))
      (if (and (> bh3 90) (< bh3 97)) (setq bh3 65))
      (if (< bh3 65) (setq bh3 65))
      (if (and (< bh3 97) (> bh3 90)) (setq bh3 97))
      (setq bh (strcat qianzhui3 (chr bh3) houzhui3))
    )

  )

  (if (= bklx "Y")       ;边框半径是否自动处理及r0值
    (progn
      (if (= zidong_r t)
        (setq r0 (/ (tdaxiao 3) 2))
        (setq r0 r)
      )
    )
    (setq r0 (/ (tdaxiao 2) 2))
  )
  (if (= bklx "J")       ;边框为矩形时r0值
    (if (= zidong_j t)
      (setq r0 (/ (tdaxiao 2) 2))
      (setq r0 (/ jgao 2))
    )
  )

  (if (= zidong_chang t) ;引线长度是否自动处理及chang0值
    (progn
      (if (= bklx "Y")
        (setq chang0 (* r0 2))
        (progn
          (if (= bklx "J")
            (if (= zidong_j t)
              (setq chang0 (tdaxiao 1))
              (setq chang0 jkuan)           
            )
            (if (= bklx "W")
              (setq chang0 (tdaxiao 1))
            )
          )
        )
        
      )
    )
    (setq chang0 chang)
  )

  ;对象捕捉
  (setq dx (getvar "osmode"))
  (setvar "osmode" 0)  




  (biankuangy r0 ob bh)
  (if (and (/= yx "N") (/= yx "n"))
    (progn
      (if (>= (car o) (car ob))
        (progn
          (setq dian1 (list(+ (car ob) (/ chang0 2)) (- (cadr ob) r0 jl)))
          (setq dian2 (list(- (car ob) (/ chang0 2)) (- (cadr ob) r0 jl)))
          (if (> jiantou0 (distance o dian1)) (setq jiantou0 0))
          (setq dianx (+ (car o) (* (/ jiantou0 (distance o dian1)) (- (car dian1) (car o)))))
          (setq diany (+ (cadr o) (* (/ jiantou0 (distance o dian1)) (- (cadr dian1) (cadr o)))))
          (command "pline" o "w" 0 (/ jiantou0 3) (list dianx diany) "w" 0 0 dian1 dian2 "")

         
        )
        (progn
          (setq dian1 (list(- (car ob) (/ chang0 2)) (- (cadr ob) r0 jl)))
          (setq dian2 (list(+ (car ob) (/ chang0 2)) (- (cadr ob) r0 jl)))
          (if (> jiantou0 (distance o dian1)) (setq jiantou0 0))
          (setq dianx (+ (car o) (* (/ jiantou0 (distance o dian1)) (- (car dian1) (car o)))))
          (setq diany (+ (cadr o) (* (/ jiantou0 (distance o dian1)) (- (cadr dian1) (cadr o)))))
          (command "pline" o "w" 0 (/ jiantou0 3) (list dianx diany) "w" 0 0 dian1 dian2 "")

         
        )
      )
    )
  )
  ;对象捕捉
  (setvar "osmode" dx)
  (setq *error* erod erod nil)

(eval bh)

)



;参数设置********************************************************************************

;初值设置
(defun chuzhi(/ qianzhui20 houzhui20 qianzhui30 houzhui30)


      (initget 1 "0 1 2 3")
      (setq bhlx (atoi (getkword "选择一种编号类型:\n<0>  自然数序列(1 2 3...)  <1>  字母序列(a b c.../A B C...)  <2>  带前/后缀自然数序列(a1 a2.../B1 B2.../(1)...)  <3>  带前/后缀字母序列(aa ab ac.../Ma Mb Mc.../(a)...)  选择其中一种0/1/2/3:")))
      (if (= bhlx 0)
        (progn
          (setq bh0 (getint "\n输入起始数值:<1>"))
          (if (= bh0 nil) (setq bh0 1))
          (setq bh0 (1- bh0))
        )
      )
      (if (= bhlx 1)
        (progn         
          (setq bh1 (1- (ascii (getstring "\n输入起始字母:<A>"))))
        )
      )
      (if (= bhlx 2)
        (progn
          (setq qianzhui20 (getstring (strcat "输入前缀:<" qianzhui2 ">")))
          (if (/= qianzhui20 "") (setq qianzhui2 qianzhui20))
          (setq bh2 (getint "\n输入起始数值:<1>"))
          (if (= bh2 nil) (setq bh2 1))
          (setq bh2 (1- bh2))
          (setq houzhui20 (getstring (strcat "输入后缀:<" houzhui2 ">")))
          (if (/= houzhui20 "") (setq houzhui2 houzhui20))
        )
      )
      (if (= bhlx 3)
        (progn
          (setq qianzhui30 (getstring (strcat "输入前缀:<" qianzhui3 ">")))
          (if (/= qianzhui30 "") (setq qianzhui3 qianzhui30))
          (setq bh3 (1- (ascii (getstring "\n输入起始字母:<A>"))))
          (setq houzhui30 (getstring (strcat "输入后缀:<" houzhui3 ">")))
          (if (/= houzhui30 "") (setq houzhui3 houzhui30))
        )
      )



  (c:sb)
)

;引线设置
(defun yinxian(/ yx0 yxf jl0 chang0 jiantou0)
  (initget "Y N")
  (if (= yx "Y") (setq yxf "N") (setq yxf "Y"))
  (setq yx0 (getkword (strcat "\n" "编号是否带引线?<Y>/<N>:<" yxf ">")))
  (if (= yx0 nil) (setq yx yxf) (setq yx yx0))
  (if (= yx "Y")
    (progn
      (setq jl0 (getdist (strcat "输入编号到引线的距离:<" (rtos jl) ">")))
      (if (/= jl0 nil) (setq jl jl0))
      (setq chang0 (getdist "输入水平段引线的长度:<自动>"))
      (if (/= chang0 nil) (setq chang chang0 zidong_chang nil) (setq zidong_chang t))
      (setq jiantou0 (getdist (strcat "输入箭头大小:<" (rtos jiantou) ">")))
      (if (/= jiantou0 nil) (setq jiantou jiantou0))



    )
  )
  (c:sb)
)

;边框设置
(defun bkshezhi(/ r0)
  (initget 1 "Y W J")
  (setq bklx (getkword "\n选择边框类型[圆(Y)/矩形(J)/无(W)]:"))

  (if (= bklx "Y")
    (progn

      (setq r0 (getdist (strcat "输入圆半径:<" "自动" ">")))
      (if (/= r0 nil) (setq r r0 zidong_r nil) (setq zidong_r t))
    )
  )
  (if (= bklx "J")
    (progn
      (setq jkuan (getdist "\n输入矩形宽:<自动>"))
      (if (= jkuan nil)
        (setq zidong_j t)
        (progn
          (setq zidong_j nil)
          (setq jgao (getdist "\n输入矩形高度:"))
        )
      )
    )
  )







(c:sb)
)
;文字设置
(defun wenzi(/ th0 ta0)
(setq th0 (getdist (strcat "输入文字高度:<" (rtos th) ">")))
  (if (/= th0 nil)
    (progn
      (setq th th0)

    )

  )


  (setq ta0 (getangle (strcat "输入文字角度:<" (rtos ta) ">")))
  (if (/= ta0 nil)
    (progn
      (setq ta ta0)
      (setq ta (* (/ ta pi) 180))
    )
  )

(c:sb)
)  

;绘边框  
(defun biankuangy(banjing yuanxin bianhao)
  (if (= bklx "Y")
    (command "circle" yuanxin banjing)
  )
  (if (= bklx "J")
    (progn
      (if (= zidong_j t)
        (setq jkuan0 (tdaxiao 1) jgao0 (tdaxiao 2))
        (setq jkuan0 jkuan jgao0 jgao)
      )
      (command "pline")
      (command (list (- (car yuanxin) (/ jkuan0 2)) (- (cadr yuanxin) (/ jgao0 2))))
      (command "w" 0 0)
      (command (list (+ (car yuanxin) (/ jkuan0 2)) (- (cadr yuanxin) (/ jgao0 2))))
      (command (list (+ (car yuanxin) (/ jkuan0 2)) (+ (cadr yuanxin) (/ jgao0 2))))
      (command (list (- (car yuanxin) (/ jkuan0 2)) (+ (cadr yuanxin) (/ jgao0 2))))
      (command "c")
    )
  )




  (command "text" "J" "MC" yuanxin th ta bianhao)

)  
;将当前文字样式的文字高度项设置为0
(defun gaodu0()
  (command "style" "" "" 0 "" "" "" "" "")
  (c:sb)
)


;编号文字宽与高
(defun tdaxiao(x / a b c)  ;x=t则b=宽.x=nil则b=高
  (setq a (textbox (list (cons 1 bh))))
  (setq c (/ (- (cadar a) (cadadr a)) pianyi))
  (if (= x 1)
    (setq b (- (caadr a) (caar a) c))
    (if (= x 2)
      (setq b (- (cadadr a) (cadar a) c))
      (setq b (- (distance (car a) (cadr a)) c))
    )
  )
  (eval b)
)






 楼主| 发表于 2013-9-16 20:37 | 显示全部楼层
本帖最后由 boylovecfy 于 2013-9-16 20:43 编辑
vlisp2012 发表于 2013-9-16 20:07
下面算做你说的循环吗:

能不能标识下修改的部分呢,
发表于 2013-9-16 20:40 | 显示全部楼层
;主函数*********************************************************************


(defun c:sb(/ o ob)
  (defun er(str)
    (setvar "osmode" dx)   
    (princ "\nSB已取消")   
  )
  (setq erod *error* *error* er)

(while
发表于 2015-6-11 19:53 | 显示全部楼层
把这个做成对话框的该多好啊
发表于 2015-11-27 21:33 | 显示全部楼层
楼主辛苦了,标记一下
发表于 2015-12-21 20:22 | 显示全部楼层
dfgfghgjhjkhjkfdghfgh
发表于 2015-12-22 08:15 | 显示全部楼层
楼上是个不错的解释………………
发表于 2016-6-15 10:18 | 显示全部楼层
非常感谢分享,如果编号能再加一个自主输入就更好了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-2 09:42 , Processed in 0.585906 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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