乐筑天下

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

[编程交流] 定制acaddoc。lsp

[复制链接]

12

主题

48

帖子

40

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 12:13:09 | 显示全部楼层 |阅读模式
大家好!
 
因此,我正在努力最终开始找出AutoCAD的编码和变量。我当前的项目是创建一个启动lisp,用于设置新图形和/或现有图形的所有值。我已经正确配置了所有命令,但是,有没有办法不让它输出它更改的设置?基本上,当您启动图形(新/旧)时,它会实现所有更改,但命令行不会显示该过程。
 
其次,在阿卡多克内部。lsp,我希望最后一个命令在用户继续之前调用自定义LISP:
  1. (command "DWG")

在阿卡多克结束的时候,我一直收到一个错误。lsp:
  1. Enter new value for SPLINESEGS <20>: 20 FACETRES
  2. Enter new value for FACETRES <10.0000>: 10 ISOLINES
  3. Enter new value for ISOLINES <10>: 20 [b]DWG Unknown command "DWG".  Press F1 for
  4. help.[/b]

我不知道在《阿卡多克》结束时调用LISP缺少了什么。LSP。
 
这是整个阿卡多克。lsp:
  1. ;
  2. ;
  3. ;North American Stone Drawing Set Up
  4. ;
  5. ;
  6. ;---------------------
  7. ;LISP Loads
  8. ;
  9. (autoload "autoDPROP" '("autoDPROP"))
  10. (autoload "nasc_props" '("nasc_props" "dwg"))
  11. ;ENVIRONMENT
  12. (command "base" "0,0,0")
  13. (setvar "osmode" 6255)
  14. (command "-INSERT" "Z_STD_SETUP" "0,0" "1" "" "0")
  15. (command "ERASE" "L" "")
  16. (command "-STYLE" "SHEET" "tahoma.TTF" "0" "1" "0" "N" "N")
  17. (command "-LAYER" "S" "0-STONE" "")
  18. (command "-DIMSTYLE" "R" "16")
  19. (command "LTSCALE" "6")
  20. (command "PDMODE" "3")
  21. (command "PDSIZE" "0")
  22. (command "-HATCH" "P" "AR-SAND" "0.25" "0" "")
  23. (command "-UNITS" "4" "16" "1" "0" "0" "N")
  24. (command "VIEWRES" "Y""20000")
  25. (command "SPLINESEGS" "20")
  26. (command "FACETRES" "10")
  27. (command "ISOLINES" "20")
  28. (c:dwg)

 
我至少走对了吗???
回复

使用道具 举报

48

主题

1073

帖子

1043

银币

后起之秀

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

铜币
238
发表于 2022-7-6 12:17:43 | 显示全部楼层
它告诉您,AutoCAD没有已知的名为“DWG”的命令
 
我假设您正在尝试启动一个名为dwg的lisp文件,在这种情况下,您需要先加载它。我在这里猜测,但尝试一下(类似)
 
  1. (load "DWG")
  2. DWG
回复

使用道具 举报

12

主题

48

帖子

40

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 12:21:35 | 显示全部楼层
我的道歉。。。是的,我正在尝试加载自定义LISP。我应该解释一下,我在命令集中有这个功能。
  1. (autoload "nasc_props" '("nasc_props"))

 
nasc_props是使用DWG命令的lisp:
  1. (defun C:DWG ()
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

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

铜币
362
发表于 2022-7-6 12:23:55 | 显示全部楼层
首先,通常不能*调用这样的外部定义的lisp命令(命令“dwg”)[*例外情况是使用(vlax add cmd)]
 
其次,如果要自动加载“nasc_props”,并且该文件包含“Dwg”函数,则需要将“Dwg”添加到(autoload)调用的第二个参数中,如下所示:
 
  1. (autoload "nasc_props" '("nasc_props" "dwg"))

 
最后,要调用此函数,可以执行以下操作:
 
  1. (c:dwg)
回复

使用道具 举报

12

主题

48

帖子

40

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 12:26:08 | 显示全部楼层
我将代码更改为您显示的代码,并编辑了我的原始帖子以反映这些更改。现在我得到以下信息:
  1. Job Number:*Cancel*
  2. Job Number:
  3. Command: *Cancel*
  4. Function cancelled

 
进一步讨论我试图自动调用的lisp的描述,我附上下面的代码。此lisp旨在要求用户在命令行上输入自定义DWGPROPS信息。阿卡多克之后。lsp完成,nasc_道具。lsp工作正常。
 
这是从属lisp(在acaddoc.lsp中命名为AutoDPROP.lsp)
  1. ;;; *********************************************** *************************
  2. ;;; * Library DWGruLispLib Copyright © 2007 DWGru Programmers Group
  3. ;;; *
  4. ;;; * _dwgru-Dwgprops-get-all-prop
  5. ;;; *
  6. ;;; * 27/12/2007 Version 0001. Vladimir Azarko (VVA)
  7. ;;; *********************************************** *************************
  8. (defun _dwgru-dwgprops-get-all-prop (Doc / si ret nc key value)
  9. ;;; Returns the file's properties, set the team _dwgprops
  10. ;;; Returns an associative list, where the key is:
  11. ;; - For properties created by the user (tab OTHER)
  12. ;;; Property name
  13. ;; - For standard properties (tab PAPER)
  14. ;;; Key field
  15. ;;; NAME - *TITLE*
  16. ;;; AUTHOR - *AUTHOR*
  17. ;;; TOPIC - *SUBJECT*
  18. ;;; KEY WORDS - *KEYWORDS*
  19. ;;; NOTES - *COMMENTS*
  20. ;;; Hyperlink Base - *HYPERLINK*
  21. ;;;!! Key fields are converted to uppercase
  22. ;;; Doc - a pointer to the PDF document, nil - the current
  23.   
  24. ;;; Example
  25. ;;; (_dwgru-dwgprops-get-all-prop nil) ;;;(("* AUTHOR * "" VVA ") (" * COMMENTS * "" Memo ") (" * HYPERLINK * "" Base ")
  26.                                ;;;("* KEYWORDS * "" Key ") (" * TITLE * "" named ") (" * SUBJECT * "" R ") (" UNIQKEY "" Key "))
  27. (and
  28. (or Doc
  29.    (setq Doc (vla-get-activeDocument (vlax-get-acad-object)))
  30.    )
  31. (setq si (vla-get-SummaryInfo Doc))
  32. (setq ret (list
  33.     (list "*AUTHOR*" (vla-get-author si))
  34.     (list "*COMMENTS*" (vla-get-comments si))
  35.            (list "*HYPERLINK*" (vla-get-HyperlinkBase si))
  36.     (list "*KEYWORDS*" (vla-get-keywords si))
  37.            (list "*TITLE*" (vla-get-Title si))
  38.     (list "*SUBJECT*" (vla-get-Subject si))
  39.     )
  40. )
  41. (setq nc (vla-numcustominfo si))
  42. (while (> nc 0)
  43. (vla-GetCustomByIndex si (- nc 1) 'key 'value)
  44. (setq ret (append ret (list(list (strcase key) value))))  
  45. (setq nc (1- nc))
  46. )
  47. (vlax-release-object si)
  48. )
  49. ret
  50. )   
  51. ;;; *********************************************** *************************
  52. ;;; * Library DWGruLispLib Copyright © 2007 DWGru Programmers Group
  53. ;;; *
  54. ;;; * _dwgru-Dwgprops-get-custom-prop
  55. ;;; *
  56. ;;; * 27/12/2007 Version 0001. Vladimir Azarko (VVA)
  57. ;;; *********************************************** *************************
  58. (defun _dwgru-dwgprops-get-custom-prop (key Doc / app counter counter2 counter3 doc dwgprops kv)
  59. ;;; Returns the value of the property created by the user (team _dwgprops)
  60. ;;; Returns an associative list, where the key is:
  61. ;; - For properties created by the user (tab OTHER)
  62. ;;; Key - a string property name (tab OTHER)
  63. ;; - For standard properties (tab PAPER)
  64. ;;; Key field
  65. ;;; NAME - *TITLE*
  66. ;;; AUTHOR - *AUTHOR*
  67. ;;; TOPIC - *SUBJECT*
  68. ;;; KEY WORDS - *KEYWORDS*
  69. ;;; NOTES - *COMMENTS*
  70. ;;; Hyperlink Base - *HYPERLINK*
  71. ;;;
  72. ;;; Uses the library
  73. ;;; _dwgru-Dwgprops-get-all-prop
  74. ;;; _dwgru-Assoc (_dwgru-assoc-multi)
  75.   
  76. ;;; Doc - a pointer to the PDF document, nil - the current
  77.   
  78. (cadr (_dwgru-assoc key (_dwgru-dwgprops-get-all-prop Doc)))
  79. )
  80. ;;; *********************************************** *************************
  81. ;;; * Library DWGruLispLib Copyright © 2007 DWGru Programmers Group
  82. ;;; *
  83. ;;; * _dwgru-Dwgprops-set-custom-prop
  84. ;;; *
  85. ;;; * 27/12/2007 Version 0001. Vladimir Azarko (VVA)
  86. ;;; *********************************************** *************************
  87. (defun _dwgru-dwgprops-set-custom-prop (key value Doc / si)
  88. ;;, Create in the properties of the figure (team _dwgprops bookmark OTHER)
  89. ;;; Property with key and value value
  90. ;;; If the property was not, it is created, otherwise the changes
  91. ;;; Key - a string property name (tab OTHER)
  92. ;;; Value - a string (string) - value of property
  93. ;;; Uses the library
  94. ;;; _dwgru-Dwgprops-get-custom-prop
  95. ;;; Doc - a pointer to the PDF document, nil - the current
  96. ;;; Returns - nil
  97. ;;; Example
  98. ;;; (_dwgru-dwgprops-set-custom-prop "dwgru" "dwgru-dwgprops-set-custom-prop" nil)
  99.   (or Doc
  100.   (setq Doc (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
  101.     )
  102.   (setq si (vla-Get-SummaryInfo Doc))
  103.   (if (_dwgru-dwgprops-get-custom-prop key Doc)
  104.     (vla-SetCustomByKey si key value)
  105.     (vla-AddCustomInfo si key value)
  106.   )
  107. )
  108. (defun _dwgru-assoc-multi (key lst)
  109.   (if (= (type key) 'str)
  110.     (setq key (strcase key))
  111.     ); _ End of if
  112.   (vl-remove-if-not
  113.     (function
  114.       (lambda (a / b)
  115.         (and (setq b (car a))
  116.              (or (and (= (type b) 'str) (= (strcase b) key)) (equal b key))
  117.              ); _ End of and
  118.         ); _ End of lambda
  119.       ); _ End of function
  120.     lst
  121.     ); _ End of vl-remove-if-not
  122.   ); _ End of defun
  123. (defun _dwgru-assoc (key lst)
  124.   (car (_dwgru-assoc-multi key lst))
  125.   ); _ End of defun

 
这是nasc_的道具。lsp
  1. ;;; *********************************************** *************************
  2. ;;; * NASC Field Properties*
  3. ;;; *
  4. ;;  *Allows user to type in job info in command bar*
  5. ;;  *for use with the FIELDS in the titleblock*
  6. ;;; *
  7. ;;  *For North American Stone Company*
  8. ;;; *
  9. ;;; * 11/09/2009 Version 0001. Vladimir Azarko (VVA)
  10. ;;; *********************************************** *************************
  11. (defun C:DWG ()
  12. (vl-load-com) ;;; Do not forget to add
  13.   (setq str (getstring t "\nJob Number:"))
  14.   (_dwgru-dwgprops-set-custom-prop "Job Number" str nil)
  15.   (setq str (getstring "\nCustomer:"))
  16.   (_dwgru-dwgprops-set-custom-prop "Customer" str nil)
  17.   (setq str (getstring t "\nAddress:"))
  18.   (_dwgru-dwgprops-set-custom-prop "Address" str nil)
  19.   (setq str (getstring t "\nCity St:"))
  20.   (_dwgru-dwgprops-set-custom-prop "City St" str nil)
  21.   (setq str (getstring t "\nColor:"))
  22.   (_dwgru-dwgprops-set-custom-prop "Color" str nil)
  23.   (setq str (getstring t "\nDrawn By:"))
  24.   (_dwgru-dwgprops-set-custom-prop "Drawn By" str nil)  
  25.   (setq str (getstring t "\nDelivery Date:"))
  26.   (_dwgru-dwgprops-set-custom-prop "Delivery Date" str nil)
  27.   (setq str (getstring t "\nDrawing Date:"))
  28.   (_dwgru-dwgprops-set-custom-prop "Drawing Date" str nil)
  29.   (setq str (getstring t "\nFinish:"))
  30.   (_dwgru-dwgprops-set-custom-prop "Finish" str nil)
  31.   )
回复

使用道具 举报

12

主题

48

帖子

40

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 12:31:50 | 显示全部楼层
 
有没有更好的方法可以在打开或新建图形时自动调用Lisp?
回复

使用道具 举报

49

主题

1246

帖子

1210

银币

后起之秀

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

铜币
254
发表于 2022-7-6 12:34:23 | 显示全部楼层
是的,只需加载LSP文件本身的路径,使用双反斜杠而不是单反斜杠来分隔目录层次结构。例如:
这是一个名为“fixblock.lsp”的Lisp文件,我们都在我的办公室使用。它位于联网的K驱动器上。只需像加载每个Lisp文件一样输入这段代码,然后每次打开或创建新图形时,它都会出现。
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

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

铜币
362
发表于 2022-7-6 12:37:24 | 显示全部楼层
 
调用(运行),还是仅仅加载?
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 12:38:57 | 显示全部楼层
 
 
Tannar,您应该始终在所有加载函数的末尾添加nil或“Some Message”。如果在上面的代码中找不到该文件,它将出错并且不会继续(在您的情况下,您只有一件事,但仍然)。
 
例子:
  1. Command: (load "asldkfj")
  2. Error: LOAD failed: "asldkfj"
  3. Command: (load "asldkfj" nil)
  4. nil
  5. Command: (load "asldkfj" "")
  6. ""
回复

使用道具 举报

49

主题

1246

帖子

1210

银币

后起之秀

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

铜币
254
发表于 2022-7-6 12:42:46 | 显示全部楼层
是的,我肯定把我所有的东西都修好了,这是肯定的,哈哈。我会这么做,因为你说,但我不是程序员。当然,如果某个东西加载不正确,显然我知道该去哪里找到它。。。。不过谢谢你的提示。总是受到像你这样的专业人士的赞赏。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 10:12 , Processed in 0.691126 second(s), 72 queries .

© 2020-2025 乐筑天下

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