找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 738|回复: 2

[他山之石] 构造ActiveX方式的过滤选择

[复制链接]
发表于 2013-5-27 07:50:29 | 显示全部楼层 |阅读模式

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

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

×
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
  10.                         filtVar
  11.                         (logior vlax-vbarray vlax-vbInteger)
  12.                     )
  13.     )
  14.     (setq filtArray (vlax-make-safearray vlax-vbVariant '(0 . 1))
  15.           filtVar   (vlax-safearray-fill filtArray (list "INSERT" "MYAPP"))
  16.           filtData  (vlax-make-variant
  17.                         filtVar
  18.                         (logior vlax-vbarray vlax-vbVariant)
  19.                     )
  20.     )
  21.     (vla-select
  22.                 loSelectionSet
  23.                 acSelectionSetAll
  24.                 nil
  25.                 nil
  26.                 filtType
  27.                 filtData
  28.     )
  29.     (setq count (vla-get-count loSelectionSet))
  30.     (princ count)
  31.     (setq ssets (vla-get-selectionsets loDoc))
  32.     (vla-delete (vla-item ssets "filtSet"))
  33.     (princ)
  34. )

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.

评分

参与人数 1D豆 +4 收起 理由
xshrimp + 4 很给力!经验;技术要点;资料分享奖!

查看全部评分

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

已领礼包: 3255个

财富等级: 富可敌国

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

使用道具 举报

已领礼包: 5个

财富等级: 恭喜发财

发表于 2020-3-17 01:01:59 | 显示全部楼层
困扰好久天,终于找到了,万分感谢!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-26 04:45 , Processed in 0.345680 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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