设为首页收藏本站

晓东CAD家园-论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 404|回复: 0

[其他] 使用AUTOLISP增加和删除扩展实体数据

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2021-1-8 13:21:01 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x



  1. --------------------------------------------------------------------------------
  2. ;; Adding and Removing Extended Entity Data
  3. ;;***cut here to end of file, and save in a ASCII text format to file **
  4. ;;************************** XM.lsp ************************************
  5. ;; Date: April 7, 1996
  6. ;; Written for R13
  7. ;; *** Example for adding and removing extended entity data. ***
  8. ;;
  9. ;; To see how this function works, place this code fragment
  10. ;; in a file named
  11. ;; XM.LSP and place the file in a directory that is in the
  12. ;; ACAD search path
  13. ;; or in the current AutoCAD directory.
  14. ;; Start a new drawing.
  15. ;; At the AutoCAD command line type: (load "XM") <return>
  16. ;; The function will then:
  17. ;; Register the applications name.
  18. ;; Create a circle with extended entity data associated with the
  19. ;; application name.
  20. ;; Print out the assoc code list for the circle entity.
  21. ;; Remove the extended entity data from the circle.
  22. ;; Then print out the assoc list again showing the extended data
  23. ;; removed.
  24. ;;
  25. ;; AutoLISP function used in this example:
  26. ;; regapp
  27. ;; entmake
  28. ;; setq
  29. ;; assoc
  30. ;; princ
  31. ;; subst
  32. ;; entmod
  33. ;; entget
  34. ;; entlast
  35. ;;
  36. ;; See the AutoCAD Customization Guide for information
  37. ;; on using these functions
  38. ;;
  39. ;; Date: 3/7/96
  40. ;;
  41. ;; AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  42. ;; AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  43. ;; MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
  44. ;; DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  45. ;; UNINTERRUPTED OR ERROR FREE.
  46. ;;

  47. (regapp "FREDS")
  48. (entmake ; makes entity
  49.     '((0 . "CIRCLE") ; entity type
  50.     (8 . "0") ; layer name
  51.     (62 . 3) ; color
  52.     (39 . 2.75) ; thickness
  53.     (10 8.0 6.0 0.0) ; center point
  54.     (40 . 2.0) ; radius
  55.     ; create and add xdata
  56.     (-3 ("FREDS" (1002 . "{")
  57.                           (1000 . "This is my data")

  58.                           (1000 . "More Data")
  59.                           (1000 . "and some more data")
  60.                           (1040 . 12.345)
  61.                           (1010 8.97197 6.8436 0.0)
  62.                           (1040 . 2.75013)
  63.                           (1002 . "}")))
  64.     )
  65. )
  66. (Setq a (entget (entlast) '("FREDS")))
  67. ;; gets the assoc list with attached
  68. ;; extended entity data that belongs
  69. ;; to the regapp "FREDS"

  70. (princ a) ;; prints assoc list to screen
  71. (princ "\n\n") ;; two blank lines

  72. (setq z (assoc -3 a)) ;; save xdata that belongs to the
  73. ;; regapp "FREDS" to z variable

  74. (setq a (subst'(-3 ("FREDS")) (assoc -3 a) a)) ;; new assoc list without
  75. ;; xdata. The -3 assoc code has only
  76. ;; the regapp name without any data.
  77. ;; This gets substituted for the assoc
  78. ;; -3 list that has data.

  79. (entmod a) ;; modifies entity removing the
  80. ;; xdata because feeding a entmod
  81. ;; an assoc list with only the regapp
  82. ;; name for the -3 assoc code removes
  83. ;; the extended entity data from the
  84. ;; entity.

  85. (Setq a (entget (entlast) '("FREDS")))
  86. ;; gets the new assoc list to verify
  87. ;; the xdata has been removed

  88. (princ a) ;; prints the new assoc list without
  89. ;; the xdata to screen.


论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|小黑屋|手机版|Archiver|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )  

GMT+8, 2021-10-21 18:34 , Processed in 0.822825 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表