Here you go, tested on A2009 only
{code}
Public Shared Function GetAllVertices(ent As Polyline) As Point3dCollection
Dim points As New Point3dCollection()
Dim pt As New Point3d()
Dim i As Integer = 0
For i = 0 To ent.NumberOfVertices - 1
pt = ent.GetPoint3dAt(i)
points.Add(pt)
Next
Return points
End Function
<CommandMethod("Gnp")> _
Public Shared Sub TestSubEntity()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim ucs As Matrix3d = ed.CurrentUserCoordinateSystem
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Try
Using tr
Dim pno As New PromptNestedEntityOptions(vbLf & "Select Nested Polyline >>")
pno.AllowNone = False
Dim rs As PromptNestedEntityResult = ed.GetNestedEntity(pno)
If rs.Status <> PromptStatus.OK Then
Return
End If
Dim entId As ObjectId = rs.ObjectId
Dim selent As Entity = TryCast(tr.GetObject(entId, OpenMode.ForWrite), Entity)
Dim ids As ObjectId() = rs.GetContainers()
Dim blkId As ObjectId = ids(0)
If blkId.IsNull Then
Return
End If
Dim blkEnt As Entity = TryCast(tr.GetObject(blkId, OpenMode.ForRead), Entity)
If blkEnt Is Nothing Then
Return
End If
Dim bref As BlockReference = TryCast(blkEnt, BlockReference)
If bref Is Nothing Then
Return
End If
Dim mat As Matrix3d = bref.BlockTransform
Dim btrec As BlockTableRecord = TryCast(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim pline As Polyline = TryCast(selent, Polyline)
If pline Is Nothing Then
Return
End If
Dim circ As Circle
Dim points As Point3dCollection = GetAllVertices(pline)
For i As Integer = 0 To points.Count - 1
Dim p As Point3d = points(i)
circ = New Circle(p.TransformBy(mat), Vector3d.ZAxis, 0.1)
btrec.AppendEntity(circ)
tr.AddNewlyCreatedDBObject(circ, True)
Next
tr.Commit()
End Using
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(ex.Message + vbLf + ex.StackTrace)
Finally
End Try
End Sub
{code}
~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919