明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: 啵浪鼓

[求助]能输数字和字符的代码

  [复制链接]
 楼主| 发表于 2009-10-6 01:01:00 | 显示全部楼层

龙版主的程序好难懂,结果是ok,但自已一段一段执行下去想找到接口点,插程序进去就不行,; 错误: 参数类型错误: stringp 10.0

因为我想在龙版主的程序里插入如果用户输入空格将执行默认字高(if (= gs nil) (setq gs 3)),目前龙版主的程序不能接受空回车

本来很简单的程序,被我自已整的昏头了,下面的程序被整的无厘头了

(defun c:tt ()
  (setvar "cmdecho" 0)
  (command "style" "HP-CHINESET" "txt.shx,CHINESET.shx" "" "0.7" "" "N" "N" "N")
  (if(not(tblsearch "layer" "TEXT"))
     (command "layer" "new" "TEXT" "set" "TEXT" "c" "4" "TEXT" "")
     (command "layer" "set" "TEXT" "c" "4" "TEXT" "")
  )
  (princ "\nPick position to display Filename/Path : ")
  (setq vc (getvar "viewctr"))
  (setq pt (list (car vc) (cadr vc)))
  (setq dwgp (getvar "dwgprefix"))
  (setq dwgp0(substr dwgp 3 222))
  (setq dwgp1 "SERVER")
  (setq dwgn (getvar "dwgname"))
  (setq username (getvar "loginname"))

  (if (= "Server" (substr dwgp0 1 6)) 
      (setq dwgp2(substr dwgp 9 222))
      (setq dwgp2(substr dwgp 3 222))
  )

(if (= gs nil) (setq gs 3))


;(defun C:TT (/ ENP FLAG)
  (setq FLAG t)
  (while FLAG
    (cond
      ((= (progn (initget 128)
   (setq ENP
   (getpoint
     (strcat "\n FileName<A>/FilePath<B>/文字高度<" (rtos gs) ">:"    ;程序不能接受默认值或者空回车
     )
   )
   )
   )
   NIL
       )
       (setq FLAG t)
      )
      ((wcmatch (substr ENP 1 1) "[0-9]")
       (setq ENP  (atof ENP)
      FLAG NIL
       )
      )
      ((wcmatch (setq ENP (strcase (substr ENP 1 1))) "[AaBb]")
       (setq FLAG NIL)
      )
    )
  )
;  ENP
;)

  (cond
       ((and (= "B" enp)(= "b" enp))  ;如果enp=b时,gs文字高度应该为默认值
            (progn
              (command "text" (list (car pt) (cadr pt)) gs (list (+ (car pt) 10) (cadr pt))
                 (strcat dwgp1 dwgp2 dwgn))
          )
       )
       ((and (= "A" enp)(= "a" enp))  ;如果enp=a时,gs文字高度应该为默认值
            (progn
                (setq filename(substr dwgn 1 (- (strlen dwgn) 4)))
                (command "text" (list (car pt) (cadr pt)) gs (list (+ (car pt) 10) (cadr pt)) filename))
             )
       (t (progn (setq filename(substr dwgn 1 (- (strlen dwgn) 4)))      ;如果enp等于数字时,执行此段  ;目前此段根本就不成立,不管输入数字或是字母都是T
          (command "text" (list (car pt) (cadr pt)) enp (list (+ (car pt) 10) (cadr pt)) filename)))
   )
  (command "move" (entlast) "" (list (car pt) (cadr pt)) pause )
(princ)
)

发表于 2009-10-6 08:31:00 | 显示全部楼层
本帖最后由 作者 于 2009-10-7 7:56:45 编辑

(defun C:TT (/ DWGN DWGP DWGP0 DWGP1 DWGP2 ENP FILENAME FLAG ;|GS|;
      PAUSE PT USERNAME VC)
  (setvar "cmdecho" 0)
  (command "style"  "HP-CHINESET" "txt.shx,CHINESET.shx"
    ""   "0.7"        ""      "N"
    "N"   "N"
   )
  (if (not (tblsearch "layer" "TEXT"))
    (command "layer" "new" "TEXT" "set" "TEXT" "c" "4" "TEXT" "")
    (command "layer" "set" "TEXT" "c" "4" "TEXT" "")
  )
  (princ "\nPick position to display Filename/Path : ")
  (setq VC (getvar "viewctr"))
  (setq PT (list (car VC) (cadr VC)))
  (setq DWGP (getvar "dwgprefix"))
  (setq DWGP0 (substr DWGP 3 222))
  (setq DWGP1 "SERVER")
  (setq DWGN (getvar "dwgname"))
  (setq USERNAME (getvar "loginname"))
  (if (= "Server" (substr DWGP0 1 6))
    (setq DWGP2 (substr DWGP 9 222))
    (setq DWGP2 (substr DWGP 3 222))
  )
  (if (= GS NIL)
    (setq GS 3)
  )
  ;;(defun C:TT (/ ENP FLAG)
  (setq FLAG t)
  (while FLAG
     (cond
      ((= (progn (initget 128)
   (setq ENP
   (getpoint
     (strcat "\n FileName<A>/FilePath<B>/文字高度<"
      (rtos GS)
      ">:" ;程序不能接受默認值或者空回車
     )
   )
   )
   )
   NIL
       )
      (setq FLAG t)
      )
      ((wcmatch (substr ENP 1 1) "[0-9]")
       (setq ENP  (atof ENP)
      FLAG NIL
      GS   ENP
       )
       (setq FILENAME (substr DWGN 1 (- (strlen DWGN) 4)))
       (command "text"
  (list (car PT) (cadr PT))
  ENP
  (list (+ (car PT) 10) (cadr PT))
  FILENAME
       )
      )
      ((wcmatch (setq ENP (strcase (substr ENP 1 1))) "[AaBb]")
       (setq FLAG NIL)
       (cond
  ((or (= "B" ENP) (= "b" ENP)) ;如果enp=b時,gs文字高度應該為默認值
   (command "text"
     (list (car PT) (cadr PT))
     GS
     (list (+ (car PT) 10) (cadr PT))
     (strcat DWGP1 DWGP2 DWGN)
   )
  )
  ((or (= "A" ENP) (= "a" ENP)) ;如果enp=a時,gs文字高度應該為默認值
   (setq FILENAME (substr DWGN 1 (- (strlen DWGN) 4)))
   (command "text"
     (list (car PT) (cadr PT))
     GS
     (list (+ (car PT) 10) (cadr PT))
     FILENAME
   )
  )
       )
      )
    )
  )
  ;;  ENP
  ;;)
  (command "_.move"
    (entlast)
    ""
    (list (car PT) (cadr PT))
  )
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-6 07:24 , Processed in 0.147937 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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