選中區域內指定類型的對象(SelectCrossingPolygon)

Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.EditorInput
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.Geometry


Namespace TraceBoundary
    Public Class Commands
        <CommandMethod("SelectCrossingPolygon")> _
        Public Sub TraceBoundary()
            Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
            Dim ZcDB As Database = ZcDoc.Database
            Dim ZcEd As Editor = ZcDoc.Editor


            Dim peo As New PromptEntityOptions(vbLf & "Select object:")
            Dim per As PromptEntityResult = ZcEd.GetEntity(peo)
            If per.Status <> PromptStatus.OK Then
                Return
            End If


            If per.Status = PromptStatus.OK Then
                Using ZcTrans As Transaction = ZcDB.TransactionManager.StartTransaction()
                    Dim ZcBLT As BlockTable = ZcTrans.GetObject(ZcDB.BlockTableId, OpenMode.ForRead)
                    Dim Ent As Polyline = DirectCast(ZcTrans.GetObject(per.ObjectId, OpenMode.ForRead), Polyline)
                    Dim plEntPts As New Point3dCollection()
                    For i As Integer = 0 To Ent.NumberOfVertices - 1
                        plEntPts.Add(Ent.GetPoint3dAt(i))
                    Next


                    Dim pmtSelRes As PromptSelectionResult = Nothing
                    Dim typedVal As TypedValue() = New TypedValue(0) {}
                    typedVal(0) = New TypedValue(CInt(DxfCode.Start), "INSERT")


                    Dim selFilter As New SelectionFilter(typedVal)
                    pmtSelRes = ZcEd.SelectCrossingPolygon(plEntPts, selFilter)


                    Dim in_entID As New ObjectIdCollection()
                    If pmtSelRes.Status = PromptStatus.OK Then
                        For Each objId As ObjectId In pmtSelRes.Value.GetObjectIds()
                            in_entID.Add(objId)
                        Next
                    Else
                        ZcEd.WriteMessage(vbLf & "Did not find entities")
                    End If


                    ZcTrans.Commit()




                End Using
            End If




        End Sub
    End Class
End Namespace
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章