明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1330|回复: 2

[已解答] 地形图查询脚本代码修改失败,求帮助

[复制链接]
发表于 2014-9-11 17:12:26 | 显示全部楼层 |阅读模式
各位大神,我现在有个脚本,是这样运行的:
在CAD中,输入“dxt” ,然后鼠标单击获取一点,根据点的位置计算出编码,以编码为文件名,对应一个文件,然后以外部参照的形式插入文件。现成有一个可用的脚本,但是现在有新的文件,文件名称编码不一样,我现在已经修改了编码的方式,但是脚本运行不起来,提示说“参数类型错误: stringp nil”。已经检查好几遍了,我是菜鸟,但是找不出问题所在,请大家帮忙看下,在线等

本帖子中包含更多资源

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

x
发表于 2014-9-11 19:50:30 | 显示全部楼层
不知道行不行
  1. ;;; 命令tuh dxt rdx dx5k rdx5k tuh5k
  2. ;;; 引入地形图,先引用1:500,没有再引用1:1000
  3. (defun c:dxt (/ po x y mpname1000)
  4.   (setvar "cmdecho" 0)
  5.   (while (setq po (getpoint "\n拾取一点插入地形,右键退出:"))
  6.     (setq x (car po) y (cadr po))
  7.     (calth1000 y x)
  8.     (setq mpname1000 (strcat "E:/2014/2/" strmapname ".dwg"))
  9.     (if (findfile mpname1000)
  10.       (command "xref" "" mpname1000 "0,0,0" "" "" "")
  11.       (princ "\nSorry,无此处1000比例的地形图\n")
  12.     )
  13.   )
  14.   (princ)
  15. )
  16. ;;; 退出引用的地形图
  17. (defun c:rdx (/ po1 x y mpname1000 strmapname1000 )
  18.   (setvar "cmdecho" 0)
  19.   (while (setq po1 (getpoint "\n拾取一点卸载地形,右键退出:"))
  20.     (setq x (car po1) y (cadr po1))
  21.     (calth1000 y x)
  22.     (setq mpname1000 strmapname)
  23.     (setq strmapname1000 (strcat "E:/2014/2/" strmapname ".dwg" ))
  24.     (if (findfile strmapname1000)
  25.       (command "xref" "d" mpname1000)
  26.     )
  27.   )
  28.   (princ)
  29. )
  30. ;;; ===========
  31. ;;; make sure this point within the map,so as to calculate the tkname correctly
  32. ;;; 图名
  33. (defun sheetid (); calculate the first letter of the sheetID
  34.   (setq istate1 (fix (/ fy 1000)))
  35.   (setq strmapname (itoa istate1))
  36.   (setq istate2 (fix (/ fx 100)))
  37.   (setq istate00 (/ (- istate2 672) 8))
  38.   (if (/= istate00 (fix istate00))
  39.     (setq strmapname (strcat strmapname "-" (itoa (fix (+ (* (fix istate00) 0.8) 67.2)))))
  40.     (setq strmapname (strcat strmapname "-" (itoa istate2)))
  41.   )
  42. )
  43. ;;; 计算1000的图号
  44. (defun calth1000 (fx fy / istate5 istate3 istate4)
  45.   (sheetid)
  46.   (setq istate5 (- (fix (/ fx 80)) (* (fix (/ fx 800)) 10)))
  47.   (setq istate3 (- (fix (/ fy 100)) (* (fix (/ fy 1000)) 10)))
  48.   (if (and (= istate5 7) (= istate3 0)) (setq istate4 "1"))
  49.   (if (and (= istate5 7) (= istate3 2)) (setq istate4 "2"))
  50.   (if (and (= istate5 7) (= istate3 5)) (setq istate4 "3"))
  51.   (if (and (= istate5 7) (= istate3 7)) (setq istate4 "4"))
  52.   (if (and (= istate5 5) (= istate3 0)) (setq istate4 "5"))
  53.   (if (and (= istate5 5) (= istate3 2)) (setq istate4 "6"))
  54.   (if (and (= istate5 5) (= istate3 5)) (setq istate4 "7"))
  55.   (if (and (= istate5 5) (= istate3 7)) (setq istate4 "8"))
  56.   (if (and (= istate5 2) (= istate3 0)) (setq istate4 "9"))
  57.   (if (and (= istate5 2) (= istate3 2)) (setq istate4 "10"))
  58.   (if (and (= istate5 2) (= istate3 5)) (setq istate4 "11"))
  59.   (if (and (= istate5 2) (= istate3 7)) (setq istate4 "12"))
  60.   (if (and (= istate5 0) (= istate3 0)) (setq istate4 "13"))
  61.   (if (and (= istate5 0) (= istate3 2)) (setq istate4 "14"))
  62.   (if (and (= istate5 0) (= istate3 5)) (setq istate4 "15"))
  63.   (if (and (= istate5 0) (= istate3 7)) (setq istate4 "16"))
  64.   (setq strmapname (strcat strmapname "-" istate4))
  65. ;(princ (strcat "图号" strmapname "ok\n"))
  66. )
  67. (princ)
 楼主| 发表于 2014-9-11 20:03:49 | 显示全部楼层
ZZXXQQ 发表于 2014-9-11 19:50
不知道行不行

谢谢,帮我纠正了一些错误,我自己又修改了一些代码,现在可以用了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-24 03:15 , Processed in 0.155139 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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