你好
您尚未发布strparse函数(它可能位于启动时运行的另一个lisp中)。如果你错过了它,这将是你的问题,否则你需要张贴它,这样我们就可以看到它还有什么问题。
以下是您的一些代码评论,希望能有所帮助:
- ; Define Function redef_instruments
- (defun c:redef_instruments ()
- ; Change Current Layer
- (setvar "clayer" "specblk")
- ; Get Block List in current drawing
- (setq lst_blk (ai_table "BLOCK" 1))
- ;If there's a block list
- (if lst_blk
- ; then do everything within the progn parenthesis
- (progn
- ; for each block in the block list
- (foreach str_blk lst_blk
- ; open InstrumentMap.csv located in the same folder as the current drawing
- (setq file_blk
- (open (strcat (getvar "dwgprefix") "InstrumentMap.csv") "r")
- )
- ; iterate through each line in the csv file until it runs out
- (while (setq record (read-line file_blk))
- ; look for coma, return strname [i][b][color=Red](MISSING strparse FUNCTION)[/color][/b][/i]
- (setq str_name (nth 0 [b][color=Red](strparse[/color][/b] record ",")))
- ; if everything returns true in the AND parenthesis
- (if
- (and
- ;
- (= (strcase str_name) (strcase str_blk))
- (> (length [b][color=Red](strparse[/color][/b] record ",")) 1)
- (/= (setq str_newname (nth 1 [b][color=Red](strparse[/color][/b] record ","))) "")
- )
- (progn
- (redefineinstruments str_name str_newname)
- )
- )
- )
- (close file_blk)
- )
- )
- )
- )
- ; Redefine Instructments Function
- (defun redefineinstruments (old new / blist
- attlst_old attlst_new
- val scx scy scz
- )
- (setq ss_old (ssget "x" (list '(0 . "INSERT") (cons 2 old))))
- (if ss_old
- (progn
- (setq blist
- (sel2lst ss_old)
- )
- (foreach nb blist
- (command "insert"
- (strcat new "=" (findfile (strcat new ".dwg")))
- (getval 10 nb)
- "XYZ"
- 1
- 1
- 1
- (rtod (getval 50 nb))
- )
- (setq attlst_old (att2lst nb))
- (setq attlst_new (att2lst (entlast)))
- (setval 1 (getval 1 (nth 0 attlst_old)) (nth 0 attlst_new))
- (setval 1 (getval 1 (nth 1 attlst_old)) (nth 1 attlst_new))
- (setval 1 (getval 1 (nth 3 attlst_old)) (nth 2 attlst_new))
- (setval 1 (getval 1 (nth 4 attlst_old)) (nth 3 attlst_new))
- (setval 1 (getval 1 (nth 5 attlst_old)) (nth 4 attlst_new))
- (setval 1 (getval 1 (nth 6 attlst_old)) (nth 5 attlst_new))
- (setval 1 (getval 1 (nth 7 attlst_old)) (nth 6 attlst_new))
- (setval 1 (getval 1 (nth 8 attlst_old)) (nth 7 attlst_new))
- (setval 1 (getval 1 (nth 9 attlst_old)) (nth 8 attlst_new))
- (setval 1 (getval 1 (nth 10 attlst_old)) (nth 9 attlst_new))
- (setval 1 (getval 1 (nth 11 attlst_old)) (nth 10 attlst_new))
- (setval 1 (getval 1 (nth 12 attlst_old)) (nth 11 attlst_new))
- (setval 1 (getval 1 (nth 13 attlst_old)) (nth 12 attlst_new))
- (entdel nb)
- )
- )
- )
- (entupd (entlast))
- )
|