找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 917|回复: 0

[他山之石] Using an ARX ActiveX server to update the block description from LISP

[复制链接]
发表于 2013-6-2 10:36:56 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 Free-Lancer 于 2013-6-2 10:38 编辑

Using an ARX ActiveX server to update the block description from LISPBy Xiaodong Liang
Issue      
How can I update the Description Field in the Block Definition using lisp ? Using the Lisp entmod function does not seem to work.

Solution      
The only way to do this at present is to use the ActiveX server exposed in the adskUnSupp arx utility, the latest utility for AutoCAD 2013 is available at

ADN AutoCAD Utilities

With that ARX, and the following lisp code which loads the ARX module, connects to the ActiveX interface from adskUnSupp ARX, and loads it's type library to enable the Block Description Property to be set directly via a lisp function call.
  1. ;assume the utilities are installed at
  2. ; C:\Program Files\Autodesk\ADNUtilities2013_X64\AutoCADControls\

  3. (defun RunAcadUnSupp (/ rtn )
  4. (if (null (setq rtn (member "AsdkUnsupp2013.arx" (arx)))) (setq rtn (arxload
  5. "asdkunsupp2007.arx")))
  6. (if (null rtn)
  7.    (progn
  8.      (princ "\nAsdkUnsupp2013.arx Not Loaded, Exiting.")
  9.      (exit)
  10.    )
  11. )
  12. (vl-load-com)
  13. (setq AcadApp (vlax-get-acad-object))
  14. ;;; Change the Path to adskUnSupp2007 here ->
  15. (setq unSupp_ARXPath "C:\\Program Files\\Autodesk\\ADNUtilities2013_X64\\AutoCADControls\\")
  16. (if (null unsupM-AddAnonymousGroup)
  17.     (if (findfile (strcat unSupp_ARXPath "AsdkUnsupp2013.arx"))
  18.     (vlax-import-type-library
  19.      :tlb-filename
  20.      (strcat unSupp_ARXPath "AsdkUnsupp2013.arx")
  21.      :methods-prefix
  22.      "unsupM-"
  23.      :properties-prefix
  24.      "unsupP-"
  25.      :constants-prefix
  26.      "unsupC-"
  27.     )
  28.    (progn
  29.      (alert (strcat "Exiting - Can't find "" unSupp_ARXPath
  30. "asdkunsupp2007.arx" """))
  31.      (exit)
  32.    )
  33. )
  34. )
  35. (setq unSuppX (vla-GetInterfaceObject acadApp "Asdkunsupp2007.Application.1"))
  36. (setq AcadDoc (vla-Get-ActiveDocument AcadApp))
  37. (setq UtilObj (vla-Get-Utility AcadDoc))
  38. (setq Blocks (vla-Get-Blocks AcadDoc))
  39. (vla-GetEntity UtilObj 'BlockRefObj 'selPt "\nSelect a Inserted Block: ")
  40. (if (equal
  41.     (setq ObjType (vla-Get-ObjectName BlockRefObj))
  42.     "AcDbBlockReference"
  43.      )
  44.       (progn
  45.      (setq BlkName (vla-Get-Name BlockRefObj))
  46.      (setq BlkObject (vla-Item Blocks BlkName))
  47.      (setq exBlkDescriptn (unsupP-Get-BlockDescription unSuppX BlkObject))
  48.      (setq aNewDescriptn (getString T (strcat "\nEnter New Block
  49. Description<" exBlkDescriptn ">:")))
  50.      (if (and aNewDescriptn (not (equal aNewDescriptn "")))
  51.         (unsupP-Put-BlockDescription unSuppX BlkObject aNewDescriptn)
  52.      )  
  53.       )
  54.    )
  55.    (CleanUpOnExit)
  56. )

  57. (defun CleanUpOnExit ()

  58. (if BlockRefObj (progn (vlax-Release-Object BlockRefObj) (setq BlockRefObj
  59. nil)))
  60. (if Blocks (progn (vlax-Release-Object Blocks) (setq Blocks nil)))
  61. (if UtilObj (progn (vlax-Release-Object UtilObj) (setq UtilObj nil)))
  62. (if AcadDoc (progn (vlax-Release-Object AcadDoc) (setq AcadDoc nil)))
  63. (if unSuppX (progn (vlax-Release-Object unSuppX) (setq unSuppX nil)))
  64. (if AcadApp (progn (vlax-Release-Object AcadApp) (setq AcadApp nil)))
  65. (princ)
  66. )

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

本版积分规则

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

GMT+8, 2024-11-15 20:10 , Processed in 0.352670 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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