CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

SelectByPolygon Method (ActiveX)

2023-1-4 03:53| 发布者: admin| 查看: 1024| 评论: 0|来自: AutoCAD

摘要: 选择围栏内的对象并将其添加到选择集中。

选择围栏内的对象并将其添加到选择集中。

支持的平台:仅窗口

签名

工 务 局:

object.SelectByPolygon Mode, PointsList [, FilterType, FilterData]
对象

类型:选择集

此方法适用的对象。

模式

访问:仅输入

类型:枚举AcSelect

  • acSelectionSetFence
  • acSelectionSetWindowPolygon
  • acSelectionSetCrossingPolygon
积分列表

访问:仅输入

类型:变体(双精度的三元素数组)

指定选择围栏的 3D WCS 坐标数组。

过滤器类型

访问:仅输入;自选

类型:变体

指定要使用的筛选器类型的 DXF 组代码。

过滤数据

访问:仅输入;自选

类型:变体

要筛选的值。

返回值(RetVal)

无返回值。

言论

以下选择模式可用:

  • 围栏:选择穿过选择围栏的所有对象。围栏由点列表中的坐标定义。
  • 窗口多边形:选择由点列表定义的多边形中的对象。
  • 交叉多边形:选择多边形定义的区域内的对象并穿过该区域的对象。使用点列表定义面的坐标。AutoCAD 将关闭多边形的最后一个矢量。多边形定义不能交叉自身。

此方法支持筛选机制。

有关更多选择模式选项,请参阅、和方法。SelectSelectAtPointSelectOnScreen

例子

工 务 局:

Sub Example_SelectByPolygon()
    ' This example adds objects to a selection set by defining a polygon.
    
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_SSET2")
     
    ' Add to the selection set all the objects that lie within a fence 
    Dim mode As Integer
    Dim pointsArray(0 To 11) As Double
    mode = acSelectionSetFence
    pointsArray(0) = 28.2: pointsArray(1) = 17.2: pointsArray(2) = 0
    pointsArray(3) = -5: pointsArray(4) = 13: pointsArray(5) = 0
    pointsArray(6) = -3.3: pointsArray(7) = -3.6: pointsArray(8) = 0
    pointsArray(9) = 28: pointsArray(10) = -3: pointsArray(11) = 0
    
    ssetObj.SelectByPolygon mode, pointsArray
    
    ' Add to the selection set all the Circles that lie within fence 
    ReDim gpCode(0 To 1) As Integer
    gpCode(0) = 0
    gpCode(1) = 10
    
    Dim pnt(0 To 2) As Double
    pnt(0) = 3: pnt(1) = 6: pnt(2) = 0
    
    ReDim dataValue(0 To 1) As Variant
    dataValue(0) = "Circle"
    dataValue(1) = pnt
    
    Dim groupCode As Variant, dataCode As Variant
    groupCode = gpCode
    dataCode = dataValue
    
    ssetObj.SelectByPolygon mode, pointsArray, groupCode, dataCode
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_SelectByPolygon()
    ;; This example adds objects to a selection set by defining a polygon.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    (setq ssetObj (vla-Add (vla-get-SelectionSets doc) "TEST_SSET2"))
     
    ;; Add to the selection set all the objects that lie within a fence 
    (setq mode acSelectionSetFence)
    (setq pointsArray (vlax-make-safearray vlax-vbDouble '(0 . 11)))
    (vlax-safearray-fill pointsArray '(28.2 17.2 0
                                       -5 13 0
                                       -3.3 -3.6 0
                                       28 -3 0
                                      )
    )
    
    (vla-SelectByPolygon ssetObj mode pointsArray)

    (alert (strcat "Objects selected: " (itoa (vla-get-Count ssetObj))))
    (vla-Clear ssetObj)

    ;; Add to the selection set all the Circles that lie within fence and at point 3,6
    (setq gpCode (vlax-make-safearray vlax-vbInteger '(0 . 1)))
    (vlax-safearray-put-element gpCode 0 0)
    (vlax-safearray-put-element gpCode 1 10)

    (setq pnt (vlax-3d-point 3 6 0))

    (setq dataValue (vlax-make-safearray vlax-vbVariant '(0 . 1)))
    (vlax-safearray-put-element dataValue 0 "Circle")
    (vlax-safearray-put-element dataValue 1 pnt)
    
    (vla-SelectByPolygon ssetObj mode pointsArray gpCode dataValue)
    (alert (strcat "Objects selected: " (itoa (vla-get-Count ssetObj))))

    (vla-Delete ssetObj)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 15:09

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部