Try this code, tested on A2009
<CommandMethod("multlayers", CommandFlags.UsePickSet And CommandFlags.Redraw)> _
Public Sub SortManyLayers()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim height As Double = 0.2
Dim color As Integer = 256
Dim tid As ObjectId = ObjectId.Null
Dim ar As New ArrayList()
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Using tr
Try
Dim pso As PromptSelectionOptions = New PromptSelectionOptions
pso.MessageForRemoval = vbLf + "Select circles only"
pso.MessageForAdding = vbLf + "Select circles"
Dim tv As TypedValue() = New TypedValue() {New TypedValue(0, "circle"), New TypedValue(8, "0,BORDER-A,BORDER-B,BORDER-E1")}
Dim flt As New SelectionFilter(tv)
Dim res As PromptSelectionResult
res = ed.GetSelection(pso, flt)
If res.Status <> PromptStatus.OK Then
Return
End If
Dim sset As SelectionSet = res.Value
Dim n As Integer = 0
For Each obj As SelectedObject In sset
Dim dbobj As DBObject = tr.GetObject(obj.ObjectId, OpenMode.ForRead)
Dim circ As Circle = TryCast(dbobj, Circle)
If circ IsNot Nothing Then
'If n = 0 Then
Dim pt As Point3d = circ.Center
Dim cid As ObjectId = circ.ObjectId
Dim kp As New KeyValuePair(Of ObjectId, Point3d)(cid, pt)
ar.Add(kp)
'End If
End If
Next
ed.WriteMessage(vbLf & "Count Circles = " + ar.Count.ToString())
tr.Commit()
Catch ex As System.Exception
ed.WriteMessage(ex.ToString)
Finally
For Each kp As KeyValuePair(Of ObjectId, Point3d) In ar
ed.WriteMessage(vbLf + "ObjectID: {0}" + vbTab + "Center Point: {1}", kp.Key, kp.Value)
Next
End Try
End Using
End Sub
~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919