明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2406|回复: 6

自动放大编序号的程序

[复制链接]
发表于 2012-6-12 16:01:05 | 显示全部楼层 |阅读模式
本帖最后由 s678z 于 2012-6-12 16:05 编辑

下面这个程序竖直,水平编序号,但不能自动连续编号,当图框放大时没法用,谁能参考后面哪个程序改进,加入放大系数,自动连续编号。
(princ"\n总装明细序号填写程序")
(defun c:mxxh(/ oldecho oldlayer oldstyle oldsize oldpwid oldsnap oldortho
                sele txto txt pt_s pt_m pt_t pt_r pt_l pt_c pt_e tt num)
  (setq oldecho (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setq oldlayer (getvar "clayer"))
       (if (=(tblobjname "LAYER" "3") nil)
           (progn
               (entmake (list
                            '(0 . "LAYER")
                            '(100 . "AcDbSymbolTableRecord")
                            '(100 . "AcDbLayerTableRecord")
                            '(6 . "CONTINUOUS")
                            '(62 . 3)
                            '(70 . 0)
                             (cons 2 "3")
                        )
               )
           )
       )
   (setvar "clayer" "3")
  (setq oldstyle (getvar "textstyle"))
  (setq oldsize (getvar "textsize"))
  (setq oldpwid (getvar "plinewid"))
  (setvar "plinewid" 0)
  (setq oldsnap(getvar"osmode"))
  (setq oldortho(getvar"orthomode"))
  (initget "Single Horizonal Vertical")
  (setq sele(getkword "\n部装明细序号填写方式[水平多项(H)/垂直多项(V)/单一序号(S)]<单一序号>:"))
  (if (not sele)
    (setq sele "Single")
  )
  (setq txt0 1)
  (while (/= sele "eXit")
    (initget 1)
        (setvar "osmode" 0)
(setq pt_s(getpoint "\n选择引线起点:"))
(initget 1)
        (setvar "osmode" oldsnap)
        (setvar "orthomode" 0)
(setq pt_m(getpoint pt_s"\n选择序号起点:"))
(setq pt_t (polar pt_m (/ PI 2) 3.5))
(command "donut" "0" "0.5" "non" pt_s "")
(cond
   ((= sele "Single")
     (princ (strcat"\n请输入序号<" (itoa txt0) ">:"))
  (setq txt(getint))
  (if (not txt)
    (setq txt txt0)
  )
  (setq txt0 (+ txt 1))
  (if (> (car pt_m)(car pt_s))
    (progn
      (setq pt_c (polar pt_m PI 4))
   (setq pt_e (polar pt_m 0  4))
    )
    (progn
      (setq pt_c (polar pt_m 0  4))
   (setq pt_e (polar pt_m PI 4))
    )
  )
  (command "pline" "non" pt_s "non" pt_c "non" pt_e "")
  (command "text" "m" "non" pt_t "5" "0" txt)
   )
   ((= sele "Vertical")
     (initget 1)
  (setq num(getint"\n请输入同零件组的项数:"))
  (if (>(car pt_m)(car pt_s))
    (progn
      (setq pt_c(polar pt_m PI 4))
   (setq pt_e(polar pt_m 0  4))
    )
    (progn
      (setq pt_c(polar pt_m 0  4))
   (setq pt_e(polar pt_m PI 4))
    )
  )
  (setq tt 1)
  (while(<= tt num)
    (princ(strcat "\n请输入序号<" (itoa txt0) ">:"))
    (setq txt(getint))
    (if (not txt)
      (setq txt txt0)
    )
    (setq txt0 (+ txt 1))
          (command "pline" "non" pt_s "non" pt_c "non" pt_e "")
    (command "text" "m" "non" pt_t "5" "0" txt)
    (setq pt_s pt_c)
    (setq pt_c (polar pt_c (/ PI 2) 8))
    (setq pt_e (polar pt_e (/ PI 2) 8))
    (setq pt_t (polar pt_t (/ PI 2) 8))
    (setq tt (1+ tt))
  )
   )
   ((= sele "Horizonal")
     (initget 1)
  (setq num(getint"\n请输入同零件组的项数:"))
  (setq pt_l(polar pt_m PI 4))
  (setq pt_r(polar pt_l 0 (+(*(- num 1) 10.828) 8)))
  (if (and (<(car pt_l)(car pt_s))(>(abs(- (car pt_l) (car pt_s)))(abs(-(car pt_r)(car pt_s)))))
    (progn
      (command "pline" "non" pt_s "non" pt_r "non" "@8<180" "")
   (setq tt 1)
   (while (< tt num)
     (command "pline" "@" "non" "@2<-135" "non" "@2<135" "non" "@8<180" "")
     (setq tt (1+ tt))
   )
    )
    (progn
      (command "pline" "non" pt_s "non" pt_l "non" "@8<0" "")
   (setq tt 1)
   (while(< tt num)
     (command "pline" "@" "non" "@2<-45" "non" "@2<45" "non" "@8<0" "")
     (setq tt(1+ tt))
   )
    )
  )
     (setq tt 1)
  (while (<= tt num)
    (princ (strcat "\n请输入序号<" (itoa txt0) ">:"))
    (setq txt (getint))
    (if (not txt)
      (setq txt txt0)
    )
    (setq txt0 (+ txt 1))
    (command "text" "m" "non" pt_t "5" "0" txt)
    (setq pt_t(polar pt_t 0 10.828))
    (setq tt (1+ tt))
  )
   )
)
    (initget "Single Horizonal Vertical eXit")
    (setq sele(getkword "\n部装明细序号填写方式[水平多项(H)/垂直多项(V)/单一序号(S)/退出(X)]<退出>:"))
    (if (not sele)
      (setq sele "eXit")
    )
  )
  (setvar "clayer" oldlayer)
  (setvar "cmdecho" oldecho)
  (setvar "textstyle" oldstyle)
  (setvar "textsize" oldsize)
  (setvar "plinewid" oldpwid)
  (setvar "orthomode" oldortho)
  (princ)
)
(princ"已装载")


参考程序
(defun c:n (/ p1 p2 p3 txt)
  (if (= scalefactor nil)
(setq scalefactor (getreal "\nPlease input scalefactor:"))
)
(setq txt (getstring "\nNumber: "))
(while (and (setvar "OSMODE" 0)
            (setq p1 (getpoint "\nInput P1: "))
            (setvar "OSMODE" 512)
            (setq p2 (getpoint p1 "\nInput P2: "))
           (setvar "OSMODE" 0)
           (setq p3 (getpoint p2 "\nInput P3: ")))
(setq angle1 (angle p2 p3))
  (if (< (/ pi 2) angle1 (* 1.5 pi)) (progn
   (command "pline" p1 p2 (polar p2 pi (* 7 scalefactor)) "")
   (command "text" "j" "bc" (polar p2 2.737 (* 3.5 scalefactor)) (* 5 scalefactor) 0 txt "")
  )
(progn
   (command "pline" p1 p2 (polar p2 0 (* 7 scalefactor)) "")
  (command "text" "j" "bc" (polar p2 0.4 (* 3.5 scalefactor)) (* 5 scalefactor) 0 txt "")
  ))
  (command "change" "l" "" "p" "la" "文字标注层" "")
  (setq txt (itoa (1+ (atoi txt))))
)
(princ)
(setvar "OSMODE" 167)
)
;;;;;;;;;;;;;;;;;;;;

本帖子中包含更多资源

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

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2012-6-12 21:20:08 | 显示全部楼层
本帖最后由 ZZXXQQ 于 2012-7-16 22:25 编辑

游客,本帖隐藏的内容需要发帖数高于 5 才可浏览,你当前发帖数只有 0
 楼主| 发表于 2012-6-13 08:42:30 | 显示全部楼层
谢谢ZZXXQQ,但程序在运行至输入同零件组项数后显示错误,“请输入同零件组的项数:2 ; 错误: no function definition: ITOS”,其余两种选择没有自动连续编号和循环,没有比例系数。
请ZZXXQQ再帮我研究研究。
发表于 2012-7-13 09:24:48 | 显示全部楼层
试试这个如何

本帖子中包含更多资源

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

x
 楼主| 发表于 2012-7-16 09:09:06 | 显示全部楼层
本帖最后由 s678z 于 2012-7-16 09:40 编辑
自贡黄明儒 发表于 2012-7-13 09:24
试试这个如何


能自动打出序号数量,自动化程度提高了,这随图纸放大的原理是什么?但没有往左方向的编号。文字高度制图标准是5mm,距离下横线1.5mm,连线折线45°,竖直向上的最后一个序号数字不需要上横线和旁边的竖线,焦点捕捉用最近点退出时还原到osmode=167,可参考上面的程序,我还是倾向于上面的lisp程序改进,那个大部已经达到制图要求了。
发表于 2012-7-16 15:54:25 | 显示全部楼层
ITOS改为RTOS,比例系数SC有的,也可设置成根据图框比例来。
发表于 2012-12-14 20:22:54 | 显示全部楼层
还在学习过程中,谢谢提供
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-6-3 13:47 , Processed in 0.219039 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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