Message 1 of 2
Delete mtext objects created by VBA

Not applicable
03-06-2019
10:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have created mtext above my block through VBA code. Once created can i delete those mtext using code. Im using that mtext to display some text regarding the block.
Private Sub GetBlockInfo() Dim ent As AcadEntity Dim block As AcadBlockReference Dim vAtts As Variant Dim StrNo As String Dim result Dim I As Long Dim point1, point2, point3 As Double For Each ent In ThisDrawing.ModelSpace If TypeOf ent Is AcadBlockReference Then Set block = ent If (block.Name) = "RMNUM" Then If block.HasAttributes Then vAtts = block.GetAttributes
For I = LBound(vAtts) To UBound(vAtts) If vAtts(I).TagString = "NUMBER" Then StrNo = vAtts(I).textString End If Next
point1 = block.InsertionPoint(0) point2 = block.InsertionPoint(1) point3 = block.InsertionPoint(2) result = CreateMText(point1, point2, point3, StrNo) End If End If End If Next End Sub Function CreateMText(ByVal x As Double, ByVal y As Double, ByVal z As Double, ByVal str As String) Dim mtextObj As AcadMText Dim insertPoint(0 To 2) As Double Dim width As Double Dim textString As String insertPoint(0) = x - 1 insertPoint(1) = y + 3 insertPoint(2) = z width = 4 textString = "Block number is" & str 'This is sample Set mtextObj = ThisDrawing.ModelSpace.AddMText(insertPoint, width, textString) ZoomAll End Function
Here i chose mtext because the details which im going to display has multiple rows. IS there anyother best thing to display like a popup would be fine.
After creating mtext for all blocks, once the user doesn't want these details, then another macro should delete this mtext . As mtext doesn't have 'Name', i cannot search and delete those though VBA. Pls advice me on this.