乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 69|回复: 6

[编程交流] 错误:错误的参数类型:lent

[复制链接]

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 12:12:03 | 显示全部楼层 |阅读模式
我不是一个有经验的lisper,但我可以操作一些我们有的lisp例程。我们正在尝试运行一个lisp例程,该例程曾经工作过,但现在我遇到了错误:
 
错误:错误的参数类型:lentyp nil
 
我们要做的是用一个更新的块替换一个块,该块在一批图形上命名为相同的东西。下面是lisp例程挂起或中断的地方。我不明白为什么它没有完成循环和例行程序。
 
(defun c:redef_仪器()
(setvar“clayer”“specblk”)
(setq lst\U blk(ai\U表格“BLOCK”1))
(如果是lst_blk
(程序
(foreach str\u blk lst\u blk
(setq file_blk
(打开(strcat(getvar“dwgprefix”)“InstrumentMap.csv”)“r”)
)
(while(setq记录(read line file_blk))
(setq str_名称(第n个0(strparse记录“,”))
(如果
(和
(=(strcase str\u name)(strcase str\u blk))
(>(长度(strparse记录“,”)1)
(/=(setq str_newname(第n个1(strparse记录“,”))“”)
)
(程序
(重新定义Instruments str\u name str\u newname)
)
)
)
(关闭file_blk)
)
)
)
)
(重新定义仪器(旧/新/blist
attlst\u旧attlst\u新
val scx scy scz
)
(setq ss_old(ssget“x”(list)(0。“INSERT”)(cons 2 old)))
(如果ss_旧
(程序
(setq blist
(sel2lst ss_old)
)
(foreach nb blist)
(命令“插入”
(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(第0个attlst\u旧))(第0个attlst\u新))
(setval 1(getval 1(nth 1 attlst\u old))(nth 1 attlst\u new))
(设置值1(设置值1(第3个attlst\u旧))(第2个attlst\u新))
(设置值1(设置值1(第4个attlst\u旧))(第3个attlst\u新))
(设置值1(设置值1(第5个attlst\u旧))(第4个attlst\u新))
(设置值1(设置值1(第6个attlst\u旧))(第5个attlst\u新))
(设置值1(设置值1(第7个attlst\u旧))(第6个attlst\u新))
(设置值1(设置值1(第8个attlst\u旧))(第7个attlst\u新))
(设置值1(设置值1(第9个attlst\u旧))(第8个attlst\u新))
(设置值1(设置值1(第10个attlst\u旧))(第9个attlst\u新))
(设置值1(设置值1(第11个attlst\u旧))(第10个attlst\u新))
(设置值1(设置值1(第12个attlst\u旧))(第11个attlst\u新))
(设置值1(设置值1(第13个attlst\u旧))(第12个attlst\u新))
(entdel nb)
)
)
)
(entupd(entlast))
)
 
任何帮助或指导都将不胜感激。另外,如果有人能在上半部分对代码进行注释,这样我就能理解代码真正在做什么。
 
非常感谢
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 12:25:50 | 显示全部楼层
此外,我们希望保留旧块中的属性,删除第三个属性,并将属性的所有其他值向上移动一个,即:第n个3=第n个2
回复

使用道具 举报

14

主题

271

帖子

257

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 12:42:00 | 显示全部楼层
你好
您尚未发布strparse函数(它可能位于启动时运行的另一个lisp中)。如果你错过了它,这将是你的问题,否则你需要张贴它,这样我们就可以看到它还有什么问题。
以下是您的一些代码评论,希望能有所帮助:
  1. ; Define Function redef_instruments
  2. (defun c:redef_instruments ()
  3. ; Change Current Layer
  4. (setvar "clayer" "specblk")
  5. ; Get Block List in current drawing
  6. (setq lst_blk (ai_table "BLOCK" 1))
  7. ;If there's a block list
  8. (if lst_blk
  9.    ; then do everything within the progn parenthesis
  10.    (progn
  11.      ; for each block in the block list
  12.      (foreach str_blk lst_blk
  13.    ; open InstrumentMap.csv located in the same folder as the current drawing
  14.    (setq file_blk
  15.           (open (strcat (getvar "dwgprefix") "InstrumentMap.csv") "r")
  16.          )
  17.    ; iterate through each line in the csv file until it runs out
  18.    (while (setq record (read-line file_blk))
  19.      ; look for coma, return strname [i][b][color=Red](MISSING strparse FUNCTION)[/color][/b][/i]
  20.      (setq str_name (nth 0 [b][color=Red](strparse[/color][/b] record ",")))
  21.      ; if everything returns true in the AND parenthesis
  22.      (if
  23.        (and
  24.          ;
  25.          (= (strcase str_name) (strcase str_blk))
  26.          (> (length [b][color=Red](strparse[/color][/b] record ",")) 1)
  27.          (/= (setq str_newname (nth 1 [b][color=Red](strparse[/color][/b] record ","))) "")
  28.          )
  29.        (progn
  30.          (redefineinstruments str_name str_newname)
  31.          )
  32.        )
  33.      )
  34.    (close file_blk)
  35.    )
  36.      )
  37.    )
  38. )
  39. ; Redefine Instructments Function
  40. (defun redefineinstruments (old new / blist
  41.                attlst_old attlst_new
  42.                val scx scy scz
  43.                )
  44. (setq ss_old (ssget "x" (list '(0 . "INSERT") (cons 2 old))))
  45. (if ss_old
  46.    (progn
  47.      (setq blist
  48.         (sel2lst ss_old)
  49.        )
  50.      (foreach nb blist
  51.    (command "insert"
  52.         (strcat new "=" (findfile (strcat new ".dwg")))
  53.         (getval 10 nb)
  54.         "XYZ"
  55.         1
  56.         1
  57.         1
  58.         (rtod (getval 50 nb))
  59.         )
  60.    (setq attlst_old (att2lst nb))
  61.    (setq attlst_new (att2lst (entlast)))
  62.    (setval 1 (getval 1 (nth 0 attlst_old)) (nth 0 attlst_new))
  63.    (setval 1 (getval 1 (nth 1 attlst_old)) (nth 1 attlst_new))
  64.    (setval 1 (getval 1 (nth 3 attlst_old)) (nth 2 attlst_new))
  65.    (setval 1 (getval 1 (nth 4 attlst_old)) (nth 3 attlst_new))
  66.    (setval 1 (getval 1 (nth 5 attlst_old)) (nth 4 attlst_new))
  67.    (setval 1 (getval 1 (nth 6 attlst_old)) (nth 5 attlst_new))
  68.    (setval 1 (getval 1 (nth 7 attlst_old)) (nth 6 attlst_new))
  69.    (setval 1 (getval 1 (nth 8 attlst_old)) (nth 7 attlst_new))
  70.    (setval 1 (getval 1 (nth 9 attlst_old)) (nth 8 attlst_new))
  71.    (setval 1 (getval 1 (nth 10 attlst_old)) (nth 9 attlst_new))
  72.    (setval 1 (getval 1 (nth 11 attlst_old)) (nth 10 attlst_new))
  73.    (setval 1 (getval 1 (nth 12 attlst_old)) (nth 11 attlst_new))
  74.    (setval 1 (getval 1 (nth 13 attlst_old)) (nth 12 attlst_new))
  75.    (entdel nb)
  76.    )
  77.      )
  78.    )
  79. (entupd (entlast))
  80. )
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 12:49:21 | 显示全部楼层
这在另一个加载的Lisp例程中。
 
;;STRPARSE用于解析字符串(并保留空令牌)
(defun strparse(strng chs/len c l s chsl cnt)
;;delim==一个chs。
(setq chsl(strtol chs))
(setq len(strlen strng)
s“”
cnt(1+len));_setq结束
(而(>(setq cnt(1-cnt))0)
(setq c(substr strng cnt 1))
(if(成员c chsl)
(如果(/=cnt len)
;; “1,2,”->(“1”“2”)而非(“1”“2”)
(setq l(cons s l)
s“”);_setq结束
) ;_ if结束
(setq s(strcat c s));_if结束
) ;_ while结束
(cons s l)
;; ",1,2" -> ("" "1" "2")
) ;_ defun结束
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 12:53:05 | 显示全部楼层
我在读另一篇帖子,有人说Lisp末尾的entupd可能会给出错误:错误的参数类型:lentyp nil?
 
谢谢你的帮助,它正在清理泥水。
回复

使用道具 举报

14

主题

271

帖子

257

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 13:03:39 | 显示全部楼层
请注意,在发布时,请将代码括在代码括号[code][/code]中。
 
如果这个代码已经发布在其他地方,为什么你不在那里问呢?
 
无论如何。。。
 
为什么不注释掉这行(entupd(entlast))并看看它是否有效。。。?
 
函数strparse使用另一个缺少的函数strtol。
回复

使用道具 举报

14

主题

271

帖子

257

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 13:13:33 | 显示全部楼层
在自助方面,您是否使用visual lisp编辑器?如果是这样的话,你可以在某个地方暂停Lisp程序,然后逐行检查每一行。这样你就会发现错误发生的地方。也是学习的好方法。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-5 10:21 , Processed in 0.993796 second(s), 66 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表