选择集特效过滤



    <CommandMethod("tcTest", CommandFlags.Modal)> _
    Public Sub Test()
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor

        Using tr As Transaction = db.TransactionManager.StartTransaction()
            Dim filter As TypedValue() = {New TypedValue(0, "LWPOLYLINE")}
            AddHandler ed.SelectionAdded, AddressOf ed_SelectionAdded
            Dim psr As PromptSelectionResult = ed.GetSelection(New SelectionFilter(filter))
            RemoveHandler ed.SelectionAdded, AddressOf ed_SelectionAdded
            If psr.Status <> PromptStatus.OK Then
                Return
            End If
            ed.SetImpliedSelection(psr.Value)
            tr.Commit()
        End Using
    End Sub

    Private Sub ed_SelectionAdded(ByVal sender As Object, ByVal e As SelectionAddedEventArgs)
        Dim ids As ObjectId() = e.AddedObjects.GetObjectIds()
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim tr As Transaction = db.TransactionManager.StartTransaction()
        Dim i As Integer = 0
        While i < ids.Length
            Using pline As Polyline = CType(tr.GetObject(ids(i), OpenMode.ForRead), Polyline)
                If pline.GetPoint2dAt(0).IsEqualTo(pline.GetPoint2dAt(pline.NumberOfVertices - 1)) Then
                    'e.Remove(i)
                End If
            End Using
            System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
        End While
    End Sub




Bounding Boxes around Blocks.

without Security Concern Message

欢迎关注微信公众账号ByCAD