乐筑天下

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

[编程交流] 帮助排除Autolisp故障

[复制链接]

1

主题

1

帖子

0

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 09:16:04 | 显示全部楼层 |阅读模式
程序中用于转换多行文字和属性的部分有问题,因此可以将其作为文本输出到文件中。如果有人愿意帮助我解决程序故障,我将不胜感激。
 
  1. ;define program - listing your variable names here
  2. ; resets them to nil after the program finishes
  3. ;;;--- Main Application
  4. (defun C:ESBTEXT2(/ lts ernote filen fil eset en enlist cntr et ne ned)
  5. (setq rep (getint "Please enter the number of times the wire number should output: "))
  6. ;;;--- Setup three list to hold the data
  7. (setq TBNOList(list) WIRENOList (list) DEVIDList(list))
  8. ;turn echo off
  9. (setvar "cmdecho" 0)
  10. ;get ltscale (Note: ltscale should always equal dimscale)
  11. (setq lts(getvar "ltscale"))
  12. ;set the exit note to successful
  13. (setq ernote "\n....ESBTEXT Complete.")
  14. ;if ssget returns a valid selection set
  15. (if
  16. (setq eset
  17. (ssget "X"
  18. '(
  19. (-4 . "<OR")
  20. (8 . "TBNO")
  21. (8 . "WIRENO")
  22. (8 . "DEVID")
  23. (-4 . "OR>")
  24. )
  25. )
  26. )
  27. ;progn necessary for multiple statements inside an if statement
  28. (progn
  29. ;set the entity counter to zero [the first entity in a set is zero]
  30. (setq cntr 0)
  31. ;step through each entity in the selection set
  32. (while (< cntr (sslength eset))
  33. ;get the entity name indexed by cntr
  34. (setq en(ssname eset cntr))
  35. ;get the DXF group codes for the entity
  36. (setq enlist(entget en)
  37. et (cdr (assoc 0 enlist))
  38. )
  39. ;check the group code 0 to see if entity type = TEXT
  40. (if (cond ((= et "TEXT")(setq str (cdr (assoc 1 enlist))))
  41. ((= et "MTEXT")
  42. ;COMBINE GROUP 3's AND GROUP 1's INTO ONE STRING
  43. (setq str (vl-remove-if-not '(lambda (q)(or (= (car q) 3)(= (car q) 1))) enlist)
  44. str (apply 'strcat (mapcar 'cdr cs))
  45. )
  46. )
  47. ((and (= et "INSERT")(= (cdr (assoc 66 enlist)) 1))
  48. (setq ne (entnext en))
  49. (while (and ne (= (cdr (assoc 0 (setq ned (entget ne)))) "ATTRIB"))
  50. (setq str (cdr (assoc 1 ned))
  51. ne (entnext ne)
  52. )
  53. (cond
  54. ((= (cdr(assoc 8 enlist)) "TBNO") (setq TBNOList (append TBNOList (list str))))
  55. ((= (cdr(assoc 8 enlist)) "WIRENO")(setq WIRENOList(append WIRENOList (list str))))
  56. ((= (cdr(assoc 8 enlist)) "DEVID") (setq DEVIDList(append DEVIDList (list str))))
  57. )
  58. )
  59. nil
  60. )
  61. )
  62. ;progn necessary for multiple statements inside an if statement
  63. (progn
  64. ;;;--- Add it to the appropriate list
  65. (cond
  66. ((= (cdr(assoc 8 enlist)) "TBNO") (setq TBNOList (append TBNOList (list str))))
  67. ((= (cdr(assoc 8 enlist)) "WIRENO")(setq WIRENOList(append WIRENOList (list str))))
  68. ((= (cdr(assoc 8 enlist)) "DEVID") (setq DEVIDList(append DEVIDList (list str))))
  69. )
  70. ) ;close the if progn
  71. ) ;close the if statement
  72. ;increment the counter to get the next entity
  73. (setq cntr(+ cntr 1))
  74. ) ;close the while loop
  75. ;;;--- Sort the list
  76. (setq TBNOList (srtAN TBNOList))
  77. (setq WIRENOList (srtAN WIRENOList))
  78. (setq DEVIDList (srtAN DEVIDList))
  79. ;;;--- Print the list (parameters = [FileName Prefix] [Name of List] [Print Repeat]
  80. (prinFile "TBNO_" TBNOList 1)
  81. (prinFile "WIRENO_" WIRENOList Rep)
  82. (prinFile "DEVID_" DEVIDList 1)
  83. );progn
  84. );if
  85. ;turn the command echo back on
  86. (setvar "cmdecho" 1)
  87. ;clear the command line
  88. (princ "\n")
  89. ;supress last echo
  90. (princ)
  91. )

 
非常感谢。
 
布拉德·梅斯纳
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 03:11 , Processed in 2.818865 second(s), 54 queries .

© 2020-2025 乐筑天下

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