明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1260|回复: 2

[提问] 圆坐标统计工具,,,,字母编码不能递增

[复制链接]
发表于 2016-10-14 00:14 | 显示全部楼层 |阅读模式
本帖最后由 皇上快溜 于 2016-10-14 00:23 编辑

字母编码不能结合孔大小特征递增,如图,编码全是A123,,不能递增到 B 和 c ,,,,




   (setq P2 (getpoint "\n基准点:"))
   (setq P3 '(0 0))
   (if (= P2 NIL)
     (setq P2 P3)
   )
   (setq X_P2 (car P2))
   (setq Y_P2 (nth 1 P2))
   (setq txt "ABCDEFGHJKLMNPQRSTUVWXYZ")  ;;;;;;;;字母
   (setq SS (ssget '((0 . "CIRCLE"))))
   (setq        COUNT 0
         N 0
   )
   (setq i 1)  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;字母循环起点
   (setq stxt (substr txt i 1))  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;字母循环起点
   (setq R_LIST NIL)
   (setq X_LIST NIL)
   (setq Y_LIST NIL)
   (repeat (sslength SS)
     (setq EN (ssname SS N))
     (setq ED (entget EN))
     (if        (not (member
                (setq CEN (cdr (assoc 10 ED)))
                CEN_LIST
              )
         )
       (progn
         (setq CEN_LIST (append CEN_LIST (list CEN)))
         (setq CEN_X (list (car CEN)))
         (setq CEN_Y (list (cadr CEN)))
         (setq TMP (cdr (assoc 40 ED)))
         (setq R_LIST (cons (list TMP COUNT) R_LIST))
         (setq X_LIST (cons CEN_X X_LIST))
         (setq Y_LIST (cons CEN_Y Y_LIST))

         ;(setq jjtxt (strcat stxt R_LIST))  ;;;;;;在这里想将 stxt 结合 R_LIST 值的变化定义成字母可递增的函数 jjtxt 失败了

         (setq COUNT (1+ COUNT))  ;;;;;;;;;数字
         (setq NOU (itoa COUNT))  ;;;;;;;;;;;;;;数字循环
         (setq xtxt (strcat stxt NOU))  ;;;;;;;;;;;;;;;;;字母 + 数字
         (command "_.text" "j" "C" CEN T_HIGH "" xtxt)  ;;;;;;;;;;;;;;;字母 + 数字(文本标注)
       )
     )
     (setq i (+ i 1))  ;;;;;;;;字母递增
     (setq N (1+ N))  ;;;;;;;;;;;;;;;;;选圆循环
   )

前后摆弄了两个功能类似的程序,都不如意。想请各位高人帮忙改改,谢谢个位。

本帖子中包含更多资源

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

x
 楼主| 发表于 2016-10-14 00:20 | 显示全部楼层
本帖最后由 皇上快溜 于 2016-10-14 00:24 编辑

全码



(defun AI_ERROR        (ERRMSG)
   (if ERRMSG
     '("console break"
       "Function Cancelled"
      )
     (princ (strcat "\nError: " ERRMSG))
   )
   (princ)
) ;_defun
;;;_______________________________________________________
(defun WRITE_LIST (R_LIST /)
   (command "_.text" "j" "C" P1 T_HIGH 0 "序号")
   (command "_.text"
            "j"
            "C"
            (polar P1 0 (* T_HIGH 7))
            T_HIGH
            0
            "孔  径"
   )
   (command "_.text"
            "j"
            "C"
            (polar P1 0 (* T_HIGH 16))
            T_HIGH
            0
            "X 坐标"
   )
   (command "_.text"
            "j"
            "C"
            (polar P1 0 (* T_HIGH 26))
            T_HIGH
            0
            "Y 坐标"
   )
   (setq P1 (polar P1 (/ pi -2.0) (* T_HIGH 2)))
   (setq N 1)
   (while (/= (setq DATA (car R_LIST)) NIL)
     (setq DATA1 (car X_LIST))
     (setq DATA2 (car Y_LIST))
     (command "_.text"
              "j"
              "c"
              (polar P1 0 (* T_HIGH 7))
              T_HIGH
              ""
              (strcat "%%C" (rtos (* (car DATA) 2.0) 2 2))
     )
     (command "_.text"
              "j"
              "c"
              (polar P1 0 (* T_HIGH 16))
              T_HIGH
              ""
              (rtos (- (car DATA1) X_P2))
     )
     (command "_.text"
              "j"
              "c"
              (polar P1 0 (* T_HIGH 25))
              T_HIGH
              ""
              (rtos (- (car DATA2) Y_P2))
     )
     (command "_.text"
              "j"
              "C"
              (polar P1 0 (* T_HIGH 0.25))
              T_HIGH
              ""
              (rtos N)
     )
     (setq P1 (polar P1 (/ pi -2.0) (* T_HIGH 2)))
     (setq R_LIST (cdr R_LIST))
     (setq X_LIST (cdr X_LIST))
     (setq Y_LIST (cdr Y_LIST))
     (setq N (1+ N))
   )
)
;;;_______________________________________________________
(defun WRITE_LINE (/ LL)
   (setq P1 (polar P1 (/ pi 2.0) (* T_HIGH 1.5)))
   (command "_.LINE"
            (polar P1 pi (* T_HIGH 2.5))
            (polar P1 0 (* T_HIGH 30))
            ""
   )
   (command "_.CHANGE" (entlast) "" "P" "Color" "2" "")
   (command "_.ARRAY"
            (entlast)
            ""
            "R"
            (+ (length R_LIST) 2)
            ""
            (* 2 T_HIGH)
   )
   (command "_.LINE"
            (polar P1 pi (* T_HIGH 2.5))
            (cdr (assoc 10 (entget (entlast))))
            ""
   )
   (command "_.CHANGE" (entlast) "" "P" "Color" "2" "")
   (setq LL (entlast))
   (command "_.COPY" LL "" P1 (polar P1 0 (* T_HIGH 5.0)))
   (command "_.COPY" LL "" P1 (polar P1 0 (* T_HIGH 13.5)))
   (command "_.COPY" LL "" P1 (polar P1 0 (* T_HIGH 23)))
   (command "_.COPY" LL "" P1 (polar P1 0 (* T_HIGH 32.5)))
)
;;;_______________________________________________________
(defun C:LBB (/              T_HIG   T_HIGH  SS      COUNT   R_LIST  X_LIST
               Y_LIST  EN      ED      CEN     CEN_X   CEN_Y   TMP
               NOU     P1      CEN_LIST N
              )
   (setvar "MODEMACRO" "***SPRING***")
   (setq CM (getvar "cmdecho"))
   (setvar "cmdecho" 0)
   (setq        OLD_ERROR *ERROR*
         *ERROR*        AI_ERROR
   )
   (command "_.UNDO" "group")
   (command "_.UCS" "World")
   (princ "\n字高:")
   (setq T_HIG (getvar "TEXTSIZE"))
   (princ T_HIG)
   (setq T_HIGH (getstring ">"))
   (if (= T_HIGH "")
     (setq T_HIGH T_HIG)
     (setq T_HIGH (atof T_HIGH))
   )
   (setq P2 (getpoint "\n基准点:"))
   (setq P3 '(0 0))
   (if (= P2 NIL)
     (setq P2 P3)
   )
   (setq X_P2 (car P2))
   (setq Y_P2 (nth 1 P2))
   (setq txt "ABCDEFGHJKLMNPQRSTUVWXYZ")  ;;;;;;;;字母
   (setq SS (ssget '((0 . "CIRCLE"))))
   (setq        COUNT 0
         N 0
   )
   (setq i 1)  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;字母循环起点
   (setq stxt (substr txt i 1)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;字母循环起点
   (setq R_LIST NIL)
   (setq X_LIST NIL)
   (setq Y_LIST NIL)
   (repeat (sslength SS)
     (setq EN (ssname SS N))
     (setq ED (entget EN))
     (if        (not (member
                (setq CEN (cdr (assoc 10 ED)))
                CEN_LIST
              )
         )
       (progn
         (setq CEN_LIST (append CEN_LIST (list CEN)))
         (setq CEN_X (list (car CEN)))
         (setq CEN_Y (list (cadr CEN)))
         (setq TMP (cdr (assoc 40 ED)))
         (setq R_LIST (cons (list TMP COUNT) R_LIST))
         (setq X_LIST (cons CEN_X X_LIST))
         (setq Y_LIST (cons CEN_Y Y_LIST))

         ;(setq jjtxt (strcat stxt R_LIST))  ;;;;;;;;;;;;;;;;;这里

         (setq COUNT (1+ COUNT))  ;;;;;;;;;数字
         (setq NOU (itoa COUNT))  ;;;;;;;;;;;;;;数字循环
         (setq xtxt (strcat stxt NOU))  ;;;;;;;;;;;;;;;;;字母 + 数字
         (command "_.text" "j" "C" CEN T_HIGH "" xtxt)  ;;;;;;;;;;;;;;;字母 + 数字(文本标注)
       )
     )
     (setq i (+ i 1))  ;;;;;;;;字母递增
     (setq N (1+ N))  ;;;;;;;;;;;;;;;;;选圆循环
   )
   (setq X_LIST (reverse X_LIST))
   (setq Y_LIST (reverse Y_LIST))
   (setq P1 (getpoint "\ninsert point"))
   (setq        R_LIST (vl-sort        R_LIST
                         (function (lambda (E1 E2)
                                     (< (cadr E1) (cadr E2))
                                   )
                         )
                )
   )
   (WRITE_LIST R_LIST)
   (WRITE_LINE)
   (command "_.UCS" "Prev")
   (command "_.UNDO" "end")
   (setvar "cmdecho" CM)
   (setq *ERROR* OLD_ERROR)
   (princ)
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-3-29 05:12 , Processed in 0.196725 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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