CAD二次开发(Vba)------select和selectbypolygon选择不到object问题解决

cad使用select和selectbypolygon时出现选择范围正确但选择范围内object选择不到selectionset集合中,在进行绘图过程中发现不停的狂按鼠标中键(zoomall)时会选择到object,建议在使用select和selectbypolygon时添加一行zoomall语句,尤其是循环搜索时。

 代码放一段官方的帮助文档,添加了一行ZoomALL。

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")
    
    zoomall

    ' 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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值