<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Delete Text inside the block in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11982672#M1491</link>
    <description>&lt;P&gt;You should have gotten some hints from your previous question about adding text (or whatever entity, for that matter) to an existing block definition (AcadBlock): the same as adding text to Model/PaperSpace, you simply call AcadBlock.AddText().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Deleting something from a block definition would be similar to deleting from Model/PaperSpace: you simply find it and delete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the code would be rather simple, something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set cadBlock=acadDoc.Blocks("theBlock") '' along as you are sure a block definition with the name exists&lt;/P&gt;
&lt;P&gt;Dim ent As AcadBlock&lt;/P&gt;
&lt;P&gt;Dim txt As AcadText&lt;/P&gt;
&lt;P&gt;For Each ent in cadBlock&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If TypeOf ent Is AcadText Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Set txt=ent&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; '' You may want to only delete the AcadText with certain text string&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; If UCase(txt.TextString)="TARGET TEXT VALUE" Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; txt.Delete&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; End If&lt;/P&gt;
&lt;P&gt;&amp;nbsp; End If&lt;/P&gt;
&lt;P&gt;Next&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After the block definition is updated because of this deleting, and there are block references to this definition in drawing, you may want to regen the drawing, if the drawing is to remain open for user to continue working on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2023 12:23:52 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2023-05-23T12:23:52Z</dc:date>
    <item>
      <title>Delete Text inside the block</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11981667#M1489</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to remove the text from block reference using selectionsetcrossingpolygon method inside the block . But the code doesnt work properly, instead its deleting the text from modelspace. Help me find the solution&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921" target="_blank"&gt;@norman.yuan&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14801" target="_blank"&gt;@Ed.Jobe&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sub removetext()&lt;BR /&gt;&lt;BR /&gt;Dim acadApp As Object&lt;BR /&gt;Dim acadDoc As Object&lt;BR /&gt;Set acadApp = GetObject(, "AutoCAD.Application")&lt;BR /&gt;Set acadDoc = acadApp.ActiveDocument&lt;BR /&gt;acadDoc.SetVariable "PICKSTYLE", 1&lt;/P&gt;&lt;P&gt;On Error GoTo 0&lt;BR /&gt;&lt;BR /&gt;' Create AcadSelectionSet Object&lt;BR /&gt;Dim ssetObj As Object&lt;BR /&gt;Err.Clear&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set ssetObj = acadDoc.SelectionSets("SS")&lt;BR /&gt;If Err Then&lt;BR /&gt;Set ssetObj = acadDoc.SelectionSets.Add("SS")&lt;BR /&gt;End If&lt;BR /&gt;On Error GoTo 0&lt;BR /&gt;&lt;BR /&gt;ssetObj.Clear&lt;/P&gt;&lt;P&gt;ReDim AreaLineCoords(0 To 11) As Double&lt;BR /&gt;AreaLineCoords(0) = 9.3196&lt;BR /&gt;AreaLineCoords(1) = 5.9139&lt;BR /&gt;AreaLineCoords(2) = 0&lt;BR /&gt;AreaLineCoords(3) = 18.5304&lt;BR /&gt;AreaLineCoords(4) = 5.9139&lt;BR /&gt;AreaLineCoords(5) = 0&lt;BR /&gt;AreaLineCoords(6) = 18.5304&lt;BR /&gt;AreaLineCoords(7) = 9.2155&lt;BR /&gt;AreaLineCoords(8) = 0&lt;BR /&gt;AreaLineCoords(9) = 9.3196&lt;BR /&gt;AreaLineCoords(10) = 9.2155&lt;BR /&gt;AreaLineCoords(11) = 0&lt;BR /&gt;&lt;BR /&gt;' Get the block reference for the "new" block&lt;BR /&gt;Dim cadBlock As Object&lt;BR /&gt;Set cadBlock = acadDoc.Blocks.Item("new")&lt;/P&gt;&lt;P&gt;' Create a new selection set&lt;BR /&gt;Dim blockSelSet As Object&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set blockSelSet = acadDoc.SelectionSets("blockSelSet")&lt;BR /&gt;On Error GoTo 0&lt;BR /&gt;&lt;BR /&gt;' If the selection set exists, clear it; otherwise, create a new selection set&lt;BR /&gt;If Not blockSelSet Is Nothing Then&lt;BR /&gt;blockSelSet.Clear&lt;BR /&gt;Else&lt;BR /&gt;Set blockSelSet = acadDoc.SelectionSets.Add("blockSelSet")&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' Select the block reference&lt;BR /&gt;blockSelSet.Select acSelectionSetAll, cadBlock&lt;BR /&gt;&lt;BR /&gt;' Display the selected block name&lt;BR /&gt;MsgBox "Selected block: " &amp;amp; cadBlock.Name&lt;BR /&gt;&lt;BR /&gt;' Select the text objects within the specified polygonal area in the block reference&lt;BR /&gt;blockSelSet.SelectByPolygon acSelectionSetCrossingPolygon, AreaLineCoords&lt;BR /&gt;&lt;BR /&gt;' Display the count of selected objects&lt;BR /&gt;MsgBox "Number of selected objects: " &amp;amp; blockSelSet.Count&lt;BR /&gt;&lt;BR /&gt;' Find the type of selected objects&lt;BR /&gt;Dim selectedType As String&lt;BR /&gt;If blockSelSet.Count &amp;gt; 0 Then&lt;BR /&gt;selectedType = TypeName(blockSelSet.Item(0))&lt;BR /&gt;Else&lt;BR /&gt;selectedType = "None"&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' Display the type of selected objects&lt;BR /&gt;MsgBox "Selected object type: " &amp;amp; selectedType&lt;BR /&gt;&lt;BR /&gt;' Loop through the selected objects and delete the text objects&lt;BR /&gt;Dim obj As Object&lt;BR /&gt;For Each obj In blockSelSet&lt;BR /&gt;If TypeOf obj Is acadText Then&lt;BR /&gt;Dim textObj As acadText&lt;BR /&gt;Set textObj = obj&lt;BR /&gt;Debug.Print textObj.TextString&lt;BR /&gt;textObj.Delete&lt;BR /&gt;End If&lt;BR /&gt;Next obj&lt;BR /&gt;&lt;BR /&gt;acadDoc.SetVariable "PICKSTYLE", 0&lt;/P&gt;&lt;P&gt;MsgBox "Done"&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 04:26:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11981667#M1489</guid>
      <dc:creator>balaananthan_r</dc:creator>
      <dc:date>2023-05-23T04:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Text inside the block</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11981975#M1490</link>
      <description>&lt;P&gt;Sub removetext()&lt;BR /&gt;&lt;BR /&gt;Dim acadApp As Object&lt;BR /&gt;Dim acadDoc As Object&lt;BR /&gt;Set acadApp = GetObject(, "AutoCAD.Application")&lt;BR /&gt;Set acadDoc = acadApp.ActiveDocument&lt;BR /&gt;&lt;BR /&gt;On Error GoTo 0&lt;BR /&gt;&lt;BR /&gt;' Create AcadSelectionSet Object&lt;BR /&gt;Dim ssetObj As Object&lt;BR /&gt;Err.Clear&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set ssetObj = acadDoc.SelectionSets("SS")&lt;BR /&gt;If Err Then&lt;BR /&gt;Set ssetObj = acadDoc.SelectionSets.Add("SS")&lt;BR /&gt;End If&lt;BR /&gt;On Error GoTo 0&lt;BR /&gt;&lt;BR /&gt;ssetObj.Clear&lt;/P&gt;&lt;P&gt;ReDim AreaLineCoords(0 To 11) As Double&lt;BR /&gt;AreaLineCoords(0) = 9.3196&lt;BR /&gt;AreaLineCoords(1) = 5.9139&lt;BR /&gt;AreaLineCoords(2) = 0&lt;BR /&gt;AreaLineCoords(3) = 18.5304&lt;BR /&gt;AreaLineCoords(4) = 5.9139&lt;BR /&gt;AreaLineCoords(5) = 0&lt;BR /&gt;AreaLineCoords(6) = 18.5304&lt;BR /&gt;AreaLineCoords(7) = 9.2155&lt;BR /&gt;AreaLineCoords(8) = 0&lt;BR /&gt;AreaLineCoords(9) = 9.3196&lt;BR /&gt;AreaLineCoords(10) = 9.2155&lt;BR /&gt;AreaLineCoords(11) = 0&lt;BR /&gt;&lt;BR /&gt;' Get the block reference for the "new" block&lt;BR /&gt;Dim cadBlock As Object&lt;BR /&gt;Set cadBlock = acadDoc.Blocks.Item("new")&lt;BR /&gt;&lt;BR /&gt;' Create a new selection set&lt;BR /&gt;Dim blockSelSet As Object&lt;/P&gt;&lt;P&gt;On Error Resume Next&lt;BR /&gt;Set blockSelSet = acadDoc.SelectionSets("blockselset2")&lt;BR /&gt;On Error GoTo 0&lt;BR /&gt;&lt;BR /&gt;''' If the selection set exists, clear it; otherwise, create a new selection set&lt;BR /&gt;If Not blockSelSet Is Nothing Then&lt;BR /&gt;blockSelSet.Clear&lt;BR /&gt;Else&lt;BR /&gt;Set blockSelSet = acadDoc.SelectionSets.Add("blockSelSet6")&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;acadDoc.SendCommand "_-bedit" &amp;amp; vbCr &amp;amp; "new" &amp;amp; vbCrLf&lt;BR /&gt;'Select the block reference&lt;BR /&gt;blockSelSet.Select acSelectionSetAll, cadBlock&lt;BR /&gt;&lt;BR /&gt;' Select the text objects within the specified polygonal area in the block reference&lt;BR /&gt;blockSelSet.SelectByPolygon acSelectionSetCrossingPolygon, AreaLineCoords&lt;BR /&gt;&lt;BR /&gt;' Display the count of selected objects&lt;BR /&gt;'MsgBox "Number of selected objects: " &amp;amp; blockSelSet.Count&lt;BR /&gt;&lt;BR /&gt;'blockSelSet.Erase&lt;BR /&gt;&lt;BR /&gt;' Loop through the selected objects and delete the text objects&lt;BR /&gt;Dim obj As Object&lt;BR /&gt;For Each obj In blockSelSet&lt;BR /&gt;If TypeOf obj Is acadText Then&lt;BR /&gt;Dim textObj As acadText&lt;BR /&gt;Set textObj = obj&lt;BR /&gt;Debug.Print textObj.TextString&lt;BR /&gt;textObj.Delete&lt;BR /&gt;End If&lt;BR /&gt;Next obj&lt;BR /&gt;&lt;BR /&gt;acadDoc.SendCommand "bclose" &amp;amp; vbCr &amp;amp; vbCrLf&lt;/P&gt;&lt;P&gt;MsgBox "Done"&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works , but i need to manually choose the "save the changes in autocad" (Image attached) . Is there any other way to automate this&amp;nbsp;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="balaananthan_r_0-1684827206337.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1217905iE577AE883057C632/image-size/medium?v=v2&amp;amp;px=400" role="button" title="balaananthan_r_0-1684827206337.png" alt="balaananthan_r_0-1684827206337.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 07:33:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11981975#M1490</guid>
      <dc:creator>balaananthan_r</dc:creator>
      <dc:date>2023-05-23T07:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Text inside the block</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11982672#M1491</link>
      <description>&lt;P&gt;You should have gotten some hints from your previous question about adding text (or whatever entity, for that matter) to an existing block definition (AcadBlock): the same as adding text to Model/PaperSpace, you simply call AcadBlock.AddText().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Deleting something from a block definition would be similar to deleting from Model/PaperSpace: you simply find it and delete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the code would be rather simple, something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set cadBlock=acadDoc.Blocks("theBlock") '' along as you are sure a block definition with the name exists&lt;/P&gt;
&lt;P&gt;Dim ent As AcadBlock&lt;/P&gt;
&lt;P&gt;Dim txt As AcadText&lt;/P&gt;
&lt;P&gt;For Each ent in cadBlock&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If TypeOf ent Is AcadText Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Set txt=ent&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; '' You may want to only delete the AcadText with certain text string&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; If UCase(txt.TextString)="TARGET TEXT VALUE" Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; txt.Delete&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; End If&lt;/P&gt;
&lt;P&gt;&amp;nbsp; End If&lt;/P&gt;
&lt;P&gt;Next&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After the block definition is updated because of this deleting, and there are block references to this definition in drawing, you may want to regen the drawing, if the drawing is to remain open for user to continue working on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 12:23:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11982672#M1491</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-05-23T12:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Text inside the block</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11982739#M1492</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;. I will try in this way. Is there is any option to make selection set inside the block by using selectbypolygon method .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As per my second post, is there a way in autocad&amp;nbsp; to close the prompt dialog boxes (save or discard the changes) using VBA code itself instead of manual selection. I tried sendkey method but its not working in autocad&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 12:45:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11982739#M1492</guid>
      <dc:creator>balaananthan_r</dc:creator>
      <dc:date>2023-05-23T12:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Text inside the block</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11983394#M1493</link>
      <description>&lt;P&gt;Sorry, I do not know a way to dismiss that dialog box, except for SendKey as possible approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd think it is really bad practice to get into Block Editor for what your want to do, which is rather simple, as I showed in my reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 16:45:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-text-inside-the-block/m-p/11983394#M1493</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-05-23T16:45:13Z</dc:date>
    </item>
  </channel>
</rss>

