yukyman 发表于 2014-9-11 17:12:26

地形图查询脚本代码修改失败,求帮助

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

ZZXXQQ 发表于 2014-9-11 19:50:30

不知道行不行;;; 命令tuh dxt rdx dx5k rdx5k tuh5k
;;; 引入地形图,先引用1:500,没有再引用1:1000
(defun c:dxt (/ po x y mpname1000)
(setvar "cmdecho" 0)
(while (setq po (getpoint "\n拾取一点插入地形,右键退出:"))
    (setq x (car po) y (cadr po))
    (calth1000 y x)
    (setq mpname1000 (strcat "E:/2014/2/" strmapname ".dwg"))
    (if (findfile mpname1000)
      (command "xref" "" mpname1000 "0,0,0" "" "" "")
      (princ "\nSorry,无此处1000比例的地形图\n")
    )
)
(princ)
)
;;; 退出引用的地形图
(defun c:rdx (/ po1 x y mpname1000 strmapname1000 )
(setvar "cmdecho" 0)
(while (setq po1 (getpoint "\n拾取一点卸载地形,右键退出:"))
    (setq x (car po1) y (cadr po1))
    (calth1000 y x)
    (setq mpname1000 strmapname)
    (setq strmapname1000 (strcat "E:/2014/2/" strmapname ".dwg" ))
    (if (findfile strmapname1000)
      (command "xref" "d" mpname1000)
    )
)
(princ)
)
;;; ===========
;;; make sure this point within the map,so as to calculate the tkname correctly
;;; 图名
(defun sheetid (); calculate the first letter of the sheetID
(setq istate1 (fix (/ fy 1000)))
(setq strmapname (itoa istate1))
(setq istate2 (fix (/ fx 100)))
(setq istate00 (/ (- istate2 672) 8))
(if (/= istate00 (fix istate00))
    (setq strmapname (strcat strmapname "-" (itoa (fix (+ (* (fix istate00) 0.8) 67.2)))))
    (setq strmapname (strcat strmapname "-" (itoa istate2)))
)
)
;;; 计算1000的图号
(defun calth1000 (fx fy / istate5 istate3 istate4)
(sheetid)
(setq istate5 (- (fix (/ fx 80)) (* (fix (/ fx 800)) 10)))
(setq istate3 (- (fix (/ fy 100)) (* (fix (/ fy 1000)) 10)))
(if (and (= istate5 7) (= istate3 0)) (setq istate4 "1"))
(if (and (= istate5 7) (= istate3 2)) (setq istate4 "2"))
(if (and (= istate5 7) (= istate3 5)) (setq istate4 "3"))
(if (and (= istate5 7) (= istate3 7)) (setq istate4 "4"))
(if (and (= istate5 5) (= istate3 0)) (setq istate4 "5"))
(if (and (= istate5 5) (= istate3 2)) (setq istate4 "6"))
(if (and (= istate5 5) (= istate3 5)) (setq istate4 "7"))
(if (and (= istate5 5) (= istate3 7)) (setq istate4 "8"))
(if (and (= istate5 2) (= istate3 0)) (setq istate4 "9"))
(if (and (= istate5 2) (= istate3 2)) (setq istate4 "10"))
(if (and (= istate5 2) (= istate3 5)) (setq istate4 "11"))
(if (and (= istate5 2) (= istate3 7)) (setq istate4 "12"))
(if (and (= istate5 0) (= istate3 0)) (setq istate4 "13"))
(if (and (= istate5 0) (= istate3 2)) (setq istate4 "14"))
(if (and (= istate5 0) (= istate3 5)) (setq istate4 "15"))
(if (and (= istate5 0) (= istate3 7)) (setq istate4 "16"))
(setq strmapname (strcat strmapname "-" istate4))
;(princ (strcat "图号" strmapname "ok\n"))
)
(princ)

yukyman 发表于 2014-9-11 20:03:49

ZZXXQQ 发表于 2014-9-11 19:50 static/image/common/back.gif
不知道行不行

谢谢,帮我纠正了一些错误,我自己又修改了一些代码,现在可以用了
页: [1]
查看完整版本: 地形图查询脚本代码修改失败,求帮助