CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

处理选择集

2023-1-1 02:23| 发布者: admin| 查看: 298| 评论: 0|来自: AutoCAD

处理选择集的 ObjectARX 函数类似于 AutoLISP 中的函数。该函数提供了创建选择集的最通用方法。它通过以下三种方式之一创建选择集: ® acedSSGet()

  • 提示用户选择对象。
  • 通过使用 PICKFIRST 集或“交叉”、“交叉多边形”、“围栏”、“上一个”、“窗口”或“窗口多边形”选项(如在交互式 AutoCAD 使用中),或通过指定单个点或点围栏,显式指定要选择的图元。
  • 通过指定所选图元必须匹配的属性和条件列表来过滤当前图形数据库。您可以将筛选器与上述任何选项一起使用。
int 
acedSSGet (
    const char *str, 
    const void *pt1,
    const void *pt2,
    const struct resbuf *entmask, 
    ads_name ss);

第一个参数 to 是一个字符串,用于描述要使用的选择选项,如下表所示。acedSSGet()

aceedSSGet 的选择选项

 

选型代码

描述

单点选择(如果指定了 pt1)

或用户选择(如果 pt1 也是 NULL)

#

非几何(全部、上一个、上一个)

:$

提供的提示

.

用户选择

:?

其他回调

一个

B

C

路口

正中电

交叉多边形

:D

重复项正常

:E

光圈内的一切

F

栅栏

G

暗示

:K

关键字回传

L

最后

M

Multiple

P

Previous

:S

Force single object selection only

W

Window

WP

Window Polygon

X

Extended search (search whole database)

The next two arguments specify point values for the relevant options. (They should be if they don't apply.) If the fourth argument, , is not , it points to the list of entity field values used in filtering. The fifth argument, , identifies the selection set's name. NULLentmaskNULLss

The following code shows representative calls to . As the call illustrates, for the polygon options “” and “” (but not for “”), automatically closes the list of points. You don't need to build a list that specifies a final point identical to the first. acedSSGet()acutBuildList()CPWPFacedSSGet()

ads_point pt1, pt2, pt3, pt4; 
struct resbuf *pointlist; 
ads_name ssname; 
pt1[X] = pt1[Y] = pt1[Z] = 0.0; 
pt2[X] = pt2[Y] = 5.0; pt2[Z] = 0.0; 
// Get the current PICKFIRST set, if there is one; 
// otherwise, ask the user for a general entity selection. 
acedSSGet(NULL, NULL, NULL, NULL, ssname); 
// Get the current PICKFIRST set, if there is one. 
acedSSGet("I", NULL, NULL, NULL, ssname); 
// Selects the most recently selected objects. 
acedSSGet("P", NULL, NULL, NULL, ssname); 
// Selects the last entity added to the database. 
acedSSGet("L", NULL, NULL, NULL, ssname); 
// Selects entity passing through point (5,5). 
acedSSGet(NULL, pt2, NULL, NULL, ssname); 
// Selects entities inside the window from (0,0) to (5,5). 
acedSSGet("W", pt1, pt2, NULL, ssname); 
// Selects entities enclosed by the specified polygon. 
pt3[X] = 10.0; pt3[Y] = 5.0; pt3[Z] = 0.0; 
pt4[X] = 5.0; pt4[Y] = pt4[Z] = 0.0; 
pointlist = acutBuildList(RTPOINT, pt1, RTPOINT, pt2, 
	RTPOINT, pt3, RTPOINT, pt4, 0); 
acedSSGet("WP", pointlist, NULL, NULL, ssname); 
// Selects entities crossing the box from (0,0) to (5,5). 
acedSSGet("C", pt1, pt2, NULL, ssname); 
// Selects entities crossing the specified polygon. 
acedSSGet("CP", pointlist, NULL, NULL, ssname); 
acutRelRb(pointlist); 
// Selects the entities crossed by the specified fence. 
pt4[Y] = 15.0; pt4[Z] = 0.0; 
pointlist = acutBuildList(RTPOINT, pt1, RTPOINT, pt2, 
	RTPOINT, pt3, RTPOINT, pt4, 0); 
acedSSGet("F", pointlist, NULL, NULL, ssname); 
acutRelRb(pointlist); 

的补码是函数,一旦应用程序完成使用,它就会释放一个选择集。选择集由名称指定。下面的代码片段使用上一示例中的声明。acedSSGet()acedSSFree()ads_name

acedSSFree(ssname); 
注意:AutoCAD 不能同时打开超过 128 个选择集。此限制包括在同时运行的所有 ObjectARX 和 AutoLISP 应用程序中打开的选择集。您的系统上的限制可能不同。如果达到限制,AutoCAD 将拒绝创建更多选择集。不建议同时管理大量选择集。相反,在任何给定时间保持合理数量的集处于打开状态,并尽快调用释放未使用的选择集。与 AutoLISP 不同,ObjectARX 环境没有自动垃圾回收功能,以便在使用选择集后释放它们。应用程序在收到 、 或消息时应始终释放其打开的选择集。acedSSFree()kUnloadDwgMsgkEndMsgkQuitMsg

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 13:21

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部