Hi,
Do you mean, you need to display the block reference clone and its extent points along the path ?
In that case, using transient graphics to show them might help.
Here is a sample code that you can try. When prompted select a block reference and a polyline path. The block reference is cloned and displayed along the path at sampled points.
Public Class Test
Implements IExtensionApplication
Private _markers As DBObjectCollection = Nothing
<CommandMethod("Test")> _
Public Sub TestMethod()
Dim activeDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = activeDoc.Database
Dim ed As Editor = activeDoc.Editor
Dim peo1 As New PromptEntityOptions("Select a block reference : ")
peo1.SetRejectMessage("Not a block reference")
peo1.AddAllowedClass(GetType(BlockReference), True)
Dim per1 As PromptEntityResult = ed.GetEntity(peo1)
If per1.Status <> PromptStatus.OK Then
Return
End If
Dim brefId As ObjectId = per1.ObjectId
Dim peo2 As New PromptEntityOptions("Select a polyline : ")
peo2.SetRejectMessage("Not a polyline")
peo2.AddAllowedClass(GetType(Polyline), True)
Dim per2 As PromptEntityResult = ed.GetEntity(peo2)
If per2.Status <> PromptStatus.OK Then
Return
End If
Dim plineId As ObjectId = per2.ObjectId
ClearTransientGraphics()
_markers = New DBObjectCollection()
Dim intCol As New IntegerCollection()
Dim samplePoints As New Point3dCollection
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim bref As BlockReference = TryCast(tr.GetObject(brefId, OpenMode.ForRead), BlockReference)
Dim pline As Polyline = TryCast(tr.GetObject(plineId, OpenMode.ForRead), Polyline)
If pline IsNot Nothing Then
Dim segCount As Integer = pline.NumberOfVertices
For cnt As Integer = 0 To segCount - 1
Dim vertexPt As Point3d = pline.GetPoint3dAt(cnt)
Dim type As SegmentType = pline.GetSegmentType(cnt)
Select Case type
Case SegmentType.Arc
Dim arc2d As CircularArc2d = pline.GetArcSegment2dAt(cnt)
Dim samplePts1 As Point2d() = arc2d.GetSamplePoints(5)
For Each pt2d As Point2d In samplePts1
samplePoints.Add(New Point3d(pt2d.X, pt2d.Y, 0.0))
Next
Exit Select
Case SegmentType.Line
Dim line2d As LineSegment2d = pline.GetLineSegment2dAt(cnt)
Dim samplePts2 As Point2d() = line2d.GetSamplePoints(5)
For Each pt2d As Point2d In samplePts2
samplePoints.Add(New Point3d(pt2d.X, pt2d.Y, 0.0))
Next
Exit Select
End Select
Next
End If
For Each pt As Point3d In samplePoints
Dim marker1 As BlockReference
marker1 = bref.Clone()
marker1.Position = pt
Autodesk.AutoCAD.GraphicsInterface.TransientManager.CurrentTransientManager.AddTransient(marker1, Autodesk.AutoCAD.GraphicsInterface.TransientDrawingMode.Highlight, 128, intCol)
_markers.Add(marker1)
Dim exts As Extents3d
exts = marker1.GeometryExtentsBestFit()
Dim marker2 As DBObject
'marker2 = New DBPoint(exts.MinPoint)
marker2 = New Circle(exts.MinPoint, Vector3d.ZAxis, 0.1)
Autodesk.AutoCAD.GraphicsInterface.TransientManager.CurrentTransientManager.AddTransient(marker2, Autodesk.AutoCAD.GraphicsInterface.TransientDrawingMode.Highlight, 128, intCol)
_markers.Add(marker2)
Dim marker3 As DBObject
'marker3 = New DBPoint(exts.MaxPoint)
marker3 = New Circle(exts.MaxPoint, Vector3d.ZAxis, 0.1)
Autodesk.AutoCAD.GraphicsInterface.TransientManager.CurrentTransientManager.AddTransient(marker3, Autodesk.AutoCAD.GraphicsInterface.TransientDrawingMode.Highlight, 128, intCol)
_markers.Add(marker3)
Next
tr.Commit()
End Using
End Sub
Private Sub IExtensionApplication_Initialize() Implements IExtensionApplication.Initialize
End Sub
Private Sub ClearTransientGraphics()
Dim intCol As New IntegerCollection()
If _markers IsNot Nothing Then
For Each marker As DBObject In _markers
Autodesk.AutoCAD.GraphicsInterface.TransientManager.CurrentTransientManager.EraseTransient(marker, intCol)
marker.Dispose()
Next
End If
End Sub
Private Sub IExtensionApplication_Terminate() Implements IExtensionApplication.Terminate
ClearTransientGraphics()
End Sub
End Class
Balaji
Developer Technical Services
Autodesk Developer Network