乐筑天下

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

[编程交流] 自动加载lisp

[复制链接]

8

主题

45

帖子

37

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-6 07:29:51 | 显示全部楼层 |阅读模式
嗨,伙计们
 
我为office开发了一个简单的电子表格,列出了我多年来收集的lisp例程,我认为这些例程非常有用。在电子表格中,有文件名、类别、描述栏,以及一些其他信息,用于链接到如何使用lisp的在线说明。目前,我只有*。lsp文件位于网络上的一个文件夹中,因此任何人都可以加载它。我只是想知道是否有可能在这些按钮旁边放一个按钮,或者一个链接,可以自动将lisp例程安装/加载到AutoCAD上以供永久使用?或者这会很复杂?我没有任何编程经验。
回复

使用道具 举报

44

主题

542

帖子

502

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
220
发表于 2022-7-6 07:36:21 | 显示全部楼层
在AutoCad中,您可以使用工具=>加载应用程序=>启动套件内容并将其添加到其中。然后,每次AutoCad启动时,这些LISP都会添加到laod中。
 
因此,如果只有少数用户,您可以这样做(它甚至可以指向网络上的lisp文件,因此如果您更新它,它将为所有用户更新等等)。
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 07:37:28 | 显示全部楼层
请点击此处查看其他选项。
使用Excel构建acaddoc。lsp文件,不要忘记将其保存为简单的ASCII文件。在所有工作站上使用相同的字母映射所述网络驱动器将非常有用。
回复

使用道具 举报

8

主题

45

帖子

37

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-6 07:42:36 | 显示全部楼层
 
是的,我知道如何加载lisps,我只是想知道是否有一种自动化的方法。所以,只要有人按下一个按钮,它就会为你做一切。我觉得这是一个很酷的小功能。
 
此外,我还尝试在“acaddoc.lsp”文件中加载多个Lisp。它启动第一个lisp,但不启动第二个lisp。你必须在他们之间放一个分隔物吗?
回复

使用道具 举报

5

主题

1074

帖子

1088

银币

初来乍到

Rank: 1

铜币
9
发表于 2022-7-6 07:46:55 | 显示全部楼层
如果你喜欢Lisp程序的套路,但像我一样,Lisp程序的挑战,我建议你去李Mac的网站,看看很多很棒的东西。
我最喜欢的一个是图层控制器,试试,你会喜欢的。谢谢李!
这只是李慷慨提供的众多方案之一。
回复

使用道具 举报

8

主题

45

帖子

37

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-6 07:48:32 | 显示全部楼层
是的,我用的很多Lisp程序是李·麦克斯。层控制器很棒!!我将把它推广到办公室的电脑上。特别适合工程师,因为他们从不分层!!!!!
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 07:53:53 | 显示全部楼层
你能把文件的第一行贴出来试着调试一下吗?
回复

使用道具 举报

8

主题

45

帖子

37

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-6 07:55:35 | 显示全部楼层
我在我的“acaddoc.lsp”文件中添加了2个lisp,第一个lisp“grd”在打开autoCAD会话时可以正常工作,但图层控制器不工作,文件显示(第一部分是我的公司编码):
 
  1. (if
  2. (and
  3. (not (menugroup "mmacad"))
  4. (findfile "mmacad.cuix")
  5. );and
  6. (command "menuload" "mmacad.cuix")
  7. );if
  8. (and
  9. (menugroup "mmacad")
  10. (menucmd "p50=+MMACAD.POP1")
  11. );and
  12. (setvar "SAVETIME" 10)
  13. (setvar "layernotify" 0)
  14. (setvar "layereval" 0)
  15. (defun c:grd()
  16. (setvar "cmdecho" 0)
  17. (setq osm (getvar "osmode"))
  18. (setvar "osmode" 0)
  19. (setq p1 (getpoint "\nLower left corner point: ")
  20.      p2 (getcorner p1 "\nOpposite corner: ")
  21. xd (abs (- (car p2)(car p1)))
  22. yd (abs (- (cadr p2)(cadr p1)))
  23. st (getdist "\nStep : ")
  24. nx (fix (/ xd st))
  25. ny (fix ( / yd st))
  26. )
  27. (if (or (>= st (/ xd 2))(>= st (/ yd 2)))
  28. (progn
  29. (alert "Wrong parameters defined")(exit)(princ)))
  30. (command "rectang" p1 p2)
  31. (setq r1 (list (car p1)(+ (cadr p1) st)(caddr p1))
  32. r2 (list (car p2)(cadr r1)(caddr p2)))
  33. (command "pline" r1 r2 "")
  34. (command "array" "L" "" "R" ny 1 st "")
  35.   (setq c1 (list (+ (car p1)st)(cadr p1)(caddr p1))
  36. c2  (list (car c1)(cadr p2)(caddr p2)))
  37. (command "pline" c1 c2 "")
  38. (command "array" "L" "" "R" 1 nx st "")
  39. (setvar "cmdecho" 1)
  40. (setvar "osmode" osm)
  41. )This one should create simmetric grid:
  42. Code:
  43.            (defun C:GCL (/)
  44. ;;-------------------=={ Layer Director }==-------------------;;
  45. ;;                                                            ;;
  46. ;;  Uses a Command Reactor to automatically set the active    ;;
  47. ;;  layer upon the user invoking a command.                   ;;
  48. ;;                                                            ;;
  49. ;;  Layer settings are stored in the list at the top of the   ;;
  50. ;;  program. The first entry in the list is the command on    ;;
  51. ;;  which the reactor will trigger, it may use wildcards.     ;;
  52. ;;  The second entry is the name of the layer to be set when  ;;
  53. ;;  the command is called, this layer will be created if      ;;
  54. ;;  not present in the active drawing.                        ;;
  55. ;;                                                            ;;
  56. ;;  The Director is enabled upon loading this program.        ;;
  57. ;;  It may be manually switched ON and OFF by typing          ;;
  58. ;;  'LDON' and 'LDOFF' respectively at the command line.      ;;
  59. ;;------------------------------------------------------------;;
  60. ;;  Author: Lee Mac, Copyright © 2012 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url]       ;;
  61. ;;------------------------------------------------------------;;
  62. ;;  Version 1.1    -    24-04-2012                            ;;
  63. ;;------------------------------------------------------------;;
  64. ;;------------------------------------------------------------;;
  65. ;;  Layer Data                                                ;;
  66. ;;  ========================================================  ;;
  67. ;;                                                            ;;
  68. ;;  Populate this list with commands for which the current    ;;
  69. ;;  layer should be changed.                                  ;;
  70. ;;                                                            ;;
  71. ;;  The first item is the name of a command that will cue a   ;;
  72. ;;  layer change. The command name should be the full command ;;
  73. ;;  name, not an alias. This command name is not              ;;
  74. ;;  case-sensitive and may use wildcards.                     ;;
  75. ;;                                                            ;;
  76. ;;  e.g. "[DM]TEXT,TEXT" will cue a layer change for the      ;;
  77. ;;  Text, DText and MText commands.                           ;;
  78. ;;                                                            ;;
  79. ;;  e.g. "*LEADER" will cue a layer change for the Leader,    ;;
  80. ;;  QLeader and MLeader commands.                             ;;
  81. ;;                                                            ;;
  82. ;;  The second item is the name of the Layer to be set to     ;;
  83. ;;  current when the command is called. This layer will be    ;;
  84. ;;  created if not present in the active drawing.             ;;
  85. ;;------------------------------------------------------------;;
  86. (setq *LayerDirector-LayerData*
  87.   '(
  88. ;;        COMMAND           LAYER NAME                        ;;
  89.        ("[DM]TEXT,TEXT"   "MM-Text"      )
  90.        ("DIM*"            "MM-Dims")
  91.        ("*VPORT*"         "MM-Vport" )
  92.        ("*LEADER"         "MM-Text")
  93.    )
  94. )
  95. ;;------------------------------------------------------------;;
  96. ;;  Print Command Debug Mode  [ t / nil ]                     ;;
  97. ;;  ========================================================  ;;
  98. ;;                                                            ;;
  99. ;;  If set to T the program will print the command name when  ;;
  100. ;;  a command is called. This is useful when determining      ;;
  101. ;;  the correct command name to use in the Layer Data list.   ;;
  102. ;;------------------------------------------------------------;;
  103. (setq *PrintCommand* nil)
  104. ;;------------------------------------------------------------;;
  105. ;;  Commands:  [ LDON / LDOFF ]                               ;;
  106. ;;  ========================================================  ;;
  107. ;;                                                            ;;
  108. ;;  Use these to manually turn the Layer Director on & off.   ;;
  109. ;;------------------------------------------------------------;;
  110. (defun c:LDON  nil (LM:LayerDirector  t ))
  111. (defun c:LDOFF nil (LM:LayerDirector nil))
  112. ;;------------------------------------------------------------;;
  113. (defun LM:LayerDirector ( on / reactor )
  114.    (setq reactor
  115.        (car
  116.            (vl-member-if
  117.                (function
  118.                    (lambda ( reactor )
  119.                        (eq "LayerDirector" (vlr-data reactor))
  120.                    )
  121.                )
  122.                (cdar (vlr-reactors :vlr-command-reactor))
  123.            )
  124.        )
  125.    )
  126.    (if on
  127.        (if reactor
  128.            (if (vlr-added-p reactor)
  129.                (princ "\nLayer Director already running.")
  130.                (progn
  131.                    (vlr-add reactor)
  132.                    (princ "\nLayer Director Enabled.")
  133.                )
  134.            )
  135.            (progn
  136.                (vlr-command-reactor "LayerDirector"
  137.                   '(
  138.                        (:vlr-commandwillstart . LM:LayerDirector-Set)
  139.                        (:vlr-commandended     . LM:LayerDirector-Reset)
  140.                        (:vlr-commandcancelled . LM:LayerDirector-Reset)
  141.                        (:vlr-commandfailed    . LM:LayerDirector-Reset)
  142.                    )
  143.                )
  144.                (princ "\nLayer Director Enabled.")
  145.            )
  146.        )
  147.        (if reactor
  148.            (progn
  149.                (vlr-remove reactor)
  150.                (princ "\nLayer Director Disabled.")
  151.            )
  152.            (princ "\nLayer Director not running.")
  153.        )
  154.    )
  155.    (princ)
  156. )
  157. (defun LM:LayerDirector-Set ( reactor params / layer tmp )
  158.    (if
  159.        (and
  160.            (setq params (strcase (car params)))
  161.            (setq layer
  162.                (cadar
  163.                    (vl-member-if
  164.                        (function
  165.                            (lambda ( item )
  166.                                (wcmatch params (strcase (car item)))
  167.                            )
  168.                        )
  169.                        *LayerDirector-LayerData*
  170.                    )
  171.                )
  172.            )
  173.            (setq tmp (LM:LayerDirector-CreateLayer layer))
  174.            (zerop (logand 1 (cdr (assoc 70 tmp))))
  175.        )
  176.        (progn
  177.            (setq *LayerDirector-OldLayer* (getvar 'clayer))
  178.            (setvar 'clayer layer)
  179.        )
  180.    )
  181.    (if *PrintCommand* (print params))
  182.    (princ)
  183. )
  184. (defun LM:LayerDirector-Reset ( reactor params / tmp )
  185.    (if
  186.        (and
  187.            (not (wcmatch (strcase (car params)) "U,UNDO"))
  188.            *LayerDirector-OldLayer*
  189.            (setq tmp (tblsearch "LAYER" *LayerDirector-OldLayer*))
  190.            (zerop (logand 1 (cdr (assoc 70 tmp))))
  191.        )
  192.        (progn
  193.            (setvar 'clayer *LayerDirector-OldLayer*)
  194.            (setq *LayerDirector-OldLayer* nil)
  195.        )
  196.    )
  197.    (princ)
  198. )
  199. (defun LM:LayerDirector-CreateLayer ( name )
  200.    (cond
  201.        (   (tblsearch "LAYER" name))
  202.        (   (entmake
  203.                (list
  204.                   '(0 . "LAYER")
  205.                   '(100 . "AcDbSymbolTableRecord")
  206.                   '(100 . "AcDbLayerTableRecord")
  207.                    (cons 2 name)
  208.                   '(70 . 0)
  209.                )
  210.            )
  211.        )
  212.    )
  213. )
  214. ;;------------------------------------------------------------;;
  215. (vl-load-com)
  216. (LM:LayerDirector t)  ;; Director will run when loaded.
  217. (princ)
  218. ;;------------------------------------------------------------;;
  219. ;;                         End of File                        ;;
  220. ;;------------------------------------------------------------;;
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 08:01:12 | 显示全部楼层
可以肯定的是,这是你的阿卡多克的内容。lsp文件?我认为最好将所有例程定义保存在自己的文件中,并在acaddoc中调用它们。lsp。例子:
  1. (load "C:\\MyAutoLISPTools\\Routine1st.LSP" (prompt "\nUnable to load Routine1st!"))
  2. (load "C:\\MyAutoLISPTools\\Routine2nd.LSP" (prompt "\nUnable to load Routine2nd!"))
  3. ...
  4. (princ)

 
关于发布的代码,存在不平衡的偏执;更准确地说,这个定义不是封闭的:
  1. (defun C:GCL (/)
回复

使用道具 举报

8

主题

45

帖子

37

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-6 08:03:53 | 显示全部楼层
谢谢MSasu
 
好的,我已经更新了阿卡多克。lsp,但当我打开AutoCAD时,LISP没有加载,它显示:
 
  1. (if
  2. (and
  3. (not (menugroup "mmacad"))
  4. (findfile "mmacad.cuix")
  5. );and
  6. (command "menuload" "mmacad.cuix")
  7. );if
  8. (and
  9. (menugroup "mmacad")
  10. (menucmd "p50=+MMACAD.POP1")
  11. );and
  12. (setvar "SAVETIME" 10)
  13. (setvar "layernotify" 0)
  14. (setvar "layereval" 0)
  15. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\attnumber.lsp (prompt "\nUnable to load Routine1st!"))
  16. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\BlkImport.lsp (prompt "\nUnable to load Routine1st!"))
  17. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\ChangeBlockInsertionV1-3.lsp (prompt "\nUnable to load Routine1st!"))
  18. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\copyinc.lsp (prompt "\nUnable to load Routine1st!"))
  19. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\dimcurve.lsp (prompt "\nUnable to load Routine1st!"))
  20. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\fa.lsp (prompt "\nUnable to load Routine1st!"))
  21. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\fixtxt.lsp (prompt "\nUnable to load Routine1st!"))
  22. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\grd.lsp (prompt "\nUnable to load Routine1st!"))
  23. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\insertall.lsp (prompt "\nUnable to load Routine1st!"))
  24. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\LabelV1-1.lsp (prompt "\nUnable to load Routine1st!"))
  25. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\LayerDirectorV1-1[1].lsp (prompt "\nUnable to load Routine1st!"))
  26. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\LayoutTools.lsp (prompt "\nUnable to load Routine1st!"))
  27. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\LDOrderV1-2.lsp (prompt "\nUnable to load Routine1st!"))
  28. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\Legend.lsp (prompt "\nUnable to load Routine1st!"))
  29. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\List block.lsp (prompt "\nUnable to load Routine1st!"))
  30. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\ll.lsp (prompt "\nUnable to load Routine1st!"))
  31. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\MaskV1-0.lsp (prompt "\nUnable to load Routine1st!"))
  32. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\normblocks.lsp (prompt "\nUnable to load Routine1st!"))
  33. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\num.lsp (prompt "\nUnable to load Routine1st!"))
  34. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\ple.lsp (prompt "\nUnable to load Routine1st!"))
  35. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\plen.lsp (prompt "\nUnable to load Routine1st!"))
  36. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\pline-3d-2d.lsp (prompt "\nUnable to load Routine1st!"))
  37. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\pllen.lsp (prompt "\nUnable to load Routine1st!"))
  38. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\polylen.lsp (prompt "\nUnable to load Routine1st!"))
  39. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\pst.lsp (prompt "\nUnable to load Routine1st!"))
  40. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\pt2blk.lsp (prompt "\nUnable to load Routine1st!"))
  41. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\PtManagerV2-4[1].lsp (prompt "\nUnable to load Routine1st!"))
  42. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\reorderpoints.lsp (prompt "\nUnable to load Routine1st!"))
  43. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\StripMtext v5-0c.lsp (prompt "\nUnable to load Routine1st!"))
  44. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\super.lsp (prompt "\nUnable to load Routine1st!"))
  45. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\SuperFlatten 1.2b.lsp (prompt "\nUnable to load Routine1st!"))
  46. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\t2m.lsp (prompt "\nUnable to load Routine1st!"))
  47. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\TL.lsp (prompt "\nUnable to load Routine1st!"))
  48. (load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\TrailpitswithTable.LSP (prompt "\nUnable to load Routine1st!"))
  49. (princ)
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 04:08 , Processed in 0.474919 second(s), 83 queries .

© 2020-2025 乐筑天下

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