Hi,
I have a object which im cloning and moving along a path.I am finding the GeometricExtentsBestFit points of the block and plotting in the drawing.I want to clone the object with these points.Any idea on how to do this.Please help.
Dim bref As BlockReference = actran.GetObject(idsBox(0), OpenMode.ForWrite).
Dim BlockCloneNew As BlockReference = bref.Clone()
Dim bestFit AsExtents3d = bref.GeometryExtentsBestFit
Dim bestfitMin As Point3d = bestFit.MinPoint
Dim bestfitMax1 As Point3d = bestFit1.MaxPoint
Thanks in advance
Solved! Go to Solution.
Solved by Balaji_Ram. Go to Solution.
Hi,
Can someone suggest me on how to make the block and points as a single entity as mentioned above.
Thanks in advance
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
Sorry. I do not get the exact picture. Can you please share a drawing or a screenshot of what you are trying to do ?
Hi,
The Point3d structure do not inherit from Entity neither from DBObject. A Point3d instance is only a geomeric object and cannot be added to an entity or cloned as DBObject instances.
You can create DBPoint instances, which are entities, from the Point3d and create a new BlockTableRecord which contains the source block reference and the DBPoint instances, then, insert it and clone it.
But you may also get the extents of the cloned object...
Or if you want to embed the extents (coordinates) of the source object to the cloned one(s), you can store them in the source block reference as attributes, xdata or extension dictionary xrecords before doing the cloning operation.
Can't find what you're looking for? Ask the community or share your knowledge.