nxy_918 发表于 2006-5-7 15:42:00

怪事情,哪位知道,选择集?

用下面程序,进行选择,不知道为什么,这个图形里的这几条线,居然选不中,很是不解,哪位高手帮我看看,谢谢!
注意:选择裁切线要选外围的l3DPolyline白色多边形Sub Test_cut()
Dim ss As AcadSelectionSet
Dim obj As AcadEntity
Dim pArray() As Double
'Dim pArray As Variant
Dim basePnt As Variant
Dim i As Integer
'Dim groupCode As Variant, dataCode As Variant
Dim Coord As Variant

On Error Resume Next
'ThisDrawing.Utility.Prompt vbCr & "选择要裁切范围线:"
ThisDrawing.Utility.GetEntity obj, basePnt, "选择要裁切范围线:"
If Err Then
   Exit Sub
Else
         Do While ThisDrawing.SelectionSets.count > 0
            ThisDrawing.SelectionSets.Item(0).Delete
         Loop
         Set ss = ThisDrawing.SelectionSets.Add("tt")
      Coord = obj.Coordinates '获取顶点坐标数组
      ReDim pArray(0 To UBound(Coord)) As Double
      For i = 0 To UBound(Coord)
            pArray(i) = Coord(i)
      Next i
      Call ss.SelectByPolygon(acSelectionSetFence, pArray)
      If ss.count > 0 Then
      Dim removeObjects(0 To 0) As AcadEntity
          Set removeObjects(0) = obj
         ss.RemoveItems removeObjects
         For i = 0 To ss.count - 1
             ss.Item(i).Highlight True
         Next
      End If
End If
End Sub

nxy_918 发表于 2006-5-7 18:36:00

图形传不上去,没办法

xinghesnak 发表于 2006-5-8 08:57:00

<P>楼上的,你的程序有问题,通过坐标选择的时候应该输入三维坐标变量,由<FONT color=#0000ff>Pline的Coordinates</FONT> 属性得到是二维坐标,你改成这样就行了</P>
<P>。。。。。。</P>
<P>&nbsp;Set ss = ThisDrawing.SelectionSets.Add("tt")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Coord = obj.Coordinates '获取顶点坐标数组<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReDim pArray(0 To UBound(Coord) + (UBound(Coord) + 1) / 2) As Double<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim j As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 0 To UBound(Coord)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pArray(i) = Coord(i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 1 To (UBound(Coord) + 1) / 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For j = UBound(pArray) To i * 3 - 1 Step -1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pArray(j) = pArray(j - 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pArray(i * 3 - 1) =&nbsp;obj.Elevation <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call ss.SelectByPolygon(acSelectionSetFence, pArray)</P>
<P>。。。。。。</P>
<P>这样做就是人为的增加一个Z轴坐标值。。。。。。^_^</P>
页: [1]
查看完整版本: 怪事情,哪位知道,选择集?