乐筑天下

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

[编程交流] Lisp问题

[复制链接]

3

主题

14

帖子

11

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 08:53:44 | 显示全部楼层 |阅读模式
豪迪·亚尔
 
我是Autolisp的初学者,已经编写了一个程序,可以在任何图形中插入任何块。这有点粗糙,但这无关紧要。它实际上工作得很好。唯一的问题是,在我运行它之后,下次我使用连接到数据库的图形时,它会失去连接。除非我用lisp程序更改文件夹名,否则我无法取回它。这是唯一的问题,(据我所知),但我真的希望它被修复。
 
以下是程序:
 
  1. (defun c:blocks ()
  2. (command
  3.    "insert"
  4.    "S:\\9-AutoCAD\\Blocks\\Blocks_for_Tool_Palettes.dwg"
  5.    "0,0"        "0.00001"
  6.    "0.00001"        "0"
  7.   )
  8. (command "erase" "l" "")
  9. (princ)
  10. (alert
  11.    "Click OK then type in the code for the corresponding block you want from
  12. the following:
  13. B1= [modelspace]_Existing MH not shown on Council GIS
  14. B2= [modelspace]_Connectivity different to that shown on Council GIS
  15. B3= [modelspace]_MH in different location to that shown on Council GIS
  16. B4= [modelspace]_Install New 600mm dia. Access Chamber
  17. B5= [modelspace]_Existing manhole
  18. B6= [modelspace]_Node
  19. B7= [modelspace]_New access chamber
  20. B8= [modelspace]_Existing access chamber
  21. B9= [modelspace]_House names
  22. B10= [modelspace]_Road names
  23. B11= [modelspace]_Pipe script
  24. B12= [modelspace]_Rehab assessment number
  25. B13= [paperspace]_STAMP_Tender
  26. B14= [paperspace]_STAMP_Preliminary
  27. B15= [paperspace]_STAMP_Issued for Construction
  28. B16= [paperspace]_STAMP_As built
  29. B17= [paperspace]_STAMP_Revision Stamp
  30. B18= [paperspace]_Manhole
  31. B19= [paperspace]_Node
  32. B20= [paperspace]_Access Chamber"
  33. )
  34. (setq usercode (strcase (getstring "\nEnter code: ") nil))
  35. (cond
  36.    ((= "B1" usercode)
  37.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  38. point:"))
  39.   (command
  40.     "-insert"
  41.     "Existing MH not shown on Council GIS"
  42.     userinsertionpoint
  43.     ""
  44.     ""
  45.    )
  46.     )
  47.    )
  48.    ((= "B2" usercode)
  49.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  50. point:"))
  51.   (command
  52.     "-insert"
  53.     "Connectivity different to that shown on GIS"
  54.     userinsertionpoint
  55.     ""
  56.     ""
  57.    )
  58.     )
  59.    )
  60.    ((= "B3" usercode)
  61.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  62. point:"))
  63.   (command
  64.     "-insert"
  65.     "MH in different location to that shown on Council GIS"
  66.     userinsertionpoint
  67.     ""
  68.     ""
  69.    )
  70.     )
  71.    )
  72.    ((= "B4" usercode)
  73.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  74. point:"))
  75.   (command
  76.     "-insert"
  77.     "Install New 600mm dia. Access Chamber"
  78.     userinsertionpoint
  79.     ""
  80.     ""
  81.    )
  82.     )
  83.    )
  84.    ((= "B5" usercode)
  85.     (and
  86.       (and (setq userinsertionpoint
  87.     (getpoint "\nSpecify insertion point:")
  88.     )
  89.     (command "-insert"     "_ManholeExisting"
  90.       "S"     "25.4"    userinsertionpoint
  91.       ""      ""     ""
  92.      )
  93.       )
  94.     )
  95.    )
  96.    ((= "B6" usercode)
  97.     (and (setq userinsertionpoint
  98.   (getpoint "\nSpecify insertion point:")
  99.   )
  100.     )
  101.     (command "-insert"      "Model View Node"
  102.       "s"      "0.85"     userinsertionpoint
  103.       ""      ""      ""
  104.      )
  105.    )
  106.    ((= "B7" usercode)
  107.     (and
  108.       (setq userinsertionpoint
  109.       (getpoint "\nSpecify insertion point:")
  110.       )
  111.       (command "-insert"   "New Access Chamber"
  112. userinsertionpoint
  113.       ""            ""    ""
  114.        )
  115.     )
  116.    )
  117.    ((= "B8" usercode)
  118.     (and (setq userinsertionpoint
  119.   (getpoint "\nSpecify insertion point:")
  120.   )
  121.   (command "-insert"        "Existing Access Chamber"
  122.     userinsertionpoint  ""
  123.     ""         ""
  124.    )
  125.     )
  126.    )
  127.    ((= "B9" usercode)
  128.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  129. point:"))
  130.   (command "-insert"
  131.     "ACMAP_ANN_TEMPLATE_House Names"
  132.     userinsertionpoint
  133.     "20" "20" "0"    "House Names"
  134.    )
  135.     )
  136.    )
  137.    ((= "B10" usercode)
  138.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  139. point:"))
  140.   (command "-insert"   "ACMAP_ANN_TEMPLATE_Road_Name"
  141.     userinsertionpoint  "20"
  142.     "20"    "0" "Road_Name"
  143.    )
  144.     )
  145.    )
  146.    ((= "B11" usercode)
  147.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  148. point:"))
  149.   (command "-insert"
  150.     "ACMAP_ANN_TEMPLATE_Pipe Script"
  151.     userinsertionpoint   "20"
  152.     "20"     "0" "Pipe Script"
  153.    )
  154.     )
  155.    )
  156.    ((= "B12" usercode)
  157.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  158. point:"))
  159.   (command
  160.     "-insert"
  161.     "ACMAP_ANN_TEMPLATE_Rehab Assessment No"
  162.     userinsertionpoint        "20"
  163.     "20"          "0" "Rehab Assessment No"
  164.    )
  165.     )
  166.    )
  167.    ((= "B13" usercode)
  168.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  169. point:"))
  170.   (command "-insert" "TENDER" userinsertionpoint "" "")
  171.     )
  172.    )
  173.    ((= "B14" usercode)
  174.     (command "-insert" "PRELIMINARY" "s" "0.025" "70,60" "" "")
  175.    )
  176.    ((= "B15" usercode)
  177.     (command "-insert"        "Issued for Construction"
  178.       "s"        "0.025"  "70,60"
  179.       ""        ""
  180.      )
  181.    )
  182.    ((= "B16" usercode)
  183.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  184. point:"))
  185.   (command "-insert" "AS BUILT" userinsertionpoint "" "")
  186.     )
  187.    )
  188.    ((= "B17" usercode)
  189.     (and (setq userinsertionpoint (getpoint "\nSpecify insertion
  190. point:"))
  191.   (command "-insert"    "Revised Stamp" userinsertionpoint
  192.     ""     ""     ""
  193.    )
  194.     )
  195.    )
  196.    ((= "B18" usercode)
  197.     (and (setq userinsertionpoint
  198.   (getpoint "\nSpecify insertion point:")
  199.   )
  200.   (command "-insert"        "Manhole Paperspace2"
  201.     userinsertionpoint  "1"
  202.     "1" "0" ""        
  203.    )
  204.     )
  205.    )
  206.    ((= "B19" usercode)
  207.     (and (setq userinsertionpoint
  208.   (getpoint "\nSpecify insertion point:")
  209.   )
  210.   (command "-insert"        "Node Paperspace"
  211.     userinsertionpoint  
  212.     "1"         "1" "0" ""
  213.    )
  214.     )
  215.    )
  216.    ((= "B20" usercode)
  217.     (and (setq userinsertionpoint
  218.   (getpoint "\nSpecify insertion point:")
  219.   )
  220.   (command "-insert"        "Access Chamber Paperspace"
  221.     userinsertionpoint  "1"
  222.     "1" "0"    ""   
  223.    )
  224.     )
  225.    )
  226.    (T (alert "That is not a valid code"))
  227. )
  228. (command "_.purge" "_all" "" "_no")
  229. (command "_.purge" "_all" "" "_no")
  230. (command "_.purge" "_all" "" "_no")
  231. (command "_.purge" "_all" "" "_no")
  232. (princ "finished")
  233. (princ)
  234. )
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 09:07:27 | 显示全部楼层
我能听到尖叫声
 
键入名称有点过时,我使用菜单和sld图像,这很过时,但比记住块名要好,我们有大约200多个块
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-6 09:19:29 | 显示全部楼层
seegs,
 
请阅读代码发布指南并编辑您的帖子。
回复

使用道具 举报

3

主题

14

帖子

11

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 09:30:59 | 显示全部楼层
很好的一点,它们中的大多数都在工具选项板中,只是散落着过时的块。我想把它们分为一类是最好的办法。我只是觉得我应该尝试一个强硬的Lisp程序例程来提高我的技能。
顺便问一下,这些菜单和sld图像是关于什么的?
回复

使用道具 举报

3

主题

14

帖子

11

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 09:43:45 | 显示全部楼层
啊,我的错
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 09:50:43 | 显示全部楼层
它与hatch中的填充图案相同,但是有了块的图片,你可以在一个标题下有多个页面,并且有很多标题,我将尝试查找上一篇文章
 
这有一个例子
 
http://www.cadtutor.net/forum/showthread.php?30342-从cad库中查找自定义程序到插入块&高亮显示=幻灯片
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-6 09:59:27 | 显示全部楼层
 
请编辑您的帖子。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 06:03 , Processed in 0.407867 second(s), 66 queries .

© 2020-2025 乐筑天下

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