找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1576|回复: 1

[他山之石] Activex方法创建带过滤表的选择集

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2013-8-22 09:39:49 | 显示全部楼层 |阅读模式

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

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

×
Making a filtered selection set using Visual LISP (ActiveX functions)
By Balaji Ramamoorthy
The ActiveX method SelectionSet.Select to create a filtered set of database objects that meet this criteria:
Block references, such as INSERT entities, and that have extended entity data that is registered under application name "MYAPP"
The plain AutoLISP expression is: (ssget "X" '((0 . "INSERT") (-3 ("MYAPP"))))
Here is the code using the ActiveX call :

  1. (defun c:myappSet ()
  2.   (vl-load-com)
  3.   (setq loAcad (vlax-get-acad-object)
  4.         loDoc (vla-get-activedocument loAcad)
  5.         loSelectionSet (vla-add (vla-get-selectionsets loDoc) "filtSet")
  6.   )
  7.   (setq filtArray (vlax-make-safearray vlax-vbInteger '(0 . 1))
  8.         filtVar (vlax-safearray-fill filtArray (list 0 1001))
  9.         filtType (vlax-make-variant filtVar (logior vlax-vbarray vlax-vbInteger))
  10.   )
  11.   (setq filtArray (vlax-make-safearray vlax-vbVariant '(0 . 1))
  12.         filtVar (vlax-safearray-fill filtArray (list "INSERT" "MYAPP"))
  13.         filtData (vlax-make-variant filtVar (logior vlax-vbarray vlax-vbVariant))
  14.   )
  15.   (vla-select loSelectionSet acSelectionSetAll nil nil filtType filtData)
  16.   (setq count (vla-get-count loSelectionSet))
  17.   (princ count)
  18.   (setq ssets (vla-get-selectionsets loDoc))
  19.   (vla-delete (vla-item ssets "filtSet"))
  20.   (princ)
  21. )


It is tempting for a Visual LISP developer to supply list arguments for the parameters filtType and filtData in the vla-select call, but ActiveX does not comprehend lists. The filtType parameter requires an array of integers while filtData is permitted to be a array of variant types.
For a closer examination of safearrays and variants, see the Visual LISP Developer's Guide. Refer to the section entitled "Converting AutoLISP Data Types to ActiveX Data Types".
Also, the group code designating xdata is 1001 instead of -3. This is different, of course, from the Visual LISP approach to filtering xdata, which makes use of the -3 extended data sentinel rather than group code.




论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2013-8-25 13:27:58 | 显示全部楼层
收藏啦。 VL函数还是了解不多。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-12-23 02:55 , Processed in 0.384938 second(s), 34 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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